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; };
7 #define CAPTION_DISTANCE 18
9 public enum ButtonState /*: byte*/ { up, down, over, disabled, upChecked, downChecked, overChecked, disabledChecked };
10 //use and extend preexisting enum? -> public enum Alignment { left, right, center };
11 public enum BoxAlignment { center, left, right, top, bottom }; // topLeftCorner, topRightCorner, bottomLeftCorner, bottomRightCorner
13 public class Button : CommonControl
19 public property Percentage opacity
21 isset { return (buttonStyle.checkBox || buttonStyle.radio) ? (Window::opacity != 0) : Window::opacity != 1; }
22 get { return Window::opacity; }
23 set { Window::opacity = value; }
25 public property bool drawBehind
27 isset { return (buttonStyle.checkBox || buttonStyle.radio) ? (Window::drawBehind != drawBehind) : Window::drawBehind != false; }
28 get { return Window::drawBehind; }
29 set { Window::drawBehind = value; }
31 class_property(icon) = "<:ecere>controls/button.png";
35 Color background = this.background;
37 if(colors[down] == colors[up]) colors[down] = background;
38 if(colors[over] == colors[up]) colors[over] = background;
39 if(colors[disabled] == colors[up]) colors[disabled] = background;
40 colors[0] = background;
45 Color foreground = this.foreground;
47 if(textColor[down] == textColor[up]) textColor[down] = foreground;
48 if(textColor[over] == textColor[up]) textColor[over] = foreground;
49 if(textColor[disabled] == textColor[up]) textColor[disabled] = foreground;
50 textColor[0] = foreground;
56 SetInitSize(initSize);
62 SetInitSize(initSize);
65 ButtonBits buttonStyle;
67 BitmapResource bitmaps[ButtonState];
68 int captionHeight, captionWidth;
70 Color textColor[ButtonState];
72 bool hint:1, key:1, captured:1, over:1, checked:1;
73 Color colors[ButtonState];
75 BoxAlignment bitmapAlignment;
79 background = activeBorder;
85 buttonStyle.offset = true;
87 // SetCursor(eInterface_GetCursor(__ecereModule->app, CUR_ARROW));
92 textColor[up] = textColor[down] =
93 textColor[over] = black;
94 textColor[disabled] = Color { 85, 85, 85 };
96 colors[up] = activeBorder;
97 colors[down] = activeBorder;
98 colors[over] = activeBorder;
99 colors[disabled] = white;
100 colors[upChecked] = Color { 233,229,221 };
101 colors[overChecked] = activeBorder;
102 colors[downChecked] = Color { 233,229,221 };
103 colors[disabledChecked] = activeBorder;
106 Bitmap GetButtonBitmap()
108 ButtonState state = this.state;
109 Bitmap buttonBitmap = bitmaps[(int)checked*4 + state].bitmap;
110 if(!buttonBitmap) buttonBitmap = bitmaps[(int)checked * 4+up].bitmap;
111 if(!buttonBitmap) buttonBitmap = bitmaps[up].bitmap;
112 if(!isEnabled && bitmaps[disabled]) buttonBitmap = bitmaps[disabled].bitmap;
116 void OnRedraw(Surface surface)
118 ButtonState state = this.state;
119 Bitmap buttonBitmap = GetButtonBitmap();
120 char * text = this.text;
121 int offset = (state == down && buttonStyle.offset) ? 1 : 0;
122 Color backColor = colors[(int)checked*4 + state];
123 int isDefault = this.isDefault;
127 if(!backColor) backColor = colors[up];
130 surface.TextFont(font);
132 surface.TextExtent(text, strlen(text),&tw, &th);
134 if(buttonStyle.bevelOver && checked)
139 if(bitmaps[disabled]) buttonBitmap = bitmaps[disabled].bitmap;
143 if(buttonBitmap && buttonStyle.bevelOver && !buttonStyle.checkBox && !buttonStyle.radio && text)
147 if((buttonStyle.bevel || buttonStyle.bevelOver) /* && opacity && backColor*/)
149 if(!buttonStyle.scale || !buttonBitmap)
151 surface.SetBackground({(byte)(opacity * 255), backColor});
152 //surface.Area(1, 1,clientSize.w-3+offset,clientSize.h-3+offset);
153 surface.Area(0, 0,clientSize.w-1,clientSize.h-1);
158 if(buttonStyle.checkBox && !buttonBitmap)
161 int start = (clientSize.h - height) / 2;
164 // surface.SetBackground(activeBorder);
165 surface.SetBackground(gainsboro);
166 else if(active && !text)
167 surface.SetBackground((offset ? activeBorder : Color { 0,0,170 }));
169 surface.SetBackground((offset ? activeBorder : background /*white*/));
170 surface.Area(2, start+2,height-3,start+height-3);
172 surface.SetForeground(Color { 85, 85, 85 });
173 surface.HLine(0, height - 2, start + 0);
174 surface.VLine(start+1, start+height - 2, 0);
176 surface.SetForeground(Color { 64,64,64 });
177 surface.HLine(1, height - 3, start + 1);
178 surface.VLine(start+2, start+height - 3, 1);
180 surface.SetForeground(Color { 212,208,200 });
181 surface.HLine(1, height - 2, start + height-2);
182 surface.VLine(start+1, start+height - 3, height-2);
184 surface.SetForeground(white);
185 surface.HLine(0, height - 1, start + height-1);
186 surface.VLine(start+0, start+height - 2, height-1);
191 surface.SetForeground(white);
193 surface.SetForeground(Color { 85, 85, 85 });
195 surface.SetForeground(foreground /*black*/);
196 surface.DrawLine(4, start+8, 7,start+11);
197 surface.DrawLine(4, start+9, 7,start+12);
198 surface.DrawLine(7, start+11, 11,start+3);
199 surface.DrawLine(7, start+12, 11,start+4);
206 surface.SetForeground(white);
207 if(buttonStyle.radio || buttonStyle.checkBox)
209 int x = 0, y = (clientSize.h-buttonBitmap.height)/2;
210 if(buttonStyle.bevelOver && text)
212 x = (CAPTION_DISTANCE-buttonBitmap.width)/2 + offset;
213 y = (clientSize.h-buttonBitmap.height)/2 + offset;
216 // Radio Buttons and Checkboxes
217 surface.Blit(buttonBitmap,
219 0,0,buttonBitmap.width,buttonBitmap.height);
224 if(buttonStyle.scale)
226 if(buttonStyle.bevel || buttonStyle.offset)
227 surface.Stretch(buttonBitmap,
228 1 + offset, 1 + offset,0,0,
229 clientSize.w-3,clientSize.h-3,buttonBitmap.width,buttonBitmap.height);
231 surface.Stretch(buttonBitmap, 0,0, 0,0,
232 clientSize.w,clientSize.h,buttonBitmap.width,buttonBitmap.height);
237 bw = buttonBitmap.width;
238 bh = buttonBitmap.height;
240 if(bitmapAlignment == left || bitmapAlignment == right)
242 if(bitmapAlignment == left)
245 x = clientSize.w-bw-2;
246 y = (clientSize.h-bh)/2;
248 else if(bitmapAlignment == top || bitmapAlignment == bottom)
250 x = (clientSize.w-bw)/2;
251 if(bitmapAlignment == top)
254 y = clientSize.h-bh-2;
258 x = (clientSize.w-bw)/2;
259 y = (clientSize.h-bh - (int)(buttonStyle.bevelOver && text) * th)/2;
261 if(buttonStyle.bevel || buttonStyle.offset)
266 surface.Blit(buttonBitmap, x,y, 0,0, bw,bh);
272 if(buttonStyle.bevel ||
273 (buttonStyle.bevelOver &&
274 (state == down || state == over || checked)))
276 if(state == down || checked)
278 surface.SetForeground(Color { 85, 85, 85 });
279 surface.HLine(isDefault + 0, clientSize.w-2-isDefault, 0);
280 surface.VLine(isDefault + 1, clientSize.h-2-isDefault, 0);
281 surface.SetForeground(white);
282 surface.HLine(isDefault + 0, clientSize.w-1-isDefault, clientSize.h-1-isDefault);
283 surface.VLine(isDefault + 0, clientSize.h-2-isDefault, clientSize.w-1-isDefault);
287 surface.SetForeground(white);
288 surface.HLine(0 + isDefault, clientSize.w-2 - isDefault, isDefault);
289 surface.VLine(1 + isDefault, clientSize.h-2 - isDefault, isDefault);
290 surface.SetForeground(Color { 85, 85, 85 });
291 surface.HLine(1 + isDefault, clientSize.w-2 - isDefault, clientSize.h-2 - isDefault);
292 surface.VLine(1 + isDefault, clientSize.h-3 - isDefault, clientSize.w-2 - isDefault);
294 if(buttonStyle.bevel)
296 surface.SetForeground(black);
297 surface.HLine( isDefault, clientSize.w-1 - isDefault, clientSize.h-1 - isDefault);
298 surface.VLine( isDefault, clientSize.h-2 - isDefault, clientSize.w-1 - isDefault);
304 surface.TextOpacity(false);
305 surface.SetForeground((textColor[state] ? textColor[state] : textColor[up]));
308 if((buttonStyle.radio || buttonStyle.checkBox) && !(buttonStyle.bevelOver))
309 WriteCaption(surface, /*clientSize.h +*/ CAPTION_DISTANCE + 3,
310 (clientSize.h - th - 4)/2);
315 if(buttonStyle.bevelOver && buttonBitmap && !buttonStyle.checkBox && !buttonStyle.radio)
317 if(bitmapAlignment == top)
318 y = (clientSize.h - bh - 4 - th - 5)/2 + offset + bh + 4;
319 else if(bitmapAlignment == bottom)
320 y = (clientSize.h - bh - 4 - th - 5)/2 + offset;
321 else//if(bitmapAlignment == left || bitmapAlignment == right)
322 y = clientSize.h - th - 5 + offset;
325 y = (clientSize.h - th - 1)/2 + offset;
327 if(buttonStyle.ellipsis)
329 int width = clientSize.w - 2*6;
332 surface.WriteTextDots(alignment, x, y, width, text, strlen(text));
338 width = clientSize.w - 2 * 6;
339 if(bitmapAlignment == left || bitmapAlignment == right)
341 if(bitmapAlignment == left)
345 if(buttonStyle.checkBox || ((buttonStyle.radio /*|| buttonStyle.bevelOver*/) && buttonBitmap))
347 x += CAPTION_DISTANCE + 3;
352 if(alignment == right)
354 else if(alignment == center)
355 x += (width - tw) / 2;
357 WriteCaption(surface, x, y);
362 // Activation Highlight
365 surface.SetForeground(black);
366 surface.Rectangle(0,0,clientSize.w-1,clientSize.h-1);
368 if(!(buttonStyle.bevelOver) && !isRemote)
370 if(active/* && (text || !(buttonStyle.radio || buttonStyle.checkBox))*/)
373 surface.SetForeground(black);
374 surface.LineStipple(0x5555);
376 if((buttonStyle.radio || buttonStyle.checkBox) && text)
378 x1 = /*clientSize.h + */CAPTION_DISTANCE;
387 x2 = clientSize.w - 5+offset;
388 y2 = clientSize.h - 5+offset;
390 if(buttonStyle.radio || buttonStyle.checkBox)
398 if((x2 - x1) & 1) x2++;
399 if((y2 - y1) & 1) y2++;
401 surface.Rectangle(x1, y1, x2, y2);
402 surface.LineStipple(0);
408 void TVisionOnRedraw(Window window,Surface surface)
410 Button * button = (Button *)window->data;
411 int state = this.state;
414 int offset = (buttonStyle.bevel && state == down) ? textCellW : 0;
416 if(clientSize.h <= textCellH || clientSize.w <= 2*textCellW) offset = 0;
421 surface.TextOpacity(false);
422 surface.SetForeground((active ? white : black) );
424 surface.SetBackground(GREEN);
426 if(buttonStyle.bevel)
430 if(clientSize.h > textCellH && clientSize.w > 2*textCellW)
431 surface.Area(textCellW,0,clientSize.w-textCellW,clientSize.h-textCellH-1);
432 else if(!window->background)
433 surface.Area(0,0,clientSize.w-1,clientSize.h-1);
437 if(clientSize.h > textCellH && clientSize.w > 2*textCellW)
439 surface.Area(0,0,clientSize.w-2*textCellW,clientSize.h-textCellH-1);
440 surface.SetForeground(black);
441 eSurface_DrawingChar(surface, 223);
442 surface.HLine(textCellW,clientSize.w-textCellW,window->h-textCellH);
445 eSurface_DrawingChar(surface, 219);
446 surface.VLine(1,clientSize.h-textCellH,clientSize.w-textCellW);
448 eSurface_DrawingChar(surface, 220);
449 surface.HLine(clientSize.w - textCellW, clientSize.w - textCellW, 0);
451 else if(!window->background)
452 surface.Area(0,0,clientSize.w-1,clientSize.h-1);
456 surface.SetForeground(((active || state == down) ? ((BITwindow->buttonStyle, ES_DEFAULT)) ? LT_RED : white) : ((BITwindow->buttonStyle, ES_DEFAULT)) ? LT_CYAN : textColor[state])) );
458 if(buttonStyle.checkBox)
459 surface.WriteText(0,0, checked ? "[\373]" : "[ ] = 3);
460 if(buttonStyle.radio)
461 surface.WriteText(0,0, checked ? "(\007)" : "( ) = 3);
464 surface.TextExtent(text,strlen(text),&tw, &th);
466 if(buttonStyle.radio || buttonStyle.checkBox)
467 surface.SetForeground(((state == down) ? ((BITwindow->buttonStyle, ES_DEFAULT)) ? LT_RED : white) : ((BITwindow->buttonStyle, ES_DEFAULT)) ? LT_CYAN : textColor[state])));
469 if(buttonStyle.radio || buttonStyle.checkBox)
470 WriteCaption(surface, 4*textCellW, (clientSize.h - th - 2)/2);
475 tw = textCellW; th = textCellH;
476 surface.WriteTextf((clientSize.w - tw)/2 + offset, (clientSize.h - th - 2)/2 + offset.%c = symbol);
480 WriteCaption(surface,(clientSize.w - tw)/2 + offset,(clientSize.h - th - 2)/2 + offset);
484 bool OnMouseMove(int x, int y, Modifiers mods)
486 if(!mods.isSideEffect)
487 return NotifyMouseMove(master, this, x,y, mods);
491 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
493 //eSystem_Logf("%s %s\n = text, active ? "Activated" : "Deactivated;
496 if(!buttonStyle.toggle)
503 if(hint && NotifyReleased(master, this, 0, 0, 0))
515 bool OnLeftButtonDown(int x, int y, Modifiers mods)
517 if(x >= 0 && y >= 0 && x < size.w && y < size.h)
519 if(buttonStyle.toggle)
521 state = (state == down) ? up : down;
522 if(NotifyPushed(master, this, x,y, mods) &&
523 NotifyClicked(master, this, x,y, mods))
530 Window master = this.master;
533 if(NotifyPushed(master, this, x,y, mods))
536 if(!buttonStyle.stayUp)
546 bool OnLeftButtonUp(int x, int y, Modifiers mods)
548 if(!(buttonStyle.toggle))
557 releasedResult = NotifyReleased(master, this, x,y, mods);
560 if(x >= 0 && y >= 0 && x < size.w && y < size.h)
562 if(buttonStyle.checkBox)
563 property::checked = !checked;
564 else if(buttonStyle.radio)
565 property::checked = true;
567 // state = mods ? up : over;
569 state = over ? over : up;
574 if(NotifyClicked(master, this, x,y, mods))
591 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
593 return NotifyDoubleClick(master, this, x,y, mods);
596 bool OnMouseOver(int x, int y, Modifiers mods)
601 if(!(buttonStyle.toggle || buttonStyle.stayUp))
616 if(NotifyMouseOver(master, this, x,y, mods))
622 void OnMouseCaptureLost()
636 bool OnMouseLeave(Modifiers mods)
640 if( (!buttonStyle.stayDown || !hint) /*&& !buttonStyle.toggle */)
642 if(!(buttonStyle.toggle) || state == over)
646 if(NotifyMouseLeave(master, this, mods))
653 bool OnLoadGraphics()
657 display.FontExtent(font,text,strlen(text), &captionWidth, &captionHeight);
660 display.FontExtent(font," ", 1, &captionWidth, &captionHeight);
663 if(bitmapAlignment != center && !buttonStyle.checkBox && !buttonStyle.radio && !buttonStyle.scale)
665 Bitmap buttonBitmap = GetButtonBitmap();
668 if(bitmapAlignment == left || bitmapAlignment == right)
669 captionWidth += buttonBitmap.width + 4;
671 captionHeight += buttonBitmap.height + 4;
677 bool OnResizing(int *width, int *height)
679 if(buttonStyle.checkBox || buttonStyle.radio || buttonStyle.bevelOver)
681 Bitmap bitmap0 = bitmaps[0] ? bitmaps[0].bitmap : null;
682 if(!*width && bitmap0) *width = bitmap0.width;
683 if(!*height && bitmap0) *height = bitmap0.height;
685 *height = Max(*height, captionHeight + 2);
689 *width = Max(*width, /**height + */captionWidth + CAPTION_DISTANCE + 16);
691 *width = Max(*width, /**height + */captionWidth + CAPTION_DISTANCE + 8);
695 *width = Max(*width, *height);
697 *width = Max(*width, 32);
702 if(guiApp.textMode && buttonStyle.bevel)
705 *width = Max(*width, captionWidth + 8);
707 *height = Max(*height, captionHeight + 16);
712 *width = Max(*width, captionWidth + /*4*/12);
714 *height = Max(*height, captionHeight + /*6*/ 8);
721 bool OnKeyUp(Key key, unichar character)
723 if(key == space || key.code == enter || key.code == keyPadEnter || (key == hotKey && !buttonStyle.keyRepeat))
728 /*return */OnLeftButtonUp(0,0, key.modifiers);
736 bool OnKeyDown(Key key, unichar character)
738 if(!key.alt && !key.ctrl)
743 if(buttonStyle.keyRepeat) break;
747 OnLeftButtonDown(0,0, key.modifiers);
748 if(key.code == hotKey)
755 OnActivate(false, null, null, true);
764 bool OnKeyHit(Key key, unichar character)
769 if(parent.CycleChildren(false, false, false, !(buttonStyle.bevelOver && buttonStyle.radio)))
771 if(buttonStyle.bevelOver && buttonStyle.radio)
773 Button b = (Button)parent.activeChild;
774 if(b && b != this && eClass_IsDerived(b._class, class(Button)) && b.buttonStyle.radio && b.buttonStyle.bevelOver)
776 b.OnLeftButtonDown(0,0,(Modifiers)key); // Casting Key to Modifiers is bad
777 b.OnLeftButtonUp(0,0,(Modifiers)key);
783 case right: case down:
784 if(parent.CycleChildren(true, false, false, !(buttonStyle.bevelOver && buttonStyle.radio)))
786 if(buttonStyle.bevelOver && buttonStyle.radio)
788 Button b = (Button)parent.activeChild;
789 if(b && b != this && eClass_IsDerived(b._class, class(Button)) && b.buttonStyle.radio && b.buttonStyle.bevelOver)
791 b.OnLeftButtonDown(0,0,(Modifiers)key);
792 b.OnLeftButtonUp(0,0,(Modifiers)key);
799 if(buttonStyle.keyRepeat)
802 OnLeftButtonDown(0,0, key.modifiers);
804 /*return */OnLeftButtonUp(0,0, key.modifiers);
812 void SetColor(ButtonState state, Color value)
814 colors[state] = value;
817 void SetTextColor(ButtonState state, Color value)
819 textColor[state] = value;
824 if(buttonStyle.radio)
826 RemoveResource(bitmaps[up]);
827 RemoveResource(bitmaps[down]);
828 RemoveResource(bitmaps[disabled]);
829 RemoveResource(bitmaps[upChecked]);
830 RemoveResource(bitmaps[downChecked]);
831 RemoveResource(bitmaps[disabledChecked]);
834 bitmaps[down] = null;
835 bitmaps[disabled] = null;
836 bitmaps[upChecked] = null;
837 bitmaps[downChecked] = null;
838 bitmaps[disabledChecked] = null;
840 buttonStyle.radio = false;
844 virtual bool Window::NotifyClicked(Button button, int x, int y, Modifiers mods);
845 virtual bool Window::NotifyDoubleClick(Button button, int x, int y, Modifiers mods);
846 virtual bool Window::NotifyPushed(Button button, int x, int y, Modifiers mods);
847 virtual bool Window::NotifyReleased(Button button, int x, int y, Modifiers mods);
848 virtual bool Window::NotifyMouseMove(Button button, int x, int y, Modifiers mods);
849 virtual bool Window::NotifyMouseOver(Button button, int x, int y, Modifiers mods);
850 virtual bool Window::NotifyMouseLeave(Button button, Modifiers mods);
853 property bool isRadio
855 property_category "Behavior"
862 RemoveResource(bitmaps[up]);
863 RemoveResource(bitmaps[down]);
864 RemoveResource(bitmaps[disabled]);
865 RemoveResource(bitmaps[upChecked]);
866 RemoveResource(bitmaps[downChecked]);
867 RemoveResource(bitmaps[disabledChecked]);
869 bitmaps[up] = BitmapResource { };
870 bitmaps[down] = BitmapResource { };
871 bitmaps[disabled] = BitmapResource { };
872 bitmaps[upChecked] = BitmapResource { };
873 bitmaps[downChecked] = BitmapResource { };
874 bitmaps[disabledChecked] = BitmapResource { };
875 bitmaps[up].fileName = "<:ecere>elements/optionBoxUp.png";
876 bitmaps[down].fileName = "<:ecere>elements/optionBoxDown.png";
877 bitmaps[disabled].fileName = "<:ecere>elements/optionBoxDisabled.png";
878 bitmaps[upChecked].fileName = "<:ecere>elements/optionBoxSelectedUp.png";
879 bitmaps[downChecked].fileName = "<:ecere>elements/optionBoxSelectedDown.png";
880 bitmaps[disabledChecked].fileName = "<:ecere>elements/optionBoxDisabledSelected.png";
882 AddResource(bitmaps[up]);
883 AddResource(bitmaps[down]);
884 AddResource(bitmaps[disabled]);
885 AddResource(bitmaps[upChecked]);
886 AddResource(bitmaps[downChecked]);
887 AddResource(bitmaps[disabledChecked]);
890 buttonStyle.radio = true;
891 buttonStyle.checkBox = false;
892 buttonStyle.bevel = false;
902 SetInitSize(initSize);
904 get { return buttonStyle.radio; }
906 property bool isCheckbox
908 property_category "Behavior"
913 buttonStyle.checkBox = true;
916 buttonStyle.radio = false;
917 buttonStyle.bevel = false;
922 buttonStyle.checkBox = false;
925 SetInitSize(initSize);
927 get { return buttonStyle.checkBox; }
931 property_category "Behavior"
936 buttonStyle.bevel = true;
938 buttonStyle.checkBox = false;
939 buttonStyle.radio = false;
940 buttonStyle.bevelOver = false;
946 buttonStyle.bevel = false;
951 get { return buttonStyle.bevel; }
953 property bool bevelOver
955 property_category "Behavior"
960 buttonStyle.bevelOver = true;
961 buttonStyle.offset = true;
962 buttonStyle.bevel = false;
966 buttonStyle.bevelOver = false;
967 buttonStyle.offset = false;
970 get { return buttonStyle.bevelOver; }
972 property bool toggle { property_category "Behavior" set { buttonStyle.toggle = value; } get { return buttonStyle.toggle; } };
973 property bool checked
975 property_category "Appearance"
978 if(buttonStyle.toggle)
980 state = value ? down : up;
984 if(buttonStyle.radio && value)
986 Window parent = this.parent;
990 for(otherWindow = parent.firstChild; otherWindow; otherWindow = otherWindow.next)
992 if(otherWindow != this && eClass_IsDerived(otherWindow._class, _class))
994 Button otherButton = (Button)otherWindow;
995 if(otherButton.buttonStyle.radio)
996 otherButton.checked = false;
1005 get { return buttonStyle.toggle ? (state == down) : checked; }
1007 property Alignment alignment { property_category "Appearance" set { alignment = value; } get { return alignment; } };
1008 property BitmapResource bitmap
1010 property_category "Appearance"
1014 RemoveResource(bitmaps[up]);
1015 bitmaps[up] = value;
1017 RemoveResource(bitmaps[over]);
1018 RemoveResource(bitmaps[down]);
1019 RemoveResource(bitmaps[disabled]);
1020 RemoveResource(bitmaps[upChecked]);
1021 RemoveResource(bitmaps[overChecked]);
1022 RemoveResource(bitmaps[downChecked]);
1023 RemoveResource(bitmaps[disabledChecked]);
1025 bitmaps[over] = null;
1026 bitmaps[down] = null;
1027 bitmaps[disabled] = null;
1028 bitmaps[upChecked] = null;
1029 bitmaps[overChecked] = null;
1030 bitmaps[downChecked] = null;
1031 bitmaps[disabledChecked] = null;
1034 if(buttonStyle.radio && !value)
1036 AddResource((bitmaps[up] = BitmapResource { fileName = "<:ecere>elements/optionBox.png" }));
1037 AddResource((bitmaps[down] = BitmapResource { fileName = "<:ecere>elements/optionBox.png" }));
1038 AddResource((bitmaps[disabled] = BitmapResource { fileName = "<:ecere>elements/optionBoxDisabled.png" }));
1039 AddResource((bitmaps[upChecked] = BitmapResource { fileName = "<:ecere>elements/optionBoxSelected.png" }));
1040 AddResource((bitmaps[downChecked] = BitmapResource { fileName = "<:ecere>elements/optionBoxSelected.png" }));
1041 AddResource((bitmaps[disabledChecked] = BitmapResource { fileName = "<:ecere>elements/optionBoxDisabledSelected.png" }));
1043 else */if(!bitmaps[disabled])
1045 bitmaps[disabled] = BitmapResource { fileName = bitmap.fileName, grayed = true };
1046 AddResource(bitmaps[disabled]);
1049 get { return bitmaps[up]; }
1051 property bool stayUp { property_category "Behavior" set { buttonStyle.stayUp = value; } get { return buttonStyle.stayUp; } };
1052 property bool scaleBitmap { property_category "Appearance" set { buttonStyle.scale = value; } get { return buttonStyle.scale; } };
1053 property bool keyRepeat { property_category "Behavior" set { buttonStyle.keyRepeat = value; } get { return buttonStyle.keyRepeat; } };
1054 property unichar symbol { property_category "Appearance" set { this.symbol = value; } get { return symbol; } };
1055 property bool ellipsis { property_category "Appearance" set { buttonStyle.ellipsis = value; } get { return buttonStyle.ellipsis; } };
1056 property bool stayDown { property_category "Behavior" set { buttonStyle.stayDown = value; } get { return buttonStyle.stayDown; } };
1057 property bool offset { property_category "Behavior" set { buttonStyle.offset = value; } get { return buttonStyle.offset; } };
1059 property ButtonState buttonState { get { return state; } set { state = value; } };
1060 property BoxAlignment bitmapAlignment { property_category "Appearance" set { bitmapAlignment = value; } get { return bitmapAlignment; } };