7 #define CORNER (BORDER * 2)
12 #define BUTTON_OFFSET 0
14 #define NAME_OFFSETX 4
19 #define MENU_HEIGHT 25
20 #define STATUS_HEIGHT 18
22 #define TEXT_COLOR skinForeground
23 #define TEXT_INACTIVE darkGray
25 define skinBackground = Color { r = 40, g = 40, b = 40 };
26 define skinForeground = white;
27 define skinTextForeground = lightGray;
28 define evenRowBackground = Color { 80, 70, 60 };
29 define selectionColor = steelBlue;
31 ColorKey skinGradient[3] =
33 { Color { 40,40,40 }, 0.0f },
35 { Color { 40,40,40 }, 1.0f },
39 define skinBackground = white; //Color { 255, 255, 255 };
40 define skinForeground = black;
41 define skinTextForeground = black;
42 define evenRowBackground = lavender;
43 define selectionColor = cornflowerBlue;
45 ColorKey skinGradient[2] =
52 class AcovelSkin_Window : Window
54 void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving)
56 bool isNormal = (state == normal || state == maximized);
57 int top = 0, border = 0, bottom = 0;
58 if(state == minimized)
59 top = border = bottom = DEAD_BORDER;
60 else if(((BorderBits)borderStyle).sizable)
62 top = isNormal ? TOP : 0;
63 border = isNormal ? BORDER : 0;
66 else if(((BorderBits)borderStyle).fixed)
68 top = 2; //DEAD_BORDER;
72 else if(((BorderBits)borderStyle).contour)
79 if(((BorderBits)borderStyle).deep || ((BorderBits)borderStyle).bevel)
81 int deepTop = 0, deepBottom = 0, deepBorder = 0;
82 if(((BorderBits)borderStyle).contour)
85 deepTop = (((BorderBits)borderStyle).fixed && (state != maximized || !parent.menuBar)) ? (top + CAPTION) : top;
86 deepBottom = (((BorderBits)borderStyle).sizable && isNormal) ? bottom : border;
89 surface.Bevel(((BorderBits)borderStyle).bevel ? false : true, deepBorder, deepTop,
90 size.w - deepBorder - deepBorder, size.h - deepBottom - deepTop);
93 if(((BorderBits)borderStyle).fixed && (state != maximized || !parent.menuBar))
96 if(state != maximized || !((BorderBits)borderStyle).sizable)
98 // Frame for ES_CAPTION windows
99 surface.Bevel(false, 0, 0, size.w, size.h);
100 surface.SetForeground(activeBorder);
101 surface.Rectangle(2, 2, size.w-3, size.h-3);
103 // Resizeable frame is 1 pixel thicker
104 if(((BorderBits)borderStyle).sizable && isNormal)
105 surface.Rectangle(3, 3, size.w - 4, size.h - 4);
110 surface.Gradient(gradient, sizeof(gradient) / sizeof(ColorKey), GRADIENT_SMOOTHNESS, GRADIENT_DIRECTION,
111 border, top, size.w - border - 1, top + CAPTION - 2);
113 surface.Gradient(gradientInactive, sizeof(gradientInactive) / sizeof(ColorKey),
114 GRADIENT_SMOOTHNESS, GRADIENT_DIRECTION,
115 border, top, size.w - border - 1, top + CAPTION - 2);
117 surface.SetForeground(activeBorder);
118 if(state != minimized)
119 surface.HLine(border, size.w-border-1, top + CAPTION-1);
122 surface.SetForeground(skinBackground);
123 surface.Rectangle(0,0, size.w-1, size.h-1);
124 surface.SetForeground(active ? TEXT_COLOR : TEXT_INACTIVE /*skinForeground*/);
125 surface.Rectangle(1,1, size.w-2, size.h-2);
126 surface.SetBackground(skinBackground);
127 surface.Area(2, 2, size.w-3, CAPTION + 2);
129 // surface.TextFont(captionFont);
130 // surface.WriteText(4,2, name, strlen(name));
132 surface.SetForeground((active ? TEXT_COLOR : TEXT_INACTIVE));
133 surface.TextOpacity(false);
134 surface.TextFont(captionFont);
137 int buttonsSize = border +
138 ((hasMaximize || hasMinimize) ? 52 : 18);
139 surface.WriteTextDots(left, border + NAME_OFFSETX, top + NAME_OFFSET,
140 size.w - (buttonsSize + border + 4), name, strlen(name));
143 if(((BorderBits)borderStyle).contour && !((BorderBits)borderStyle).fixed)
145 surface.SetForeground(skinForeground /*black*/);
146 surface.Rectangle(0, 0, size.w - 1, size.h - 1);
149 if(state != minimized && hasHorzScroll && hasVertScroll)
151 if(sbh && sbh.visible && sbv && sbv.visible)
153 surface.SetBackground(activeBorder);
155 clientStart.x + clientSize.w,
156 clientStart.y + clientSize.h,
157 clientStart.x + clientSize.w + SB_WIDTH - 1,
158 clientStart.y + clientSize.h + SB_HEIGHT - 1);
163 void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h)
166 if((((BorderBits)borderStyle).deep || ((BorderBits)borderStyle).bevel) && state != minimized)
171 if(((BorderBits)borderStyle).sizable && (state == normal || state == maximized))
176 if(((BorderBits)borderStyle).fixed && (state != maximized || !parent.menuBar))
179 if(!((BorderBits)borderStyle).sizable || state == minimized)
185 if(((BorderBits)borderStyle).contour && !((BorderBits)borderStyle).fixed)
190 if(hasMenuBar && state != minimized)
194 if(statusBar && state != minimized)
200 bool IsMouseMoving(int x, int y, int w, int h)
202 BorderBits style = (BorderBits)borderStyle; // TOFIX: borderStyle.fixed doesn't work
205 bool resizeX, resizeY, resizeEndX, resizeEndY;
206 if(!IsMouseResizing(x, y, w, h, &resizeX, &resizeY, &resizeEndX, &resizeEndY))
212 bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
216 *resizeX = *resizeY = *resizeEndX = *resizeEndY = false;
218 if(((BorderBits)borderStyle).sizable && (state == normal))
221 if(Box { 0, 0,CORNER-1, TOP-1 }.IsPointInside({x, y}))
222 result = *resizeX = *resizeY = true;
224 if(Box { w-CORNER-1, 0, w-1, TOP-1 }.IsPointInside({x, y}))
225 result = *resizeEndX = *resizeY = true;
227 if(Box { 0, h-BOTTOM-1, CORNER-1, h-1 }.IsPointInside({x, y}))
228 result = *resizeX = *resizeEndY = true;
229 // BottomRight Corner
230 if(Box { w-CORNER-1, h-BOTTOM-1, w-1, h-1 }.IsPointInside({x, y}))
231 result = *resizeEndX = *resizeEndY = true;
233 if(Box { 0,TOP, BORDER, h-BOTTOM-1 }.IsPointInside({x, y}))
234 result = *resizeX = true;
236 if(Box { w-BORDER-1, TOP, w-1, h-BOTTOM-1 }.IsPointInside({x, y}))
237 result = *resizeEndX = true;
239 if(Box { CORNER, 0, w-CORNER-1, TOP-1 }.IsPointInside({x, y}))
240 result = *resizeY = true;
242 if(Box { CORNER, h-BOTTOM-1, w-CORNER-1, h-1 }.IsPointInside({x, y}))
243 result = *resizeEndY = true;
248 void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh)
250 bool isNormal = (state == normal || state == maximized);
251 if(((BorderBits)borderStyle).fixed && (state != maximized || !parent.menuBar))
259 if(((BorderBits)borderStyle).sizable && isNormal)
261 // GetDecorationsSize(window, mw, mh);
268 if(hasVertScroll && hasHorzScroll)
270 *mw += 2 * SB_WIDTH + SB_WIDTH;
271 *mh += 2 * SB_HEIGHT + SB_HEIGHT;
273 if(((BorderBits)borderStyle).sizable && isNormal)
279 void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
281 bool isNormal = (state == normal || state == maximized);
282 MinMaxValue aw = 0, ah = 0;
286 GetDecorationsSize(&aw, &ah);
288 // Compute client area start
289 if(((BorderBits)borderStyle).deep || ((BorderBits)borderStyle).bevel)
295 if(((BorderBits)borderStyle).sizable && isNormal)
306 if(((BorderBits)borderStyle).fixed && (state != maximized || !parent.menuBar))
309 if(!((BorderBits)borderStyle).sizable || state == minimized)
316 if(((BorderBits)borderStyle).contour && !((BorderBits)borderStyle).fixed)
322 // Reduce client area
330 void UpdateNonClient()
332 bool isNormal = (state == normal || state == maximized);
333 int top = 0, border = 0;
335 if(state == minimized)
336 top = border = DEAD_BORDER;
337 else if(((BorderBits)borderStyle).sizable)
339 if(state == maximized && parent.menuBar)
346 top = isNormal ? TOP : 0;
347 border = isNormal ? BORDER : 0;
350 else if(((BorderBits)borderStyle).fixed)
355 else if(((BorderBits)borderStyle).contour)
360 insideBorder = border;
361 if(((BorderBits)borderStyle).deep)
366 if(state == minimized)
367 menuBar.visible = false;
369 menuBar.visible = true;
370 menuBar.Move(clientStart.x, clientStart.y - MENU_HEIGHT, size.w - insideBorder * 2, MENU_HEIGHT);
374 if(state == minimized)
375 statusBar.visible = false;
378 statusBar.visible = true;
379 statusBar.anchor = { left = clientStart.x, bottom = border };
380 statusBar.size.w = size.w - insideBorder * 2;
386 minimizeButton.anchor = { right = ((maximizeButton && !maximizeButton.disabled) ? 49 : 24) + border, top = top + BUTTON_OFFSET };
387 minimizeButton.size = { 20, 10 };
388 minimizeButton.foreground = skinForeground;
389 minimizeButton.background = skinBackground;
390 minimizeButton.bevel = false;
391 minimizeButton.OnRedraw = Minimize_OnRedraw;
392 minimizeButton.visible = true;
394 if(maximizeButton && !maximizeButton.disabled)
396 maximizeButton.anchor = { right = 24 + border, top = top + BUTTON_OFFSET };
397 maximizeButton.size = { 20, 10 };
398 maximizeButton.bevel = false;
399 maximizeButton.foreground = skinForeground;
400 maximizeButton.background = skinBackground;
401 maximizeButton.OnRedraw = Maximize_OnRedraw;
402 maximizeButton.visible = true;
406 closeButton.anchor = { right = -1 + border, top = top + BUTTON_OFFSET };
407 closeButton.size = { 20, 10 };
408 closeButton.bevel = false;
409 closeButton.foreground = skinForeground;
410 closeButton.background = skinBackground;
411 closeButton.OnRedraw = Close_OnRedraw;
412 closeButton.visible = true;
416 void OnApplyGraphics()
418 background = skinBackground;
419 foreground = skinForeground;
423 static void Button::SmallButton_OnRedraw(Surface surface)
425 surface.SetForeground(parent.active ? TEXT_COLOR : TEXT_INACTIVE);
426 surface.VLine(0, clientSize.h-2, 0);
427 surface.VLine(0, clientSize.h-2, clientSize.w-1);
428 surface.HLine(1,clientSize.w-2, clientSize.h-1);
431 static void Button::Minimize_OnRedraw(Surface surface)
433 SmallButton_OnRedraw(this, surface);
434 surface.DrawLine( 5, 3, 14, 3);
435 surface.DrawLine( 5, 4, 14, 4);
438 static void Button::Maximize_OnRedraw(Surface surface)
440 SmallButton_OnRedraw(this, surface);
441 surface.Rectangle( 5, 2, 14, 7);
442 surface.DrawLine( 5, 3, 14, 4);
445 static void Button::Close_OnRedraw(Surface surface)
447 SmallButton_OnRedraw(this, surface);
448 surface.DrawLine( 7, 2, 12, 7);
449 surface.DrawLine( 8, 2, 13, 7);
450 surface.DrawLine( 12, 2, 7, 7);
451 surface.DrawLine( 13, 2, 8, 7);
454 class AcovelSkin_StatusBar : StatusBar
456 void OnApplyGraphics()
458 background = skinBackground;
459 foreground = skinForeground;
463 class AcovelSkin_FileDialog : FileDialog
465 void OnApplyGraphics()
468 background = skinBackground;
469 foreground = skinForeground;
470 for(child = firstChild; child; child = child.next)
473 child.foreground = skinForeground;
478 #define PUREVTBL(c) ((int (**)())*(void **)((byte *)class(c).data + 4))
480 extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnApplyGraphics;
481 extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw;
490 class AcovelSkin_Button : Button
492 void OnApplyGraphics()
494 //background = skinBackground;
495 background = Color { (int)70 * 6/10, (int)130* 6/10, (int)180* 6/10 };
496 foreground = skinForeground;
499 void OnRedraw(Surface surface)
501 int isDefault = (int)this.isDefault;
502 PUREVTBL(Button)[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw](this, surface);
503 if(bevel || (bevelOver && (buttonState == down || buttonState == over || checked)))
506 if(buttonState == down || checked)
508 surface.SetForeground(selectionColor);
509 surface.HLine(isDefault + 0, clientSize.w-2-isDefault, 0);
510 surface.VLine(isDefault + 1, clientSize.h-2-isDefault, 0);
511 surface.SetForeground(Color { Min((int)c.r * 16/10, 255), Min((int)c.g * 16/10, 255), Min((int)c.b * 16/10,255) });
512 surface.HLine(isDefault + 0, clientSize.w-1-isDefault, clientSize.h-1-isDefault);
513 surface.VLine(isDefault + 0, clientSize.h-2-isDefault, clientSize.w-1-isDefault);
517 surface.SetForeground(Color { Min((int)c.r * 16/10, 255), Min((int)c.g * 16/10, 255), Min((int)c.b * 16/10,255) });
518 surface.HLine(0 + isDefault, clientSize.w-2 - isDefault, isDefault);
519 surface.VLine(1 + isDefault, clientSize.h-2 - isDefault, isDefault);
522 surface.SetForeground(selectionColor);
523 surface.HLine(1 + isDefault, clientSize.w-2 - isDefault, clientSize.h-2 - isDefault);
524 surface.VLine(1 + isDefault, clientSize.h-3 - isDefault, clientSize.w-2 - isDefault);
528 //surface.SetForeground(skinForeground);
529 surface.SetForeground(Color { c.r * 4/10, c.g * 4/10, c.b * 4/10 });
530 surface.HLine( isDefault, clientSize.w-1 - isDefault, clientSize.h-1 - isDefault);
531 surface.VLine( isDefault, clientSize.h-2 - isDefault, clientSize.w-1 - isDefault);
537 surface.SetForeground(skinForeground);
538 surface.Rectangle(0,0,clientSize.w-1,clientSize.h-1);
540 if(!(bevelOver) && !isRemote)
545 int offset = (buttonState == down && this.offset) ? 1 : 0;
546 surface.SetForeground(skinForeground);
547 surface.LineStipple(0x5555);
549 #define CAPTION_DISTANCE 18
550 if((isRadio || isCheckbox) && text)
552 x1 = /*clientSize.h + */CAPTION_DISTANCE;
561 x2 = clientSize.w - 5+offset;
562 y2 = clientSize.h - 5+offset;
564 if(isRadio || isCheckbox)
572 if((x2 - x1) & 1) x2++;
573 if((y2 - y1) & 1) y2++;
575 surface.Rectangle(x1, y1, x2, y2);
576 surface.LineStipple(0);
582 class AcovelSkin_ScrollBar : ScrollBar
584 void OnApplyGraphics()
586 PUREVTBL(ScrollBar)[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnApplyGraphics](this);
588 background = { skinBackground.r * 9 / 6, skinBackground.g * 9 / 6, skinBackground.b * 9 / 6 };
590 upBtn.background = Color { 70 * 6/10, 130* 6/10, 180* 6/10 }; //skinBackground;
591 upBtn.bitmap = { "<:ecere>elements/arrowUp.png", monochrome = true };
592 downBtn.background = Color { 70 * 6/10, 130* 6/10, 180* 6/10 }; //skinBackground;
593 downBtn.bitmap = { "<:ecere>elements/arrowDown.png", monochrome = true };
594 thumb.background = Color { 70 * 6/10, 130* 6/10, 180* 6/10 }; //skinBackground;
598 class AcovelSkin_DropBox : DropBox
600 void OnApplyGraphics()
602 PUREVTBL(DropBox)[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnApplyGraphics](this);
603 button.bitmap = { "<:ecere>elements/arrowDown.png", monochrome = true };
604 background = skinBackground;
605 foreground = skinForeground;
606 this.selectionColor = ::selectionColor;
610 class AcovelSkin_ListBox : ListBox
612 void OnApplyGraphics()
614 PUREVTBL(ListBox)[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnApplyGraphics](this);
615 background = skinBackground;
616 foreground = skinForeground;
617 this.selectionColor = ::selectionColor;
621 class AcovelSkin : Skin
623 class_property(name) = "Acovel";
624 class_property(selectionColor) = (Color)selectionColor;
625 class_property(disabledBackColor) = (Color)Color{ 0,0,0 };
626 class_property(disabledFrontColor) = (Color)Color{ 128,128,128 };
628 FontResource ::SystemFont()
630 return { faceName = "Tahoma", size = 8.25f };
633 FontResource ::CaptionFont()
635 return { faceName = "Verdana", size = 6.5f };
638 char * ::CursorsBitmaps(uint id, int *hotSpotX, int *hotSpotY, byte ** paletteShades)
643 BitmapResource ::GetBitmap(int id)
653 int ::HorizontalSBH()