1 namespace gui::controls;
5 class ButtonBits { bool bevel:1, scale:1, offset:1, stayDown:1, checkBox:1, toggle:1, radio:1, keyRepeat:1, bevelOver:1, ellipsis:1, stayUp:1; };
8 #define CAPTION_DISTANCE 36
10 #define CAPTION_DISTANCE 18
13 public enum ButtonState /*: byte*/ { up, down, over, disabled, upChecked, downChecked, overChecked, disabledChecked };
14 //use and extend preexisting enum? -> public enum Alignment { left, right, center };
15 public enum BoxAlignment { center, left, right, top, bottom }; // topLeftCorner, topRightCorner, bottomLeftCorner, bottomRightCorner
17 public class Button : CommonControl
23 public property Percentage opacity
25 isset { return (buttonStyle.checkBox || buttonStyle.radio) ? (Window::opacity != 0) : Window::opacity != 1; }
26 get { return Window::opacity; }
27 set { Window::opacity = value; }
29 public property bool drawBehind
31 isset { return (buttonStyle.checkBox || buttonStyle.radio) ? (Window::drawBehind != drawBehind) : Window::drawBehind != false; }
32 get { return Window::drawBehind; }
33 set { Window::drawBehind = value; }
35 class_property(icon) = "<:ecere>controls/button.png";
39 Color background = this.background;
41 if(colors[down] == colors[up]) colors[down] = background;
42 if(colors[over] == colors[up]) colors[over] = background;
43 if(colors[disabled] == colors[up]) colors[disabled] = background;
44 colors[0] = background;
49 Color foreground = this.foreground;
51 if(textColor[down] == textColor[up]) textColor[down] = foreground;
52 if(textColor[over] == textColor[up]) textColor[over] = foreground;
53 if(textColor[disabled] == textColor[up]) textColor[disabled] = foreground;
54 textColor[0] = foreground;
60 SetInitSize(initSize);
66 SetInitSize(initSize);
69 ButtonBits buttonStyle;
71 BitmapResource bitmaps[ButtonState];
72 int captionHeight, captionWidth;
74 Color textColor[ButtonState];
76 Color colors[ButtonState];
78 BoxAlignment bitmapAlignment;
79 struct { bool hint:1, key:1, captured:1, over:1, checked:1; };
83 background = formColor;
89 buttonStyle.offset = true;
91 // SetCursor(eInterface_GetCursor(__ecereModule->app, CUR_ARROW));
96 textColor[up] = textColor[down] =
97 textColor[over] = black;
98 textColor[disabled] = Color { 85, 85, 85 };
100 colors[up] = formColor;
101 colors[down] = formColor;
102 colors[over] = formColor;
103 colors[disabled] = white;
104 colors[upChecked] = Color { 233,229,221 };
105 colors[overChecked] = formColor;
106 colors[downChecked] = Color { 233,229,221 };
107 colors[disabledChecked] = formColor;
110 Bitmap GetButtonBitmap()
112 ButtonState state = this.state;
113 Bitmap buttonBitmap = bitmaps[(int)checked*4 + state].bitmap;
114 if(!buttonBitmap) buttonBitmap = bitmaps[(int)checked * 4+up].bitmap;
115 if(!buttonBitmap) buttonBitmap = bitmaps[up].bitmap;
116 if(!isEnabled && bitmaps[disabled]) buttonBitmap = bitmaps[disabled].bitmap;
120 void OnRedraw(Surface surface)
122 ButtonState state = this.state;
123 Bitmap buttonBitmap = GetButtonBitmap();
124 const char * text = this.text;
125 int offset = (state == down && buttonStyle.offset) ? 1 : 0;
126 Color backColor = colors[(int)checked*4 + state];
127 int isDefault = this.isDefault;
131 if(!backColor) backColor = colors[up];
134 surface.TextFont(font);
136 surface.TextExtent(text, strlen(text),&tw, &th);
138 if(buttonStyle.bevelOver && checked)
143 if(bitmaps[disabled]) buttonBitmap = bitmaps[disabled].bitmap;
147 if(buttonBitmap && buttonStyle.bevelOver && !buttonStyle.checkBox && !buttonStyle.radio && text)
151 if((buttonStyle.bevel || buttonStyle.bevelOver) /* && opacity && backColor*/)
153 if(!buttonStyle.scale || !buttonBitmap)
155 surface.SetBackground({(byte)(opacity * 255), backColor});
156 //surface.Area(1, 1,clientSize.w-3+offset,clientSize.h-3+offset);
157 surface.Area(0, 0,clientSize.w-1,clientSize.h-1);
162 if(buttonStyle.checkBox && !buttonBitmap)
164 #if defined(HIGH_DPI)
169 int start = (clientSize.h - height) / 2;
172 // surface.SetBackground(formColor);
173 surface.SetBackground(gainsboro);
174 else if(active && !text)
175 surface.SetBackground((offset ? formColor : Color { 0,0,170 }));
177 surface.SetBackground((offset ? formColor : background /*white*/));
178 surface.Area(2, start+2,height-3,start+height-3);
180 surface.SetForeground(Color { 85, 85, 85 });
181 surface.HLine(0, height - 2, start + 0);
182 surface.VLine(start+1, start+height - 2, 0);
184 surface.SetForeground(Color { 64,64,64 });
185 surface.HLine(1, height - 3, start + 1);
186 surface.VLine(start+2, start+height - 3, 1);
188 surface.SetForeground(Color { 212,208,200 });
189 surface.HLine(1, height - 2, start + height-2);
190 surface.VLine(start+1, start+height - 3, height-2);
192 surface.SetForeground(white);
193 surface.HLine(0, height - 1, start + height-1);
194 surface.VLine(start+0, start+height - 2, height-1);
199 surface.SetForeground(white);
201 surface.SetForeground(Color { 85, 85, 85 });
203 surface.SetForeground(foreground /*black*/);
205 surface.DrawLine(8, start+16, 14,start+22);
206 surface.DrawLine(8, start+18, 14,start+24);
207 surface.DrawLine(14, start+22, 19,start+6);
208 surface.DrawLine(14, start+24, 19,start+8);
210 surface.DrawLine(4, start+8, 7,start+11);
211 surface.DrawLine(4, start+9, 7,start+12);
212 surface.DrawLine(7, start+11, 11,start+3);
213 surface.DrawLine(7, start+12, 11,start+4);
221 surface.SetForeground(white);
222 if(buttonStyle.radio || buttonStyle.checkBox)
224 int x = 0, y = (clientSize.h-buttonBitmap.height)/2;
225 if(buttonStyle.bevelOver && text)
227 x = (CAPTION_DISTANCE-buttonBitmap.width)/2 + offset;
228 y = (clientSize.h-buttonBitmap.height)/2 + offset;
231 // Radio Buttons and Checkboxes
232 surface.Blit(buttonBitmap,
234 0,0,buttonBitmap.width,buttonBitmap.height);
239 if(buttonStyle.scale)
241 if(buttonStyle.bevel || buttonStyle.offset)
242 surface.Stretch(buttonBitmap,
243 1 + offset, 1 + offset,0,0,
244 clientSize.w-3,clientSize.h-3,buttonBitmap.width,buttonBitmap.height);
246 surface.Stretch(buttonBitmap, 0,0, 0,0,
247 clientSize.w,clientSize.h,buttonBitmap.width,buttonBitmap.height);
252 bw = buttonBitmap.width;
253 bh = buttonBitmap.height;
255 if(bitmapAlignment == left || bitmapAlignment == right)
257 if(bitmapAlignment == left)
260 x = clientSize.w-bw-2;
261 y = (clientSize.h-bh)/2;
263 else if(bitmapAlignment == top || bitmapAlignment == bottom)
265 x = (clientSize.w-bw)/2;
266 if(bitmapAlignment == top)
269 y = clientSize.h-bh-2;
273 x = (clientSize.w-bw)/2;
274 y = (clientSize.h-bh - (int)(buttonStyle.bevelOver && text) * th)/2;
276 if(buttonStyle.bevel || buttonStyle.offset)
281 surface.Blit(buttonBitmap, x,y, 0,0, bw,bh);
287 if(buttonStyle.bevel ||
288 (buttonStyle.bevelOver &&
289 (state == down || state == over || checked)))
291 if(state == down || checked)
293 surface.SetForeground(Color { 85, 85, 85 });
294 surface.HLine(isDefault + 0, clientSize.w-2-isDefault, 0);
295 surface.VLine(isDefault + 1, clientSize.h-2-isDefault, 0);
296 surface.SetForeground(white);
297 surface.HLine(isDefault + 0, clientSize.w-1-isDefault, clientSize.h-1-isDefault);
298 surface.VLine(isDefault + 0, clientSize.h-2-isDefault, clientSize.w-1-isDefault);
302 surface.SetForeground(white);
303 surface.HLine(0 + isDefault, clientSize.w-2 - isDefault, isDefault);
304 surface.VLine(1 + isDefault, clientSize.h-2 - isDefault, isDefault);
305 surface.SetForeground(Color { 85, 85, 85 });
306 surface.HLine(1 + isDefault, clientSize.w-2 - isDefault, clientSize.h-2 - isDefault);
307 surface.VLine(1 + isDefault, clientSize.h-3 - isDefault, clientSize.w-2 - isDefault);
309 if(buttonStyle.bevel)
311 surface.SetForeground(black);
312 surface.HLine( isDefault, clientSize.w-1 - isDefault, clientSize.h-1 - isDefault);
313 surface.VLine( isDefault, clientSize.h-2 - isDefault, clientSize.w-1 - isDefault);
319 surface.TextOpacity(false);
320 surface.SetForeground((textColor[state] ? textColor[state] : textColor[up]));
323 if((buttonStyle.radio || buttonStyle.checkBox) && !(buttonStyle.bevelOver))
324 WriteCaption(surface, /*clientSize.h +*/ CAPTION_DISTANCE + 3,
325 (clientSize.h - th - 4)/2);
330 if(buttonStyle.bevelOver && buttonBitmap && !buttonStyle.checkBox && !buttonStyle.radio)
332 if(bitmapAlignment == top)
333 y = (clientSize.h - bh - 4 - th - 5)/2 + offset + bh + 4;
334 else if(bitmapAlignment == bottom)
335 y = (clientSize.h - bh - 4 - th - 5)/2 + offset;
336 else//if(bitmapAlignment == left || bitmapAlignment == right)
337 y = clientSize.h - th - 5 + offset;
340 y = (clientSize.h - th - 1)/2 + offset;
342 if(buttonStyle.ellipsis)
344 int width = clientSize.w - 2*6;
347 surface.WriteTextDots(alignment, x, y, width, text, strlen(text));
353 width = clientSize.w - 2 * 6;
354 if(bitmapAlignment == left || bitmapAlignment == right)
356 if(bitmapAlignment == left)
360 if(buttonStyle.checkBox || ((buttonStyle.radio /*|| buttonStyle.bevelOver*/) && buttonBitmap))
362 x += CAPTION_DISTANCE + 3;
367 if(alignment == right)
369 else if(alignment == center)
370 x += (width - tw) / 2;
372 WriteCaption(surface, x, y);
377 // Activation Highlight
380 surface.SetForeground(black);
381 surface.Rectangle(0,0,clientSize.w-1,clientSize.h-1);
383 if(!(buttonStyle.bevelOver) && !isRemote)
385 if(active/* && (text || !(buttonStyle.radio || buttonStyle.checkBox))*/)
388 surface.SetForeground(black);
389 surface.LineStipple(0x5555);
391 if((buttonStyle.radio || buttonStyle.checkBox) && text)
393 x1 = /*clientSize.h + */CAPTION_DISTANCE;
402 x2 = clientSize.w - 5+offset;
403 y2 = clientSize.h - 5+offset;
405 if(buttonStyle.radio || buttonStyle.checkBox)
413 if((x2 - x1) & 1) x2++;
414 if((y2 - y1) & 1) y2++;
416 surface.Rectangle(x1, y1, x2, y2);
417 surface.LineStipple(0);
423 void TVisionOnRedraw(Window window,Surface surface)
425 Button * button = (Button *)window->data;
426 int state = this.state;
429 int offset = (buttonStyle.bevel && state == down) ? textCellW : 0;
431 if(clientSize.h <= textCellH || clientSize.w <= 2*textCellW) offset = 0;
436 surface.TextOpacity(false);
437 surface.SetForeground((active ? white : black) );
439 surface.SetBackground(GREEN);
441 if(buttonStyle.bevel)
445 if(clientSize.h > textCellH && clientSize.w > 2*textCellW)
446 surface.Area(textCellW,0,clientSize.w-textCellW,clientSize.h-textCellH-1);
447 else if(!window->background)
448 surface.Area(0,0,clientSize.w-1,clientSize.h-1);
452 if(clientSize.h > textCellH && clientSize.w > 2*textCellW)
454 surface.Area(0,0,clientSize.w-2*textCellW,clientSize.h-textCellH-1);
455 surface.SetForeground(black);
456 eSurface_DrawingChar(surface, 223);
457 surface.HLine(textCellW,clientSize.w-textCellW,window->h-textCellH);
460 eSurface_DrawingChar(surface, 219);
461 surface.VLine(1,clientSize.h-textCellH,clientSize.w-textCellW);
463 eSurface_DrawingChar(surface, 220);
464 surface.HLine(clientSize.w - textCellW, clientSize.w - textCellW, 0);
466 else if(!window->background)
467 surface.Area(0,0,clientSize.w-1,clientSize.h-1);
471 surface.SetForeground(((active || state == down) ? ((BITwindow->buttonStyle, ES_DEFAULT)) ? LT_RED : white) : ((BITwindow->buttonStyle, ES_DEFAULT)) ? LT_CYAN : textColor[state])) );
473 if(buttonStyle.checkBox)
474 surface.WriteText(0,0, checked ? "[\373]" : "[ ] = 3);
475 if(buttonStyle.radio)
476 surface.WriteText(0,0, checked ? "(\007)" : "( ) = 3);
479 surface.TextExtent(text,strlen(text),&tw, &th);
481 if(buttonStyle.radio || buttonStyle.checkBox)
482 surface.SetForeground(((state == down) ? ((BITwindow->buttonStyle, ES_DEFAULT)) ? LT_RED : white) : ((BITwindow->buttonStyle, ES_DEFAULT)) ? LT_CYAN : textColor[state])));
484 if(buttonStyle.radio || buttonStyle.checkBox)
485 WriteCaption(surface, 4*textCellW, (clientSize.h - th - 2)/2);
490 tw = textCellW; th = textCellH;
491 surface.WriteTextf((clientSize.w - tw)/2 + offset, (clientSize.h - th - 2)/2 + offset.%c = symbol);
495 WriteCaption(surface,(clientSize.w - tw)/2 + offset,(clientSize.h - th - 2)/2 + offset);
499 bool OnMouseMove(int x, int y, Modifiers mods)
501 if(!mods.isSideEffect)
502 return NotifyMouseMove(master, this, x,y, mods);
506 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
508 //eSystem_Logf("%s %s\n = text, active ? "Activated" : "Deactivated;
511 if(!buttonStyle.toggle)
518 if(hint && NotifyReleased(master, this, 0, 0, 0))
530 bool OnLeftButtonDown(int x, int y, Modifiers mods)
532 if(x >= 0 && y >= 0 && x < size.w && y < size.h)
534 if(buttonStyle.toggle)
536 state = (state == down) ? up : down;
537 if(NotifyPushed(master, this, x,y, mods) &&
538 NotifyClicked(master, this, x,y, mods))
545 Window master = this.master;
548 if(NotifyPushed(master, this, x,y, mods))
551 if(!buttonStyle.stayUp)
561 bool OnLeftButtonUp(int x, int y, Modifiers mods)
563 if(!(buttonStyle.toggle))
572 releasedResult = NotifyReleased(master, this, x,y, mods);
575 if(x >= 0 && y >= 0 && x < size.w && y < size.h)
577 if(buttonStyle.checkBox)
578 property::checked = !checked;
579 else if(buttonStyle.radio)
580 property::checked = true;
582 // state = mods ? up : over;
584 state = over ? over : up;
589 if(NotifyClicked(master, this, x,y, mods))
606 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
608 return NotifyDoubleClick(master, this, x,y, mods);
611 bool OnMouseOver(int x, int y, Modifiers mods)
616 if(!(buttonStyle.toggle || buttonStyle.stayUp))
631 if(NotifyMouseOver(master, this, x,y, mods))
637 void OnMouseCaptureLost()
651 bool OnMouseLeave(Modifiers mods)
655 if( (!buttonStyle.stayDown || !hint) /*&& !buttonStyle.toggle */)
657 if(!(buttonStyle.toggle) || state == over)
661 if(NotifyMouseLeave(master, this, mods))
668 bool OnLoadGraphics()
672 display.FontExtent(font,text,strlen(text), &captionWidth, &captionHeight);
675 display.FontExtent(font," ", 1, &captionWidth, &captionHeight);
678 if(bitmapAlignment != center && !buttonStyle.checkBox && !buttonStyle.radio && !buttonStyle.scale)
680 Bitmap buttonBitmap = GetButtonBitmap();
683 if(bitmapAlignment == left || bitmapAlignment == right)
684 captionWidth += buttonBitmap.width + 4;
686 captionHeight += buttonBitmap.height + 4;
692 bool OnResizing(int *width, int *height)
694 // Checking *width/*height for zero does not work with minClientSize being set
695 Size initSize = this.initSize;
696 if(this.anchor.left.type != none && this.anchor.right.type != none) initSize.w = 1;
697 if(this.anchor.top.type != none && this.anchor.bottom.type != none) initSize.h = 1;
699 if(buttonStyle.checkBox || buttonStyle.radio || buttonStyle.bevelOver)
701 Bitmap bitmap0 = bitmaps[0] ? bitmaps[0].bitmap : null;
702 if(!initSize.w /**width*/ && bitmap0) *width = Max(*width, bitmap0.width);
703 if(!initSize.h /**height*/ && bitmap0) *height = Max(*height, bitmap0.height);
705 *height = Max(*height, captionHeight + 2);
709 *width = Max(*width, /**height + */captionWidth + CAPTION_DISTANCE + 16);
711 *width = Max(*width, /**height + */captionWidth + CAPTION_DISTANCE + 8);
715 *width = Max(*width, *height);
717 *width = Max(*width, 32);
722 if(!caption && bitmap && bitmap.bitmap)
724 if(!initSize.w /**width*/)
725 *width = Max(*width, bitmap.bitmap.width);
726 if(!initSize.h /**height*/)
727 *height = Max(*height, bitmap.bitmap.height);
729 else if(guiApp.textMode && buttonStyle.bevel)
731 if(!initSize.w /**width*/)
732 *width = Max(*width, captionWidth + 8);
733 if(!initSize.h /**height*/)
734 *height = Max(*height, captionHeight + 16);
738 if(!initSize.w /**width*/)
739 *width = Max(*width, captionWidth + /*4*/12);
740 if(!initSize.h /**height*/)
741 *height = Max(*height, captionHeight + /*6*/ 8);
748 bool OnKeyUp(Key key, unichar character)
750 if(key == space || key.code == enter || key.code == keyPadEnter || (key == hotKey && !buttonStyle.keyRepeat))
755 /*return */OnLeftButtonUp(0,0, key.modifiers);
763 bool OnKeyDown(Key key, unichar character)
765 if(!key.alt && !key.ctrl)
770 if(buttonStyle.keyRepeat) break;
774 OnLeftButtonDown(0,0, key.modifiers);
775 if(key.code == hotKey)
782 OnActivate(false, null, null, true);
791 bool OnKeyHit(Key key, unichar character)
796 if(parent.CycleChildren(false, false, false, !(buttonStyle.bevelOver && buttonStyle.radio)))
798 if(buttonStyle.bevelOver && buttonStyle.radio)
800 Button b = (Button)parent.activeChild;
801 if(b && b != this && eClass_IsDerived(b._class, class(Button)) && b.buttonStyle.radio && b.buttonStyle.bevelOver)
803 b.OnLeftButtonDown(0,0,(Modifiers)key); // Casting Key to Modifiers is bad
804 b.OnLeftButtonUp(0,0,(Modifiers)key);
810 case right: case down:
811 if(parent.CycleChildren(true, false, false, !(buttonStyle.bevelOver && buttonStyle.radio)))
813 if(buttonStyle.bevelOver && buttonStyle.radio)
815 Button b = (Button)parent.activeChild;
816 if(b && b != this && eClass_IsDerived(b._class, class(Button)) && b.buttonStyle.radio && b.buttonStyle.bevelOver)
818 b.OnLeftButtonDown(0,0,(Modifiers)key);
819 b.OnLeftButtonUp(0,0,(Modifiers)key);
826 if(buttonStyle.keyRepeat)
829 OnLeftButtonDown(0,0, key.modifiers);
831 /*return */OnLeftButtonUp(0,0, key.modifiers);
839 void SetColor(ButtonState state, Color value)
841 colors[state] = value;
844 void SetTextColor(ButtonState state, Color value)
846 textColor[state] = value;
851 if(buttonStyle.radio)
853 RemoveResource(bitmaps[up]);
854 RemoveResource(bitmaps[down]);
855 RemoveResource(bitmaps[disabled]);
856 RemoveResource(bitmaps[upChecked]);
857 RemoveResource(bitmaps[downChecked]);
858 RemoveResource(bitmaps[disabledChecked]);
861 bitmaps[down] = null;
862 bitmaps[disabled] = null;
863 bitmaps[upChecked] = null;
864 bitmaps[downChecked] = null;
865 bitmaps[disabledChecked] = null;
867 buttonStyle.radio = false;
871 virtual bool Window::NotifyClicked(Button button, int x, int y, Modifiers mods);
872 virtual bool Window::NotifyDoubleClick(Button button, int x, int y, Modifiers mods);
873 virtual bool Window::NotifyPushed(Button button, int x, int y, Modifiers mods);
874 virtual bool Window::NotifyReleased(Button button, int x, int y, Modifiers mods);
875 virtual bool Window::NotifyMouseMove(Button button, int x, int y, Modifiers mods);
876 virtual bool Window::NotifyMouseOver(Button button, int x, int y, Modifiers mods);
877 virtual bool Window::NotifyMouseLeave(Button button, Modifiers mods);
880 property bool isRadio
882 property_category $"Behavior"
889 RemoveResource(bitmaps[up]);
890 RemoveResource(bitmaps[down]);
891 RemoveResource(bitmaps[disabled]);
892 RemoveResource(bitmaps[upChecked]);
893 RemoveResource(bitmaps[downChecked]);
894 RemoveResource(bitmaps[disabledChecked]);
896 bitmaps[up] = BitmapResource { };
897 bitmaps[down] = BitmapResource { };
898 bitmaps[disabled] = BitmapResource { };
899 bitmaps[upChecked] = BitmapResource { };
900 bitmaps[downChecked] = BitmapResource { };
901 bitmaps[disabledChecked] = BitmapResource { };
902 bitmaps[up].fileName = "<:ecere>elements/optionBoxUp.png";
903 bitmaps[down].fileName = "<:ecere>elements/optionBoxDown.png";
904 bitmaps[disabled].fileName = "<:ecere>elements/optionBoxDisabled.png";
905 bitmaps[upChecked].fileName = "<:ecere>elements/optionBoxSelectedUp.png";
906 bitmaps[downChecked].fileName = "<:ecere>elements/optionBoxSelectedDown.png";
907 bitmaps[disabledChecked].fileName = "<:ecere>elements/optionBoxDisabledSelected.png";
909 AddResource(bitmaps[up]);
910 AddResource(bitmaps[down]);
911 AddResource(bitmaps[disabled]);
912 AddResource(bitmaps[upChecked]);
913 AddResource(bitmaps[downChecked]);
914 AddResource(bitmaps[disabledChecked]);
917 buttonStyle.radio = true;
918 buttonStyle.checkBox = false;
919 buttonStyle.bevel = false;
929 SetInitSize(initSize);
931 get { return buttonStyle.radio; }
933 property bool isCheckbox
935 property_category $"Behavior"
940 buttonStyle.checkBox = true;
943 buttonStyle.radio = false;
944 buttonStyle.bevel = false;
949 buttonStyle.checkBox = false;
952 SetInitSize(initSize);
954 get { return buttonStyle.checkBox; }
958 property_category $"Behavior"
963 buttonStyle.bevel = true;
965 buttonStyle.checkBox = false;
966 buttonStyle.radio = false;
967 buttonStyle.bevelOver = false;
973 buttonStyle.bevel = false;
978 get { return buttonStyle.bevel; }
980 property bool bevelOver
982 property_category $"Behavior"
987 buttonStyle.bevelOver = true;
988 buttonStyle.offset = true;
989 buttonStyle.bevel = false;
993 buttonStyle.bevelOver = false;
994 buttonStyle.offset = false;
997 get { return buttonStyle.bevelOver; }
999 property bool toggle { property_category $"Behavior" set { buttonStyle.toggle = value; } get { return buttonStyle.toggle; } };
1000 property bool checked
1002 property_category $"Appearance"
1005 if(buttonStyle.toggle)
1007 state = value ? down : up;
1011 if(buttonStyle.radio && value)
1013 Window parent = this.parent;
1017 for(otherWindow = parent.firstChild; otherWindow; otherWindow = otherWindow.next)
1019 if(otherWindow != this && eClass_IsDerived(otherWindow._class, _class))
1021 Button otherButton = (Button)otherWindow;
1022 if(otherButton.buttonStyle.radio)
1023 otherButton.checked = false;
1032 get { return buttonStyle.toggle ? (state == down) : checked; }
1034 property Alignment alignment { property_category $"Appearance" set { alignment = value; } get { return alignment; } };
1035 property BitmapResource bitmap
1037 property_category $"Appearance"
1041 RemoveResource(bitmaps[up]);
1042 bitmaps[up] = value;
1044 RemoveResource(bitmaps[over]);
1045 RemoveResource(bitmaps[down]);
1046 RemoveResource(bitmaps[disabled]);
1047 RemoveResource(bitmaps[upChecked]);
1048 RemoveResource(bitmaps[overChecked]);
1049 RemoveResource(bitmaps[downChecked]);
1050 RemoveResource(bitmaps[disabledChecked]);
1052 bitmaps[over] = null;
1053 bitmaps[down] = null;
1054 bitmaps[disabled] = null;
1055 bitmaps[upChecked] = null;
1056 bitmaps[overChecked] = null;
1057 bitmaps[downChecked] = null;
1058 bitmaps[disabledChecked] = null;
1061 if(buttonStyle.radio && !value)
1063 AddResource((bitmaps[up] = BitmapResource { fileName = "<:ecere>elements/optionBox.png" }));
1064 AddResource((bitmaps[down] = BitmapResource { fileName = "<:ecere>elements/optionBox.png" }));
1065 AddResource((bitmaps[disabled] = BitmapResource { fileName = "<:ecere>elements/optionBoxDisabled.png" }));
1066 AddResource((bitmaps[upChecked] = BitmapResource { fileName = "<:ecere>elements/optionBoxSelected.png" }));
1067 AddResource((bitmaps[downChecked] = BitmapResource { fileName = "<:ecere>elements/optionBoxSelected.png" }));
1068 AddResource((bitmaps[disabledChecked] = BitmapResource { fileName = "<:ecere>elements/optionBoxDisabledSelected.png" }));
1070 else */if(!bitmaps[disabled])
1072 bitmaps[disabled] = BitmapResource { fileName = bitmap.fileName, grayed = true };
1073 AddResource(bitmaps[disabled]);
1076 get { return bitmaps[up]; }
1078 property bool stayUp { property_category $"Behavior" set { buttonStyle.stayUp = value; } get { return buttonStyle.stayUp; } };
1079 property bool scaleBitmap { property_category $"Appearance" set { buttonStyle.scale = value; } get { return buttonStyle.scale; } };
1080 property bool keyRepeat { property_category $"Behavior" set { buttonStyle.keyRepeat = value; } get { return buttonStyle.keyRepeat; } };
1081 property unichar symbol { property_category $"Appearance" set { this.symbol = value; } get { return symbol; } };
1082 property bool ellipsis { property_category $"Appearance" set { buttonStyle.ellipsis = value; } get { return buttonStyle.ellipsis; } };
1083 property bool stayDown { property_category $"Behavior" set { buttonStyle.stayDown = value; } get { return buttonStyle.stayDown; } };
1084 property bool offset { property_category $"Behavior" set { buttonStyle.offset = value; } get { return buttonStyle.offset; } };
1086 property ButtonState buttonState { get { return state; } set { state = value; } };
1087 property BoxAlignment bitmapAlignment { property_category $"Appearance" set { bitmapAlignment = value; } get { return bitmapAlignment; } };