* After stippi's request, I was urged to update the decorators as well.

* Applied a minor style update to them. There are many many more violations in
  there, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35274 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2010-01-24 13:46:49 +00:00
parent 3c50a64697
commit 2069f565e8
3 changed files with 156 additions and 161 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2001-2006, Haiku.
* Copyright 2001-2010, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -523,13 +523,13 @@ BeDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
// the user might be clicking on and gradually work our way out into larger
// rectangles.
if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(pt))
return DEC_CLOSE;
return CLICK_CLOSE;
if (!(fFlags & B_NOT_ZOOMABLE) && fZoomRect.Contains(pt))
return DEC_ZOOM;
return CLICK_ZOOM;
if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(pt))
return DEC_RESIZE;
return CLICK_RESIZE;
bool clicked = false;
@ -538,7 +538,7 @@ BeDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
// tab sliding in any case if either shift key is held down
// except sliding up-down by moving mouse left-right would look strange
if ((modifiers & B_SHIFT_KEY) && (fLook != kLeftTitledWindowLook))
return DEC_SLIDETAB;
return CLICK_SLIDE_TAB;
clicked = true;
} else if (fLeftBorder.Contains(pt) || fRightBorder.Contains(pt)
@ -554,7 +554,7 @@ BeDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
BRect temp(BPoint(fBottomBorder.right - 18, fBottomBorder.bottom - 18),
fBottomBorder.RightBottom());
if (temp.Contains(pt))
return DEC_RESIZE;
return CLICK_RESIZE;
}
clicked = true;
@ -565,16 +565,16 @@ BeDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
// resize area with the second mouse button. So we check this after
// the check above
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0)
return DEC_MOVETOBACK;
return CLICK_MOVE_TO_BACK;
if (fWasDoubleClick && !(fFlags & B_NOT_MINIMIZABLE))
return DEC_MINIMIZE;
return CLICK_MINIMIZE;
return DEC_DRAG;
return CLICK_DRAG;
}
// Guess user didn't click anything
return DEC_NONE;
return CLICK_NONE;
}

View File

