Reserved space for the close and zoom buttons, even if they were absent.
Hack workaround: enlarged the text width a bit, because the title often appeared truncated for no apparent reason. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13012 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
//
|
//
|
||||||
// File Name: DefaultDecorator.cpp
|
// File Name: DefaultDecorator.cpp
|
||||||
// Author: DarkWyrm <[email protected]>
|
// Author: DarkWyrm <[email protected]>
|
||||||
// Description: Fallback decorator for the app_server
|
// Description: Default and fallback decorator for the app_server
|
||||||
//
|
//
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ DefaultDecorator::GetSizeLimits(float* minWidth, float* minHeight,
|
|||||||
float* maxWidth, float* maxHeight) const
|
float* maxWidth, float* maxHeight) const
|
||||||
{
|
{
|
||||||
if (_tabrect.IsValid())
|
if (_tabrect.IsValid())
|
||||||
*minWidth = max_c(*minWidth, fMinTabWidth - 4.0);
|
*minWidth = max_c(*minWidth, fMinTabWidth);
|
||||||
if (_resizerect.IsValid())
|
if (_resizerect.IsValid())
|
||||||
*minHeight = max_c(*minHeight, _resizerect.Height() - fBorderWidth);
|
*minHeight = max_c(*minHeight, _resizerect.Height() - fBorderWidth);
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,6 @@ DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
|
|||||||
// We got this far, so user is clicking on the border?
|
// We got this far, so user is clicking on the border?
|
||||||
if (fLeftBorder.Contains(pt) || fRightBorder.Contains(pt)
|
if (fLeftBorder.Contains(pt) || fRightBorder.Contains(pt)
|
||||||
|| fTopBorder.Contains(pt) || fBottomBorder.Contains(pt)) {
|
|| fTopBorder.Contains(pt) || fBottomBorder.Contains(pt)) {
|
||||||
|
|
||||||
// check resize area
|
// check resize area
|
||||||
if (!(_flags & B_NOT_RESIZABLE) &&
|
if (!(_flags & B_NOT_RESIZABLE) &&
|
||||||
(_look == B_TITLED_WINDOW_LOOK || _look == B_FLOATING_WINDOW_LOOK)) {
|
(_look == B_TITLED_WINDOW_LOOK || _look == B_FLOATING_WINDOW_LOOK)) {
|
||||||
@@ -385,7 +384,8 @@ DefaultDecorator::_DoLayout()
|
|||||||
fMinTabWidth += offset + size;
|
fMinTabWidth += offset + size;
|
||||||
|
|
||||||
// fMaxTabWidth contains fMinWidth + the width required for the title
|
// fMaxTabWidth contains fMinWidth + the width required for the title
|
||||||
fMaxTabWidth = _driver ? _driver->StringWidth(GetTitle(), strlen(GetTitle()), &_drawdata) : 0.0;
|
fMaxTabWidth = _driver ? _driver->StringWidth(GetTitle(), strlen(GetTitle()),
|
||||||
|
&_drawdata) : 0.0;
|
||||||
if (fMaxTabWidth > 0.0)
|
if (fMaxTabWidth > 0.0)
|
||||||
fMaxTabWidth += fTextOffset;
|
fMaxTabWidth += fTextOffset;
|
||||||
fMaxTabWidth += fMinTabWidth;
|
fMaxTabWidth += fMinTabWidth;
|
||||||
@@ -399,7 +399,6 @@ DefaultDecorator::_DoLayout()
|
|||||||
// layout buttons and truncate text
|
// layout buttons and truncate text
|
||||||
_tabrect.right = _tabrect.left + tabWidth;
|
_tabrect.right = _tabrect.left + tabWidth;
|
||||||
_LayoutTabItems(_tabrect);
|
_LayoutTabItems(_tabrect);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no tab
|
// no tab
|
||||||
fMinTabWidth = 0.0;
|
fMinTabWidth = 0.0;
|
||||||
@@ -411,17 +410,17 @@ DefaultDecorator::_DoLayout()
|
|||||||
|
|
||||||
// calculate left/top/right/bottom borders
|
// calculate left/top/right/bottom borders
|
||||||
if (fBorderWidth > 0) {
|
if (fBorderWidth > 0) {
|
||||||
fLeftBorder.Set( _frame.left - fBorderWidth, _frame.top,
|
fLeftBorder.Set(_frame.left - fBorderWidth, _frame.top,
|
||||||
_frame.left - 1, _frame.bottom);
|
_frame.left - 1, _frame.bottom);
|
||||||
|
|
||||||
fRightBorder.Set( _frame.right + 1, _frame.top ,
|
fRightBorder.Set(_frame.right + 1, _frame.top ,
|
||||||
_frame.right + fBorderWidth, _frame.bottom);
|
_frame.right + fBorderWidth, _frame.bottom);
|
||||||
|
|
||||||
fTopBorder.Set( _frame.left - fBorderWidth, _frame.top - fBorderWidth,
|
fTopBorder.Set(_frame.left - fBorderWidth, _frame.top - fBorderWidth,
|
||||||
_frame.right + fBorderWidth, _frame.top - 1);
|
_frame.right + fBorderWidth, _frame.top - 1);
|
||||||
|
|
||||||
fBottomBorder.Set( _frame.left - fBorderWidth, _frame.bottom + 1,
|
fBottomBorder.Set(_frame.left - fBorderWidth, _frame.bottom + 1,
|
||||||
_frame.right + fBorderWidth, _frame.bottom + fBorderWidth);
|
_frame.right + fBorderWidth, _frame.bottom + fBorderWidth);
|
||||||
} else {
|
} else {
|
||||||
// no border ... (?) useful when displaying windows that are just images
|
// no border ... (?) useful when displaying windows that are just images
|
||||||
fLeftBorder.Set(0.0, 0.0, -1.0, -1.0);
|
fLeftBorder.Set(0.0, 0.0, -1.0, -1.0);
|
||||||
@@ -660,16 +659,16 @@ DefaultDecorator::_DrawZoom(BRect r)
|
|||||||
STRACE(("_DrawZoom(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
|
STRACE(("_DrawZoom(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
|
||||||
// If this has been implemented, then the decorator has a Zoom button
|
// If this has been implemented, then the decorator has a Zoom button
|
||||||
// which should be drawn based on the state of the member zoomstate
|
// which should be drawn based on the state of the member zoomstate
|
||||||
BRect zr( r );
|
|
||||||
|
|
||||||
zr.left += 3.0;
|
BRect zr(r);
|
||||||
zr.top += 3.0;
|
zr.left += 3.0;
|
||||||
_DrawBlendedRect( zr, GetZoom() );
|
zr.top += 3.0;
|
||||||
|
_DrawBlendedRect(zr, GetZoom());
|
||||||
|
|
||||||
zr = r;
|
zr = r;
|
||||||
zr.right -= 5.0;
|
zr.right -= 5.0;
|
||||||
zr.bottom -= 5.0;
|
zr.bottom -= 5.0;
|
||||||
_DrawBlendedRect( zr, GetZoom() );
|
_DrawBlendedRect(zr, GetZoom());
|
||||||
}
|
}
|
||||||
|
|
||||||
// _SetFocus
|
// _SetFocus
|
||||||
@@ -768,17 +767,29 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
|
|||||||
_GetButtonSizeAndOffset(tabRect, &offset, &size);
|
_GetButtonSizeAndOffset(tabRect, &offset, &size);
|
||||||
|
|
||||||
// calulate close rect based on the tab rectangle
|
// calulate close rect based on the tab rectangle
|
||||||
_closerect.Set( tabRect.left + offset, tabRect.top + offset,
|
if (GetFlags() & B_NOT_CLOSABLE) {
|
||||||
tabRect.left + offset + size, tabRect.top + offset + size);
|
_closerect.Set(tabRect.left + offset, tabRect.top + offset,
|
||||||
|
tabRect.left + offset, tabRect.top + offset + size);
|
||||||
|
} else {
|
||||||
|
_closerect.Set(tabRect.left + offset, tabRect.top + offset,
|
||||||
|
tabRect.left + offset + size, tabRect.top + offset + size);
|
||||||
|
}
|
||||||
|
|
||||||
// calulate zoom rect based on the tab rectangle
|
// calulate zoom rect based on the tab rectangle
|
||||||
_zoomrect.Set( tabRect.right - offset - size, tabRect.top + offset,
|
if (GetFlags() & B_NOT_ZOOMABLE) {
|
||||||
tabRect.right - offset, tabRect.top + offset + size);
|
_zoomrect.Set(tabRect.right, tabRect.top + offset,
|
||||||
|
tabRect.right, tabRect.top + offset + size);
|
||||||
|
} else {
|
||||||
|
_zoomrect.Set(tabRect.right - offset - size, tabRect.top + offset,
|
||||||
|
tabRect.right - offset, tabRect.top + offset + size);
|
||||||
|
}
|
||||||
|
|
||||||
// calculate room for title
|
// calculate room for title
|
||||||
float width = (_zoomrect.left - _closerect.right) - fTextOffset * 2.0;
|
// ToDo: the +2 is there because the title often appeared
|
||||||
|
// truncated for no apparent reason - OTOH the title does
|
||||||
|
// also not appear perfectly in the middle
|
||||||
|
float width = (_zoomrect.left - _closerect.right) - fTextOffset * 2 + 2;
|
||||||
fTruncatedTitle = GetTitle();
|
fTruncatedTitle = GetTitle();
|
||||||
_drawdata.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, width);
|
_drawdata.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, width);
|
||||||
// _drawdata.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_BEGINNING, width);
|
fTruncatedTitleLength = fTruncatedTitle.Length();
|
||||||
fTruncatedTitleLength = strlen(fTruncatedTitle.String());
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,73 +31,73 @@
|
|||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
|
|
||||||
class DefaultDecorator: public Decorator {
|
class DefaultDecorator: public Decorator {
|
||||||
public:
|
public:
|
||||||
DefaultDecorator(BRect frame,
|
DefaultDecorator(BRect frame,
|
||||||
int32 look,
|
int32 look,
|
||||||
int32 feel,
|
int32 feel,
|
||||||
int32 flags);
|
int32 flags);
|
||||||
virtual ~DefaultDecorator();
|
virtual ~DefaultDecorator();
|
||||||
|
|
||||||
virtual void MoveBy(float x, float y);
|
virtual void MoveBy(float x, float y);
|
||||||
virtual void MoveBy(BPoint pt);
|
virtual void MoveBy(BPoint pt);
|
||||||
virtual void ResizeBy(float x, float y);
|
virtual void ResizeBy(float x, float y);
|
||||||
virtual void ResizeBy(BPoint pt);
|
virtual void ResizeBy(BPoint pt);
|
||||||
|
|
||||||
virtual void Draw(BRect r);
|
virtual void Draw(BRect r);
|
||||||
virtual void Draw();
|
virtual void Draw();
|
||||||
|
|
||||||
virtual void GetSizeLimits(float* minWidth, float* minHeight,
|
virtual void GetSizeLimits(float* minWidth, float* minHeight,
|
||||||
float* maxWidth, float* maxHeight) const;
|
float* maxWidth, float* maxHeight) const;
|
||||||
|
|
||||||
virtual void GetFootprint(BRegion *region);
|
virtual void GetFootprint(BRegion *region);
|
||||||
|
|
||||||
virtual BRect SlideTab(float dx, float dy);
|
virtual BRect SlideTab(float dx, float dy);
|
||||||
virtual click_type Clicked(BPoint pt, int32 buttons,
|
virtual click_type Clicked(BPoint pt, int32 buttons,
|
||||||
int32 modifiers);
|
int32 modifiers);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void _DoLayout();
|
virtual void _DoLayout();
|
||||||
|
|
||||||
virtual void _DrawFrame(BRect r);
|
virtual void _DrawFrame(BRect r);
|
||||||
virtual void _DrawTab(BRect r);
|
virtual void _DrawTab(BRect r);
|
||||||
|
|
||||||
virtual void _DrawClose(BRect r);
|
virtual void _DrawClose(BRect r);
|
||||||
virtual void _DrawTitle(BRect r);
|
virtual void _DrawTitle(BRect r);
|
||||||
virtual void _DrawZoom(BRect r);
|
virtual void _DrawZoom(BRect r);
|
||||||
|
|
||||||
virtual void _SetFocus();
|
virtual void _SetFocus();
|
||||||
virtual void _SetColors();
|
virtual void _SetColors();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _DrawBlendedRect(BRect r, bool down);
|
void _DrawBlendedRect(BRect r, bool down);
|
||||||
void _GetButtonSizeAndOffset(const BRect& tabRect,
|
void _GetButtonSizeAndOffset(const BRect& tabRect,
|
||||||
float* offset, float*size) const;
|
float* offset, float*size) const;
|
||||||
void _LayoutTabItems(const BRect& tabRect);
|
void _LayoutTabItems(const BRect& tabRect);
|
||||||
|
|
||||||
RGBColor fButtonHighColor;
|
RGBColor fButtonHighColor;
|
||||||
RGBColor fButtonLowColor;
|
RGBColor fButtonLowColor;
|
||||||
RGBColor fTextColor;
|
RGBColor fTextColor;
|
||||||
RGBColor fTabColor;
|
RGBColor fTabColor;
|
||||||
|
|
||||||
RGBColor* fFrameColors;
|
RGBColor* fFrameColors;
|
||||||
|
|
||||||
// Individual rects for handling window frame
|
// Individual rects for handling window frame
|
||||||
// rendering the proper way
|
// rendering the proper way
|
||||||
BRect fRightBorder;
|
BRect fRightBorder;
|
||||||
BRect fLeftBorder;
|
BRect fLeftBorder;
|
||||||
BRect fTopBorder;
|
BRect fTopBorder;
|
||||||
BRect fBottomBorder;
|
BRect fBottomBorder;
|
||||||
|
|
||||||
int32 fBorderWidth;
|
int32 fBorderWidth;
|
||||||
|
|
||||||
// bool fSlidingTab;
|
// bool fSlidingTab;
|
||||||
// uint32 fTabOffset;
|
// uint32 fTabOffset;
|
||||||
float fTextOffset;
|
float fTextOffset;
|
||||||
|
|
||||||
float fMinTabWidth;
|
float fMinTabWidth;
|
||||||
float fMaxTabWidth;
|
float fMaxTabWidth;
|
||||||
BString fTruncatedTitle;
|
BString fTruncatedTitle;
|
||||||
int32 fTruncatedTitleLength;
|
int32 fTruncatedTitleLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user