MacDecorator: only formatting changes

WinDecorator:
 * Now compilable
 * Windows are drawing properly
 * The window title is still missing for some reason


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34762 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues
2009-12-24 11:25:28 +00:00
parent 2eef77bfda
commit b6cb7d4779
4 changed files with 369 additions and 213 deletions
@@ -247,7 +247,7 @@ MacDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
} }
if (!(fFlags & B_NOT_ZOOMABLE) && fZoomRect.Contains(point)) { if (!(fFlags & B_NOT_ZOOMABLE) && fZoomRect.Contains(point)) {
STRACE("MacDecorator():Clicked() - Zoom\n"); STRACE(("MacDecorator():Clicked() - Zoom\n"));
return DEC_ZOOM; return DEC_ZOOM;
} }
@@ -278,7 +278,7 @@ MacDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
void void
MacDecorator::_DoLayout(void) MacDecorator::_DoLayout()
{ {
int32 kDefaultBorderWidth = 6; int32 kDefaultBorderWidth = 6;
STRACE(("MacDecorator: Do Layout\n")); STRACE(("MacDecorator: Do Layout\n"));
@@ -607,7 +607,7 @@ MacDecorator::_DrawTab(BRect invalid)
} }
void void
MacDecorator::_DrawClose(BRect r) MacDecorator::_DrawClose(BRect r)
{ {
bool down=GetClose(); bool down=GetClose();
@@ -650,7 +650,7 @@ MacDecorator::_DrawClose(BRect r)
} }
void void
MacDecorator::_DrawTitle(BRect rect) MacDecorator::_DrawTitle(BRect rect)
{ {
if(IsFocus()) if(IsFocus())
@@ -716,7 +716,8 @@ void MacDecorator::_DrawZoom(BRect r)
} }
void MacDecorator::_DrawMinimize(BRect r) void
MacDecorator::_DrawMinimize(BRect r)
{ {
bool down=GetClose(); bool down=GetClose();
@@ -761,14 +762,14 @@ void MacDecorator::_DrawMinimize(BRect r)
} }
void void
MacDecorator::_SetColors() MacDecorator::_SetColors()
{ {
_SetFocus(); _SetFocus();
} }
void void
MacDecorator::_UpdateFont(DesktopSettings& settings) MacDecorator::_UpdateFont(DesktopSettings& settings)
{ {
ServerFont font; ServerFont font;
@@ -785,8 +786,8 @@ MacDecorator::_UpdateFont(DesktopSettings& settings)
/*! \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*/)
{ {
@@ -820,5 +821,5 @@ extern "C" float get_decorator_version(void)
extern "C" Decorator *(instantiate_decorator)(DesktopSettings &desktopSetting, BRect rec, extern "C" Decorator *(instantiate_decorator)(DesktopSettings &desktopSetting, BRect rec,
window_look loo, uint32 flag) window_look loo, uint32 flag)
{ {
return (new MacDecorator(desktopSetting, rec, loo, flag)); return new MacDecorator(desktopSetting, rec, loo, flag);
} }
+5 -2
View File
@@ -2,9 +2,12 @@ SubDir HAIKU_TOP src add-ons decorators WinDecorator ;
UseFreeTypeHeaders ; UseFreeTypeHeaders ;
UseHeaders [ FDirName $(HAIKU_TOP) src servers app ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app ] ;
UsePrivateHeaders [ FDirName servers app ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing ] ;
UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing Painter ] ;
UsePrivateHeaders app shared interface graphics ;
UseLibraryHeaders agg ;
Addon WinDecorator : Addon WinDecorator :
WinDecorator.cpp WinDecorator.cpp
: be libappserver.so : be <nogrist>app_server $(TARGET_LIBSTDC++)
; ;
@@ -1,219 +1,322 @@
#include <Point.h> /*
#include "DisplayDriver.h" Copyright 2009, Haiku.
#include <View.h> Distributed under the terms of the MIT License.
#include "LayerData.h" */
#include "ColorUtils.h"
/*! Decorator looking like Windows 95 */
#include "WinDecorator.h" #include "WinDecorator.h"
#include "RGBColor.h"
#include <Point.h>
#include <View.h>
#include "DesktopSettings.h"
#include "DrawingEngine.h"
#include "PatternHandler.h" #include "PatternHandler.h"
#include "RGBColor.h"
//#define DEBUG_DECOR
#ifdef DEBUG_DECOR //#define DEBUG_DECORATOR
#include <stdio.h> #ifdef DEBUG_DECORATOR
# include <stdio.h>
# define STRACE(x) printf x ;
#else
# define STRACE(x) ;
#endif #endif
WinDecorator::WinDecorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
: Decorator(rect,wlook,wfeel,wflags) WinDecorator::WinDecorator(DesktopSettings& settings, BRect rect,
window_look look, uint32 flags)
: Decorator(settings, rect, look, flags)
{ {
#ifdef DEBUG_DECOR
printf("WinDecorator()\n");
#endif
taboffset=0; taboffset=0;
frame_highcol.SetColor(255,255,255); frame_highcol = (rgb_color){ 255, 255, 255, 255 };
frame_midcol.SetColor(216,216,216); frame_midcol = (rgb_color){ 216, 216, 216, 255 };
frame_lowcol.SetColor(110,110,110); frame_lowcol = (rgb_color){ 110, 110, 110, 255 };
frame_lowercol.SetColor(0,0,0); frame_lowercol = (rgb_color){ 0, 0, 0, 255 };
fFocusTabColor = settings.UIColor(B_WINDOW_TAB_COLOR);
fFocusTextColor = settings.UIColor(B_WINDOW_TEXT_COLOR);
fNonFocusTabColor = settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR);
fNonFocusTextColor = settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR);
_UpdateFont(settings);
_DoLayout(); _DoLayout();
textoffset=5; textoffset=5;
STRACE(("WinDecorator()\n"));
} }
WinDecorator::~WinDecorator(void)
WinDecorator::~WinDecorator()
{ {
#ifdef DEBUG_DECOR STRACE(("~WinDecorator()\n"));
printf("~WinDecorator()\n");
#endif
} }
click_type WinDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
void
WinDecorator::SetTitle(const char* string, BRegion* updateRegion)
{ {
if(_closerect.Contains(pt)) // TODO: we could be much smarter about the update region
{
#ifdef DEBUG_DECOR BRect rect = TabRect();
printf("WinDecorator():Clicked() - Close\n");
#endif
Decorator::SetTitle(string);
if (updateRegion == NULL)
return;
BRect updatedRect = TabRect();
if (rect.left > updatedRect.left)
rect.left = updatedRect.left;
if (rect.right < updatedRect.right)
rect.right = updatedRect.right;
updateRegion->Include(rect);
}
void
WinDecorator::FontsChanged(DesktopSettings& settings, BRegion* updateRegion)
{
// get previous extent
if (updateRegion != NULL) {
BRegion extent;
GetFootprint(&extent);
updateRegion->Include(&extent);
}
_UpdateFont(settings);
_DoLayout();
if (updateRegion != NULL) {
BRegion extent;
GetFootprint(&extent);
updateRegion->Include(&extent);
}
}
// SetLook
// SetFlags
void
WinDecorator::MoveBy(BPoint pt)
{
// Move all internal rectangles the appropriate amount
fFrame.OffsetBy(pt);
fCloseRect.OffsetBy(pt);
fTabRect.OffsetBy(pt);
fBorderRect.OffsetBy(pt);
fZoomRect.OffsetBy(pt);
fMinimizeRect.OffsetBy(pt);
}
void
WinDecorator::ResizeBy(BPoint offset, BRegion* dirty)
{
// Move all internal rectangles the appropriate amount
fFrame.right += offset.x;
fFrame.bottom += offset.y;
fTabRect.right += offset.x;
fBorderRect.right += offset.x;
fBorderRect.bottom += offset.y;
// fZoomRect.OffsetBy(offset.x,0);
// fMinimizeRect.OffsetBy(offset.x,0);
if (dirty) {
dirty->Include(fTabRect);
dirty->Include(fBorderRect);
}
// TODO probably some other layouting stuff here
_DoLayout();
}
void
WinDecorator::GetFootprint(BRegion* region)
{
// This function calculates the decorator's footprint in coordinates
// relative to the view. This is most often used to set a Window
// object's visible region.
if (!region)
return;
region->MakeEmpty();
if (fLook == B_NO_BORDER_WINDOW_LOOK)
return;
region->Set(fBorderRect);
region->Include(fTabRect);
region->Exclude(fFrame);
}
click_type
WinDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
{
if (fCloseRect.Contains(pt)) {
STRACE(("WinDecorator():Clicked() - Close\n"));
return DEC_CLOSE; return DEC_CLOSE;
} }
if(_zoomrect.Contains(pt)) if (fZoomRect.Contains(pt)) {
{ STRACE(("WinDecorator():Clicked() - Zoom\n"));
#ifdef DEBUG_DECOR
printf("WinDecorator():Clicked() - Zoom\n");
#endif
return DEC_ZOOM; return DEC_ZOOM;
} }
// Clicking in the tab? // Clicking in the tab?
if(_tabrect.Contains(pt)) if (fTabRect.Contains(pt)) {
{
// Here's part of our window management stuff // Here's part of our window management stuff
if(buttons==B_PRIMARY_MOUSE_BUTTON && !GetFocus()) /* TODO This is missing DEC_MOVETOFRONT
if(buttons==B_PRIMARY_MOUSE_BUTTON && !IsFocus())
return DEC_MOVETOFRONT; return DEC_MOVETOFRONT;
*/
return DEC_DRAG; return DEC_DRAG;
} }
// We got this far, so user is clicking on the border? // We got this far, so user is clicking on the border?
BRect srect(_frame); if(fBorderRect.Contains(pt) && !fFrame.Contains(pt))
srect.top+=19;
BRect clientrect(srect.InsetByCopy(3,3));
if(srect.Contains(pt) && !clientrect.Contains(pt))
{ {
#ifdef DEBUG_DECOR STRACE(("WinDecorator():Clicked() - Resize\n"));
printf("WinDecorator():Clicked() - Resize\n");
#endif
return DEC_RESIZE; return DEC_RESIZE;
} }
// Guess user didn't click anything // Guess user didn't click anything
#ifdef DEBUG_DECOR STRACE(("WinDecorator():Clicked()\n"));
printf("WinDecorator():Clicked()\n");
#endif
return DEC_NONE; return DEC_NONE;
} }
void WinDecorator::_DoLayout(void)
void
WinDecorator::_DoLayout()
{ {
#ifdef DEBUG_DECOR STRACE(("WinDecorator()::_DoLayout()\n"));
printf("WinDecorator()::_DoLayout()\n");
#endif
_borderrect=_frame;
_tabrect=_frame;
_tabrect.InsetBy(4,4); bool hasTab = false;
_tabrect.bottom=_tabrect.top+19;
_zoomrect=_tabrect; fBorderRect=fFrame;
_zoomrect.top+=3; fTabRect=fFrame;
_zoomrect.right-=3;
_zoomrect.bottom-=3;
_zoomrect.left=_zoomrect.right-15;
_closerect=_zoomrect; switch (Look()) {
_zoomrect.OffsetBy(0-_zoomrect.Width()-3,0); case B_MODAL_WINDOW_LOOK:
fBorderRect.InsetBy(-4, -4);
break;
_minimizerect=_zoomrect; case B_TITLED_WINDOW_LOOK:
_minimizerect.OffsetBy(0-_zoomrect.Width()-1,0); case B_DOCUMENT_WINDOW_LOOK:
} hasTab = true;
fBorderRect.InsetBy(-4, -4);
break;
case B_FLOATING_WINDOW_LOOK:
hasTab = true;
break;
void WinDecorator::MoveBy(float x, float y) case B_BORDERED_WINDOW_LOOK:
{ fBorderRect.InsetBy(-1, -1);
MoveBy(BPoint(x,y)); break;
}
void WinDecorator::MoveBy(BPoint pt) default:
{ break;
// Move all internal rectangles the appropriate amount }
_frame.OffsetBy(pt);
_closerect.OffsetBy(pt); if (hasTab) {
_tabrect.OffsetBy(pt); fBorderRect.top -= 19;
_borderrect.OffsetBy(pt);
_zoomrect.OffsetBy(pt); fTabRect.top -= 19;
_minimizerect.OffsetBy(pt); fTabRect.bottom=fTabRect.top+19;
}
fZoomRect=fTabRect;
void WinDecorator::GetFootprint(BRegion *region) fZoomRect.top+=3;
{ fZoomRect.right-=3;
// This function calculates the decorator's footprint in coordinates fZoomRect.bottom-=3;
// relative to the layer. This is most often used to set a WinBorder fZoomRect.left=fZoomRect.right-15;
// object's visible region.
if(!region) fCloseRect=fZoomRect;
return; fZoomRect.OffsetBy(0-fZoomRect.Width()-3,0);
region->Set(_borderrect); fMinimizeRect=fZoomRect;
region->Include(_tabrect); fMinimizeRect.OffsetBy(0-fZoomRect.Width()-1,0);
}
void WinDecorator::_DrawTitle(BRect r)
{
_drawdata.SetHighColor(_colors->window_tab_text);
_drawdata.SetLowColor(GetFocus()?_colors->window_tab:_colors->inactive_window_tab);
int32 titlecount=_ClipTitle((_minimizerect.left-5)-(_tabrect.left+5));
BString titlestr=GetTitle();
if(titlecount<titlestr.CountChars())
{
titlestr.Truncate(titlecount-1);
titlestr+="...";
titlecount+=2;
} }
_driver->DrawString(titlestr.String(),titlecount,
BPoint(_tabrect.left+5,_closerect.bottom-1),&_drawdata);
} }
void WinDecorator::_SetFocus(void)
void
WinDecorator::_DrawTitle(BRect r)
{
fDrawingEngine->SetHighColor(textcol);
fDrawingEngine->SetLowColor(IsFocus()?fFocusTabColor:fNonFocusTabColor);
fTruncatedTitle = Title();
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
(fTabRect.left + textoffset) - (fZoomRect.left - 5));
fTruncatedTitleLength = fTruncatedTitle.Length();
fDrawingEngine->SetFont(fDrawState.Font());
fDrawingEngine->DrawString(fTruncatedTitle,fTruncatedTitleLength,
BPoint(fTabRect.left+textoffset,fCloseRect.bottom-1));
}
void
WinDecorator::_SetFocus(void)
{ {
// 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(GetFocus()) if (IsFocus()) {
{
// 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=_colors->window_tab; tab_highcol=fFocusTabColor;
textcol=_colors->window_tab_text; textcol=fFocusTextColor;
} } else {
else
{
// tab_highcol.SetColor(220,220,220); // tab_highcol.SetColor(220,220,220);
// tab_lowcol.SetColor(128,128,128); // tab_lowcol.SetColor(128,128,128);
tab_highcol=_colors->inactive_window_tab; tab_highcol=fNonFocusTabColor;
textcol=_colors->inactive_window_tab_text; textcol=fNonFocusTextColor;
} }
} }
void WinDecorator::Draw(BRect update)
void
WinDecorator::Draw(BRect update)
{ {
#ifdef DEBUG_DECOR STRACE(("WinDecorator::Draw(): ")); update.PrintToStream();
printf("WinDecorator::Draw(): "); update.PrintToStream();
#endif
// Draw the top view's client area - just a hack :)
// RGBColor blue(100,100,255);
// _drawdata.SetHighColor(blue);
_driver->FillRect(_borderrect,_colors->document_background); fDrawingEngine->SetDrawState(&fDrawState);
if(_borderrect.Intersects(update))
_driver->FillRect(_borderrect,_colors->document_background);
_DrawFrame(update); _DrawFrame(update);
_DrawTab(update); _DrawTab(update);
} }
void WinDecorator::Draw(void)
void
WinDecorator::Draw(void)
{ {
#ifdef DEBUG_DECOR STRACE(("WinDecorator::Draw()\n"));
printf("WinDecorator::Draw()\n");
#endif
// Draw the top view's client area - just a hack :) fDrawingEngine->SetDrawState(&fDrawState);
// RGBColor blue(100,100,255);
// _drawdata.SetHighColor(blue);
_driver->FillRect(_borderrect,_colors->document_background); _DrawFrame(fBorderRect);
_driver->FillRect(_borderrect,_colors->document_background); _DrawTab(fTabRect);
DrawFrame();
DrawTab();
} }
void WinDecorator::_DrawZoom(BRect r)
void
WinDecorator::_DrawZoom(BRect r)
{ {
DrawBeveledRect(r,GetZoom()); DrawBeveledRect(r,GetZoom());
@@ -228,14 +331,15 @@ void WinDecorator::_DrawZoom(BRect r)
if(GetZoom()) if(GetZoom())
rect.OffsetBy(1,1); rect.OffsetBy(1,1);
_drawdata.SetHighColor(RGBColor(0,0,0)); fDrawingEngine->SetHighColor(RGBColor(0,0,0));
_driver->StrokeRect(rect,_drawdata.HighColor()); fDrawingEngine->StrokeRect(rect);
rect.InsetBy(1,1); rect.InsetBy(1,1);
_driver->StrokeLine(rect.LeftTop(),rect.RightTop(),_drawdata.HighColor()); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop());
} }
void WinDecorator::_DrawClose(BRect r) void
WinDecorator::_DrawClose(BRect r)
{ {
// Just like DrawZoom, but for a close button // Just like DrawZoom, but for a close button
DrawBeveledRect(r,GetClose()); DrawBeveledRect(r,GetClose());
@@ -250,12 +354,12 @@ void WinDecorator::_DrawClose(BRect r)
if(GetClose()) if(GetClose())
rect.OffsetBy(1,1); rect.OffsetBy(1,1);
_drawdata.SetHighColor(RGBColor(0,0,0)); fDrawingEngine->SetHighColor(RGBColor(0,0,0));
_driver->StrokeLine(rect.LeftTop(),rect.RightBottom(),_drawdata.HighColor()); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightBottom());
_driver->StrokeLine(rect.RightTop(),rect.LeftBottom(),_drawdata.HighColor()); fDrawingEngine->StrokeLine(rect.RightTop(),rect.LeftBottom());
rect.OffsetBy(1,0); rect.OffsetBy(1,0);
_driver->StrokeLine(rect.LeftTop(),rect.RightBottom(),_drawdata.HighColor()); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightBottom());
_driver->StrokeLine(rect.RightTop(),rect.LeftBottom(),_drawdata.HighColor()); fDrawingEngine->StrokeLine(rect.RightTop(),rect.LeftBottom());
} }
void WinDecorator::_DrawMinimize(BRect r) void WinDecorator::_DrawMinimize(BRect r)
@@ -263,36 +367,39 @@ void WinDecorator::_DrawMinimize(BRect r)
// Just like DrawZoom, but for a Minimize button // Just like DrawZoom, but for a Minimize button
DrawBeveledRect(r,GetMinimize()); DrawBeveledRect(r,GetMinimize());
_drawdata.SetHighColor(textcol); fDrawingEngine->SetHighColor(textcol);
BRect rect(r.left+5,r.bottom-4,r.right-5,r.bottom-3); BRect rect(r.left+5,r.bottom-4,r.right-5,r.bottom-3);
if(GetMinimize()) if(GetMinimize())
rect.OffsetBy(1,1); rect.OffsetBy(1,1);
_drawdata.SetHighColor(RGBColor(0,0,0)); fDrawingEngine->SetHighColor(RGBColor(0,0,0));
_driver->StrokeRect(rect,_drawdata.HighColor()); fDrawingEngine->StrokeRect(rect);
} }
void WinDecorator::_DrawTab(BRect r)
void
WinDecorator::_DrawTab(BRect r)
{ {
// 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(_look==B_NO_BORDER_WINDOW_LOOK) if(fLook==B_NO_BORDER_WINDOW_LOOK)
return; return;
// _driver->StrokeRect(_tabrect,frame_lowcol);
// UpdateTitle(layer->name->String()); fDrawingEngine->FillRect(fTabRect,tab_highcol);
_driver->FillRect(_tabrect,tab_highcol); _DrawTitle(r);
// Draw the buttons if we're supposed to // Draw the buttons if we're supposed to
if(!(_flags & B_NOT_CLOSABLE)) if(!(fFlags & B_NOT_CLOSABLE))
_DrawClose(_closerect); _DrawClose(fCloseRect);
if(!(_flags & B_NOT_ZOOMABLE)) if(!(fFlags & B_NOT_ZOOMABLE))
_DrawZoom(_zoomrect); _DrawZoom(fZoomRect);
} }
void WinDecorator::DrawBeveledRect(BRect r, bool down)
void
WinDecorator::DrawBeveledRect(BRect r, bool down)
{ {
RGBColor higher,high,mid,low,lower; RGBColor higher,high,mid,low,lower;
@@ -317,95 +424,123 @@ void WinDecorator::DrawBeveledRect(BRect r, bool down)
BPoint pt; BPoint pt;
// Top highlight // Top highlight
_drawdata.SetHighColor(higher); fDrawingEngine->SetHighColor(higher);
_driver->StrokeLine(rect.LeftTop(),rect.RightTop(),higher); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop());
// Left highlight // Left highlight
_driver->StrokeLine(rect.LeftTop(),rect.LeftBottom(),higher); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom());
// Right shading // Right shading
pt=rect.RightTop(); pt=rect.RightTop();
pt.y++; pt.y++;
_driver->StrokeLine(pt,rect.RightBottom(),lower); fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower);
// Bottom shading // Bottom shading
pt=rect.LeftBottom(); pt=rect.LeftBottom();
pt.x++; pt.x++;
_driver->StrokeLine(pt,rect.RightBottom(),lower); fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower);
rect.InsetBy(1,1); rect.InsetBy(1,1);
// Top inside highlight // Top inside highlight
_driver->StrokeLine(rect.LeftTop(),rect.RightTop(),higher); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop());
// Left inside highlight // Left inside highlight
_driver->StrokeLine(rect.LeftTop(),rect.LeftBottom(),higher); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom());
// Right inside shading // Right inside shading
pt=rect.RightTop(); pt=rect.RightTop();
pt.y++; pt.y++;
_driver->StrokeLine(pt,rect.RightBottom(),lower); fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower);
// Bottom inside shading // Bottom inside shading
pt=rect.LeftBottom(); pt=rect.LeftBottom();
pt.x++; pt.x++;
_driver->StrokeLine(pt,rect.RightBottom(),lower); fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower);
rect.InsetBy(1,1); rect.InsetBy(1,1);
_driver->FillRect(rect,mid); fDrawingEngine->FillRect(rect,mid);
} }
void WinDecorator::_SetColors(void)
void
WinDecorator::_SetColors()
{ {
_SetFocus(); _SetFocus();
} }
void WinDecorator::_DrawFrame(BRect rect)
void
WinDecorator::_UpdateFont(DesktopSettings& settings)
{ {
if(_look==B_NO_BORDER_WINDOW_LOOK) ServerFont font;
if (fLook == B_FLOATING_WINDOW_LOOK) {
settings.GetDefaultPlainFont(font);
} else
settings.GetDefaultBoldFont(font);
font.SetFlags(B_FORCE_ANTIALIASING);
font.SetSpacing(B_STRING_SPACING);
fDrawState.SetFont(font);
}
void
WinDecorator::_DrawFrame(BRect rect)
{
if(fLook==B_NO_BORDER_WINDOW_LOOK)
return; return;
BRect r=_borderrect; if (fBorderRect == fFrame)
return;
_drawdata.SetHighColor(RGBColor(255,0,0)); BRect r=fBorderRect;
_driver->StrokeRect(r,_drawdata.HighColor());
fDrawingEngine->SetHighColor(frame_lowercol);
fDrawingEngine->StrokeRect(r);
if ( fLook == B_BORDERED_WINDOW_LOOK)
return;
BPoint pt; BPoint pt;
pt=r.RightTop(); pt=r.RightTop();
pt.x--; pt.x--;
_driver->StrokeLine(r.LeftTop(),pt,frame_midcol); fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_midcol);
pt=r.LeftBottom(); pt=r.LeftBottom();
pt.y--; pt.y--;
_driver->StrokeLine(r.LeftTop(),pt,frame_midcol); fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_midcol);
_driver->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowercol); fDrawingEngine->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowercol);
_driver->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowercol); fDrawingEngine->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowercol);
r.InsetBy(1,1); r.InsetBy(1,1);
pt=r.RightTop(); pt=r.RightTop();
pt.x--; pt.x--;
_driver->StrokeLine(r.LeftTop(),pt,frame_highcol); fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_highcol);
pt=r.LeftBottom(); pt=r.LeftBottom();
pt.y--; pt.y--;
_driver->StrokeLine(r.LeftTop(),pt,frame_highcol); fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_highcol);
_driver->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowcol); fDrawingEngine->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowcol);
_driver->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowcol); fDrawingEngine->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowcol);
r.InsetBy(1,1); r.InsetBy(1,1);
_driver->StrokeRect(r,frame_midcol); fDrawingEngine->StrokeRect(r,frame_midcol);
r.InsetBy(1,1); r.InsetBy(1,1);
_driver->StrokeRect(r,frame_midcol); fDrawingEngine->StrokeRect(r,frame_midcol);
} }
extern "C" float get_decorator_version(void) extern "C" float get_decorator_version(void)
{ {
return 1.00; return 1.00;
} }
extern "C" Decorator *instantiate_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
extern "C" Decorator *instantiate_decorator(DesktopSettings &desktopSetting, BRect rect,
window_look wlook, int32 wflags)
{ {
return new WinDecorator(rect,wlook,wfeel,wflags); return new WinDecorator(desktopSetting, rect, wlook, wflags);
} }
@@ -6,19 +6,25 @@
class WinDecorator: public Decorator class WinDecorator: public Decorator
{ {
public: public:
WinDecorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags); WinDecorator(DesktopSettings& settings,
BRect frame, window_look wlook,
uint32 wflags);
~WinDecorator(void); ~WinDecorator(void);
void MoveBy(float x, float y); void SetTitle(const char* string,
BRegion* updateRegion = NULL);
void FontsChanged(DesktopSettings& settings,
BRegion* updateRegion);
void MoveBy(BPoint pt); void MoveBy(BPoint pt);
// void ResizeBy(float x, float y); void ResizeBy(BPoint pt, BRegion* dirty);
// void ResizeBy(BPoint pt);
void Draw(BRect r); void Draw(BRect r);
void Draw(void); void Draw(void);
void GetFootprint(BRegion *region); void GetFootprint(BRegion *region);
click_type Clicked(BPoint pt, int32 buttons, int32 modifiers); click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
protected: protected:
void _UpdateFont(DesktopSettings& settings);
void _DrawClose(BRect r); void _DrawClose(BRect r);
void _DrawFrame(BRect r); void _DrawFrame(BRect r);
void _DrawTab(BRect r); void _DrawTab(BRect r);
@@ -31,11 +37,22 @@ protected:
void DrawBeveledRect(BRect r, bool down); void DrawBeveledRect(BRect r, bool down);
uint32 taboffset; uint32 taboffset;
RGBColor tab_highcol, tab_lowcol; rgb_color tab_highcol;
RGBColor frame_highcol, frame_midcol, frame_lowcol, frame_lowercol; rgb_color tab_lowcol;
RGBColor textcol; rgb_color frame_highcol;
rgb_color frame_midcol;
rgb_color frame_lowcol;
rgb_color frame_lowercol;
rgb_color textcol;
rgb_color fFocusTabColor;
rgb_color fNonFocusTabColor;
rgb_color fFocusTextColor;
rgb_color fNonFocusTextColor;
uint64 solidhigh, solidlow; uint64 solidhigh, solidlow;
BString fTruncatedTitle;
int32 fTruncatedTitleLength;
bool slidetab; bool slidetab;
int textoffset; int textoffset;
}; };