@ -1,7 +1,8 @@
/*
Copyright 2009, Haiku.
Distributed under the terms of the MIT License.
*/
* Copyright 2009-2010, Haiku.
* Distributed under the terms of the MIT License.
*/
/*! Decorator looking like Mac OS 9 */
@ -29,7 +30,8 @@
MacDecorator::MacDecorator(DesktopSettings& settings, BRect rect,
window_look look, uint32 flags)
: Decorator(settings, rect, look, flags)
:
Decorator(settings, rect, look, flags)
{
frame_highcol = (rgb_color){ 255, 255, 255, 255 };
frame_midcol = (rgb_color){ 216, 216, 216, 255 };
@ -184,9 +186,6 @@ MacDecorator::ResizeBy(BPoint offset, BRegion* dirty)
_DoLayout();
}
// settablocation
// setsettings
// getsettings
void
MacDecorator::Draw(BRect update)
@ -211,8 +210,6 @@ MacDecorator::Draw()
}
// getsizelimits
void
MacDecorator::GetFootprint(BRegion* region)
{
@ -243,22 +240,22 @@ MacDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
{
if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(point)) {
STRACE(("MacDecorator():Clicked() - Close\n"));
return DEC_CLOSE;
return CLICK_CLOSE;
}
if (!(fFlags & B_NOT_ZOOMABLE) && fZoomRect.Contains(point)) {
STRACE(("MacDecorator():Clicked() - Zoom\n"));
return DEC_ZOOM;
return CLICK_ZOOM;
}
// Clicking in the tab?
if (fTabRect.Contains(point)) {
// Here's part of our window management stuff
/* TODO This is missing DEC_MOVETOFRONT
/* TODO This is missing CLICK_MOVETOFRONT
if(buttons==B_PRIMARY_MOUSE_BUTTON && !IsFocus())
return DEC_MOVETOFRONT;
return CLICK_MOVETOFRONT;
*/
return DEC_DRAG;
return CLICK_DRAG;
}
// We got this far, so user is clicking on the border?
@ -268,12 +265,12 @@ MacDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
|| fLook == B_MODAL_WINDOW_LOOK)
&& fBorderRect.Contains(point) && !fFrame.Contains(point)) {
STRACE(("MacDecorator():Clicked() - Resize\n"));
return DEC_RESIZE;
return CLICK_RESIZE;
}
// Guess user didn't click anything
STRACE(("MacDecorator():Clicked()\n"));
return DEC_NONE;
return CLICK_NONE;
}
@ -514,7 +511,7 @@ MacDecorator::_DrawFrame(BRect invalid)
}
void
void
MacDecorator::_DrawTab(BRect invalid)
{
// If a window has a tab, this will draw it and any buttons which are
@ -526,9 +523,7 @@ MacDecorator::_DrawTab(BRect invalid)
fDrawingEngine->SetHighColor(RGBColor(frame_midcol));
fDrawingEngine->FillRect(rect,frame_midcol);
if(IsFocus())
{
if (IsFocus()) {
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowercol);
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_lowercol);
fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowercol);
@ -541,15 +536,13 @@ MacDecorator::_DrawTab(BRect invalid)
fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowcol);
// Draw the neat little lines on either side of the title if there's room
if((fTabRect.left+textoffset)>(fCloseRect.right+5))
{
if (fTabRect.left + textoffset > fCloseRect.right + 5) {
// Left side
BPoint offset(fCloseRect.right+5,fCloseRect.top),
pt2(fTabRect.left+textoffset-5,fCloseRect.top);
pt2(fTabRect.left+textoffset-5,fCloseRect.top);
fDrawState.SetHighColor(RGBColor(frame_highcol));
for(int32 i=0;i<6;i++)
{
for (int32 i = 0; i < 6; i++) {
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
offset.y+=2;
pt2.y+=2;
@ -558,43 +551,41 @@ MacDecorator::_DrawTab(BRect invalid)
offset.Set(fCloseRect.right+6,fCloseRect.top+1),
pt2.Set(fTabRect.left+textoffset-4,fCloseRect.top+1);
fDrawState.SetHighColor(RGBColor(frame_lowcol));
for(int32 i=0;i<6;i++)
{
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
offset.y+=2;
pt2.y+=2;
for (int32 i = 0; i < 6; i++) {
fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor());
offset.y += 2;
pt2.y += 2;
}
// Right side
offset.Set(fTabRect.left+textoffset+titlepixelwidth+6,fZoomRect.top),
pt2.Set(fZoomRect.left-6,fZoomRect.top);
if(offset.x<pt2.x)
{
offset.Set(fTabRect.left + textoffset + titlepixelwidth + 6,
fZoomRect.top), pt2.Set(fZoomRect.left - 6, fZoomRect.top);
if (offset.x < pt2.x) {
fDrawState.SetHighColor(RGBColor(frame_highcol));
for(int32 i=0;i<6;i++)
{
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
offset.y+=2;
pt2.y+=2;
for (int32 i = 0; i < 6; i++) {
fDrawingEngine->StrokeLine(offset, pt2,
fDrawState.HighColor());
offset.y += 2;
pt2.y += 2;
}
offset.Set(fTabRect.left+textoffset+titlepixelwidth+7,fZoomRect.top+1),
pt2.Set(fZoomRect.left-5,fZoomRect.top+1);
offset.Set(fTabRect.left+textoffset + titlepixelwidth + 7,
fZoomRect.top + 1), pt2.Set(fZoomRect.left - 5,
fZoomRect.top + 1);
fDrawState.SetHighColor(frame_lowcol);
for(int32 i=0;i<6;i++)
{
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
offset.y+=2;
pt2.y+=2;
for(int32 i = 0; i < 6; i++) {
fDrawingEngine->StrokeLine(offset, pt2,
fDrawState.HighColor());
offset.y += 2;
pt2.y += 2;
}
}
}
// Draw the buttons if we're supposed to
if(!(fFlags & B_NOT_CLOSABLE))
if (!(fFlags & B_NOT_CLOSABLE))
_DrawClose(fCloseRect);
if(!(fFlags & B_NOT_ZOOMABLE))
if (!(fFlags & B_NOT_ZOOMABLE))
_DrawZoom(fZoomRect);
} else {
// Not focused - Just draw a plain light grey area with the title in the middle
@ -610,42 +601,42 @@ MacDecorator::_DrawTab(BRect invalid)
void
MacDecorator::_DrawClose(BRect r)
{
bool down=GetClose();
bool down = GetClose();
// Just like DrawZoom, but for a close button
BRect rect(r);
BPoint offset(r.LeftTop()),pt2(r.RightTop());
BPoint offset(r.LeftTop()), pt2(r.RightTop());
// Topleft dark grey border
pt2.x--;
fDrawingEngine->SetHighColor(RGBColor(136,136,136));
fDrawingEngine->StrokeLine(offset,pt2);
fDrawingEngine->SetHighColor(RGBColor(136, 136, 136));
fDrawingEngine->StrokeLine(offset, pt2);
pt2=r.LeftBottom();
pt2 = r.LeftBottom();
pt2.y--;
fDrawingEngine->StrokeLine(offset,pt2);
fDrawingEngine->StrokeLine(offset, pt2);
// Bottomright white border
offset=r.RightBottom();
pt2=r.RightTop();
offset = r.RightBottom();
pt2 = r.RightTop();
pt2.y++;
fDrawingEngine->SetHighColor(RGBColor(255,255,255));
fDrawingEngine->StrokeLine(offset,pt2);
fDrawingEngine->SetHighColor(RGBColor(255, 255, 255));
fDrawingEngine->StrokeLine(offset, pt2);
pt2=r.LeftBottom();
pt2 = r.LeftBottom();
pt2.x++;
fDrawingEngine->StrokeLine(offset,pt2);
fDrawingEngine->StrokeLine(offset, pt2);
// Black outline
rect.InsetBy(1,1);
fDrawingEngine->SetHighColor(RGBColor(0,0,0));
rect.InsetBy(1, 1);
fDrawingEngine->SetHighColor(RGBColor(0, 0, 0));
fDrawingEngine->StrokeRect(rect);
// Double-shaded button
rect.InsetBy(1,1);
rect.InsetBy(1, 1);
_DrawBlendedRect(fDrawingEngine, rect, down);
rect.InsetBy(1,1);
rect.InsetBy(1, 1);
_DrawBlendedRect(fDrawingEngine, rect, !down);
}
@ -653,7 +644,7 @@ MacDecorator::_DrawClose(BRect r)
void
MacDecorator::_DrawTitle(BRect rect)
{
if(IsFocus())
if (IsFocus())
fDrawingEngine->SetHighColor(fFocusTextColor);
else
fDrawingEngine->SetHighColor(fNonFocusTextColor);
@ -662,18 +653,19 @@ MacDecorator::_DrawTitle(BRect rect)
fTruncatedTitle = Title();
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
(fZoomRect.left - 5) - (fCloseRect.right + 5));
(fZoomRect.left - 5) - (fCloseRect.right + 5));
fTruncatedTitleLength = fTruncatedTitle.Length();
fDrawingEngine->SetFont(fDrawState.Font());
fDrawingEngine->DrawString(fTruncatedTitle,fTruncatedTitleLength,
BPoint(fTabRect.left+textoffset,fCloseRect.bottom-1));
BPoint(fTabRect.left+textoffset,fCloseRect.bottom-1));
}
void MacDecorator::_DrawZoom(BRect r)
void
MacDecorator::_DrawZoom(BRect r)
{
bool down=GetClose();
bool down = GetClose();
// Just like DrawZoom, but for a close button
BRect rect(r);
@ -681,84 +673,85 @@ void MacDecorator::_DrawZoom(BRect r)
BPoint offset(r.LeftTop()),pt2(r.RightTop());
pt2.x--;
fDrawState.SetHighColor(RGBColor(136,136,136));
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
fDrawState.SetHighColor(RGBColor(136, 136, 136));
fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor());
pt2=r.LeftBottom();
pt2 = r.LeftBottom();
pt2.y--;
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor());
offset=r.RightBottom();
pt2=r.RightTop();
offset = r.RightBottom();
pt2 = r.RightTop();
pt2.y++;
fDrawState.SetHighColor(RGBColor(255,255,255));
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
fDrawState.SetHighColor(RGBColor(255, 255, 255));
fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor());
pt2=r.LeftBottom();
pt2 = r.LeftBottom();
pt2.x++;
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor());
rect.InsetBy(1,1);
fDrawState.SetHighColor(RGBColor(0,0,0));
fDrawingEngine->StrokeRect(rect,fDrawState.HighColor());
rect.InsetBy(1, 1);
fDrawState.SetHighColor(RGBColor(0, 0, 0));
fDrawingEngine->StrokeRect(rect, fDrawState.HighColor());
rect.InsetBy(1,1);
rect.InsetBy(1, 1);
_DrawBlendedRect(fDrawingEngine, rect, down);
rect.InsetBy(1,1);
_DrawBlendedRect(fDrawingEngine, rect, !down);
rect.top+=2;
rect.top += 2;
rect.left--;
rect.right++;
fDrawState.SetHighColor(RGBColor(0,0,0));
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),fDrawState.HighColor());
fDrawState.SetHighColor(RGBColor(0, 0, 0));
fDrawingEngine->StrokeLine(rect.LeftTop(), rect.RightTop(),
fDrawState.HighColor());
}
void
MacDecorator::_DrawMinimize(BRect r)
{
bool down=GetClose();
bool down = GetClose();
// Just like DrawZoom, but for a close button
BRect rect(r);
BPoint offset(r.LeftTop()),pt2(r.RightTop());
BPoint offset(r.LeftTop()), pt2(r.RightTop());
pt2.x--;
fDrawState.SetHighColor(RGBColor(136,136,136));
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
fDrawState.SetHighColor(RGBColor(136, 136, 136));
fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor());
pt2=r.LeftBottom();
pt2 = r.LeftBottom();
pt2.y--;
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor());
offset=r.RightBottom();
pt2=r.RightTop();
offset = r.RightBottom();
pt2 = r.RightTop();
pt2.y++;
fDrawState.SetHighColor(RGBColor(255,255,255));
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
fDrawState.SetHighColor(RGBColor(255, 255, 255));
fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor());
pt2=r.LeftBottom();
pt2 = r.LeftBottom();
pt2.x++;
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor());
rect.InsetBy(1,1);
fDrawState.SetHighColor(RGBColor(0,0,0));
fDrawingEngine->StrokeRect(rect,fDrawState.HighColor());
rect.InsetBy(1, 1);
fDrawState.SetHighColor(RGBColor(0, 0, 0));
fDrawingEngine->StrokeRect(rect, fDrawState.HighColor());
rect.InsetBy(1,1);
rect.InsetBy(1, 1);
_DrawBlendedRect(fDrawingEngine, rect, down);
rect.InsetBy(1,1);
rect.InsetBy(1, 1);
_DrawBlendedRect(fDrawingEngine, rect, !down);
rect.top+=4;
rect.bottom-=4;
rect.InsetBy(-2,0);
rect.top += 4;
rect.bottom -= 4;
rect.InsetBy(-2, 0);
fDrawState.SetHighColor(RGBColor(0,0,0));
fDrawingEngine->StrokeRect(rect,fDrawState.HighColor());
fDrawState.SetHighColor(RGBColor(0, 0, 0));
fDrawingEngine->StrokeRect(rect, fDrawState.HighColor());
}
@ -812,14 +805,19 @@ MacDecorator::_DrawBlendedRect(DrawingEngine* engine, BRect rect,
}
extern "C" float get_decorator_version(void)
// #pragma mark -
extern "C" float
get_decorator_version(void)
{
return 1.00;
}
extern "C" Decorator *(instantiate_decorator)(DesktopSettings &desktopSetting, BRect rec,
window_look loo, uint32 flag)
extern "C" Decorator*
instantiate_decorator(DesktopSettings& desktopSetting, BRect rect,
window_look look, uint32 flag)
{
return new MacDecorator(desktopSetting, rec, loo, flag);
return new MacDecorator(desktopSetting, rect, look, flag);
}

