Fixup the Mac Decorator, it compiles and works
... but it still needs a lot more work to integrate with S&T.
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*! Decorator looking like Mac OS 9 */
|
/*! Decorator resembling Mac OS 8 and 9 */
|
||||||
|
|
||||||
|
|
||||||
#include "MacDecorator.h"
|
#include "MacDecorator.h"
|
||||||
@@ -39,7 +39,6 @@ MacDecorAddOn::MacDecorAddOn(image_id id, const char* name)
|
|||||||
:
|
:
|
||||||
DecorAddOn(id, name)
|
DecorAddOn(id, name)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -50,28 +49,21 @@ MacDecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MacDecorator::MacDecorator(DesktopSettings& settings, BRect rect)
|
MacDecorator::MacDecorator(DesktopSettings& settings, BRect frame)
|
||||||
:
|
:
|
||||||
Decorator(settings, rect)
|
Decorator(settings, frame),
|
||||||
|
fButtonHighColor((rgb_color){ 232, 232, 232, 255 }),
|
||||||
|
fButtonLowColor((rgb_color){ 128, 128, 128, 255 }),
|
||||||
|
fFrameHighColor((rgb_color){ 255, 255, 255, 255 }),
|
||||||
|
fFrameMidColor((rgb_color){ 216, 216, 216, 255 }),
|
||||||
|
fFrameLowColor((rgb_color){ 110, 110, 110, 255 }),
|
||||||
|
fFrameLowerColor((rgb_color){ 0, 0, 0, 255 }),
|
||||||
|
fFocusTextColor(settings.UIColor(B_WINDOW_TEXT_COLOR)),
|
||||||
|
fNonFocusTextColor(settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR))
|
||||||
{
|
{
|
||||||
_UpdateFont(settings);
|
|
||||||
|
|
||||||
frame_highcol = (rgb_color){ 255, 255, 255, 255 };
|
|
||||||
frame_midcol = (rgb_color){ 216, 216, 216, 255 };
|
|
||||||
frame_lowcol = (rgb_color){ 110, 110, 110, 255 };
|
|
||||||
frame_lowercol = (rgb_color){ 0, 0, 0, 255 };
|
|
||||||
|
|
||||||
fButtonHighColor = (rgb_color){ 232, 232, 232, 255 };
|
|
||||||
fButtonLowColor = (rgb_color){ 128, 128, 128, 255 };
|
|
||||||
|
|
||||||
fFocusTextColor = settings.UIColor(B_WINDOW_TEXT_COLOR);
|
|
||||||
fNonFocusTextColor = settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR);
|
|
||||||
|
|
||||||
_DoLayout();
|
|
||||||
|
|
||||||
textoffset=5;
|
|
||||||
|
|
||||||
STRACE(("MacDecorator()\n"));
|
STRACE(("MacDecorator()\n"));
|
||||||
|
STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",
|
||||||
|
frame.left, frame.top, frame.right, frame.bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -85,17 +77,17 @@ MacDecorator::~MacDecorator()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MacDecorator::Draw(BRect update)
|
MacDecorator::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
STRACE(("MacDecorator: Draw(%.1f,%.1f,%.1f,%.1f)\n",
|
STRACE(("MacDecorator: Draw(BRect updateRect): "));
|
||||||
update.left, update.top, update.right, update.bottom));
|
updateRect.PrintToStream();
|
||||||
|
|
||||||
// We need to draw a few things: the tab, the borders,
|
// We need to draw a few things: the tab, the borders,
|
||||||
// and the buttons
|
// and the buttons
|
||||||
fDrawingEngine->SetDrawState(&fDrawState);
|
fDrawingEngine->SetDrawState(&fDrawState);
|
||||||
|
|
||||||
_DrawFrame(update);
|
_DrawFrame(updateRect & fBorderRect);
|
||||||
_DrawTab(update);
|
_DrawTabs(updateRect & fTitleBarRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -106,7 +98,7 @@ MacDecorator::Draw()
|
|||||||
fDrawingEngine->SetDrawState(&fDrawState);
|
fDrawingEngine->SetDrawState(&fDrawState);
|
||||||
|
|
||||||
_DrawFrame(fBorderRect);
|
_DrawFrame(fBorderRect);
|
||||||
_DrawTab(fTitleBarRect);
|
_DrawTabs(fTitleBarRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -139,14 +131,50 @@ MacDecorator::RegionAt(BPoint where, int32& tab) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
MacDecorator::SetRegionHighlight(Region region, uint8 highlight,
|
||||||
|
BRegion* dirty, int32 tabIndex)
|
||||||
|
{
|
||||||
|
Decorator::Tab* tab
|
||||||
|
= static_cast<Decorator::Tab*>(_TabAt(tabIndex));
|
||||||
|
if (tab != NULL) {
|
||||||
|
tab->isHighlighted = highlight != 0;
|
||||||
|
// Invalidate the bitmap caches for the close/minimize/zoom button
|
||||||
|
// when the highlight changes.
|
||||||
|
switch (region) {
|
||||||
|
case REGION_CLOSE_BUTTON:
|
||||||
|
if (highlight != RegionHighlight(region))
|
||||||
|
memset(&tab->closeBitmaps, 0, sizeof(tab->closeBitmaps));
|
||||||
|
break;
|
||||||
|
case REGION_MINIMIZE_BUTTON:
|
||||||
|
if (highlight != RegionHighlight(region)) {
|
||||||
|
memset(&tab->minimizeBitmaps, 0,
|
||||||
|
sizeof(tab->minimizeBitmaps));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case REGION_ZOOM_BUTTON:
|
||||||
|
if (highlight != RegionHighlight(region))
|
||||||
|
memset(&tab->zoomBitmaps, 0, sizeof(tab->zoomBitmaps));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Decorator::SetRegionHighlight(region, highlight, dirty, tabIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MacDecorator::_DoLayout()
|
MacDecorator::_DoLayout()
|
||||||
{
|
{
|
||||||
const int32 kDefaultBorderWidth = 6;
|
|
||||||
STRACE(("MacDecorator: Do Layout\n"));
|
STRACE(("MacDecorator: Do Layout\n"));
|
||||||
|
|
||||||
// Here we determine the size of every rectangle that we use
|
// Here we determine the size of every rectangle that we use
|
||||||
// internally when we are given the size of the client rectangle.
|
// internally when we are given the size of the client rectangle.
|
||||||
|
|
||||||
|
const int32 kDefaultBorderWidth = 6;
|
||||||
|
|
||||||
bool hasTab = false;
|
bool hasTab = false;
|
||||||
|
|
||||||
if (fTopTab) {
|
if (fTopTab) {
|
||||||
@@ -174,12 +202,12 @@ MacDecorator::_DoLayout()
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
fBorderWidth = 0;
|
fBorderWidth = 0;
|
||||||
fBorderRect=fFrame;
|
|
||||||
fBorderRect.InsetBy(-fBorderWidth, -fBorderWidth);
|
fBorderRect = fFrame.InsetByCopy(-fBorderWidth, -fBorderWidth);
|
||||||
|
|
||||||
// calculate our tab rect
|
// calculate our tab rect
|
||||||
if (hasTab) {
|
if (hasTab) {
|
||||||
fBorderRect.top +=3;
|
fBorderRect.top += 3;
|
||||||
|
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
fDrawState.Font().GetHeight(fontHeight);
|
fDrawState.Font().GetHeight(fontHeight);
|
||||||
@@ -190,48 +218,54 @@ MacDecorator::_DoLayout()
|
|||||||
((fFrame.right - fFrame.left) < 32.0 ?
|
((fFrame.right - fFrame.left) < 32.0 ?
|
||||||
fFrame.left + 32.0 : fFrame.right) + fBorderWidth,
|
fFrame.left + 32.0 : fFrame.right) + fBorderWidth,
|
||||||
fFrame.top - 3);
|
fFrame.top - 3);
|
||||||
|
|
||||||
fTopTab->tabRect = fTitleBarRect; // TODO actually handle multiple tabs
|
|
||||||
|
|
||||||
fTopTab->zoomRect=fTitleBarRect;
|
for (int32 i = 0; i < fTabList.CountItems(); i++) {
|
||||||
fTopTab->zoomRect.left=fTopTab->zoomRect.right - 12;
|
Decorator::Tab* tab = fTabList.ItemAt(i);
|
||||||
fTopTab->zoomRect.bottom=fTopTab->zoomRect.top + 12;
|
|
||||||
fTopTab->zoomRect.OffsetBy(-4, 4);
|
|
||||||
|
|
||||||
fTopTab->closeRect=fTopTab->zoomRect;
|
tab->tabRect = fTitleBarRect;
|
||||||
fTopTab->minimizeRect=fTopTab->zoomRect;
|
// TODO actually handle multiple tabs
|
||||||
|
|
||||||
fTopTab->closeRect.OffsetTo(fTitleBarRect.left + 4,
|
tab->zoomRect = fTitleBarRect;
|
||||||
fTitleBarRect.top + 4);
|
tab->zoomRect.left = tab->zoomRect.right - 12;
|
||||||
|
tab->zoomRect.bottom = tab->zoomRect.top + 12;
|
||||||
|
tab->zoomRect.OffsetBy(-4, 4);
|
||||||
|
|
||||||
fTopTab->zoomRect.OffsetBy(0 - (fTopTab->zoomRect.Width() + 4), 0);
|
tab->closeRect = tab->zoomRect;
|
||||||
if (Title(fTopTab) && fDrawingEngine) {
|
tab->minimizeRect = tab->zoomRect;
|
||||||
titlepixelwidth=fDrawingEngine->StringWidth(Title(fTopTab),
|
|
||||||
strlen(Title(fTopTab)));
|
|
||||||
|
|
||||||
if (titlepixelwidth<(fTopTab->zoomRect.left
|
tab->closeRect.OffsetTo(fTitleBarRect.left + 4,
|
||||||
- fTopTab->closeRect.right-10)) {
|
fTitleBarRect.top + 4);
|
||||||
// start with offset from closerect.right
|
|
||||||
textoffset=int(((fTopTab->zoomRect.left - 5)
|
|
||||||
- (fTopTab->closeRect.right + 5)) / 2);
|
|
||||||
textoffset-=int(titlepixelwidth / 2);
|
|
||||||
|
|
||||||
// now make it the offset from fTabRect.left
|
tab->zoomRect.OffsetBy(0 - (tab->zoomRect.Width() + 4), 0);
|
||||||
textoffset+=int(fTopTab->closeRect.right + 5
|
if (Title(tab) != NULL && fDrawingEngine != NULL) {
|
||||||
- fTitleBarRect.left);
|
tab->truncatedTitle = Title(tab);
|
||||||
|
tab->truncatedTitleLength
|
||||||
|
= (int32)fDrawingEngine->StringWidth(Title(tab),
|
||||||
|
strlen(Title(tab)));
|
||||||
|
|
||||||
|
if (tab->truncatedTitleLength < (tab->zoomRect.left
|
||||||
|
- tab->closeRect.right - 10)) {
|
||||||
|
// start with offset from closerect.right
|
||||||
|
tab->textOffset = int(((tab->zoomRect.left - 5)
|
||||||
|
- (tab->closeRect.right + 5)) / 2);
|
||||||
|
tab->textOffset -= int(tab->truncatedTitleLength / 2);
|
||||||
|
|
||||||
|
// now make it the offset from fTabRect.left
|
||||||
|
tab->textOffset += int(tab->closeRect.right + 5
|
||||||
|
- fTitleBarRect.left);
|
||||||
|
} else
|
||||||
|
tab->textOffset = int(tab->closeRect.right) + 5;
|
||||||
} else
|
} else
|
||||||
textoffset=int(fTopTab->closeRect.right) + 5;
|
tab->textOffset = 0;
|
||||||
} else {
|
|
||||||
textoffset = 0;
|
|
||||||
titlepixelwidth = 0;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no tab
|
for (int32 i = 0; i < fTabList.CountItems(); i++) {
|
||||||
if (fTopTab) {
|
Decorator::Tab* tab = fTabList.ItemAt(i);
|
||||||
fTopTab->tabRect.Set(0.0, 0.0, -1.0, -1.0);
|
|
||||||
fTopTab->closeRect.Set(0.0, 0.0, -1.0, -1.0);
|
tab->tabRect.Set(0.0, 0.0, -1.0, -1.0);
|
||||||
fTopTab->zoomRect.Set(0.0, 0.0, -1.0, -1.0);
|
tab->closeRect.Set(0.0, 0.0, -1.0, -1.0);
|
||||||
fTopTab->minimizeRect.Set(0.0, 0.0, -1.0, -1.0);
|
tab->zoomRect.Set(0.0, 0.0, -1.0, -1.0);
|
||||||
|
tab->minimizeRect.Set(0.0, 0.0, -1.0, -1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,203 +291,241 @@ MacDecorator::_DrawFrame(BRect invalid)
|
|||||||
BPoint pt2 = r.LeftBottom();
|
BPoint pt2 = r.LeftBottom();
|
||||||
|
|
||||||
// Draw the left side of the frame
|
// Draw the left side of the frame
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
pt2.x++;
|
pt2.x++;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_highcol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameHighColor);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
pt2.x++;
|
pt2.x++;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
pt2.x++;
|
pt2.x++;
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
pt2.x++;
|
pt2.x++;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowcol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameLowColor);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
offset.y+=2;
|
offset.y += 2;
|
||||||
BPoint topleftpt=offset;
|
BPoint topleftpt = offset;
|
||||||
pt2.x++;
|
pt2.x++;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
|
||||||
|
|
||||||
|
offset = r.RightTop();
|
||||||
offset=r.RightTop();
|
pt2 = r.RightBottom();
|
||||||
pt2=r.RightBottom();
|
|
||||||
|
|
||||||
// Draw the right side of the frame
|
// Draw the right side of the frame
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
|
||||||
offset.x--;
|
offset.x--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowcol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameLowColor);
|
||||||
offset.x--;
|
offset.x--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
|
||||||
offset.x--;
|
offset.x--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
|
||||||
offset.x--;
|
offset.x--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_highcol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameHighColor);
|
||||||
offset.x--;
|
offset.x--;
|
||||||
offset.y+=2;
|
offset.y += 2;
|
||||||
BPoint toprightpt=offset;
|
BPoint toprightpt = offset;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
|
||||||
|
|
||||||
// Draw the top side of the frame that is not in the tab
|
// Draw the top side of the frame that is not in the tab
|
||||||
offset=r.RightTop();
|
offset = r.RightTop();
|
||||||
pt2=r.RightBottom();
|
pt2 = r.RightBottom();
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(topleftpt,toprightpt,frame_lowercol);
|
fDrawingEngine->StrokeLine(topleftpt, toprightpt, fFrameLowerColor);
|
||||||
topleftpt.y--;
|
topleftpt.y--;
|
||||||
toprightpt.x++;
|
toprightpt.x++;
|
||||||
toprightpt.y--;
|
toprightpt.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(topleftpt,toprightpt,frame_lowcol);
|
fDrawingEngine->StrokeLine(topleftpt, toprightpt, fFrameLowColor);
|
||||||
|
|
||||||
offset=r.LeftBottom();
|
offset = r.LeftBottom();
|
||||||
pt2=r.RightBottom();
|
pt2 = r.RightBottom();
|
||||||
|
|
||||||
// Draw the bottom side of the frame
|
// Draw the bottom side of the frame
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
offset.y--;
|
offset.y--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowcol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameLowColor);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
offset.y--;
|
offset.y--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
offset.y--;
|
offset.y--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
offset.y--;
|
offset.y--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_highcol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameHighColor);
|
||||||
offset.x+=2;
|
offset.x += 2;
|
||||||
offset.y--;
|
offset.y--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
|
||||||
offset.y--;
|
offset.y--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
} else {
|
} else {
|
||||||
fDrawingEngine->StrokeLine(r.LeftTop(), r.LeftBottom(), frame_lowcol);
|
fDrawingEngine->StrokeLine(r.LeftTop(), r.LeftBottom(),
|
||||||
fDrawingEngine->StrokeLine(r.RightTop(), r.RightBottom(), frame_lowcol);
|
fFrameLowColor);
|
||||||
fDrawingEngine->StrokeLine(r.LeftBottom(), r.RightBottom(), frame_lowcol);
|
fDrawingEngine->StrokeLine(r.RightTop(), r.RightBottom(),
|
||||||
|
fFrameLowColor);
|
||||||
|
fDrawingEngine->StrokeLine(r.LeftBottom(), r.RightBottom(),
|
||||||
|
fFrameLowColor);
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
r.InsetBy(1, 1);
|
r.InsetBy(1, 1);
|
||||||
fDrawingEngine->StrokeLine(r.LeftTop(), r.LeftBottom(), frame_midcol);
|
fDrawingEngine->StrokeLine(r.LeftTop(), r.LeftBottom(),
|
||||||
fDrawingEngine->StrokeLine(r.RightTop(), r.RightBottom(), frame_midcol);
|
fFrameMidColor);
|
||||||
fDrawingEngine->StrokeLine(r.LeftBottom(), r.RightBottom(), frame_midcol);
|
fDrawingEngine->StrokeLine(r.RightTop(), r.RightBottom(),
|
||||||
|
fFrameMidColor);
|
||||||
|
fDrawingEngine->StrokeLine(r.LeftBottom(), r.RightBottom(),
|
||||||
|
fFrameMidColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
r.InsetBy(1, 1);
|
r.InsetBy(1, 1);
|
||||||
fDrawingEngine->StrokeLine(r.LeftTop(), r.LeftBottom(), frame_lowcol);
|
fDrawingEngine->StrokeLine(r.LeftTop(), r.LeftBottom(),
|
||||||
fDrawingEngine->StrokeLine(r.RightTop(), r.RightBottom(), frame_lowcol);
|
fFrameLowColor);
|
||||||
fDrawingEngine->StrokeLine(r.LeftBottom(), r.RightBottom(), frame_lowcol);
|
fDrawingEngine->StrokeLine(r.RightTop(), r.RightBottom(),
|
||||||
|
fFrameLowColor);
|
||||||
|
fDrawingEngine->StrokeLine(r.LeftBottom(), r.RightBottom(),
|
||||||
|
fFrameLowColor);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_BORDERED_WINDOW_LOOK:
|
case B_BORDERED_WINDOW_LOOK:
|
||||||
fDrawingEngine->StrokeRect(r, frame_midcol);
|
fDrawingEngine->StrokeRect(r, fFrameMidColor);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// don't draw a border frame
|
// don't draw a border frame
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MacDecorator::_DrawTab(BRect invalid)
|
MacDecorator::_DrawTab(Decorator::Tab* tab, BRect invalid)
|
||||||
{
|
{
|
||||||
// If a window has a tab, this will draw it and any buttons which are
|
// If a window has a tab, this will draw it and any buttons which are
|
||||||
// in it.
|
// in it.
|
||||||
if (!fTitleBarRect.IsValid() || !invalid.Intersects(fTitleBarRect))
|
if (!tab->tabRect.IsValid() || !invalid.Intersects(tab->tabRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BRect rect(fTitleBarRect);
|
BRect rect(tab->tabRect);
|
||||||
fDrawingEngine->SetHighColor(RGBColor(frame_midcol));
|
fDrawingEngine->SetHighColor(RGBColor(fFrameMidColor));
|
||||||
fDrawingEngine->FillRect(rect,frame_midcol);
|
fDrawingEngine->FillRect(rect, fFrameMidColor);
|
||||||
|
|
||||||
if (IsFocus(fTopTab)) {
|
if (IsFocus(tab)) {
|
||||||
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowercol);
|
fDrawingEngine->StrokeLine(rect.LeftTop(), rect.RightTop(),
|
||||||
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_lowercol);
|
fFrameLowerColor);
|
||||||
fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowercol);
|
fDrawingEngine->StrokeLine(rect.LeftTop(), rect.LeftBottom(),
|
||||||
|
fFrameLowerColor);
|
||||||
|
fDrawingEngine->StrokeLine(rect.RightBottom(), rect.RightTop(),
|
||||||
|
fFrameLowerColor);
|
||||||
|
|
||||||
rect.InsetBy(1,1);
|
rect.InsetBy(1, 1);
|
||||||
rect.bottom++;
|
rect.bottom++;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_highcol);
|
fDrawingEngine->StrokeLine(rect.LeftTop(), rect.RightTop(),
|
||||||
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_highcol);
|
fFrameHighColor);
|
||||||
fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowcol);
|
fDrawingEngine->StrokeLine(rect.LeftTop(), rect.LeftBottom(),
|
||||||
|
fFrameHighColor);
|
||||||
|
fDrawingEngine->StrokeLine(rect.RightBottom(), rect.RightTop(),
|
||||||
|
fFrameLowColor);
|
||||||
|
|
||||||
// Draw the neat little lines on either side of the title if there's room
|
// Draw the neat little lines on either side of the title if there's
|
||||||
if (fTitleBarRect.left + textoffset > fTopTab->closeRect.right + 5) {
|
// room
|
||||||
|
float left;
|
||||||
|
if ((tab->flags & B_NOT_CLOSABLE) == 0)
|
||||||
|
left = tab->closeRect.right;
|
||||||
|
else
|
||||||
|
left = tab->tabRect.left;
|
||||||
|
|
||||||
|
float right;
|
||||||
|
if ((tab->flags & B_NOT_ZOOMABLE) == 0)
|
||||||
|
right = tab->zoomRect.left;
|
||||||
|
else if ((tab->flags & B_NOT_MINIMIZABLE) == 0)
|
||||||
|
right = tab->minimizeRect.left;
|
||||||
|
else
|
||||||
|
right = tab->tabRect.right;
|
||||||
|
|
||||||
|
if (tab->tabRect.left + tab->textOffset > left + 5) {
|
||||||
// Left side
|
// Left side
|
||||||
|
|
||||||
BPoint offset(fTopTab->closeRect.right+5,fTopTab->closeRect.top),
|
BPoint offset(left + 5, tab->closeRect.top);
|
||||||
pt2(fTitleBarRect.left+textoffset-5,fTopTab->closeRect.top);
|
BPoint pt2(tab->tabRect.left + tab->textOffset - 5,
|
||||||
fDrawState.SetHighColor(RGBColor(frame_highcol));
|
tab->closeRect.top);
|
||||||
|
|
||||||
|
fDrawState.SetHighColor(RGBColor(fFrameHighColor));
|
||||||
for (int32 i = 0; i < 6; i++) {
|
for (int32 i = 0; i < 6; i++) {
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
|
fDrawingEngine->StrokeLine(offset, pt2,
|
||||||
offset.y+=2;
|
fDrawState.HighColor());
|
||||||
pt2.y+=2;
|
offset.y += 2;
|
||||||
|
pt2.y += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset.Set(fTopTab->closeRect.right+6,fTopTab->closeRect.top+1),
|
offset.Set(left + 6, tab->closeRect.top + 1);
|
||||||
pt2.Set(fTitleBarRect.left+textoffset-4,fTopTab->closeRect.top+1);
|
pt2.Set(tab->tabRect.left + tab->textOffset - 4,
|
||||||
fDrawState.SetHighColor(RGBColor(frame_lowcol));
|
tab->closeRect.top + 1);
|
||||||
|
|
||||||
|
fDrawState.SetHighColor(RGBColor(fFrameLowColor));
|
||||||
for (int32 i = 0; i < 6; i++) {
|
for (int32 i = 0; i < 6; i++) {
|
||||||
fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor());
|
fDrawingEngine->StrokeLine(offset, pt2,
|
||||||
|
fDrawState.HighColor());
|
||||||
offset.y += 2;
|
offset.y += 2;
|
||||||
pt2.y += 2;
|
pt2.y += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right side
|
// Right side
|
||||||
|
|
||||||
offset.Set(fTitleBarRect.left + textoffset + titlepixelwidth + 6,
|
offset.Set(tab->tabRect.left + tab->textOffset + 6
|
||||||
fTopTab->zoomRect.top), pt2.Set(fTopTab->zoomRect.left - 6,
|
+ tab->truncatedTitleLength + 6, tab->zoomRect.top);
|
||||||
fTopTab->zoomRect.top);
|
pt2.Set(right - 8, tab->zoomRect.top);
|
||||||
|
|
||||||
if (offset.x < pt2.x) {
|
if (offset.x < pt2.x) {
|
||||||
fDrawState.SetHighColor(RGBColor(frame_highcol));
|
fDrawState.SetHighColor(RGBColor(fFrameHighColor));
|
||||||
for (int32 i = 0; i < 6; i++) {
|
for (int32 i = 0; i < 6; i++) {
|
||||||
fDrawingEngine->StrokeLine(offset, pt2,
|
fDrawingEngine->StrokeLine(offset, pt2,
|
||||||
fDrawState.HighColor());
|
fDrawState.HighColor());
|
||||||
offset.y += 2;
|
offset.y += 2;
|
||||||
pt2.y += 2;
|
pt2.y += 2;
|
||||||
}
|
}
|
||||||
offset.Set(fTitleBarRect.left+textoffset + titlepixelwidth + 7,
|
|
||||||
fTopTab->zoomRect.top + 1), pt2.Set(fTopTab->zoomRect.left - 5,
|
offset.Set(tab->tabRect.left + tab->textOffset + 6
|
||||||
fTopTab->zoomRect.top + 1);
|
+ tab->truncatedTitleLength + 7, tab->zoomRect.top + 1);
|
||||||
fDrawState.SetHighColor(frame_lowcol);
|
pt2.Set(right - 7, tab->zoomRect.top + 1);
|
||||||
|
|
||||||
|
fDrawState.SetHighColor(fFrameLowColor);
|
||||||
for(int32 i = 0; i < 6; i++) {
|
for(int32 i = 0; i < 6; i++) {
|
||||||
fDrawingEngine->StrokeLine(offset, pt2,
|
fDrawingEngine->StrokeLine(offset, pt2,
|
||||||
fDrawState.HighColor());
|
fDrawState.HighColor());
|
||||||
@@ -463,26 +535,64 @@ MacDecorator::_DrawTab(BRect invalid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the buttons if we're supposed to
|
_DrawButtons(tab, rect);
|
||||||
if (!(fTopTab->flags & B_NOT_CLOSABLE))
|
|
||||||
_DrawClose(fTopTab->closeRect);
|
|
||||||
if (!(fTopTab->flags & B_NOT_ZOOMABLE))
|
|
||||||
_DrawZoom(fTopTab->zoomRect);
|
|
||||||
} else {
|
} else {
|
||||||
// Not focused - Just draw a plain light grey area with the title in the middle
|
// Not focused - Just draw a plain light grey area with the title
|
||||||
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowcol);
|
// in the middle
|
||||||
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_lowcol);
|
fDrawingEngine->StrokeLine(rect.LeftTop(), rect.RightTop(),
|
||||||
fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowcol);
|
fFrameLowColor);
|
||||||
|
fDrawingEngine->StrokeLine(rect.LeftTop(), rect.LeftBottom(),
|
||||||
|
fFrameLowColor);
|
||||||
|
fDrawingEngine->StrokeLine(rect.RightBottom(), rect.RightTop(),
|
||||||
|
fFrameLowColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
_DrawTitle(fTitleBarRect);
|
_DrawTitle(tab, tab->tabRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MacDecorator::_DrawClose(BRect r)
|
MacDecorator::_DrawButtons(Decorator::Tab* tab, const BRect& invalid)
|
||||||
{
|
{
|
||||||
bool down = fTopTab->closePressed;
|
if ((tab->flags & B_NOT_CLOSABLE) == 0
|
||||||
|
&& invalid.Intersects(tab->closeRect)) {
|
||||||
|
_DrawClose(tab, false, tab->closeRect);
|
||||||
|
}
|
||||||
|
if ((tab->flags & B_NOT_MINIMIZABLE) == 0
|
||||||
|
&& invalid.Intersects(tab->minimizeRect)) {
|
||||||
|
_DrawMinimize(tab, false, tab->minimizeRect);
|
||||||
|
}
|
||||||
|
if ((tab->flags & B_NOT_ZOOMABLE) == 0
|
||||||
|
&& invalid.Intersects(tab->zoomRect)) {
|
||||||
|
_DrawZoom(tab, false, tab->zoomRect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MacDecorator::_DrawTitle(Decorator::Tab* tab, BRect rect)
|
||||||
|
{
|
||||||
|
fDrawingEngine->SetHighColor(IsFocus(tab)
|
||||||
|
? fFocusTextColor : fNonFocusTextColor);
|
||||||
|
|
||||||
|
fDrawingEngine->SetLowColor(fFrameMidColor);
|
||||||
|
|
||||||
|
tab->truncatedTitle = Title(tab);
|
||||||
|
fDrawState.Font().TruncateString(&tab->truncatedTitle, B_TRUNCATE_END,
|
||||||
|
(tab->zoomRect.left - 5) - (tab->closeRect.right + 5));
|
||||||
|
tab->truncatedTitleLength = tab->truncatedTitle.Length();
|
||||||
|
fDrawingEngine->SetFont(fDrawState.Font());
|
||||||
|
|
||||||
|
fDrawingEngine->DrawString(tab->truncatedTitle, tab->truncatedTitleLength,
|
||||||
|
BPoint(fTitleBarRect.left + tab->textOffset,
|
||||||
|
tab->closeRect.bottom - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MacDecorator::_DrawClose(Decorator::Tab* tab, bool direct, BRect r)
|
||||||
|
{
|
||||||
|
bool down = tab->closePressed;
|
||||||
|
|
||||||
// Just like DrawZoom, but for a close button
|
// Just like DrawZoom, but for a close button
|
||||||
BRect rect(r);
|
BRect rect(r);
|
||||||
@@ -523,34 +633,13 @@ MacDecorator::_DrawClose(BRect r)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MacDecorator::_DrawTitle(BRect rect)
|
MacDecorator::_DrawZoom(Decorator::Tab* tab, bool direct, BRect r)
|
||||||
{
|
{
|
||||||
if (IsFocus(fTopTab))
|
bool down = tab->zoomPressed;
|
||||||
fDrawingEngine->SetHighColor(fFocusTextColor);
|
|
||||||
else
|
|
||||||
fDrawingEngine->SetHighColor(fNonFocusTextColor);
|
|
||||||
|
|
||||||
fDrawingEngine->SetLowColor(frame_midcol);
|
|
||||||
|
|
||||||
fTruncatedTitle = Title(fTopTab);
|
|
||||||
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
|
|
||||||
(fTopTab->zoomRect.left - 5) - (fTopTab->closeRect.right + 5));
|
|
||||||
fTruncatedTitleLength = fTruncatedTitle.Length();
|
|
||||||
fDrawingEngine->SetFont(fDrawState.Font());
|
|
||||||
|
|
||||||
fDrawingEngine->DrawString(fTruncatedTitle,fTruncatedTitleLength,
|
|
||||||
BPoint(fTitleBarRect.left+textoffset,fTopTab->closeRect.bottom-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MacDecorator::_DrawZoom(BRect r)
|
|
||||||
{
|
|
||||||
bool down = fTopTab->zoomPressed;
|
|
||||||
|
|
||||||
// Just like DrawZoom, but for a close button
|
// Just like DrawZoom, but for a close button
|
||||||
BRect rect(r);
|
BRect rect(r);
|
||||||
BPoint offset(r.LeftTop()),pt2(r.RightTop());
|
BPoint offset(r.LeftTop()), pt2(r.RightTop());
|
||||||
|
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
fDrawState.SetHighColor(RGBColor(136, 136, 136));
|
fDrawState.SetHighColor(RGBColor(136, 136, 136));
|
||||||
@@ -576,7 +665,7 @@ MacDecorator::_DrawZoom(BRect r)
|
|||||||
|
|
||||||
rect.InsetBy(1, 1);
|
rect.InsetBy(1, 1);
|
||||||
_DrawBlendedRect(fDrawingEngine, rect, down);
|
_DrawBlendedRect(fDrawingEngine, rect, down);
|
||||||
rect.InsetBy(1,1);
|
rect.InsetBy(1, 1);
|
||||||
_DrawBlendedRect(fDrawingEngine, rect, !down);
|
_DrawBlendedRect(fDrawingEngine, rect, !down);
|
||||||
|
|
||||||
rect.top += 2;
|
rect.top += 2;
|
||||||
@@ -590,9 +679,9 @@ MacDecorator::_DrawZoom(BRect r)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MacDecorator::_DrawMinimize(BRect r)
|
MacDecorator::_DrawMinimize(Decorator::Tab* tab, bool direct, BRect r)
|
||||||
{
|
{
|
||||||
bool down = fTopTab->minimizePressed;
|
bool down = tab->minimizePressed;
|
||||||
|
|
||||||
// Just like DrawZoom, but for a Minimize button
|
// Just like DrawZoom, but for a Minimize button
|
||||||
BRect rect(r);
|
BRect rect(r);
|
||||||
@@ -641,14 +730,14 @@ MacDecorator::_SetTitle(Tab* tab, const char* string, BRegion* updateRegion)
|
|||||||
// TODO may this change the other tabs too ? (to make space for a longer
|
// TODO may this change the other tabs too ? (to make space for a longer
|
||||||
// title ?)
|
// title ?)
|
||||||
|
|
||||||
BRect rect = TabRect(fTopTab);
|
BRect rect = TabRect(tab);
|
||||||
|
|
||||||
_DoLayout();
|
_DoLayout();
|
||||||
|
|
||||||
if (updateRegion == NULL)
|
if (updateRegion == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rect = rect | TabRect(fTopTab);
|
rect = rect | TabRect(tab);
|
||||||
|
|
||||||
rect.bottom++;
|
rect.bottom++;
|
||||||
// the border will look differently when the title is adjacent
|
// the border will look differently when the title is adjacent
|
||||||
@@ -657,74 +746,24 @@ MacDecorator::_SetTitle(Tab* tab, const char* string, BRegion* updateRegion)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MacDecorator::_FontsChanged(DesktopSettings& settings,
|
|
||||||
BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
// get previous extent
|
|
||||||
if (updateRegion != NULL)
|
|
||||||
updateRegion->Include(&GetFootprint());
|
|
||||||
|
|
||||||
_UpdateFont(settings);
|
|
||||||
_DoLayout();
|
|
||||||
|
|
||||||
_InvalidateFootprint();
|
|
||||||
if (updateRegion != NULL)
|
|
||||||
updateRegion->Include(&GetFootprint());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MacDecorator::_SetLook(DesktopSettings& settings, window_look look,
|
|
||||||
BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
// TODO: we could be much smarter about the update region
|
|
||||||
|
|
||||||
// get previous extent
|
|
||||||
if (updateRegion != NULL)
|
|
||||||
updateRegion->Include(&GetFootprint());
|
|
||||||
|
|
||||||
fTopTab->look = look;
|
|
||||||
|
|
||||||
_UpdateFont(settings);
|
|
||||||
_DoLayout();
|
|
||||||
|
|
||||||
_InvalidateFootprint();
|
|
||||||
if (updateRegion != NULL)
|
|
||||||
updateRegion->Include(&GetFootprint());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MacDecorator::_SetFlags(uint32 flags, BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
// TODO: we could be much smarter about the update region
|
|
||||||
|
|
||||||
// get previous extent
|
|
||||||
if (updateRegion != NULL)
|
|
||||||
updateRegion->Include(&GetFootprint());
|
|
||||||
|
|
||||||
_DoLayout();
|
|
||||||
|
|
||||||
_InvalidateFootprint();
|
|
||||||
if (updateRegion != NULL)
|
|
||||||
updateRegion->Include(&GetFootprint());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// TODO : _SetFocus
|
// TODO : _SetFocus
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MacDecorator::_MoveBy(BPoint offset)
|
MacDecorator::_MoveBy(BPoint offset)
|
||||||
{
|
{
|
||||||
// TODO handle all tabs
|
// Move all internal rectangles the appropriate amount
|
||||||
|
for (int32 i = 0; i < fTabList.CountItems(); i++) {
|
||||||
|
Decorator::Tab* tab = fTabList.ItemAt(i);
|
||||||
|
tab->zoomRect.OffsetBy(offset);
|
||||||
|
tab->minimizeRect.OffsetBy(offset);
|
||||||
|
tab->closeRect.OffsetBy(offset);
|
||||||
|
tab->tabRect.OffsetBy(offset);
|
||||||
|
}
|
||||||
|
|
||||||
fFrame.OffsetBy(offset);
|
fFrame.OffsetBy(offset);
|
||||||
fTopTab->closeRect.OffsetBy(offset);
|
|
||||||
fTitleBarRect.OffsetBy(offset);
|
fTitleBarRect.OffsetBy(offset);
|
||||||
fTopTab->tabRect = fTitleBarRect;
|
|
||||||
fResizeRect.OffsetBy(offset);
|
fResizeRect.OffsetBy(offset);
|
||||||
fTopTab->zoomRect.OffsetBy(offset);
|
|
||||||
fBorderRect.OffsetBy(offset);
|
fBorderRect.OffsetBy(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,7 +785,6 @@ MacDecorator::_ResizeBy(BPoint offset, BRegion* dirty)
|
|||||||
dirty->Include(fBorderRect);
|
dirty->Include(fBorderRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO probably some other layouting stuff here
|
// TODO probably some other layouting stuff here
|
||||||
_DoLayout();
|
_DoLayout();
|
||||||
}
|
}
|
||||||
@@ -755,6 +793,77 @@ MacDecorator::_ResizeBy(BPoint offset, BRegion* dirty)
|
|||||||
// TODO : _SetSettings
|
// TODO : _SetSettings
|
||||||
|
|
||||||
|
|
||||||
|
Decorator::Tab*
|
||||||
|
MacDecorator::_AllocateNewTab()
|
||||||
|
{
|
||||||
|
Decorator::Tab* tab = new(std::nothrow) Decorator::Tab;
|
||||||
|
if (tab == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Set appropriate colors based on the current focus value. In this case,
|
||||||
|
// each decorator defaults to not having the focus.
|
||||||
|
_SetFocus(tab);
|
||||||
|
return tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
MacDecorator::_AddTab(DesktopSettings& settings, int32 index,
|
||||||
|
BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
_UpdateFont(settings);
|
||||||
|
|
||||||
|
_DoLayout();
|
||||||
|
if (updateRegion != NULL)
|
||||||
|
updateRegion->Include(fTitleBarRect);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
MacDecorator::_RemoveTab(int32 index, BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
BRect oldTitle = fTitleBarRect;
|
||||||
|
_DoLayout();
|
||||||
|
if (updateRegion != NULL) {
|
||||||
|
updateRegion->Include(oldTitle);
|
||||||
|
updateRegion->Include(fTitleBarRect);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
MacDecorator::_MoveTab(int32 from, int32 to, bool isMoving,
|
||||||
|
BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
MacDecorator::Tab* toTab = _TabAt(to);
|
||||||
|
if (toTab == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (from < to) {
|
||||||
|
fOldMovingTab.OffsetBy(toTab->tabRect.Width(), 0);
|
||||||
|
toTab->tabRect.OffsetBy(-fOldMovingTab.Width(), 0);
|
||||||
|
} else {
|
||||||
|
fOldMovingTab.OffsetBy(-toTab->tabRect.Width(), 0);
|
||||||
|
toTab->tabRect.OffsetBy(fOldMovingTab.Width(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
toTab->tabOffset = uint32(toTab->tabRect.left - fLeftBorder.left);
|
||||||
|
_LayoutTabItems(toTab, toTab->tabRect);
|
||||||
|
|
||||||
|
_CalculateTabsRegion();
|
||||||
|
|
||||||
|
if (updateRegion != NULL)
|
||||||
|
updateRegion->Include(fTitleBarRect);
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MacDecorator::_GetFootprint(BRegion* region)
|
MacDecorator::_GetFootprint(BRegion* region)
|
||||||
{
|
{
|
||||||
@@ -793,21 +902,24 @@ MacDecorator::_UpdateFont(DesktopSettings& settings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - Private methods
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Draws a rectangle with a gradient.
|
/*! \brief Draws a rectangle with a gradient.
|
||||||
\param down The rectangle should be drawn recessed or not
|
\param down The rectangle should be drawn recessed or not
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
MacDecorator::_DrawBlendedRect(DrawingEngine* engine, BRect rect,
|
MacDecorator::_DrawBlendedRect(DrawingEngine* engine, BRect rect,
|
||||||
bool down/*, bool focus*/)
|
bool down/*, bool focus*/)
|
||||||
{
|
{
|
||||||
// figure out which colors to use
|
// figure out which colors to use
|
||||||
rgb_color startColor, endColor;
|
rgb_color startColor, endColor;
|
||||||
if (down) {
|
if (down) {
|
||||||
startColor = fButtonLowColor;
|
startColor = fButtonLowColor;
|
||||||
endColor = frame_highcol;
|
endColor = fFrameHighColor;
|
||||||
} else {
|
} else {
|
||||||
startColor = fButtonHighColor;
|
startColor = fButtonHighColor;
|
||||||
endColor = frame_lowercol;
|
endColor = fFrameLowerColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill
|
// fill
|
||||||
@@ -821,76 +933,7 @@ MacDecorator::_DrawBlendedRect(DrawingEngine* engine, BRect rect,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Decorator::Tab*
|
// #pragma mark - DecorAddOn
|
||||||
MacDecorator::_AllocateNewTab()
|
|
||||||
{
|
|
||||||
Decorator::Tab* tab = new(std::nothrow) MacDecorator::Tab;
|
|
||||||
if (tab == NULL)
|
|
||||||
return NULL;
|
|
||||||
// Set appropriate colors based on the current focus value. In this case,
|
|
||||||
// each decorator defaults to not having the focus.
|
|
||||||
_SetFocus(tab);
|
|
||||||
return tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
MacDecorator::_AddTab(DesktopSettings& settings, int32 index,
|
|
||||||
BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
_UpdateFont(settings);
|
|
||||||
|
|
||||||
_DoLayout();
|
|
||||||
if (updateRegion != NULL)
|
|
||||||
updateRegion->Include(fTitleBarRect);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
MacDecorator::_RemoveTab(int32 index, BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
BRect oldTitle = fTitleBarRect;
|
|
||||||
_DoLayout();
|
|
||||||
if (updateRegion != NULL) {
|
|
||||||
updateRegion->Include(oldTitle);
|
|
||||||
updateRegion->Include(fTitleBarRect);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
MacDecorator::_MoveTab(int32 from, int32 to, bool isMoving,
|
|
||||||
BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
return false; //TODO
|
|
||||||
#if 0
|
|
||||||
MacDecorator::Tab* toTab = _TabAt(to);
|
|
||||||
if (toTab == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (from < to) {
|
|
||||||
fOldMovingTab.OffsetBy(toTab->tabRect.Width(), 0);
|
|
||||||
toTab->tabRect.OffsetBy(-fOldMovingTab.Width(), 0);
|
|
||||||
} else {
|
|
||||||
fOldMovingTab.OffsetBy(-toTab->tabRect.Width(), 0);
|
|
||||||
toTab->tabRect.OffsetBy(fOldMovingTab.Width(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
toTab->tabOffset = uint32(toTab->tabRect.left - fLeftBorder.left);
|
|
||||||
_LayoutTabItems(toTab, toTab->tabRect);
|
|
||||||
|
|
||||||
_CalculateTabsRegion();
|
|
||||||
|
|
||||||
if (updateRegion != NULL)
|
|
||||||
updateRegion->Include(fTitleBarRect);
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" DecorAddOn*
|
extern "C" DecorAddOn*
|
||||||
|
|||||||
@@ -36,62 +36,61 @@ public:
|
|||||||
|
|
||||||
virtual Region RegionAt(BPoint where, int32& tab) const;
|
virtual Region RegionAt(BPoint where, int32& tab) const;
|
||||||
|
|
||||||
|
virtual bool SetRegionHighlight(Region region,
|
||||||
|
uint8 highlight, BRegion* dirty,
|
||||||
|
int32 tab = -1);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _DoLayout();
|
void _DoLayout();
|
||||||
|
|
||||||
void _DrawFrame(BRect r);
|
virtual void _DrawFrame(BRect invalid);
|
||||||
void _DrawTab(BRect r);
|
|
||||||
|
|
||||||
void _DrawClose(BRect r);
|
virtual void _DrawTab(Decorator::Tab* tab, BRect invalid);
|
||||||
void _DrawTitle(BRect r);
|
virtual void _DrawButtons(Decorator::Tab* tab,
|
||||||
void _DrawZoom(BRect r);
|
const BRect& invalid);
|
||||||
void _DrawMinimize(BRect r);
|
virtual void _DrawTitle(Decorator::Tab* tab, BRect rect);
|
||||||
|
|
||||||
void _SetTitle(Tab* tab, const char* string,
|
virtual void _DrawMinimize(Decorator::Tab* tab, bool direct,
|
||||||
|
BRect rect);
|
||||||
|
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
|
||||||
|
BRect rect);
|
||||||
|
virtual void _DrawClose(Decorator::Tab* tab, bool direct,
|
||||||
|
BRect rect);
|
||||||
|
|
||||||
|
virtual void _SetTitle(Tab* tab, const char* string,
|
||||||
BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
|
|
||||||
void _FontsChanged(DesktopSettings& settings,
|
virtual void _MoveBy(BPoint offset);
|
||||||
BRegion* updateRegion);
|
virtual void _ResizeBy(BPoint offset, BRegion* dirty);
|
||||||
void _SetLook(DesktopSettings& settings,
|
|
||||||
window_look look,
|
Decorator::Tab* _AllocateNewTab();
|
||||||
|
|
||||||
|
virtual bool _AddTab(DesktopSettings& settings,
|
||||||
|
int32 index = -1,
|
||||||
BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
void _SetFlags(uint32 flags,
|
virtual bool _RemoveTab(int32 index,
|
||||||
|
BRegion* updateRegion = NULL);
|
||||||
|
virtual bool _MoveTab(int32 from, int32 to, bool isMoving,
|
||||||
BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
|
|
||||||
void _MoveBy(BPoint offset);
|
virtual void _GetFootprint(BRegion *region);
|
||||||
void _ResizeBy(BPoint offset, BRegion* dirty);
|
|
||||||
|
|
||||||
void _GetFootprint(BRegion *region);
|
virtual void _UpdateFont(DesktopSettings& settings);
|
||||||
|
|
||||||
// TODO
|
|
||||||
Tab* _AllocateNewTab();
|
|
||||||
bool _AddTab(DesktopSettings&, long int, BRegion*);
|
|
||||||
bool _RemoveTab(long int, BRegion*);
|
|
||||||
bool _MoveTab(long int, long int, bool, BRegion*);
|
|
||||||
private:
|
private:
|
||||||
void _UpdateFont(DesktopSettings& settings);
|
|
||||||
void _DrawBlendedRect(DrawingEngine* engine,
|
void _DrawBlendedRect(DrawingEngine* engine,
|
||||||
BRect r, bool down);
|
BRect r, bool down);
|
||||||
|
|
||||||
rgb_color fButtonHighColor;
|
rgb_color fButtonHighColor;
|
||||||
rgb_color fButtonLowColor;
|
rgb_color fButtonLowColor;
|
||||||
rgb_color frame_highcol;
|
|
||||||
rgb_color frame_midcol;
|
rgb_color fFrameHighColor;
|
||||||
rgb_color frame_lowcol;
|
rgb_color fFrameMidColor;
|
||||||
rgb_color frame_lowercol;
|
rgb_color fFrameLowColor;
|
||||||
|
rgb_color fFrameLowerColor;
|
||||||
|
|
||||||
rgb_color fFocusTextColor;
|
rgb_color fFocusTextColor;
|
||||||
rgb_color fNonFocusTextColor;
|
rgb_color fNonFocusTextColor;
|
||||||
|
|
||||||
uint64 solidhigh, solidlow;
|
|
||||||
|
|
||||||
BString fTruncatedTitle;
|
|
||||||
int32 fTruncatedTitleLength;
|
|
||||||
|
|
||||||
int32 fBorderWidth;
|
|
||||||
|
|
||||||
bool slidetab;
|
|
||||||
int textoffset;
|
|
||||||
float titlepixelwidth;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user