{
return true;
}
-
+
bool OnLeftButtonDown(int x, int y, Modifiers mods)
{
Button::OnLeftButtonDown(x, y, mods);
surface.DrawLine(x+2,h-1, w-4, h-1);
surface.PutPixel(x,h-3);
surface.PutPixel(x+1,h-2);
-
+
surface.PutPixel(w-2, h - 3);
surface.PutPixel(w-3, h - 2);
break;
surface.DrawLine(x+2,0, w-4,0);
surface.PutPixel(x, 2);
surface.PutPixel(x+1, 1);
-
+
surface.PutPixel(w-2, 2);
surface.PutPixel(w-3, 1);
break;
surface.DrawLine(w-1,y+2, w-1, h-4);
surface.PutPixel(w-3, y);
surface.PutPixel(w-2, y+1);
-
+
surface.PutPixel(w - 3, h-2);
surface.PutPixel(w - 2, h-3);
break;
surface.DrawLine(0,y+2, 0, h-4);
surface.PutPixel(2, y);
surface.PutPixel(1, y+1);
-
+
surface.PutPixel(2, h-2);
surface.PutPixel(1, h-3);
break;
if(text)
surface.TextExtent(text, strlen(text),&tw, &th);
y = (clientSize.h - th - 1)/2 + (checked ? 0 : -2);
-
+
if(ellipsis)
{
int width = clientSize.w - 2*6;
surface.LineStipple(0x5555);
surface.Rectangle(x1, y1, x2, y2);
- surface.LineStipple(0);
+ surface.LineStipple(0);
}
}
}
{
case top:
button.size = selected ? { 74, 25 } : { 70, 22 };
- button.anchor = Anchor { left = buttonsOffset + button.tab.id * 70 + 2*of, bottom = 0 };
+ button.anchor = Anchor { left = buttonsOffset + (int)button.tab.id * 70 + 2*of, bottom = 0 };
break;
case bottom:
button.size = selected ? { 74, 25 } : { 70, 22 };
- button.anchor = Anchor { left = buttonsOffset + button.tab.id * 70 + 2*of, top = 0 };
+ button.anchor = Anchor { left = buttonsOffset + (int)button.tab.id * 70 + 2*of, top = 0 };
break;
case left:
button.size = selected ? { 73, 26 } : { 70, 22 };
- button.anchor = Anchor { top = buttonsOffset + button.tab.id * 22 + 2*of, right = 0 };
+ button.anchor = Anchor { top = buttonsOffset + (int)button.tab.id * 22 + 2*of, right = 0 };
break;
case right:
button.size = selected ? { 73, 26 } : { 70, 22 };
- button.anchor = Anchor { top = buttonsOffset + button.tab.id * 22 + 2*of, left = 0 };
+ button.anchor = Anchor { top = buttonsOffset + (int)button.tab.id * 22 + 2*of, left = 0 };
break;
}
}
static define skinMainColor = Color { 0, 71, 128 };
static define skinBackground = Color { 255, 255, 255 };
static define skinTextColor = skinMainColor;
-static define skinInactiveTextColor = Color { skinMainColor.r - 20, skinMainColor.g - 20, skinMainColor.b - 20 };
+static define skinInactiveTextColor = Color { 0, 51, 108 };
#define CAPTION 14
#define NAME_OFFSET 2
tabCycle = true;
int numTabs;
- background = white;//activeBorder;
+ background = white;//formColor;
Window tabButtons { this, opacity = 0, drawBehind = true };
}
}
else
- return true;
+ return true;
}
return false;
}
- void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving)
+ void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving)
{
if(placement == bottom && ((BorderBits)borderStyle).fixed)
{
- bool isNormal = (state == normal || state == maximized);
int top = 0, border = 0, bottom = 0;
if(state == minimized)
top = border = bottom = 0;
{
surface.SetForeground(gray);
surface.Rectangle(0,1, size.w-1, CAPTION+1);
-
+
surface.SetForeground(white);
surface.Rectangle(1, 1, clientSize.w-2, CAPTION-1);
- surface.SetBackground(skinBackground);
+ surface.SetBackground(skinBackground);
surface.Area(2, 2, size.w-3, CAPTION+1);
-
+
surface.SetForeground((active ? skinTextColor : skinInactiveTextColor));
surface.TextOpacity(false);
surface.TextFont(captionFont);
{
int buttonsSize = border +
((hasMaximize || hasMinimize) ? 52 : 18);
- surface.WriteTextDots(left, border + NAME_OFFSETX, top + NAME_OFFSET,
+ surface.WriteTextDots(left, border + NAME_OFFSETX, top + NAME_OFFSET,
size.w - (buttonsSize + border + 4), name, strlen(name));
}
}
{
if(sbh && sbh.visible && sbv && sbv.visible)
{
- surface.SetBackground(activeBorder);
+ surface.SetBackground(formColor);
surface.Area(
clientStart.x + clientSize.w,
clientStart.y + clientSize.h,
{
surface.SetForeground(white);
surface.Rectangle(
- clientStart.x + 1 + (placement == left) * 80,
- clientStart.y + 1 + (placement == top) * 30,
- clientStart.x + clientSize.w - (placement == right) * 80 - 2,
+ clientStart.x + 1 + (placement == left) * 80,
+ clientStart.y + 1 + (placement == top) * 30,
+ clientStart.x + clientSize.w - (placement == right) * 80 - 2,
clientStart.y + clientSize.h - (placement == bottom) * 30 - 2);
surface.SetForeground(gray);
surface.Rectangle(
- clientStart.x + (placement == left) * 80,
- clientStart.y + (placement == top) * 30,
- clientStart.x + clientSize.w - (placement == right) * 80 - 1,
+ clientStart.x + (placement == left) * 80,
+ clientStart.y + (placement == top) * 30,
+ clientStart.x + clientSize.w - (placement == right) * 80 - 1,
clientStart.y + clientSize.h - (placement == bottom) * 30 - 1);
}
if(curButton)
{
Box box;
- int id = curTab ? curTab.id : 0;
+ //int id = curTab ? (int)curTab.id : 0;
Button button = curButton;
int x = button.position.x;
int y = button.position.y;
-
+
switch(placement)
{
case TabsPlacement::bottom:
surface.SetForeground(white);
switch(placement)
{
- case TabsPlacement::bottom: surface.VLine(clientSize.h-32 + clientStart.y + 1, clientSize.h-28 + clientStart.y + 1, x + 1 + clientStart.x); break;
+ case TabsPlacement::bottom: surface.VLine(clientSize.h-32 + clientStart.y + 1, clientSize.h-28 + clientStart.y + 1, x + 1 + clientStart.x); break;
case TabsPlacement::top: surface.VLine(clientStart.y + 30, clientStart.y + 31, x + 1 + clientStart.x); break;
case TabsPlacement::left: surface.HLine(78 + clientStart.x, 81 + clientStart.x, y + 1 + clientStart.y); break;
case TabsPlacement::right: surface.HLine(clientStart.y + 30, clientStart.y + 31, y + 1 + clientStart.y); break;
{
if(placement == bottom && ((BorderBits)borderStyle).fixed)
{
- bool isNormal = (state == normal || state == maximized);
MinMaxValue aw = 0, ah = 0;
*x = *y = 0;
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
- if(curTab == (Tab)button.id)
+ if(curTab == (Tab)(intptr)button.id)
return true;
//curButton.Activate();
curButton.MakeActive();
{
curButton.checked = false;
button.checked = true;
- curTab = (Tab)button.id;
+ curTab = (Tab)(intptr)button.id;
if(curButton)
PlaceButton(curButton, placement, false, buttonsOffset);
public void AddTab(Tab tab)
{
- tab.parent = this;
+ if(tab.parent != this)
+ {
+ tab.parent = this;
+ return;
+ }
tab.autoCreate = false;
tab.id = numTabs;
- tab.button = TabButton
+ if(!tab.button)
{
- parent = tabButtons,
- master = this, stayDown = true,
- text = tab.text, id = (uint)tab, NotifyClicked = NotifyClicked,
- tab = tab,
- background = background;
- };
- incref tab.button;
+ tab.button = TabButton
+ {
+ parent = tabButtons,
+ master = this, stayDown = true,
+ text = tab.text, id = (int64)(intptr)tab, NotifyClicked = NotifyClicked,
+ tab = tab,
+ background = background;
+ };
+ incref tab.button;
+ }
if(created)
{
{
Window child;
Tab fallbackTab = null;
- tab.parent = null;
+ // tab.parent = null;
for(child = tabButtons.children.first; child; child = child.next)
{
if(child._class == class(TabButton))
{
TabButton button = (TabButton)child;
- if(button.id == (uint)tab)
+ if(button.id == (int64)(intptr)tab)
{
if(button.created)
+ {
button.Destroy(0);
+ numTabs--;
+ }
break;
}
else
fallbackTab = tabButtons.children.first ? ((TabButton)tabButtons.children.first).tab : null;
if(fallbackTab)
fallbackTab.SelectTab();
+ else
+ curTab = null;
/*curTab = fallbackTab;
curButton = curTab.button;
curButton.checked = true;
curTab.autoCreate = true;*/
}
- numTabs--;
}
~TabControl()
int pleft = button.anchor.left.distance, nleft = newButton ? newButton.anchor.left.distance : 0;
int ptop = button.anchor.top.distance, ntop = newButton ? newButton.anchor.top.distance : 0;
if(button == curButton) continue;
- if((smartKey == left && (pleft < cleft || ptop < ctop) && (!newButton || pleft > nleft || ptop > ntop)) ||
+ if((smartKey == left && (pleft < cleft || ptop < ctop) && (!newButton || pleft > nleft || ptop > ntop)) ||
(smartKey == right && (pleft > cleft || ptop > ctop) && (!newButton || pleft < nleft || pleft < ptop)))
newButton = button;
}
button.NotifyClicked(button.master, button, 0, 0, 0);
}
- watch(text)
+ watch(caption)
{
if(button)
button.text = text;