View File

@ -1,7 +1,8 @@
/*
Copyright 2009, Haiku.
Distributed under the terms of the MIT License.
*/
* Copyright 2009-2010, Haiku.
* Distributed under the terms of the MIT License.
*/
/*! Decorator looking like Windows 95 */
@ -28,7 +29,8 @@
WinDecorator::WinDecorator(DesktopSettings& settings, BRect rect,
window_look look, uint32 flags)
: Decorator(settings, rect, look, flags)
:
Decorator(settings, rect, look, flags)
{
taboffset=0;
@ -100,15 +102,6 @@ WinDecorator::FontsChanged(DesktopSettings& settings, BRegion* updateRegion)
}
// SetLook
// SetFlags
void
WinDecorator::MoveBy(BPoint pt)
{
@ -170,34 +163,33 @@ WinDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
{
if (fCloseRect.Contains(pt)) {
STRACE(("WinDecorator():Clicked() - Close\n"));
return DEC_CLOSE;
return CLICK_CLOSE;
}
if (fZoomRect.Contains(pt)) {
STRACE(("WinDecorator():Clicked() - Zoom\n"));
return DEC_ZOOM;
return CLICK_ZOOM;
}
// Clicking in the tab?
if (fTabRect.Contains(pt)) {
// Here's part of our window management stuff
/* TODO This is missing DEC_MOVETOFRONT
/* TODO This is missing CLICK_MOVETOFRONT
if(buttons==B_PRIMARY_MOUSE_BUTTON && !IsFocus())
return DEC_MOVETOFRONT;
return CLICK_MOVETOFRONT;
*/
return DEC_DRAG;
return CLICK_DRAG;
}
// We got this far, so user is clicking on the border?
if(fBorderRect.Contains(pt) && !fFrame.Contains(pt))
{
if (fBorderRect.Contains(pt) && !fFrame.Contains(pt)) {
STRACE(("WinDecorator():Clicked() - Resize\n"));
return DEC_RESIZE;
return CLICK_RESIZE;
}
// Guess user didn't click anything
STRACE(("WinDecorator():Clicked()\n"));
return DEC_NONE;
return CLICK_NONE;
}
@ -328,7 +320,7 @@ WinDecorator::_DrawZoom(BRect r)
rect.bottom--;
rect.right--;
if(GetZoom())
if (GetZoom())
rect.OffsetBy(1,1);
fDrawingEngine->SetHighColor(RGBColor(0,0,0));
@ -351,7 +343,7 @@ WinDecorator::_DrawClose(BRect r)
rect.right--;
rect.top--;
if(GetClose())
if (GetClose())
rect.OffsetBy(1,1);
fDrawingEngine->SetHighColor(RGBColor(0,0,0));
@ -362,7 +354,9 @@ WinDecorator::_DrawClose(BRect r)
fDrawingEngine->StrokeLine(rect.RightTop(),rect.LeftBottom());
}
void WinDecorator::_DrawMinimize(BRect r)
void
WinDecorator::_DrawMinimize(BRect r)
{
// Just like DrawZoom, but for a Minimize button
DrawBeveledRect(r,GetMinimize());
@ -401,18 +395,19 @@ WinDecorator::_DrawTab(BRect r)
void
WinDecorator::DrawBeveledRect(BRect r, bool down)
{
RGBColor higher,high,mid,low,lower;
RGBColor higher;
RGBColor high;
RGBColor mid;
RGBColor low;
RGBColor lower;
if(down)
{
if (down) {
lower.SetColor(255,255,255);
low.SetColor(216,216,216);
mid.SetColor(192,192,192);
high.SetColor(128,128,128);
higher.SetColor(0,0,0);
}
else
{
} else {
higher.SetColor(255,255,255);
high.SetColor(216,216,216);
mid.SetColor(192,192,192);
@ -475,9 +470,9 @@ void
WinDecorator::_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);
@ -489,18 +484,18 @@ WinDecorator::_UpdateFont(DesktopSettings& settings)
void
WinDecorator::_DrawFrame(BRect rect)
{
if(fLook==B_NO_BORDER_WINDOW_LOOK)
if (fLook == B_NO_BORDER_WINDOW_LOOK)
return;
if (fBorderRect == fFrame)
return;
BRect r=fBorderRect;
BRect r = fBorderRect;
fDrawingEngine->SetHighColor(frame_lowercol);
fDrawingEngine->StrokeRect(r);
if ( fLook == B_BORDERED_WINDOW_LOOK)
if (fLook == B_BORDERED_WINDOW_LOOK)
return;
BPoint pt;
@ -533,13 +528,15 @@ WinDecorator::_DrawFrame(BRect rect)
}
extern "C" float get_decorator_version(void)
extern "C" float
get_decorator_version(void)
{
return 1.00;
}
extern "C" Decorator *instantiate_decorator(DesktopSettings &desktopSetting, BRect rect,
extern "C" Decorator *
instantiate_decorator(DesktopSettings &desktopSetting, BRect rect,
window_look wlook, int32 wflags)
{
return new WinDecorator(desktopSetting, rect, wlook, wflags);