* Fix the WinDecorator and some parts of the MacDecorator
* Since they all work reasonalbly well, add them to the default image. (beOs had them after all) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37864 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a09c2bb328
commit
4d978eea2f
@ -556,6 +556,10 @@ AddFilesToHaikuImage system add-ons Screen\ Savers
|
||||
AddFilesToHaikuImage system add-ons disk_systems
|
||||
: <disk_system>intel <disk_system>bfs ;
|
||||
|
||||
# decorators
|
||||
AddFilesToHaikuImage home config add-ons decorators :
|
||||
MacDecorator WinDecorator ClassicBe ;
|
||||
|
||||
# create directories that will remain empty
|
||||
AddDirectoryToHaikuImage common bin ;
|
||||
AddDirectoryToHaikuImage common include ;
|
||||
|
@ -550,11 +550,10 @@ MacDecorator::_DrawTitle(BRect rect)
|
||||
void
|
||||
MacDecorator::_DrawZoom(BRect r)
|
||||
{
|
||||
bool down = GetClose();
|
||||
bool down = GetZoom();
|
||||
|
||||
// Just like DrawZoom, but for a close button
|
||||
BRect rect(r);
|
||||
|
||||
BPoint offset(r.LeftTop()),pt2(r.RightTop());
|
||||
|
||||
pt2.x--;
|
||||
@ -597,11 +596,10 @@ MacDecorator::_DrawZoom(BRect r)
|
||||
void
|
||||
MacDecorator::_DrawMinimize(BRect r)
|
||||
{
|
||||
bool down = GetClose();
|
||||
bool down = GetMinimize();
|
||||
|
||||
// Just like DrawZoom, but for a close button
|
||||
// Just like DrawZoom, but for a Minimize button
|
||||
BRect rect(r);
|
||||
|
||||
BPoint offset(r.LeftTop()), pt2(r.RightTop());
|
||||
|
||||
pt2.x--;
|
||||
@ -748,8 +746,8 @@ MacDecorator::_ResizeBy(BPoint offset, BRegion* dirty)
|
||||
fTabRect.right += offset.x;
|
||||
fBorderRect.right += offset.x;
|
||||
fBorderRect.bottom += offset.y;
|
||||
// fZoomRect.OffsetBy(offset.x,0);
|
||||
// fMinimizeRect.OffsetBy(offset.x,0);
|
||||
// fZoomRect.OffsetBy(offset.x, 0);
|
||||
// fMinimizeRect.OffsetBy(offset.x, 0);
|
||||
if (dirty) {
|
||||
dirty->Include(fTabRect);
|
||||
dirty->Include(fBorderRect);
|
||||
@ -777,7 +775,6 @@ MacDecorator::_GetFootprint(BRegion* region)
|
||||
|
||||
if (fLook == B_NO_BORDER_WINDOW_LOOK)
|
||||
return;
|
||||
|
||||
|
||||
region->Set(fBorderRect);
|
||||
region->Exclude(fFrame);
|
||||
@ -792,9 +789,9 @@ void
|
||||
MacDecorator::_UpdateFont(DesktopSettings& settings)
|
||||
{
|
||||
ServerFont font;
|
||||
if (fLook == B_FLOATING_WINDOW_LOOK) {
|
||||
if (fLook == B_FLOATING_WINDOW_LOOK)
|
||||
settings.GetDefaultPlainFont(font);
|
||||
} else
|
||||
else
|
||||
settings.GetDefaultBoldFont(font);
|
||||
|
||||
font.SetFlags(B_FORCE_ANTIALIASING);
|
||||
|
@ -2,8 +2,6 @@
|
||||
Copyright 2009, Haiku.
|
||||
Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _MAC_DECORATOR_H_
|
||||
#define _MAC_DECORATOR_H_
|
||||
|
||||
@ -31,10 +29,10 @@ public:
|
||||
uint32 flags);
|
||||
virtual ~MacDecorator();
|
||||
|
||||
void Draw(BRect updateRect);
|
||||
void Draw();
|
||||
void Draw(BRect updateRect);
|
||||
void Draw();
|
||||
|
||||
click_type Clicked(BPoint pt, int32 buttons,
|
||||
click_type Clicked(BPoint pt, int32 buttons,
|
||||
int32 modifiers);
|
||||
|
||||
protected:
|
||||
@ -53,16 +51,16 @@ protected:
|
||||
|
||||
void _FontsChanged(DesktopSettings& settings,
|
||||
BRegion* updateRegion);
|
||||
void _SetLook(DesktopSettings& settings,
|
||||
void _SetLook(DesktopSettings& settings,
|
||||
window_look look,
|
||||
BRegion* updateRegion = NULL);
|
||||
void _SetFlags(uint32 flags,
|
||||
void _SetFlags(uint32 flags,
|
||||
BRegion* updateRegion = NULL);
|
||||
|
||||
void _SetColors();
|
||||
|
||||
void _MoveBy(BPoint offset);
|
||||
void _ResizeBy(BPoint offset, BRegion* dirty);
|
||||
void _ResizeBy(BPoint offset, BRegion* dirty);
|
||||
|
||||
void _GetFootprint(BRegion *region);
|
||||
|
||||
|
@ -9,6 +9,9 @@
|
||||
|
||||
#include "WinDecorator.h"
|
||||
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Point.h>
|
||||
#include <View.h>
|
||||
|
||||
@ -20,20 +23,40 @@
|
||||
|
||||
//#define DEBUG_DECORATOR
|
||||
#ifdef DEBUG_DECORATOR
|
||||
# include <stdio.h>
|
||||
# define STRACE(x) printf x ;
|
||||
# define STRACE(x) printf x
|
||||
#else
|
||||
# define STRACE(x) ;
|
||||
#endif
|
||||
|
||||
|
||||
WinDecorAddOn::WinDecorAddOn(image_id id, const char* name)
|
||||
:
|
||||
DecorAddOn(id, name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
WinDecorAddOn::Version()
|
||||
{
|
||||
return 1.00;
|
||||
}
|
||||
|
||||
|
||||
Decorator*
|
||||
WinDecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect,
|
||||
window_look look, uint32 flags)
|
||||
{
|
||||
return new (std::nothrow)WinDecorator(settings, rect, look, flags);
|
||||
}
|
||||
|
||||
|
||||
WinDecorator::WinDecorator(DesktopSettings& settings, BRect rect,
|
||||
window_look look, uint32 flags)
|
||||
:
|
||||
Decorator(settings, rect, look, flags),
|
||||
taboffset(0)
|
||||
Decorator(settings, rect, look, flags)
|
||||
{
|
||||
|
||||
_UpdateFont(settings);
|
||||
|
||||
// common colors to both focus and non focus state
|
||||
@ -67,132 +90,7 @@ WinDecorator::~WinDecorator()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::SetTitle(const char* string, BRegion* updateRegion)
|
||||
{
|
||||
// TODO: we could be much smarter about the update region
|
||||
|
||||
BRect rect = TabRect();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::SetLook(DesktopSettings& settings, window_look look,
|
||||
BRegion* updateRegion)
|
||||
{
|
||||
// TODO: we could be much smarter about the update region
|
||||
|
||||
// get previous extent
|
||||
if (updateRegion != NULL) {
|
||||
BRegion extent;
|
||||
GetFootprint(&extent);
|
||||
updateRegion->Include(&extent);
|
||||
}
|
||||
|
||||
fLook = look;
|
||||
|
||||
_UpdateFont(settings);
|
||||
_DoLayout();
|
||||
|
||||
if (updateRegion != NULL) {
|
||||
BRegion extent;
|
||||
GetFootprint(&extent);
|
||||
updateRegion->Include(&extent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::SetFlags(uint32 flags, BRegion* updateRegion)
|
||||
{
|
||||
// TODO: we could be much smarter about the update region
|
||||
|
||||
// get previous extent
|
||||
if (updateRegion != NULL) {
|
||||
BRegion extent;
|
||||
GetFootprint(&extent);
|
||||
updateRegion->Include(&extent);
|
||||
}
|
||||
|
||||
Decorator::SetFlags(flags, updateRegion);
|
||||
_DoLayout();
|
||||
|
||||
if (updateRegion != NULL) {
|
||||
BRegion extent;
|
||||
GetFootprint(&extent);
|
||||
updateRegion->Include(&extent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
// TODO : Add GetSettings
|
||||
|
||||
|
||||
void
|
||||
@ -208,10 +106,9 @@ WinDecorator::Draw(BRect update)
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::Draw(void)
|
||||
WinDecorator::Draw()
|
||||
{
|
||||
STRACE(("WinDecorator::Draw()\n"));
|
||||
|
||||
fDrawingEngine->SetDrawState(&fDrawState);
|
||||
|
||||
_DrawFrame(fBorderRect);
|
||||
@ -219,27 +116,7 @@ WinDecorator::Draw(void)
|
||||
}
|
||||
|
||||
|
||||
// TODO : GetSizeLimits
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
// TODO : add GetSizeLimits
|
||||
|
||||
|
||||
click_type
|
||||
@ -337,108 +214,49 @@ WinDecorator::_DoLayout()
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_DrawTitle(BRect r)
|
||||
WinDecorator::_DrawFrame(BRect rect)
|
||||
{
|
||||
//fDrawingEngine->SetDrawingMode(B_OP_OVER);
|
||||
fDrawingEngine->SetHighColor(textcol);
|
||||
fDrawingEngine->SetLowColor(IsFocus()?fFocusTabColor:fNonFocusTabColor);
|
||||
if (fLook == B_NO_BORDER_WINDOW_LOOK)
|
||||
return;
|
||||
|
||||
fTruncatedTitle = Title();
|
||||
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
|
||||
((fZoomRect.IsValid() ? fZoomRect.left :
|
||||
fCloseRect.IsValid() ? fCloseRect.left : fTabRect.right) - 5)
|
||||
- (fTabRect.left + textoffset));
|
||||
fTruncatedTitleLength = fTruncatedTitle.Length();
|
||||
if (fBorderRect == fFrame)
|
||||
return;
|
||||
|
||||
//fDrawingEngine->SetFont(fDrawState.Font());
|
||||
fDrawingEngine->DrawString(fTruncatedTitle,fTruncatedTitleLength,
|
||||
BPoint(fTabRect.left+textoffset,fCloseRect.bottom-1));
|
||||
|
||||
//fDrawingEngine->SetDrawingMode(B_OP_COPY);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_SetFocus(void)
|
||||
{
|
||||
// SetFocus() performs necessary duties for color swapping and
|
||||
// other things when a window is deactivated or activated.
|
||||
|
||||
if (IsFocus()) {
|
||||
// tab_highcol.SetColor(100,100,255);
|
||||
// tab_lowcol.SetColor(40,0,255);
|
||||
tab_highcol=fFocusTabColor;
|
||||
textcol=fFocusTextColor;
|
||||
} else {
|
||||
// tab_highcol.SetColor(220,220,220);
|
||||
// tab_lowcol.SetColor(128,128,128);
|
||||
tab_highcol=fNonFocusTabColor;
|
||||
textcol=fNonFocusTextColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_DrawZoom(BRect r)
|
||||
{
|
||||
DrawBeveledRect(r,GetZoom());
|
||||
BRect r = fBorderRect;
|
||||
|
||||
// Draw the Zoom box
|
||||
fDrawingEngine->SetHighColor(frame_lowercol);
|
||||
fDrawingEngine->StrokeRect(r);
|
||||
|
||||
BRect rect(r);
|
||||
rect.InsetBy(2,2);
|
||||
rect.InsetBy(1,0);
|
||||
rect.bottom--;
|
||||
rect.right--;
|
||||
if (fLook == B_BORDERED_WINDOW_LOOK)
|
||||
return;
|
||||
|
||||
if (GetZoom())
|
||||
rect.OffsetBy(1,1);
|
||||
BPoint pt;
|
||||
|
||||
fDrawingEngine->SetHighColor(RGBColor(0,0,0));
|
||||
fDrawingEngine->StrokeRect(rect);
|
||||
rect.InsetBy(1,1);
|
||||
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop());
|
||||
pt=r.RightTop();
|
||||
pt.x--;
|
||||
fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_midcol);
|
||||
pt=r.LeftBottom();
|
||||
pt.y--;
|
||||
fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_midcol);
|
||||
|
||||
fDrawingEngine->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowercol);
|
||||
fDrawingEngine->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowercol);
|
||||
|
||||
}
|
||||
r.InsetBy(1,1);
|
||||
pt=r.RightTop();
|
||||
pt.x--;
|
||||
fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_highcol);
|
||||
pt=r.LeftBottom();
|
||||
pt.y--;
|
||||
fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_highcol);
|
||||
|
||||
void
|
||||
WinDecorator::_DrawClose(BRect r)
|
||||
{
|
||||
// Just like DrawZoom, but for a close button
|
||||
DrawBeveledRect(r,GetClose());
|
||||
fDrawingEngine->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowcol);
|
||||
fDrawingEngine->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowcol);
|
||||
|
||||
// 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::_DrawMinimize(BRect r)
|
||||
{
|
||||
// Just like DrawZoom, but for a Minimize button
|
||||
DrawBeveledRect(r,GetMinimize());
|
||||
|
||||
fDrawingEngine->SetHighColor(textcol);
|
||||
BRect rect(r.left+5,r.bottom-4,r.right-5,r.bottom-3);
|
||||
if(GetMinimize())
|
||||
rect.OffsetBy(1,1);
|
||||
|
||||
fDrawingEngine->SetHighColor(RGBColor(0,0,0));
|
||||
fDrawingEngine->StrokeRect(rect);
|
||||
r.InsetBy(1,1);
|
||||
fDrawingEngine->StrokeRect(r,frame_midcol);
|
||||
r.InsetBy(1,1);
|
||||
fDrawingEngine->StrokeRect(r,frame_midcol);
|
||||
}
|
||||
|
||||
|
||||
@ -464,7 +282,270 @@ WinDecorator::_DrawTab(BRect invalid)
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::DrawBeveledRect(BRect r, bool down)
|
||||
WinDecorator::_DrawClose(BRect r)
|
||||
{
|
||||
// Just like DrawZoom, but for a close button
|
||||
_DrawBeveledRect(r,GetClose());
|
||||
|
||||
// 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->SetHighColor(textcol);
|
||||
fDrawingEngine->SetLowColor(IsFocus()?fFocusTabColor:fNonFocusTabColor);
|
||||
|
||||
fTruncatedTitle = Title();
|
||||
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
|
||||
((fZoomRect.IsValid() ? fZoomRect.left :
|
||||
fCloseRect.IsValid() ? fCloseRect.left : fTabRect.right) - 5)
|
||||
- (fTabRect.left + textoffset));
|
||||
fTruncatedTitleLength = fTruncatedTitle.Length();
|
||||
fDrawingEngine->SetFont(fDrawState.Font());
|
||||
|
||||
fDrawingEngine->DrawString(fTruncatedTitle,fTruncatedTitleLength,
|
||||
BPoint(fTabRect.left+textoffset,fCloseRect.bottom-1));
|
||||
|
||||
//fDrawingEngine->SetDrawingMode(B_OP_COPY);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_DrawZoom(BRect r)
|
||||
{
|
||||
_DrawBeveledRect(r,GetZoom());
|
||||
|
||||
// Draw the Zoom box
|
||||
|
||||
BRect rect(r);
|
||||
rect.InsetBy(2,2);
|
||||
rect.InsetBy(1,0);
|
||||
rect.bottom--;
|
||||
rect.right--;
|
||||
|
||||
if (GetZoom())
|
||||
rect.OffsetBy(1,1);
|
||||
|
||||
fDrawingEngine->SetHighColor(RGBColor(0,0,0));
|
||||
fDrawingEngine->StrokeRect(rect);
|
||||
rect.InsetBy(1,1);
|
||||
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop());
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_DrawMinimize(BRect r)
|
||||
{
|
||||
// Just like DrawZoom, but for a Minimize button
|
||||
_DrawBeveledRect(r,GetMinimize());
|
||||
|
||||
fDrawingEngine->SetHighColor(textcol);
|
||||
BRect rect(r.left+5,r.bottom-4,r.right-5,r.bottom-3);
|
||||
if(GetMinimize())
|
||||
rect.OffsetBy(1,1);
|
||||
|
||||
fDrawingEngine->SetHighColor(RGBColor(0,0,0));
|
||||
fDrawingEngine->StrokeRect(rect);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_SetTitle(const char* string, BRegion* updateRegion)
|
||||
{
|
||||
// TODO: we could be much smarter about the update region
|
||||
|
||||
BRect rect = TabRect();
|
||||
|
||||
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)
|
||||
updateRegion->Include(&GetFootprint());
|
||||
|
||||
_UpdateFont(settings);
|
||||
_DoLayout();
|
||||
|
||||
_InvalidateFootprint();
|
||||
if (updateRegion != NULL)
|
||||
updateRegion->Include(&GetFootprint());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_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());
|
||||
|
||||
fLook = look;
|
||||
|
||||
_UpdateFont(settings);
|
||||
_DoLayout();
|
||||
|
||||
_InvalidateFootprint();
|
||||
if (updateRegion != NULL)
|
||||
updateRegion->Include(&GetFootprint());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_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());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_SetFocus(void)
|
||||
{
|
||||
// SetFocus() performs necessary duties for color swapping and
|
||||
// other things when a window is deactivated or activated.
|
||||
|
||||
if (IsFocus()) {
|
||||
// tab_highcol.SetColor(100,100,255);
|
||||
// tab_lowcol.SetColor(40,0,255);
|
||||
tab_highcol=fFocusTabColor;
|
||||
textcol=fFocusTextColor;
|
||||
} else {
|
||||
// tab_highcol.SetColor(220,220,220);
|
||||
// tab_lowcol.SetColor(128,128,128);
|
||||
tab_highcol=fNonFocusTabColor;
|
||||
textcol=fNonFocusTextColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_SetColors()
|
||||
{
|
||||
_SetFocus();
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
// TODO : _SetSettings
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_UpdateFont(DesktopSettings& settings)
|
||||
{
|
||||
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::_DrawBeveledRect(BRect r, bool down)
|
||||
{
|
||||
RGBColor higher;
|
||||
RGBColor high;
|
||||
@ -530,85 +611,11 @@ WinDecorator::DrawBeveledRect(BRect r, bool down)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_SetColors()
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
extern "C" DecorAddOn*
|
||||
instantiate_decor_addon(image_id id, const char* name)
|
||||
{
|
||||
_SetFocus();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WinDecorator::_UpdateFont(DesktopSettings& settings)
|
||||
{
|
||||
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;
|
||||
|
||||
if (fBorderRect == fFrame)
|
||||
return;
|
||||
|
||||
BRect r = fBorderRect;
|
||||
|
||||
fDrawingEngine->SetHighColor(frame_lowercol);
|
||||
fDrawingEngine->StrokeRect(r);
|
||||
|
||||
if (fLook == B_BORDERED_WINDOW_LOOK)
|
||||
return;
|
||||
|
||||
BPoint pt;
|
||||
|
||||
pt=r.RightTop();
|
||||
pt.x--;
|
||||
fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_midcol);
|
||||
pt=r.LeftBottom();
|
||||
pt.y--;
|
||||
fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_midcol);
|
||||
|
||||
fDrawingEngine->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowercol);
|
||||
fDrawingEngine->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowercol);
|
||||
|
||||
r.InsetBy(1,1);
|
||||
pt=r.RightTop();
|
||||
pt.x--;
|
||||
fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_highcol);
|
||||
pt=r.LeftBottom();
|
||||
pt.y--;
|
||||
fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_highcol);
|
||||
|
||||
fDrawingEngine->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowcol);
|
||||
fDrawingEngine->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowcol);
|
||||
|
||||
r.InsetBy(1,1);
|
||||
fDrawingEngine->StrokeRect(r,frame_midcol);
|
||||
r.InsetBy(1,1);
|
||||
fDrawingEngine->StrokeRect(r,frame_midcol);
|
||||
}
|
||||
|
||||
|
||||
extern "C" float
|
||||
get_decorator_version(void)
|
||||
{
|
||||
return 1.00;
|
||||
}
|
||||
|
||||
|
||||
extern "C" Decorator *
|
||||
instantiate_decorator(DesktopSettings &desktopSetting, BRect rect,
|
||||
window_look wlook, int32 wflags)
|
||||
{
|
||||
return new WinDecorator(desktopSetting, rect, wlook, wflags);
|
||||
return new (std::nothrow)WinDecorAddOn(id, name);
|
||||
}
|
||||
|
@ -1,45 +1,76 @@
|
||||
/*
|
||||
Copyright 2009-2010, Haiku.
|
||||
Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _BEOS_DECORATOR_H_
|
||||
#define _BEOS_DECORATOR_H_
|
||||
|
||||
#include "Decorator.h"
|
||||
|
||||
#include "DecorManager.h"
|
||||
#include "RGBColor.h"
|
||||
|
||||
|
||||
class WinDecorAddOn : public DecorAddOn
|
||||
{
|
||||
public:
|
||||
WinDecorAddOn(image_id id, const char* name);
|
||||
|
||||
float Version();
|
||||
protected:
|
||||
virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
|
||||
BRect rect, window_look look, uint32 flags);
|
||||
};
|
||||
|
||||
|
||||
class WinDecorator: public Decorator
|
||||
{
|
||||
public:
|
||||
WinDecorator(DesktopSettings& settings,
|
||||
BRect frame, window_look wlook,
|
||||
uint32 wflags);
|
||||
~WinDecorator(void);
|
||||
WinDecorator(DesktopSettings& settings,
|
||||
BRect frame, window_look wlook,
|
||||
uint32 wflags);
|
||||
~WinDecorator(void);
|
||||
|
||||
void SetTitle(const char* string,
|
||||
BRegion* updateRegion = NULL);
|
||||
void FontsChanged(DesktopSettings& settings,
|
||||
BRegion* updateRegion);
|
||||
virtual void SetLook(DesktopSettings& settings,
|
||||
window_look look,
|
||||
BRegion* updateRegion = NULL);
|
||||
virtual void SetFlags(uint32 flags,
|
||||
BRegion* updateRegion = NULL);
|
||||
|
||||
void MoveBy(BPoint pt);
|
||||
void ResizeBy(BPoint pt, BRegion* dirty);
|
||||
void Draw(BRect r);
|
||||
void Draw(void);
|
||||
void GetFootprint(BRegion *region);
|
||||
click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
|
||||
void Draw(BRect r);
|
||||
void Draw();
|
||||
|
||||
click_type Clicked(BPoint pt, int32 buttons,
|
||||
int32 modifiers);
|
||||
|
||||
protected:
|
||||
void _UpdateFont(DesktopSettings& settings);
|
||||
void _DrawClose(BRect r);
|
||||
void _DrawFrame(BRect r);
|
||||
void _DrawTab(BRect r);
|
||||
void _DrawTitle(BRect r);
|
||||
void _DrawZoom(BRect r);
|
||||
void _DrawMinimize(BRect r);
|
||||
void _DoLayout(void);
|
||||
void _SetFocus(void);
|
||||
void _SetColors(void);
|
||||
void DrawBeveledRect(BRect r, bool down);
|
||||
void _DoLayout();
|
||||
|
||||
void _DrawFrame(BRect r);
|
||||
void _DrawTab(BRect r);
|
||||
|
||||
void _DrawClose(BRect r);
|
||||
void _DrawTitle(BRect r);
|
||||
void _DrawZoom(BRect r);
|
||||
void _DrawMinimize(BRect r);
|
||||
|
||||
void _SetTitle(const char* string,
|
||||
BRegion* updateRegion = NULL);
|
||||
|
||||
void _FontsChanged(DesktopSettings& settings,
|
||||
BRegion* updateRegion);
|
||||
void _SetLook(DesktopSettings& settings,
|
||||
window_look look,
|
||||
BRegion* updateRegion = NULL);
|
||||
void _SetFlags(uint32 flags,
|
||||
BRegion* updateRegion = NULL);
|
||||
|
||||
void _SetColors();
|
||||
|
||||
void _MoveBy(BPoint pt);
|
||||
void _ResizeBy(BPoint pt, BRegion* dirty);
|
||||
|
||||
void _GetFootprint(BRegion *region);
|
||||
void _SetFocus(void);
|
||||
|
||||
private:
|
||||
void _UpdateFont(DesktopSettings& settings);
|
||||
void _DrawBeveledRect(BRect r, bool down);
|
||||
|
||||
|
||||
uint32 taboffset;
|
||||
|
||||
rgb_color tab_highcol;
|
||||
|
Loading…
Reference in New Issue
Block a user