WinDecorator: Make it compile, use tabs

but stub out the missing pieces for now.

At this point selecting it crashes app server spectacularly.
This commit is contained in:
John Scipione
2014-02-20 19:31:13 -05:00
parent 45b17fde13
commit 196fc0d6ae
2 changed files with 308 additions and 194 deletions
@@ -13,6 +13,7 @@
#include <stdio.h> #include <stdio.h>
#include <Point.h> #include <Point.h>
#include <Rect.h>
#include <View.h> #include <View.h>
#include "DesktopSettings.h" #include "DesktopSettings.h"
@@ -33,22 +34,19 @@ WinDecorAddOn::WinDecorAddOn(image_id id, const char* name)
: :
DecorAddOn(id, name) DecorAddOn(id, name)
{ {
} }
Decorator* Decorator*
WinDecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect, WinDecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect)
window_look look, uint32 flags)
{ {
return new (std::nothrow)WinDecorator(settings, rect, look, flags); return new (std::nothrow)WinDecorator(settings, rect);
} }
WinDecorator::WinDecorator(DesktopSettings& settings, BRect rect, WinDecorator::WinDecorator(DesktopSettings& settings, BRect rect)
window_look look, uint32 flags)
: :
Decorator(settings, rect, look, flags) Decorator(settings, rect)
{ {
_UpdateFont(settings); _UpdateFont(settings);
@@ -64,9 +62,11 @@ WinDecorator::WinDecorator(DesktopSettings& settings, BRect rect,
fNonFocusTabColor = settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR); fNonFocusTabColor = settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR);
fNonFocusTextColor = settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR); fNonFocusTextColor = settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR);
fTabList.AddItem(_AllocateNewTab());
// Set appropriate colors based on the current focus value. In this case, // Set appropriate colors based on the current focus value. In this case,
// each decorator defaults to not having the focus. // each decorator defaults to not having the focus.
_SetFocus(); _SetFocus(_TabAt(0));
// Do initial decorator setup // Do initial decorator setup
_DoLayout(); _DoLayout();
@@ -86,15 +86,22 @@ WinDecorator::~WinDecorator()
// TODO : Add GetSettings // TODO : Add GetSettings
/*! \brief Updates the decorator in the rectangular area \a updateRect.
The default version updates all areas which intersect the frame and tab.
\param updateRect The rectangular area to update.
*/
void void
WinDecorator::Draw(BRect update) WinDecorator::Draw(BRect updateRect)
{ {
STRACE(("WinDecorator::Draw(): ")); update.PrintToStream(); STRACE(("WinDecorator::Draw(BRect updateRect): "));
updateRect.PrintToStream();
fDrawingEngine->SetDrawState(&fDrawState); fDrawingEngine->SetDrawState(&fDrawState);
_DrawFrame(update); _DrawFrame(updateRect & fFrame);
_DrawTab(update); _DrawTabs(updateRect & fTitleBarRect);
} }
@@ -104,8 +111,8 @@ WinDecorator::Draw()
STRACE(("WinDecorator::Draw()\n")); STRACE(("WinDecorator::Draw()\n"));
fDrawingEngine->SetDrawState(&fDrawState); fDrawingEngine->SetDrawState(&fDrawState);
_DrawFrame(fBorderRect); _DrawFrame(fFrame);
_DrawTab(fTabRect); _DrawTabs(fTitleBarRect);
} }
@@ -113,25 +120,25 @@ WinDecorator::Draw()
Decorator::Region Decorator::Region
WinDecorator::RegionAt(BPoint where) const WinDecorator::RegionAt(BPoint where, int32& tab) const
{ {
// Let the base class version identify hits of the buttons and the tab. // Let the base class version identify hits of the buttons and the tab.
Region region = Decorator::RegionAt(where); Region region = Decorator::RegionAt(where, tab);
if (region != REGION_NONE) if (region != REGION_NONE)
return region; return region;
// check the resize corner // check the resize corner
if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(where)) if (fTopTab->look == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(where))
return REGION_RIGHT_BOTTOM_CORNER; return REGION_RIGHT_BOTTOM_CORNER;
// hit-test the borders // hit-test the borders
if (!(fFlags & B_NOT_RESIZABLE) if (!(fTopTab->flags & B_NOT_RESIZABLE)
&& (fLook == B_TITLED_WINDOW_LOOK && (fTopTab->look == B_TITLED_WINDOW_LOOK
|| fLook == B_FLOATING_WINDOW_LOOK || fTopTab->look == B_FLOATING_WINDOW_LOOK
|| fLook == B_MODAL_WINDOW_LOOK) || fTopTab->look == B_MODAL_WINDOW_LOOK)
&& fBorderRect.Contains(where) && !fFrame.Contains(where)) { && fBorderRect.Contains(where) && !fFrame.Contains(where)) {
return REGION_BOTTOM_BORDER; return REGION_BOTTOM_BORDER;
// TODO: Determine the actual border! // TODO Determine the actual border!
} }
return REGION_NONE; return REGION_NONE;
@@ -146,9 +153,7 @@ WinDecorator::_DoLayout()
bool hasTab = false; bool hasTab = false;
fBorderRect = fFrame; fBorderRect = fFrame;
fTabRect=fFrame; switch ((int)fTopTab->look) {
switch (Look()) {
case B_MODAL_WINDOW_LOOK: case B_MODAL_WINDOW_LOOK:
fBorderRect.InsetBy(-4, -4); fBorderRect.InsetBy(-4, -4);
break; break;
@@ -173,33 +178,61 @@ WinDecorator::_DoLayout()
if (hasTab) { if (hasTab) {
fBorderRect.top -= 19; fBorderRect.top -= 19;
fTabRect.top -= 19; for (int32 i = 0; i < fTabList.CountItems(); i++) {
fTabRect.bottom=fTabRect.top+19; Decorator::Tab* tab = fTabList.ItemAt(i);
fZoomRect=fTabRect; tab->tabRect.top -= 19;
fZoomRect.top+=3; tab->tabRect.bottom = tab->tabRect.top + 19;
fZoomRect.right-=3;
fZoomRect.bottom-=3;
fZoomRect.left=fZoomRect.right-15;
fCloseRect=fZoomRect; tab->zoomRect = tab->tabRect;
fZoomRect.OffsetBy(0-fZoomRect.Width()-3,0); tab->zoomRect.top += 3;
tab->zoomRect.right -= 3;
tab->zoomRect.bottom -= 3;
tab->zoomRect.left = tab->zoomRect.right - 15;
fMinimizeRect=fZoomRect; tab->closeRect = tab->zoomRect;
fMinimizeRect.OffsetBy(0-fZoomRect.Width()-1,0); tab->zoomRect.OffsetBy(0 - tab->zoomRect.Width() - 3, 0);
} else {
fTabRect.Set(0.0, 0.0, -1.0, -1.0); tab->minimizeRect = tab->zoomRect;
fCloseRect.Set(0.0, 0.0, -1.0, -1.0); tab->minimizeRect.OffsetBy(0 - tab->zoomRect.Width() - 1, 0);
fZoomRect.Set(0.0, 0.0, -1.0, -1.0);
fMinimizeRect.Set(0.0, 0.0, -1.0, -1.0);
} }
} else {
for (int32 i = 0; i < fTabList.CountItems(); i++) {
Decorator::Tab* tab = fTabList.ItemAt(i);
tab->tabRect.Set(0.0, 0.0, -1.0, -1.0);
tab->closeRect.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);
}
}
}
Decorator::Tab*
WinDecorator::_AllocateNewTab()
{
Decorator::Tab* tab = new(std::nothrow) WinDecorator::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;
}
WinDecorator::Tab*
WinDecorator::_TabAt(int32 index) const
{
// TODO stub
return static_cast<WinDecorator::Tab*>(fTabList.ItemAt(index));
} }
void void
WinDecorator::_DrawFrame(BRect rect) WinDecorator::_DrawFrame(BRect rect)
{ {
if (fLook == B_NO_BORDER_WINDOW_LOOK) if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
return; return;
if (fBorderRect == fFrame) if (fBorderRect == fFrame)
@@ -210,7 +243,7 @@ WinDecorator::_DrawFrame(BRect rect)
fDrawingEngine->SetHighColor(frame_lowercol); fDrawingEngine->SetHighColor(frame_lowercol);
fDrawingEngine->StrokeRect(r); fDrawingEngine->StrokeRect(r);
if (fLook == B_BORDERED_WINDOW_LOOK) if (fTopTab->look == B_BORDERED_WINDOW_LOOK)
return; return;
BPoint pt; BPoint pt;
@@ -244,124 +277,133 @@ WinDecorator::_DrawFrame(BRect rect)
void void
WinDecorator::_DrawTab(BRect invalid) WinDecorator::_DrawTab(Decorator::Tab* tab, BRect rect)
{ {
// If a window has a tab, this will draw it and any buttons which are const BRect& tabRect = tab->tabRect;
// in it.
if (!fTabRect.IsValid() || !invalid.Intersects(fTabRect) || fLook==B_NO_BORDER_WINDOW_LOOK) // If a window has a tab, this will draw it and any buttons in it.
if (!tabRect.IsValid() || !rect.Intersects(tabRect)
|| fTopTab->look == B_NO_BORDER_WINDOW_LOOK) {
return; return;
}
fDrawingEngine->FillRect(fTabRect,tab_highcol); fDrawingEngine->FillRect(tabRect, tab_highcol);
_DrawTitle(fTabRect); _DrawTitle(tab, tabRect);
// Draw the buttons if we're supposed to // Draw the buttons if we're supposed to
// TODO : we should still draw the buttons if they are disabled, but grey them out // TODO : we should still draw the buttons if they are disabled, but grey them out
if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(fCloseRect)) DrawButtons(tab, rect);
_DrawClose(fCloseRect);
if (!(fFlags & B_NOT_ZOOMABLE) && invalid.Intersects(fZoomRect))
_DrawZoom(fZoomRect);
} }
void void
WinDecorator::_DrawClose(BRect r) WinDecorator::_DrawTitle(Decorator::Tab* tab, BRect rect)
{ {
// Just like DrawZoom, but for a close button const BRect& tabRect = tab->tabRect;
_DrawBeveledRect(r,GetClose()); const BRect& closeRect = tab->closeRect;
const BRect& zoomRect = tab->zoomRect;
// Draw the X
BRect rect(r);
rect.InsetBy(4,4);
rect.right--;
rect.top--;
if (GetClose())
rect.OffsetBy(1,1);
fDrawingEngine->SetHighColor(RGBColor(0,0,0));
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightBottom());
fDrawingEngine->StrokeLine(rect.RightTop(),rect.LeftBottom());
rect.OffsetBy(1,0);
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightBottom());
fDrawingEngine->StrokeLine(rect.RightTop(),rect.LeftBottom());
}
void
WinDecorator::_DrawTitle(BRect r)
{
//fDrawingEngine->SetDrawingMode(B_OP_OVER); //fDrawingEngine->SetDrawingMode(B_OP_OVER);
fDrawingEngine->SetHighColor(textcol); fDrawingEngine->SetHighColor(textcol);
fDrawingEngine->SetLowColor(IsFocus()?fFocusTabColor:fNonFocusTabColor); fDrawingEngine->SetLowColor(IsFocus(_TabAt(0))
? fFocusTabColor : fNonFocusTabColor);
fTruncatedTitle = Title(); fTruncatedTitle = Title(_TabAt(0));
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
((fZoomRect.IsValid() ? fZoomRect.left : ((zoomRect.IsValid() ? zoomRect.left :
fCloseRect.IsValid() ? fCloseRect.left : fTabRect.right) - 5) closeRect.IsValid() ? closeRect.left : tabRect.right) - 5)
- (fTabRect.left + textoffset)); - (tabRect.left + textoffset));
fTruncatedTitleLength = fTruncatedTitle.Length(); fTruncatedTitleLength = fTruncatedTitle.Length();
fDrawingEngine->SetFont(fDrawState.Font()); fDrawingEngine->SetFont(fDrawState.Font());
fDrawingEngine->DrawString(fTruncatedTitle, fTruncatedTitleLength, fDrawingEngine->DrawString(fTruncatedTitle, fTruncatedTitleLength,
BPoint(fTabRect.left+textoffset,fCloseRect.bottom-1)); BPoint(tabRect.left + textoffset,closeRect.bottom - 1));
//fDrawingEngine->SetDrawingMode(B_OP_COPY); //fDrawingEngine->SetDrawingMode(B_OP_COPY);
} }
void void
WinDecorator::_DrawZoom(BRect r) WinDecorator::_DrawClose(Decorator::Tab* tab, bool direct, BRect rect)
{ {
_DrawBeveledRect(r,GetZoom()); STRACE(("_DrawClose(%f, %f, %f, %f)\n", rect.left, rect.top, rect.right,
rect.bottom));
// Just like DrawZoom, but for a close button
_DrawBeveledRect(rect, true);
// Draw the X
BRect closeBox(rect);
closeBox.InsetBy(4, 4);
closeBox.right--;
closeBox.top--;
if (true)
closeBox.OffsetBy(1, 1);
fDrawingEngine->SetHighColor(RGBColor(0, 0, 0));
fDrawingEngine->StrokeLine(closeBox.LeftTop(), closeBox.RightBottom());
fDrawingEngine->StrokeLine(closeBox.RightTop(), closeBox.LeftBottom());
closeBox.OffsetBy(1, 0);
fDrawingEngine->StrokeLine(closeBox.LeftTop(), closeBox.RightBottom());
fDrawingEngine->StrokeLine(closeBox.RightTop(), closeBox.LeftBottom());
}
void
WinDecorator::_DrawZoom(Decorator::Tab* tab, bool direct, BRect rect)
{
_DrawBeveledRect(rect, true);
// Draw the Zoom box // Draw the Zoom box
BRect rect(r); BRect zoomBox(rect);
rect.InsetBy(2,2); zoomBox.InsetBy(2, 2);
rect.InsetBy(1,0); zoomBox.InsetBy(1, 0);
rect.bottom--; zoomBox.bottom--;
rect.right--; zoomBox.right--;
if (GetZoom()) if (true)
rect.OffsetBy(1,1); zoomBox.OffsetBy(1, 1);
fDrawingEngine->SetHighColor(RGBColor(0,0,0)); fDrawingEngine->SetHighColor(RGBColor(0,0,0));
fDrawingEngine->StrokeRect(rect); fDrawingEngine->StrokeRect(zoomBox);
rect.InsetBy(1,1); zoomBox.InsetBy(1, 1);
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop()); fDrawingEngine->StrokeLine(zoomBox.LeftTop(), zoomBox.RightTop());
} }
void void
WinDecorator::_DrawMinimize(BRect r) WinDecorator::_DrawMinimize(Decorator::Tab* tab, bool direct, BRect rect)
{ {
// Just like DrawZoom, but for a Minimize button // Just like DrawZoom, but for a Minimize button
_DrawBeveledRect(r,GetMinimize()); _DrawBeveledRect(rect, true);
fDrawingEngine->SetHighColor(textcol); fDrawingEngine->SetHighColor(textcol);
BRect rect(r.left+5,r.bottom-4,r.right-5,r.bottom-3); BRect minimizeBox(rect.left + 5, rect.bottom - 4, rect.right - 5,
if(GetMinimize()) rect.bottom - 3);
rect.OffsetBy(1,1); if (true)
minimizeBox.OffsetBy(1, 1);
fDrawingEngine->SetHighColor(RGBColor(0, 0, 0)); fDrawingEngine->SetHighColor(RGBColor(0, 0, 0));
fDrawingEngine->StrokeRect(rect); fDrawingEngine->StrokeRect(minimizeBox);
} }
void void
WinDecorator::_SetTitle(const char* string, BRegion* updateRegion) WinDecorator::_SetTitle(Decorator::Tab* tab, const char* string,
BRegion* updateRegion)
{ {
// TODO: we could be much smarter about the update region // TODO we could be much smarter about the update region
BRect rect = TabRect(); BRect rect = TabRect(tab);
if (updateRegion == NULL) if (updateRegion == NULL)
return; return;
BRect updatedRect = TabRect(); BRect updatedRect = TabRect(tab);
if (rect.left > updatedRect.left) if (rect.left > updatedRect.left)
rect.left = updatedRect.left; rect.left = updatedRect.left;
if (rect.right < updatedRect.right) if (rect.right < updatedRect.right)
@@ -392,13 +434,13 @@ void
WinDecorator::_SetLook(DesktopSettings& settings, window_look look, WinDecorator::_SetLook(DesktopSettings& settings, window_look look,
BRegion* updateRegion) BRegion* updateRegion)
{ {
// TODO: we could be much smarter about the update region // TODO we could be much smarter about the update region
// get previous extent // get previous extent
if (updateRegion != NULL) if (updateRegion != NULL)
updateRegion->Include(&GetFootprint()); updateRegion->Include(&GetFootprint());
fLook = look; fTopTab->look = look;
_UpdateFont(settings); _UpdateFont(settings);
_DoLayout(); _DoLayout();
@@ -412,7 +454,7 @@ WinDecorator::_SetLook(DesktopSettings& settings, window_look look,
void void
WinDecorator::_SetFlags(uint32 flags, BRegion* updateRegion) WinDecorator::_SetFlags(uint32 flags, BRegion* updateRegion)
{ {
// TODO: we could be much smarter about the update region // TODO we could be much smarter about the update region
// get previous extent // get previous extent
if (updateRegion != NULL) if (updateRegion != NULL)
@@ -427,12 +469,14 @@ WinDecorator::_SetFlags(uint32 flags, BRegion* updateRegion)
void void
WinDecorator::_SetFocus(void) WinDecorator::_SetFocus(Decorator::Tab* tab)
{ {
// TODO stub
// SetFocus() performs necessary duties for color swapping and // SetFocus() performs necessary duties for color swapping and
// other things when a window is deactivated or activated. // other things when a window is deactivated or activated.
if (IsFocus()) { if (IsFocus(_TabAt(0))) {
// tab_highcol.SetColor(100, 100, 255); // tab_highcol.SetColor(100, 100, 255);
// tab_lowcol.SetColor(40, 0, 255); // tab_lowcol.SetColor(40, 0, 255);
tab_highcol = fFocusTabColor; tab_highcol = fFocusTabColor;
@@ -447,15 +491,21 @@ WinDecorator::_SetFocus(void)
void void
WinDecorator::_MoveBy(BPoint pt) WinDecorator::_MoveBy(BPoint offset)
{ {
// Move all internal rectangles the appropriate amount // Move all tab rectangles over
fFrame.OffsetBy(pt); for (int32 i = 0; i < fTabList.CountItems(); i++) {
fCloseRect.OffsetBy(pt); Decorator::Tab* tab = fTabList.ItemAt(i);
fTabRect.OffsetBy(pt);
fBorderRect.OffsetBy(pt); tab->zoomRect.OffsetBy(offset);
fZoomRect.OffsetBy(pt); tab->closeRect.OffsetBy(offset);
fMinimizeRect.OffsetBy(pt); tab->minimizeRect.OffsetBy(offset);
tab->tabRect.OffsetBy(offset);
}
// Move all internal rectangles over
fFrame.OffsetBy(offset);
fBorderRect.OffsetBy(offset);
} }
@@ -465,17 +515,21 @@ WinDecorator::_ResizeBy(BPoint offset, BRegion* dirty)
// Move all internal rectangles the appropriate amount // Move all internal rectangles the appropriate amount
fFrame.right += offset.x; fFrame.right += offset.x;
fFrame.bottom += offset.y; fFrame.bottom += offset.y;
fTabRect.right += offset.x;
fBorderRect.right += offset.x; fBorderRect.right += offset.x;
fBorderRect.bottom += offset.y; fBorderRect.bottom += offset.y;
// fZoomRect.OffsetBy(offset.x, 0);
// fMinimizeRect.OffsetBy(offset.x, 0);
if (dirty) {
dirty->Include(fTabRect);
dirty->Include(fBorderRect);
}
for (int32 i = 0; i < fTabList.CountItems(); i++) {
Decorator::Tab* tab = fTabList.ItemAt(i);
tab->tabRect.right += offset.x;
if (dirty != NULL)
dirty->Include(tab->tabRect);
//tab->zoomRect.right += offset.x;
//tab->closeRect.right += offset.x;
//tab->minimizeRect.right += offset.x;
}
if (dirty != NULL)
dirty->Include(fBorderRect);
// TODO probably some other layouting stuff here // TODO probably some other layouting stuff here
_DoLayout(); _DoLayout();
@@ -485,31 +539,72 @@ WinDecorator::_ResizeBy(BPoint offset, BRegion* dirty)
// TODO : _SetSettings // TODO : _SetSettings
bool
WinDecorator::_AddTab(DesktopSettings& settings, int32 index,
BRegion* updateRegion)
{
// TODO stub
return false;
}
bool
WinDecorator::_RemoveTab(int32 index, BRegion* updateRegion)
{
// TODO stub
return false;
}
bool
WinDecorator::_MoveTab(int32 from, int32 to, bool isMoving,
BRegion* updateRegion)
{
// TODO stub
return false;
}
void void
WinDecorator::_GetFootprint(BRegion* region) WinDecorator::_GetFootprint(BRegion* region)
{ {
// This function calculates the decorator's footprint in coordinates // This function calculates the decorator's footprint in coordinates
// relative to the view. This is most often used to set a Window // relative to the view. This is most often used to set a Window
// object's visible region. // object's visible region.
if (!region) if (region == NULL)
return; return;
region->MakeEmpty(); region->MakeEmpty();
if (fLook == B_NO_BORDER_WINDOW_LOOK) if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
return; return;
region->Set(fBorderRect); region->Set(fBorderRect);
region->Include(fTabRect); for (int32 i = 0; i < fTabList.CountItems(); i++) {
Decorator::Tab* tab = fTabList.ItemAt(i);
region->Include(tab->tabRect);
}
region->Exclude(fFrame); region->Exclude(fFrame);
} }
void
WinDecorator::DrawButtons(Decorator::Tab* tab, const BRect& invalid)
{
if (!(tab->flags & B_NOT_MINIMIZABLE) && invalid.Intersects(tab->minimizeRect))
_DrawMinimize(tab, false, tab->minimizeRect);
if (!(tab->flags & B_NOT_ZOOMABLE) && invalid.Intersects(tab->zoomRect))
_DrawZoom(tab, false, tab->zoomRect);
if (!(tab->flags & B_NOT_CLOSABLE) && invalid.Intersects(tab->closeRect))
_DrawClose(tab, false, tab->closeRect);
}
void void
WinDecorator::_UpdateFont(DesktopSettings& settings) WinDecorator::_UpdateFont(DesktopSettings& settings)
{ {
ServerFont font; ServerFont font;
if (fLook == B_FLOATING_WINDOW_LOOK) if (fTopTab->look == B_FLOATING_WINDOW_LOOK)
settings.GetDefaultPlainFont(font); settings.GetDefaultPlainFont(font);
else else
settings.GetDefaultBoldFont(font); settings.GetDefaultBoldFont(font);
@@ -544,7 +639,7 @@ WinDecorator::_DrawBeveledRect(BRect r, bool down)
} }
BRect rect(r); BRect rect(r);
BPoint pt; BPoint point;
// Top highlight // Top highlight
fDrawingEngine->SetHighColor(higher); fDrawingEngine->SetHighColor(higher);
@@ -554,14 +649,14 @@ WinDecorator::_DrawBeveledRect(BRect r, bool down)
fDrawingEngine->StrokeLine(rect.LeftTop(), rect.LeftBottom()); fDrawingEngine->StrokeLine(rect.LeftTop(), rect.LeftBottom());
// Right shading // Right shading
pt=rect.RightTop(); point = rect.RightTop();
pt.y++; point.y++;
fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower); fDrawingEngine->StrokeLine(point, rect.RightBottom(), lower);
// Bottom shading // Bottom shading
pt=rect.LeftBottom(); point = rect.LeftBottom();
pt.x++; point.x++;
fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower); fDrawingEngine->StrokeLine(point, rect.RightBottom(), lower);
rect.InsetBy(1,1); rect.InsetBy(1,1);
@@ -572,14 +667,14 @@ WinDecorator::_DrawBeveledRect(BRect r, bool down)
fDrawingEngine->StrokeLine(rect.LeftTop(), rect.LeftBottom()); fDrawingEngine->StrokeLine(rect.LeftTop(), rect.LeftBottom());
// Right inside shading // Right inside shading
pt=rect.RightTop(); point = rect.RightTop();
pt.y++; point.y++;
fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower); fDrawingEngine->StrokeLine(point, rect.RightBottom(), lower);
// Bottom inside shading // Bottom inside shading
pt=rect.LeftBottom(); point = rect.LeftBottom();
pt.x++; point.x++;
fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower); fDrawingEngine->StrokeLine(point, rect.RightBottom(), lower);
rect.InsetBy(1,1); rect.InsetBy(1,1);
@@ -6,45 +6,56 @@
#define _WINDOWS_DECORATOR_H_ #define _WINDOWS_DECORATOR_H_
#include "Decorator.h"
#include "DecorManager.h" #include "DecorManager.h"
#include "RGBColor.h"
struct rgb_color;
class BRect;
class WinDecorAddOn : public DecorAddOn { class WinDecorAddOn : public DecorAddOn {
public: public:
WinDecorAddOn(image_id id, const char* name); WinDecorAddOn(image_id id, const char* name);
protected: protected:
virtual Decorator* _AllocateDecorator(DesktopSettings& settings, virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
BRect rect, window_look look, uint32 flags); BRect rect);
}; };
class WinDecorator: public Decorator { class WinDecorator: public Decorator {
public: public:
WinDecorator(DesktopSettings& settings, WinDecorator(DesktopSettings& settings, BRect frame);
BRect frame, window_look wlook,
uint32 wflags);
~WinDecorator(void); ~WinDecorator(void);
void Draw(BRect r); virtual void Draw(BRect updateRect);
void Draw(); virtual void Draw();
virtual Region RegionAt(BPoint where) const; virtual Region RegionAt(BPoint where, int32& tab) const;
protected: protected:
virtual void DrawButtons(Decorator::Tab* tab,
const BRect& invalid);
void _DoLayout(); void _DoLayout();
void _DrawFrame(BRect r); virtual Decorator::Tab* _AllocateNewTab();
void _DrawTab(BRect r); WinDecorator::Tab* _TabAt(int32 index) const;
void _DrawClose(BRect r); virtual void _DrawFrame(BRect rect);
void _DrawTitle(BRect r); virtual void _DrawTab(Decorator::Tab* tab, BRect rect);
void _DrawZoom(BRect r); virtual void _DrawTitle(Decorator::Tab* tab, BRect rect);
void _DrawMinimize(BRect r);
void _SetTitle(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(Decorator::Tab* tab, const char* string,
BRegion* updateRegion = NULL); BRegion* updateRegion = NULL);
void _FontsChanged(DesktopSettings& settings, void _FontsChanged(DesktopSettings& settings,
@@ -55,11 +66,19 @@ protected:
void _SetFlags(uint32 flags, void _SetFlags(uint32 flags,
BRegion* updateRegion = NULL); BRegion* updateRegion = NULL);
void _MoveBy(BPoint pt); void _MoveBy(BPoint offset);
void _ResizeBy(BPoint pt, BRegion* dirty); void _ResizeBy(BPoint offset, BRegion* dirty);
virtual bool _AddTab(DesktopSettings& settings,
int32 index = -1,
BRegion* updateRegion = NULL);
virtual bool _RemoveTab(int32 index,
BRegion* updateRegion = NULL);
virtual bool _MoveTab(int32 from, int32 to, bool isMoving,
BRegion* updateRegion = NULL);
void _GetFootprint(BRegion *region); void _GetFootprint(BRegion *region);
void _SetFocus(void); virtual void _SetFocus(Decorator::Tab* tab);
private: private:
void _UpdateFont(DesktopSettings& settings); void _UpdateFont(DesktopSettings& settings);