6 define skinBackground = Color { r = 40, g = 40, b = 40 };
7 define skinForeground = white;
8 define skinTextForeground = lightGray;
9 define evenRowBackground = Color { 80, 70, 60 };
10 define selectionColor = steelBlue;
12 ColorKey skinGradient[3] =
14 { Color { 40,40,40 }, 0.0f },
16 { Color { 40,40,40 }, 1.0f },
21 define skinForeground = black;
22 define skinTextForeground = black;
23 define skinBackground = white;
24 define evenRowBackground = lavender;
25 define selectionColor = cornflowerBlue;
27 ColorKey skinGradient[2] =
38 #define CORNER (BORDER * 2)
43 #define BUTTON_OFFSET 0
45 #define NAME_OFFSETX 4
50 #define MENU_HEIGHT 25
51 #define STATUS_HEIGHT 18
53 #define TEXT_COLOR skinForeground
54 #define TEXT_INACTIVE darkGray
56 class AcovelSkin_Window : Window
58 void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving)
60 bool isNormal = (state == normal || state == maximized);
61 int top = 0, border = 0, bottom = 0;
62 if(state == minimized)
63 top = border = bottom = DEAD_BORDER;
64 else if(((BorderBits)borderStyle).sizable)
66 top = isNormal ? TOP : 0;
67 border = isNormal ? BORDER : 0;
70 else if(((BorderBits)borderStyle).fixed)
72 top = 2; //DEAD_BORDER;
76 else if(((BorderBits)borderStyle).contour)
83 if(((BorderBits)borderStyle).deep || ((BorderBits)borderStyle).bevel)
85 int deepTop = 0, deepBottom = 0, deepBorder = 0;
86 if(((BorderBits)borderStyle).contour)
89 deepTop = (((BorderBits)borderStyle).fixed && (state != maximized || !parent.menuBar)) ? (top + CAPTION) : top;
90 deepBottom = (((BorderBits)borderStyle).sizable && isNormal) ? bottom : border;
93 surface.Bevel(((BorderBits)borderStyle).bevel ? false : true, deepBorder, deepTop,
94 size.w - deepBorder - deepBorder, size.h - deepBottom - deepTop);
97 if(((BorderBits)borderStyle).fixed && (state != maximized || !parent.menuBar))
100 if(state != maximized || !((BorderBits)borderStyle).sizable)
102 // Frame for ES_CAPTION windows
103 surface.Bevel(false, 0, 0, size.w, size.h);
104 surface.SetForeground(activeBorder);
105 surface.Rectangle(2, 2, size.w-3, size.h-3);
107 // Resizeable frame is 1 pixel thicker
108 if(((BorderBits)borderStyle).sizable && isNormal)
109 surface.Rectangle(3, 3, size.w - 4, size.h - 4);
114 surface.Gradient(gradient, sizeof(gradient) / sizeof(ColorKey), GRADIENT_SMOOTHNESS, GRADIENT_DIRECTION,
115 border, top, size.w - border - 1, top + CAPTION - 2);
117 surface.Gradient(gradientInactive, sizeof(gradientInactive) / sizeof(ColorKey),
118 GRADIENT_SMOOTHNESS, GRADIENT_DIRECTION,
119 border, top, size.w - border - 1, top + CAPTION - 2);
121 surface.SetForeground(activeBorder);
122 if(state != minimized)
123 surface.HLine(border, size.w-border-1, top + CAPTION-1);
126 surface.SetForeground(skinBackground);
127 surface.Rectangle(0,0, size.w-1, size.h-1);
128 surface.SetForeground(active ? TEXT_COLOR : TEXT_INACTIVE /*skinForeground*/);
129 surface.Rectangle(1,1, size.w-2, size.h-2);
130 surface.SetBackground(skinBackground);
131 surface.Area(2, 2, size.w-3, CAPTION + 2);
133 // surface.TextFont(captionFont);
134 // surface.WriteText(4,2, name, strlen(name));
136 surface.SetForeground((active ? TEXT_COLOR : TEXT_INACTIVE));
137 surface.TextOpacity(false);
138 surface.TextFont(captionFont);
141 int buttonsSize = border +
142 ((hasMaximize || hasMinimize) ? 52 : 18);
143 surface.WriteTextDots(left, border + NAME_OFFSETX, top + NAME_OFFSET,
144 size.w - (buttonsSize + border + 4), name, strlen(name));
147 if(((BorderBits)borderStyle).contour && !((BorderBits)borderStyle).fixed)
149 surface.SetForeground(skinForeground /*black*/);
150 surface.Rectangle(0, 0, size.w - 1, size.h - 1);
153 if(state != minimized && hasHorzScroll && hasVertScroll)
155 if(sbh && sbh.visible && sbv && sbv.visible)
157 surface.SetBackground(activeBorder);
159 clientStart.x + clientSize.w,
160 clientStart.y + clientSize.h,
161 clientStart.x + clientSize.w + SB_WIDTH - 1,
162 clientStart.y + clientSize.h + SB_HEIGHT - 1);
167 void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h)
170 if((((BorderBits)borderStyle).deep || ((BorderBits)borderStyle).bevel) && state != minimized)
175 if(((BorderBits)borderStyle).sizable && (state == normal || state == maximized))
180 if(((BorderBits)borderStyle).fixed && (state != maximized || !parent.menuBar))
183 if(!((BorderBits)borderStyle).sizable || state == minimized)
189 if(((BorderBits)borderStyle).contour && !((BorderBits)borderStyle).fixed)
194 if(hasMenuBar && state != minimized)
198 if(statusBar && state != minimized)
204 bool IsMouseMoving(int x, int y, int w, int h)
206 BorderBits style = (BorderBits)borderStyle; // TOFIX: borderStyle.fixed doesn't work
209 bool resizeX, resizeY, resizeEndX, resizeEndY;
210 if(!IsMouseResizing(x, y, w, h, &resizeX, &resizeY, &resizeEndX, &resizeEndY))
216 bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
220 *resizeX = *resizeY = *resizeEndX = *resizeEndY = false;
222 if(((BorderBits)borderStyle).sizable && (state == normal))
225 if(Box { 0, 0,CORNER-1, TOP-1 }.IsPointInside({x, y}))
226 result = *resizeX = *resizeY = true;
228 if(Box { w-CORNER-1, 0, w-1, TOP-1 }.IsPointInside({x, y}))
229 result = *resizeEndX = *resizeY = true;
231 if(Box { 0, h-BOTTOM-1, CORNER-1, h-1 }.IsPointInside({x, y}))
232 result = *resizeX = *resizeEndY = true;
233 // BottomRight Corner
234 if(Box { w-CORNER-1, h-BOTTOM-1, w-1, h-1 }.IsPointInside({x, y}))
235 result = *resizeEndX = *resizeEndY = true;
237 if(Box { 0,TOP, BORDER, h-BOTTOM-1 }.IsPointInside({x, y}))
238 result = *resizeX = true;
240 if(Box { w-BORDER-1, TOP, w-1, h-BOTTOM-1 }.IsPointInside({x, y}))
241 result = *resizeEndX = true;
243 if(Box { CORNER, 0, w-CORNER-1, TOP-1 }.IsPointInside({x, y}))
244 result = *resizeY = true;
246 if(Box { CORNER, h-BOTTOM-1, w-CORNER-1, h-1 }.IsPointInside({x, y}))
247 result = *resizeEndY = true;
252 void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh)
254 bool isNormal = (state == normal || state == maximized);
255 if(((BorderBits)borderStyle).fixed && (state != maximized || !parent.menuBar))
263 if(((BorderBits)borderStyle).sizable && isNormal)
265 // GetDecorationsSize(window, mw, mh);
272 if(hasVertScroll && hasHorzScroll)
274 *mw += 2 * SB_WIDTH + SB_WIDTH;
275 *mh += 2 * SB_HEIGHT + SB_HEIGHT;
277 if(((BorderBits)borderStyle).sizable && isNormal)
283 void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
285 bool isNormal = (state == normal || state == maximized);
286 MinMaxValue aw = 0, ah = 0;
290 GetDecorationsSize(&aw, &ah);
292 // Compute client area start
293 if(((BorderBits)borderStyle).deep || ((BorderBits)borderStyle).bevel)
299 if(((BorderBits)borderStyle).sizable && isNormal)
310 if(((BorderBits)borderStyle).fixed && (state != maximized || !parent.menuBar))
313 if(!((BorderBits)borderStyle).sizable || state == minimized)
320 if(((BorderBits)borderStyle).contour && !((BorderBits)borderStyle).fixed)
326 // Reduce client area
334 void UpdateNonClient()
336 bool isNormal = (state == normal || state == maximized);
337 int top = 0, border = 0;
339 if(state == minimized)
340 top = border = DEAD_BORDER;
341 else if(((BorderBits)borderStyle).sizable)
343 if(state == maximized && parent.menuBar)
350 top = isNormal ? TOP : 0;
351 border = isNormal ? BORDER : 0;
354 else if(((BorderBits)borderStyle).fixed)
359 else if(((BorderBits)borderStyle).contour)
364 insideBorder = border;
365 if(((BorderBits)borderStyle).deep)
370 if(state == minimized)
371 menuBar.visible = false;
373 menuBar.visible = true;
374 menuBar.Move(clientStart.x, clientStart.y - MENU_HEIGHT, size.w - insideBorder * 2, MENU_HEIGHT);
378 if(state == minimized)
379 statusBar.visible = false;
382 statusBar.visible = true;
383 statusBar.anchor = { left = clientStart.x, bottom = border };
384 statusBar.size.w = size.w - insideBorder * 2;
390 minimizeButton.anchor = { right = ((maximizeButton && !maximizeButton.disabled) ? 49 : 24) + border, top = top + BUTTON_OFFSET };
391 minimizeButton.size = { 20, 10 };
392 minimizeButton.foreground = skinForeground;
393 minimizeButton.background = skinBackground;
394 minimizeButton.bevel = false;
395 minimizeButton.OnRedraw = Minimize_OnRedraw;
396 minimizeButton.visible = true;
398 if(maximizeButton && !maximizeButton.disabled)
400 maximizeButton.anchor = { right = 24 + border, top = top + BUTTON_OFFSET };
401 maximizeButton.size = { 20, 10 };
402 maximizeButton.bevel = false;
403 maximizeButton.foreground = skinForeground;
404 maximizeButton.background = skinBackground;
405 maximizeButton.OnRedraw = Maximize_OnRedraw;
406 maximizeButton.visible = true;
410 closeButton.anchor = { right = -1 + border, top = top + BUTTON_OFFSET };
411 closeButton.size = { 20, 10 };
412 closeButton.bevel = false;
413 closeButton.foreground = skinForeground;
414 closeButton.background = skinBackground;
415 closeButton.OnRedraw = Close_OnRedraw;
416 closeButton.visible = true;
420 void OnApplyGraphics()
422 background = skinBackground;
423 foreground = skinForeground;
427 static void Button::SmallButton_OnRedraw(Surface surface)
429 surface.SetForeground(parent.active ? TEXT_COLOR : TEXT_INACTIVE);
430 surface.VLine(0, clientSize.h-2, 0);
431 surface.VLine(0, clientSize.h-2, clientSize.w-1);
432 surface.HLine(1,clientSize.w-2, clientSize.h-1);
435 static void Button::Minimize_OnRedraw(Surface surface)
437 SmallButton_OnRedraw(this, surface);
438 surface.DrawLine( 5, 3, 14, 3);
439 surface.DrawLine( 5, 4, 14, 4);
442 static void Button::Maximize_OnRedraw(Surface surface)
444 SmallButton_OnRedraw(this, surface);
445 surface.Rectangle( 5, 2, 14, 7);
446 surface.DrawLine( 5, 3, 14, 3);
449 static void Button::Close_OnRedraw(Surface surface)
451 SmallButton_OnRedraw(this, surface);
452 surface.DrawLine( 7, 2, 12, 7);
453 surface.DrawLine( 8, 2, 13, 7);
454 surface.DrawLine( 12, 2, 7, 7);
455 surface.DrawLine( 13, 2, 8, 7);
458 class AcovelSkin_StatusBar : StatusBar
460 void OnApplyGraphics()
462 background = skinBackground;
463 foreground = skinForeground;
467 class AcovelSkin_FileDialog : FileDialog
469 void OnApplyGraphics()
472 background = skinBackground;
473 foreground = skinForeground;
474 for(child = firstChild; child; child = child.next)
477 child.foreground = skinForeground;
482 #define PUREVTBL(c) ((int (**)())*(void **)((byte *)class(c).data + sizeof(void *)))
484 extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnApplyGraphics;
485 extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw;
494 class AcovelSkin_Button : Button
496 void OnApplyGraphics()
498 //background = skinBackground;
499 background = Color { (int)70 * 6/10, (int)130* 6/10, (int)180* 6/10 };
500 foreground = skinForeground;
503 void OnRedraw(Surface surface)
505 int isDefault = (int)this.isDefault;
506 ((void (*)(Window, Surface))(void *)PUREVTBL(Button)[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(this, surface);
507 if(bevel || (bevelOver && (buttonState == down || buttonState == over || checked)))
510 if(buttonState == down || checked)
512 surface.SetForeground(selectionColor);
513 surface.HLine(isDefault + 0, clientSize.w-2-isDefault, 0);
514 surface.VLine(isDefault + 1, clientSize.h-2-isDefault, 0);
515 surface.SetForeground(Color { Min((int)c.r * 16/10, 255), Min((int)c.g * 16/10, 255), Min((int)c.b * 16/10,255) });
516 surface.HLine(isDefault + 0, clientSize.w-1-isDefault, clientSize.h-1-isDefault);
517 surface.VLine(isDefault + 0, clientSize.h-2-isDefault, clientSize.w-1-isDefault);
521 surface.SetForeground(Color { Min((int)c.r * 16/10, 255), Min((int)c.g * 16/10, 255), Min((int)c.b * 16/10,255) });
522 surface.HLine(0 + isDefault, clientSize.w-2 - isDefault, isDefault);
523 surface.VLine(1 + isDefault, clientSize.h-2 - isDefault, isDefault);
526 surface.SetForeground(selectionColor);
527 surface.HLine(1 + isDefault, clientSize.w-2 - isDefault, clientSize.h-2 - isDefault);
528 surface.VLine(1 + isDefault, clientSize.h-3 - isDefault, clientSize.w-2 - isDefault);
532 //surface.SetForeground(skinForeground);
533 surface.SetForeground(Color { c.r * 4/10, c.g * 4/10, c.b * 4/10 });
534 surface.HLine( isDefault, clientSize.w-1 - isDefault, clientSize.h-1 - isDefault);
535 surface.VLine( isDefault, clientSize.h-2 - isDefault, clientSize.w-1 - isDefault);
541 surface.SetForeground(skinForeground);
542 surface.Rectangle(0,0,clientSize.w-1,clientSize.h-1);
544 if(!(bevelOver) && !isRemote)
549 int offset = (buttonState == down && this.offset) ? 1 : 0;
550 surface.SetForeground(skinForeground);
551 surface.LineStipple(0x5555);
553 #define CAPTION_DISTANCE 18
554 if((isRadio || isCheckbox) && text)
556 x1 = /*clientSize.h + */CAPTION_DISTANCE;
565 x2 = clientSize.w - 5+offset;
566 y2 = clientSize.h - 5+offset;
568 if(isRadio || isCheckbox)
576 if((x2 - x1) & 1) x2++;
577 if((y2 - y1) & 1) y2++;
579 surface.Rectangle(x1, y1, x2, y2);
580 surface.LineStipple(0);
586 class AcovelSkin_ScrollBar : ScrollBar
588 void OnApplyGraphics()
590 ((void (*)(Window))(void *)PUREVTBL(ScrollBar)[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnApplyGraphics])(this);
592 background = { skinBackground.r * 9 / 6, skinBackground.g * 9 / 6, skinBackground.b * 9 / 6 };
594 upBtn.background = Color { 70 * 6/10, 130* 6/10, 180* 6/10 }; //skinBackground;
595 upBtn.bitmap = { "<:ecere>elements/arrowUp.png", monochrome = true };
596 downBtn.background = Color { 70 * 6/10, 130* 6/10, 180* 6/10 }; //skinBackground;
597 downBtn.bitmap = { "<:ecere>elements/arrowDown.png", monochrome = true };
598 thumb.background = Color { 70 * 6/10, 130* 6/10, 180* 6/10 }; //skinBackground;
602 class AcovelSkin_DropBox : DropBox
604 void OnApplyGraphics()
606 ((void (*)(Window))(void *)PUREVTBL(DropBox)[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnApplyGraphics])(this);
607 button.bitmap = { "<:ecere>elements/arrowDown.png", monochrome = true };
608 background = skinBackground;
609 foreground = skinForeground;
610 this.selectionColor = ::selectionColor;
614 class AcovelSkin_ListBox : ListBox
616 void OnApplyGraphics()
618 ((void (*)(Window))(void *)PUREVTBL(ListBox)[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnApplyGraphics])(this);
619 background = skinBackground;
620 foreground = skinForeground;
621 this.selectionColor = ::selectionColor;
625 public class AcovelSkin : Skin
627 class_property(name) = "Acovel";
628 class_property(selectionColor) = (Color)selectionColor;
629 class_property(disabledBackColor) = (Color)Color{ 0,0,0 };
630 class_property(disabledFrontColor) = (Color)Color{ 128,128,128 };
632 FontResource ::SystemFont()
634 return { faceName = "Tahoma", size = 8.25f };
637 FontResource ::CaptionFont()
639 return { faceName = "Verdana", size = 6.5f };
642 char * ::CursorsBitmaps(uint id, int *hotSpotX, int *hotSpotY, byte ** paletteShades)
647 BitmapResource ::GetBitmap(int id)
657 int ::HorizontalSBH()