* 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:
@@ -556,6 +556,10 @@ AddFilesToHaikuImage system add-ons Screen\ Savers
|
|||||||
AddFilesToHaikuImage system add-ons disk_systems
|
AddFilesToHaikuImage system add-ons disk_systems
|
||||||
: <disk_system>intel <disk_system>bfs ;
|
: <disk_system>intel <disk_system>bfs ;
|
||||||
|
|
||||||
|
# decorators
|
||||||
|
AddFilesToHaikuImage home config add-ons decorators :
|
||||||
|
MacDecorator WinDecorator ClassicBe ;
|
||||||
|
|
||||||
# create directories that will remain empty
|
# create directories that will remain empty
|
||||||
AddDirectoryToHaikuImage common bin ;
|
AddDirectoryToHaikuImage common bin ;
|
||||||
AddDirectoryToHaikuImage common include ;
|
AddDirectoryToHaikuImage common include ;
|
||||||
|
|||||||
@@ -550,11 +550,10 @@ MacDecorator::_DrawTitle(BRect rect)
|
|||||||
void
|
void
|
||||||
MacDecorator::_DrawZoom(BRect r)
|
MacDecorator::_DrawZoom(BRect r)
|
||||||
{
|
{
|
||||||
bool down = GetClose();
|
bool down = GetZoom();
|
||||||
|
|
||||||
// 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--;
|
||||||
@@ -597,11 +596,10 @@ MacDecorator::_DrawZoom(BRect r)
|
|||||||
void
|
void
|
||||||
MacDecorator::_DrawMinimize(BRect r)
|
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);
|
BRect rect(r);
|
||||||
|
|
||||||
BPoint offset(r.LeftTop()), pt2(r.RightTop());
|
BPoint offset(r.LeftTop()), pt2(r.RightTop());
|
||||||
|
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
@@ -748,8 +746,8 @@ MacDecorator::_ResizeBy(BPoint offset, BRegion* dirty)
|
|||||||
fTabRect.right += offset.x;
|
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);
|
// fZoomRect.OffsetBy(offset.x, 0);
|
||||||
// fMinimizeRect.OffsetBy(offset.x,0);
|
// fMinimizeRect.OffsetBy(offset.x, 0);
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
dirty->Include(fTabRect);
|
dirty->Include(fTabRect);
|
||||||
dirty->Include(fBorderRect);
|
dirty->Include(fBorderRect);
|
||||||
@@ -777,7 +775,6 @@ MacDecorator::_GetFootprint(BRegion* region)
|
|||||||
|
|
||||||
if (fLook == B_NO_BORDER_WINDOW_LOOK)
|
if (fLook == B_NO_BORDER_WINDOW_LOOK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
region->Set(fBorderRect);
|
region->Set(fBorderRect);
|
||||||
region->Exclude(fFrame);
|
region->Exclude(fFrame);
|
||||||
@@ -792,9 +789,9 @@ void
|
|||||||
MacDecorator::_UpdateFont(DesktopSettings& settings)
|
MacDecorator::_UpdateFont(DesktopSettings& settings)
|
||||||
{
|
{
|
||||||
ServerFont font;
|
ServerFont font;
|
||||||
if (fLook == B_FLOATING_WINDOW_LOOK) {
|
if (fLook == B_FLOATING_WINDOW_LOOK)
|
||||||
settings.GetDefaultPlainFont(font);
|
settings.GetDefaultPlainFont(font);
|
||||||
} else
|
else
|
||||||
settings.GetDefaultBoldFont(font);
|
settings.GetDefaultBoldFont(font);
|
||||||
|
|
||||||
font.SetFlags(B_FORCE_ANTIALIASING);
|
font.SetFlags(B_FORCE_ANTIALIASING);
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
Copyright 2009, Haiku.
|
Copyright 2009, Haiku.
|
||||||
Distributed under the terms of the MIT License.
|
Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _MAC_DECORATOR_H_
|
#ifndef _MAC_DECORATOR_H_
|
||||||
#define _MAC_DECORATOR_H_
|
#define _MAC_DECORATOR_H_
|
||||||
|
|
||||||
@@ -31,10 +29,10 @@ public:
|
|||||||
uint32 flags);
|
uint32 flags);
|
||||||
virtual ~MacDecorator();
|
virtual ~MacDecorator();
|
||||||
|
|
||||||
void Draw(BRect updateRect);
|
void Draw(BRect updateRect);
|
||||||
void Draw();
|
void Draw();
|
||||||
|
|
||||||
click_type Clicked(BPoint pt, int32 buttons,
|
click_type Clicked(BPoint pt, int32 buttons,
|
||||||
int32 modifiers);
|
int32 modifiers);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -53,16 +51,16 @@ protected:
|
|||||||
|
|
||||||
void _FontsChanged(DesktopSettings& settings,
|
void _FontsChanged(DesktopSettings& settings,
|
||||||
BRegion* updateRegion);
|
BRegion* updateRegion);
|
||||||
void _SetLook(DesktopSettings& settings,
|
void _SetLook(DesktopSettings& settings,
|
||||||
window_look look,
|
window_look look,
|
||||||
BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
void _SetFlags(uint32 flags,
|
void _SetFlags(uint32 flags,
|
||||||
BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
|
|
||||||
void _SetColors();
|
void _SetColors();
|
||||||
|
|
||||||
void _MoveBy(BPoint offset);
|
void _MoveBy(BPoint offset);
|
||||||
void _ResizeBy(BPoint offset, BRegion* dirty);
|
void _ResizeBy(BPoint offset, BRegion* dirty);
|
||||||
|
|
||||||
void _GetFootprint(BRegion *region);
|
void _GetFootprint(BRegion *region);
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
|
|
||||||
#include "WinDecorator.h"
|
#include "WinDecorator.h"
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Point.h>
|
#include <Point.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
@@ -20,20 +23,40 @@
|
|||||||
|
|
||||||
//#define DEBUG_DECORATOR
|
//#define DEBUG_DECORATOR
|
||||||
#ifdef DEBUG_DECORATOR
|
#ifdef DEBUG_DECORATOR
|
||||||
# include <stdio.h>
|
# define STRACE(x) printf x
|
||||||
# define STRACE(x) printf x ;
|
|
||||||
#else
|
#else
|
||||||
# define STRACE(x) ;
|
# define STRACE(x) ;
|
||||||
#endif
|
#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,
|
WinDecorator::WinDecorator(DesktopSettings& settings, BRect rect,
|
||||||
window_look look, uint32 flags)
|
window_look look, uint32 flags)
|
||||||
:
|
:
|
||||||
Decorator(settings, rect, look, flags),
|
Decorator(settings, rect, look, flags)
|
||||||
taboffset(0)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
_UpdateFont(settings);
|
_UpdateFont(settings);
|
||||||
|
|
||||||
// common colors to both focus and non focus state
|
// common colors to both focus and non focus state
|
||||||
@@ -67,132 +90,7 @@ WinDecorator::~WinDecorator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
// TODO : Add GetSettings
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -208,10 +106,9 @@ WinDecorator::Draw(BRect update)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WinDecorator::Draw(void)
|
WinDecorator::Draw()
|
||||||
{
|
{
|
||||||
STRACE(("WinDecorator::Draw()\n"));
|
STRACE(("WinDecorator::Draw()\n"));
|
||||||
|
|
||||||
fDrawingEngine->SetDrawState(&fDrawState);
|
fDrawingEngine->SetDrawState(&fDrawState);
|
||||||
|
|
||||||
_DrawFrame(fBorderRect);
|
_DrawFrame(fBorderRect);
|
||||||
@@ -219,27 +116,7 @@ WinDecorator::Draw(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO : GetSizeLimits
|
// TODO : add 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
click_type
|
click_type
|
||||||
@@ -337,108 +214,49 @@ WinDecorator::_DoLayout()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WinDecorator::_DrawTitle(BRect r)
|
WinDecorator::_DrawFrame(BRect rect)
|
||||||
{
|
{
|
||||||
//fDrawingEngine->SetDrawingMode(B_OP_OVER);
|
if (fLook == B_NO_BORDER_WINDOW_LOOK)
|
||||||
fDrawingEngine->SetHighColor(textcol);
|
return;
|
||||||
fDrawingEngine->SetLowColor(IsFocus()?fFocusTabColor:fNonFocusTabColor);
|
|
||||||
|
|
||||||
fTruncatedTitle = Title();
|
if (fBorderRect == fFrame)
|
||||||
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
|
return;
|
||||||
((fZoomRect.IsValid() ? fZoomRect.left :
|
|
||||||
fCloseRect.IsValid() ? fCloseRect.left : fTabRect.right) - 5)
|
|
||||||
- (fTabRect.left + textoffset));
|
|
||||||
fTruncatedTitleLength = fTruncatedTitle.Length();
|
|
||||||
|
|
||||||
//fDrawingEngine->SetFont(fDrawState.Font());
|
BRect r = fBorderRect;
|
||||||
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());
|
|
||||||
|
|
||||||
// Draw the Zoom box
|
fDrawingEngine->SetHighColor(frame_lowercol);
|
||||||
|
fDrawingEngine->StrokeRect(r);
|
||||||
|
|
||||||
BRect rect(r);
|
if (fLook == B_BORDERED_WINDOW_LOOK)
|
||||||
rect.InsetBy(2,2);
|
return;
|
||||||
rect.InsetBy(1,0);
|
|
||||||
rect.bottom--;
|
|
||||||
rect.right--;
|
|
||||||
|
|
||||||
if (GetZoom())
|
BPoint pt;
|
||||||
rect.OffsetBy(1,1);
|
|
||||||
|
|
||||||
fDrawingEngine->SetHighColor(RGBColor(0,0,0));
|
pt=r.RightTop();
|
||||||
fDrawingEngine->StrokeRect(rect);
|
pt.x--;
|
||||||
rect.InsetBy(1,1);
|
fDrawingEngine->StrokeLine(r.LeftTop(),pt,frame_midcol);
|
||||||
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop());
|
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
|
fDrawingEngine->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowcol);
|
||||||
WinDecorator::_DrawClose(BRect r)
|
fDrawingEngine->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowcol);
|
||||||
{
|
|
||||||
// Just like DrawZoom, but for a close button
|
|
||||||
DrawBeveledRect(r,GetClose());
|
|
||||||
|
|
||||||
// Draw the X
|
r.InsetBy(1,1);
|
||||||
|
fDrawingEngine->StrokeRect(r,frame_midcol);
|
||||||
BRect rect(r);
|
r.InsetBy(1,1);
|
||||||
rect.InsetBy(4,4);
|
fDrawingEngine->StrokeRect(r,frame_midcol);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -464,7 +282,270 @@ WinDecorator::_DrawTab(BRect invalid)
|
|||||||
|
|
||||||
|
|
||||||
void
|
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 higher;
|
||||||
RGBColor high;
|
RGBColor high;
|
||||||
@@ -530,85 +611,11 @@ WinDecorator::DrawBeveledRect(BRect r, bool down)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
// #pragma mark -
|
||||||
WinDecorator::_SetColors()
|
|
||||||
|
|
||||||
|
extern "C" DecorAddOn*
|
||||||
|
instantiate_decor_addon(image_id id, const char* name)
|
||||||
{
|
{
|
||||||
_SetFocus();
|
return new (std::nothrow)WinDecorAddOn(id, name);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +1,76 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2009-2010, Haiku.
|
||||||
|
Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
#ifndef _BEOS_DECORATOR_H_
|
#ifndef _BEOS_DECORATOR_H_
|
||||||
#define _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
|
class WinDecorator: public Decorator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WinDecorator(DesktopSettings& settings,
|
WinDecorator(DesktopSettings& settings,
|
||||||
BRect frame, window_look wlook,
|
BRect frame, window_look wlook,
|
||||||
uint32 wflags);
|
uint32 wflags);
|
||||||
~WinDecorator(void);
|
~WinDecorator(void);
|
||||||
|
|
||||||
void SetTitle(const char* string,
|
void Draw(BRect r);
|
||||||
BRegion* updateRegion = NULL);
|
void Draw();
|
||||||
void FontsChanged(DesktopSettings& settings,
|
|
||||||
BRegion* updateRegion);
|
click_type Clicked(BPoint pt, int32 buttons,
|
||||||
virtual void SetLook(DesktopSettings& settings,
|
int32 modifiers);
|
||||||
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);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _UpdateFont(DesktopSettings& settings);
|
void _DoLayout();
|
||||||
void _DrawClose(BRect r);
|
|
||||||
void _DrawFrame(BRect r);
|
void _DrawFrame(BRect r);
|
||||||
void _DrawTab(BRect r);
|
void _DrawTab(BRect r);
|
||||||
void _DrawTitle(BRect r);
|
|
||||||
void _DrawZoom(BRect r);
|
void _DrawClose(BRect r);
|
||||||
void _DrawMinimize(BRect r);
|
void _DrawTitle(BRect r);
|
||||||
void _DoLayout(void);
|
void _DrawZoom(BRect r);
|
||||||
void _SetFocus(void);
|
void _DrawMinimize(BRect r);
|
||||||
void _SetColors(void);
|
|
||||||
void DrawBeveledRect(BRect r, bool down);
|
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;
|
uint32 taboffset;
|
||||||
|
|
||||||
rgb_color tab_highcol;
|
rgb_color tab_highcol;
|
||||||
|
|||||||
Reference in New Issue
Block a user