* You can now change the look of a window on the fly.
* renamed some Decorator functions like GetLook() to Look(). * renamed _look to fLook and _flags to fFlags. * removed the feel from decorators - they don't need to know or care about the feel. * the DefaultDecorator didn't allow resizing of modal windows. * DefaultDecorator::SetTitle() no longer clears the passed in updateRegion, it just fills it (so that you can call more than one of these methods after the other, and still get a correct update region). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15266 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
57be286609
commit
85f8bb71c7
@ -48,15 +48,16 @@ typedef enum {
|
||||
class Decorator {
|
||||
public:
|
||||
Decorator(DesktopSettings& settings, BRect rect,
|
||||
int32 look, int32 feel, int32 flags);
|
||||
window_look look, uint32 flags);
|
||||
virtual ~Decorator();
|
||||
|
||||
void SetColors(const ColorSet &cset);
|
||||
void SetDriver(DrawingEngine *driver);
|
||||
void SetFlags(int32 wflags);
|
||||
void SetFeel(int32 wfeel);
|
||||
void SetFont(ServerFont *font);
|
||||
void SetLook(int32 wlook);
|
||||
|
||||
virtual void SetLook(DesktopSettings& settings,
|
||||
window_look look, BRegion* updateRegion = NULL);
|
||||
virtual void SetFlags(uint32 flags, BRegion* updateRegion = NULL);
|
||||
|
||||
void SetClose(bool pressed);
|
||||
void SetMinimize(bool pressed);
|
||||
@ -64,17 +65,16 @@ class Decorator {
|
||||
|
||||
virtual void SetTitle(const char* string, BRegion* updateRegion = NULL);
|
||||
|
||||
int32 GetLook() const;
|
||||
int32 GetFeel() const;
|
||||
int32 GetFlags() const;
|
||||
window_look Look() const;
|
||||
uint32 Flags() const;
|
||||
|
||||
const char* GetTitle() const;
|
||||
const char* Title() const;
|
||||
|
||||
// we need to know its border(frame). WinBorder's _frame rect
|
||||
// must expand to include Decorator borders. Otherwise we can't
|
||||
// draw the border. We also add GetTabRect because I feel we'll need it
|
||||
BRect GetBorderRect() const;
|
||||
BRect GetTabRect() const;
|
||||
// draw the border. We also add TabRect because I feel we'll need it
|
||||
BRect BorderRect() const;
|
||||
BRect TabRect() const;
|
||||
|
||||
bool GetClose();
|
||||
bool GetMinimize();
|
||||
@ -140,9 +140,8 @@ class Decorator {
|
||||
DrawingEngine* _driver;
|
||||
DrawState fDrawState;
|
||||
|
||||
int32 _look;
|
||||
int32 _feel;
|
||||
int32 _flags;
|
||||
window_look fLook;
|
||||
uint32 fFlags;
|
||||
|
||||
BRect _zoomrect;
|
||||
BRect _closerect;
|
||||
@ -165,6 +164,6 @@ class Decorator {
|
||||
// add-on stuff
|
||||
typedef float get_version(void);
|
||||
typedef Decorator* create_decorator(DesktopSettings& desktopSettings, BRect rect,
|
||||
int32 look, int32 feel, int32 flags);
|
||||
window_look look, uint32 flags);
|
||||
|
||||
#endif /* _DECORATOR_H_ */
|
||||
|
@ -39,7 +39,7 @@ class DecorInfo {
|
||||
const char* Name() const { return fName.String(); }
|
||||
|
||||
Decorator* Instantiate(Desktop* desktop, BRect rect, const char* title,
|
||||
int32 look, int32 feel, int32 flags);
|
||||
window_look look, uint32 flags);
|
||||
|
||||
private:
|
||||
image_id fID;
|
||||
@ -73,16 +73,16 @@ DecorInfo::~DecorInfo()
|
||||
|
||||
Decorator *
|
||||
DecorInfo::Instantiate(Desktop* desktop, BRect rect, const char *title,
|
||||
int32 look, int32 feel, int32 flags)
|
||||
window_look look, uint32 flags)
|
||||
{
|
||||
DesktopSettings settings(desktop);
|
||||
Decorator *decorator;
|
||||
|
||||
try {
|
||||
if (fAllocator != NULL)
|
||||
decorator = fAllocator(settings, rect, look, feel, flags);
|
||||
decorator = fAllocator(settings, rect, look, flags);
|
||||
else
|
||||
decorator = new DefaultDecorator(settings, rect, look, feel, flags);
|
||||
decorator = new DefaultDecorator(settings, rect, look, flags);
|
||||
} catch (...) {
|
||||
return NULL;
|
||||
}
|
||||
@ -192,7 +192,7 @@ DecorManager::RescanDecorators()
|
||||
|
||||
Decorator *
|
||||
DecorManager::AllocateDecorator(Desktop* desktop, BRect rect, const char *title,
|
||||
int32 look, int32 feel, int32 flags)
|
||||
window_look look, uint32 flags)
|
||||
{
|
||||
// Create a new instance of the current decorator. Ownership is that of the caller
|
||||
|
||||
@ -202,7 +202,7 @@ DecorManager::AllocateDecorator(Desktop* desktop, BRect rect, const char *title,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return fCurrentDecor->Instantiate(desktop, rect, title, look, feel, flags);
|
||||
return fCurrentDecor->Instantiate(desktop, rect, title, look, flags);
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,8 +27,8 @@ class DecorManager : public BLocker {
|
||||
void RescanDecorators();
|
||||
|
||||
Decorator* AllocateDecorator(Desktop* desktop, BRect rect,
|
||||
const char *title, int32 look, int32 feel,
|
||||
int32 flags);
|
||||
const char *title, window_look look,
|
||||
uint32 flags);
|
||||
|
||||
int32 CountDecorators() const;
|
||||
|
||||
|
@ -28,32 +28,33 @@
|
||||
Does general initialization of internal data members and creates a colorset
|
||||
object.
|
||||
*/
|
||||
Decorator::Decorator(DesktopSettings& settings, BRect rect, int32 look,
|
||||
int32 feel, int32 flags)
|
||||
: _colors(new ColorSet()),
|
||||
_driver(NULL),
|
||||
fDrawState(),
|
||||
Decorator::Decorator(DesktopSettings& settings, BRect rect,
|
||||
window_look look, uint32 flags)
|
||||
:
|
||||
_colors(new ColorSet()),
|
||||
_driver(NULL),
|
||||
fDrawState(),
|
||||
|
||||
_look(look),
|
||||
_feel(feel),
|
||||
_flags(flags),
|
||||
fLook(look),
|
||||
fFlags(flags),
|
||||
|
||||
_zoomrect(),
|
||||
_closerect(),
|
||||
_minimizerect(),
|
||||
_tabrect(),
|
||||
_frame(rect),
|
||||
_resizerect(),
|
||||
_borderrect(),
|
||||
_zoomrect(),
|
||||
_closerect(),
|
||||
_minimizerect(),
|
||||
_tabrect(),
|
||||
_frame(rect),
|
||||
_resizerect(),
|
||||
_borderrect(),
|
||||
|
||||
fClosePressed(false),
|
||||
fZoomPressed(false),
|
||||
fMinimizePressed(false),
|
||||
fIsFocused(false),
|
||||
fTitle("")
|
||||
fClosePressed(false),
|
||||
fZoomPressed(false),
|
||||
fMinimizePressed(false),
|
||||
fIsFocused(false),
|
||||
fTitle("")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Destructor
|
||||
|
||||
@ -64,6 +65,7 @@ Decorator::~Decorator()
|
||||
delete _colors;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Updates the decorator's color set
|
||||
\param cset The color set to update from
|
||||
@ -75,6 +77,7 @@ Decorator::SetColors(const ColorSet &cset)
|
||||
_SetColors();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Assigns a display driver to the decorator
|
||||
\param driver A valid DrawingEngine object
|
||||
@ -90,32 +93,21 @@ Decorator::SetDriver(DrawingEngine *driver)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Sets the decorator's window flags
|
||||
\param wflags New value for the flags
|
||||
|
||||
While this call will not update the screen, it will affect how future
|
||||
updates work and immediately affects input handling.
|
||||
*/
|
||||
void
|
||||
Decorator::SetFlags(int32 wflags)
|
||||
{
|
||||
_flags = wflags;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Sets the decorator's window feel
|
||||
\param wflags New value for the feel
|
||||
|
||||
\brief Sets the decorator's window flags
|
||||
\param flags New value for the flags
|
||||
|
||||
While this call will not update the screen, it will affect how future
|
||||
updates work and immediately affects input handling.
|
||||
*/
|
||||
void
|
||||
Decorator::SetFeel(int32 wfeel)
|
||||
Decorator::SetFlags(uint32 flags, BRegion* updateRegion)
|
||||
{
|
||||
_feel = wfeel;
|
||||
fFlags = flags;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
\brief Sets the decorator's font
|
||||
\param font The new font object to copy from
|
||||
@ -123,25 +115,23 @@ Decorator::SetFeel(int32 wfeel)
|
||||
void
|
||||
Decorator::SetFont(ServerFont *font)
|
||||
{
|
||||
if (font) {
|
||||
if (font)
|
||||
fDrawState.SetFont(*font);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets the decorator's window look
|
||||
\param wflags New value for the look
|
||||
|
||||
While this call will not update the screen, it will affect how future
|
||||
updates work and immediately affects input handling.
|
||||
\param look New value for the look
|
||||
*/
|
||||
void
|
||||
Decorator::SetLook(int32 wlook)
|
||||
Decorator::SetLook(DesktopSettings& settings, window_look look,
|
||||
BRegion* updateRect)
|
||||
{
|
||||
_look = wlook;
|
||||
// TODO: relayout and redraw, no?
|
||||
fLook = look;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets the close button's value.
|
||||
\param is_down Whether the button is down or not
|
||||
@ -208,60 +198,52 @@ Decorator::SetTitle(const char* string, BRegion* updateRegion)
|
||||
\brief Returns the decorator's window look
|
||||
\return the decorator's window look
|
||||
*/
|
||||
int32
|
||||
Decorator::GetLook() const
|
||||
window_look
|
||||
Decorator::Look() const
|
||||
{
|
||||
return _look;
|
||||
return fLook;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the decorator's window feel
|
||||
\return the decorator's window feel
|
||||
*/
|
||||
int32
|
||||
Decorator::GetFeel() const
|
||||
{
|
||||
return _feel;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the decorator's window flags
|
||||
\return the decorator's window flags
|
||||
*/
|
||||
int32
|
||||
Decorator::GetFlags() const
|
||||
uint32
|
||||
Decorator::Flags() const
|
||||
{
|
||||
return _flags;
|
||||
return fFlags;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Returns the decorator's title
|
||||
\return the decorator's title
|
||||
*/
|
||||
const char*
|
||||
Decorator::GetTitle() const
|
||||
Decorator::Title() const
|
||||
{
|
||||
return fTitle.String();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Returns the decorator's border rectangle
|
||||
\return the decorator's border rectangle
|
||||
*/
|
||||
|
||||
BRect
|
||||
Decorator::GetBorderRect() const
|
||||
Decorator::BorderRect() const
|
||||
{
|
||||
return _borderrect;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Returns the decorator's tab rectangle
|
||||
\return the decorator's tab rectangle
|
||||
*/
|
||||
|
||||
BRect
|
||||
Decorator::GetTabRect() const
|
||||
Decorator::TabRect() const
|
||||
{
|
||||
return _tabrect;
|
||||
}
|
||||
|
@ -36,19 +36,15 @@
|
||||
#endif
|
||||
|
||||
|
||||
DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
|
||||
int32 look, int32 feel, int32 flags)
|
||||
: Decorator(settings, rect, look, feel, flags)
|
||||
{
|
||||
ServerFont font;
|
||||
if (_look == B_FLOATING_WINDOW_LOOK)
|
||||
settings.GetDefaultPlainFont(font);
|
||||
else
|
||||
settings.GetDefaultBoldFont(font);
|
||||
// TODO: get rid of DesktopSettings here, and introduce private accessor
|
||||
// methods to the Decorator base class
|
||||
|
||||
font.SetFlags(B_FORCE_ANTIALIASING);
|
||||
font.SetSpacing(B_STRING_SPACING);
|
||||
SetFont(&font);
|
||||
|
||||
DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
|
||||
window_look look, uint32 flags)
|
||||
: Decorator(settings, rect, look, flags)
|
||||
{
|
||||
DefaultDecorator::SetLook(settings, look);
|
||||
|
||||
fFrameColors = new RGBColor[6];
|
||||
fFrameColors[0].SetColor(152, 152, 152);
|
||||
@ -57,7 +53,7 @@ DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
|
||||
fFrameColors[3].SetColor(136, 136, 136);
|
||||
fFrameColors[4].SetColor(152, 152, 152);
|
||||
fFrameColors[5].SetColor(96, 96, 96);
|
||||
|
||||
|
||||
// Set appropriate colors based on the current focus value. In this case, each decorator
|
||||
// defaults to not having the focus.
|
||||
_SetFocus();
|
||||
@ -83,14 +79,14 @@ DefaultDecorator::~DefaultDecorator()
|
||||
void
|
||||
DefaultDecorator::SetTitle(const char* string, BRegion* updateRegion)
|
||||
{
|
||||
BRect rect = GetTabRect();
|
||||
BRect rect = TabRect();
|
||||
|
||||
Decorator::SetTitle(string);
|
||||
|
||||
if (updateRegion == NULL)
|
||||
return;
|
||||
|
||||
BRect updatedRect = GetTabRect();
|
||||
BRect updatedRect = TabRect();
|
||||
if (rect.left > updatedRect.left)
|
||||
rect.left = updatedRect.left;
|
||||
if (rect.right < updatedRect.right)
|
||||
@ -99,14 +95,54 @@ DefaultDecorator::SetTitle(const char* string, BRegion* updateRegion)
|
||||
rect.bottom++;
|
||||
// the border will look differently when the title is adjacent
|
||||
|
||||
updateRegion->Set(rect);
|
||||
updateRegion->Include(rect);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DefaultDecorator::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);
|
||||
}
|
||||
|
||||
ServerFont font;
|
||||
if (look == B_FLOATING_WINDOW_LOOK)
|
||||
settings.GetDefaultPlainFont(font);
|
||||
else
|
||||
settings.GetDefaultBoldFont(font);
|
||||
|
||||
font.SetFlags(B_FORCE_ANTIALIASING);
|
||||
font.SetSpacing(B_STRING_SPACING);
|
||||
SetFont(&font);
|
||||
|
||||
Decorator::SetLook(settings, look, updateRegion);
|
||||
_DoLayout();
|
||||
|
||||
if (updateRegion != NULL) {
|
||||
BRegion extent;
|
||||
GetFootprint(&extent);
|
||||
updateRegion->Include(&extent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DefaultDecorator::SetFlags(uint32 flags, BRegion* updateRegion)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DefaultDecorator::MoveBy(float x, float y)
|
||||
{
|
||||
MoveBy(BPoint(x,y));
|
||||
MoveBy(BPoint(x, y));
|
||||
}
|
||||
|
||||
|
||||
@ -219,7 +255,7 @@ DefaultDecorator::GetFootprint(BRegion *region)
|
||||
|
||||
region->MakeEmpty();
|
||||
|
||||
if (_look == B_NO_BORDER_WINDOW_LOOK)
|
||||
if (fLook == B_NO_BORDER_WINDOW_LOOK)
|
||||
return;
|
||||
|
||||
region->Include(fLeftBorder);
|
||||
@ -227,78 +263,37 @@ DefaultDecorator::GetFootprint(BRegion *region)
|
||||
region->Include(fTopBorder);
|
||||
region->Include(fBottomBorder);
|
||||
|
||||
if (_look == B_BORDERED_WINDOW_LOOK)
|
||||
if (fLook == B_BORDERED_WINDOW_LOOK)
|
||||
return;
|
||||
|
||||
region->Include(_tabrect);
|
||||
|
||||
if (_look == B_DOCUMENT_WINDOW_LOOK) {
|
||||
if (fLook == B_DOCUMENT_WINDOW_LOOK) {
|
||||
// include the rectangular resize knob on the bottom right
|
||||
region->Include(BRect(_frame.right - 13.0f, _frame.bottom - 13.0f,
|
||||
_frame.right, _frame.bottom));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
click_type
|
||||
DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
|
||||
{
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: Clicked\n");
|
||||
printf("\tPoint: (%.1f,%.1f)\n",pt.x,pt.y);
|
||||
printf("\tButtons:\n");
|
||||
|
||||
if (buttons == 0) {
|
||||
printf("\t\tNone\n");
|
||||
} else {
|
||||
if(buttons & B_PRIMARY_MOUSE_BUTTON)
|
||||
printf("\t\tPrimary\n");
|
||||
if(buttons & B_SECONDARY_MOUSE_BUTTON)
|
||||
printf("\t\tSecondary\n");
|
||||
if(buttons & B_TERTIARY_MOUSE_BUTTON)
|
||||
printf("\t\tTertiary\n");
|
||||
}
|
||||
|
||||
printf("\tModifiers:\n");
|
||||
|
||||
if (modifiers == 0) {
|
||||
printf("\t\tNone\n");
|
||||
} else {
|
||||
if(modifiers & B_CAPS_LOCK)
|
||||
printf("\t\tCaps Lock\n");
|
||||
if(modifiers & B_NUM_LOCK)
|
||||
printf("\t\tNum Lock\n");
|
||||
if(modifiers & B_SCROLL_LOCK)
|
||||
printf("\t\tScroll Lock\n");
|
||||
if(modifiers & B_LEFT_COMMAND_KEY)
|
||||
printf("\t\t Left Command\n");
|
||||
if(modifiers & B_RIGHT_COMMAND_KEY)
|
||||
printf("\t\t Right Command\n");
|
||||
if(modifiers & B_LEFT_CONTROL_KEY)
|
||||
printf("\t\tLeft Control\n");
|
||||
if(modifiers & B_RIGHT_CONTROL_KEY)
|
||||
printf("\t\tRight Control\n");
|
||||
if(modifiers & B_LEFT_OPTION_KEY)
|
||||
printf("\t\tLeft Option\n");
|
||||
if(modifiers & B_RIGHT_OPTION_KEY)
|
||||
printf("\t\tRight Option\n");
|
||||
if(modifiers & B_LEFT_SHIFT_KEY)
|
||||
printf("\t\tLeft Shift\n");
|
||||
if(modifiers & B_RIGHT_SHIFT_KEY)
|
||||
printf("\t\tRight Shift\n");
|
||||
if(modifiers & B_MENU_KEY)
|
||||
printf("\t\tMenu\n");
|
||||
}
|
||||
printf("\tPoint: (%.1f,%.1f)\n", pt.x,pt.y);
|
||||
printf("\tButtons: %ld, Modifiers: 0x%lx\n", buttons, modifiers);
|
||||
#endif // DEBUG_DECORATOR
|
||||
|
||||
|
||||
// In checking for hit test stuff, we start with the smallest rectangles the user might
|
||||
// be clicking on and gradually work our way out into larger rectangles.
|
||||
if (!(_flags & B_NOT_CLOSABLE) && _closerect.Contains(pt))
|
||||
if (!(fFlags & B_NOT_CLOSABLE) && _closerect.Contains(pt))
|
||||
return DEC_CLOSE;
|
||||
|
||||
if (!(_flags & B_NOT_ZOOMABLE) && _zoomrect.Contains(pt))
|
||||
if (!(fFlags & B_NOT_ZOOMABLE) && _zoomrect.Contains(pt))
|
||||
return DEC_ZOOM;
|
||||
|
||||
if (_look == B_DOCUMENT_WINDOW_LOOK && _resizerect.Contains(pt))
|
||||
if (fLook == B_DOCUMENT_WINDOW_LOOK && _resizerect.Contains(pt))
|
||||
return DEC_RESIZE;
|
||||
|
||||
// Clicking in the tab?
|
||||
@ -316,14 +311,16 @@ DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
|
||||
if (fLeftBorder.Contains(pt) || fRightBorder.Contains(pt)
|
||||
|| fTopBorder.Contains(pt) || fBottomBorder.Contains(pt)) {
|
||||
// check resize area
|
||||
if (!(_flags & B_NOT_RESIZABLE) &&
|
||||
(_look == B_TITLED_WINDOW_LOOK || _look == B_FLOATING_WINDOW_LOOK)) {
|
||||
|
||||
if (!(fFlags & B_NOT_RESIZABLE)
|
||||
&& (fLook == B_TITLED_WINDOW_LOOK
|
||||
|| fLook == B_FLOATING_WINDOW_LOOK
|
||||
|| fLook == B_MODAL_WINDOW_LOOK)) {
|
||||
BRect temp(BPoint(fBottomBorder.right - 18, fBottomBorder.bottom - 18),
|
||||
fBottomBorder.RightBottom());
|
||||
if (temp.Contains(pt))
|
||||
return DEC_RESIZE;
|
||||
}
|
||||
|
||||
// NOTE: On R5, windows are not moved to back if clicked inside the resize area with
|
||||
// the second mouse button. So we check this after the check above
|
||||
if (buttons == B_SECONDARY_MOUSE_BUTTON)
|
||||
@ -336,6 +333,7 @@ DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
|
||||
return DEC_NONE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DefaultDecorator::_DoLayout()
|
||||
{
|
||||
@ -345,7 +343,7 @@ DefaultDecorator::_DoLayout()
|
||||
|
||||
bool hasTab = false;
|
||||
|
||||
switch (GetLook()) {
|
||||
switch (Look()) {
|
||||
case B_MODAL_WINDOW_LOOK:
|
||||
fBorderWidth = 5;
|
||||
break;
|
||||
@ -374,7 +372,7 @@ DefaultDecorator::_DoLayout()
|
||||
fTabOffset = 0;
|
||||
// distance from one item of the tab bar to another.
|
||||
// In this case the text and close/zoom rects
|
||||
fTextOffset = (_look == B_FLOATING_WINDOW_LOOK) ? 10 : 18;
|
||||
fTextOffset = (fLook == B_FLOATING_WINDOW_LOOK) ? 10 : 18;
|
||||
|
||||
font_height fontHeight;
|
||||
fDrawState.Font().GetHeight(fontHeight);
|
||||
@ -387,7 +385,7 @@ DefaultDecorator::_DoLayout()
|
||||
_frame.top - fBorderWidth);
|
||||
|
||||
// format tab rect for a floating window - make the rect smaller
|
||||
if (_look == B_FLOATING_WINDOW_LOOK) {
|
||||
if (fLook == B_FLOATING_WINDOW_LOOK) {
|
||||
_tabrect.InsetBy(0, 2);
|
||||
_tabrect.OffsetBy(0, 2);
|
||||
}
|
||||
@ -398,13 +396,13 @@ DefaultDecorator::_DoLayout()
|
||||
|
||||
// fMinTabWidth contains just the room for the buttons
|
||||
fMinTabWidth = 4.0 + fTextOffset;
|
||||
if (!(_flags & B_NOT_CLOSABLE))
|
||||
if (!(fFlags & B_NOT_CLOSABLE))
|
||||
fMinTabWidth += offset + size;
|
||||
if (!(_flags & B_NOT_ZOOMABLE))
|
||||
if (!(fFlags & B_NOT_ZOOMABLE))
|
||||
fMinTabWidth += offset + size;
|
||||
|
||||
// fMaxTabWidth contains fMinWidth + the width required for the title
|
||||
fMaxTabWidth = _driver ? _driver->StringWidth(GetTitle(), strlen(GetTitle()),
|
||||
fMaxTabWidth = _driver ? _driver->StringWidth(Title(), strlen(Title()),
|
||||
&fDrawState) : 0.0;
|
||||
if (fMaxTabWidth > 0.0)
|
||||
fMaxTabWidth += fTextOffset;
|
||||
@ -466,7 +464,7 @@ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
|
||||
_driver->FillRect(_frame, fDrawState.HighColor());
|
||||
#endif
|
||||
|
||||
if (_look == B_NO_BORDER_WINDOW_LOOK)
|
||||
if (fLook == B_NO_BORDER_WINDOW_LOOK)
|
||||
return;
|
||||
|
||||
if (fBorderWidth <= 0)
|
||||
@ -474,7 +472,7 @@ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
|
||||
|
||||
// Draw the border frame
|
||||
BRect r = BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom());
|
||||
switch (_look) {
|
||||
switch (fLook) {
|
||||
case B_TITLED_WINDOW_LOOK:
|
||||
case B_DOCUMENT_WINDOW_LOOK:
|
||||
case B_MODAL_WINDOW_LOOK: {
|
||||
@ -543,11 +541,11 @@ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
|
||||
}
|
||||
|
||||
// Draw the resize thumb if we're supposed to
|
||||
if (!(_flags & B_NOT_RESIZABLE)) {
|
||||
if (!(fFlags & B_NOT_RESIZABLE)) {
|
||||
|
||||
r = _resizerect;
|
||||
|
||||
switch (_look){
|
||||
switch (fLook){
|
||||
case B_DOCUMENT_WINDOW_LOOK: {
|
||||
|
||||
// Explicitly locking the driver is normally unnecessary. However, we need to do
|
||||
@ -637,9 +635,9 @@ DefaultDecorator::_DrawTab(BRect r)
|
||||
_DrawTitle(_tabrect);
|
||||
|
||||
// Draw the buttons if we're supposed to
|
||||
if (!(_flags & B_NOT_CLOSABLE))
|
||||
if (!(fFlags & B_NOT_CLOSABLE))
|
||||
_DrawClose(_closerect);
|
||||
if (!(_flags & B_NOT_ZOOMABLE))
|
||||
if (!(fFlags & B_NOT_ZOOMABLE))
|
||||
_DrawZoom(_zoomrect);
|
||||
}
|
||||
|
||||
@ -774,7 +772,7 @@ DefaultDecorator::_DrawBlendedRect(BRect r, bool down)
|
||||
void
|
||||
DefaultDecorator::_GetButtonSizeAndOffset(const BRect& tabRect, float* offset, float* size) const
|
||||
{
|
||||
*offset = _look == B_FLOATING_WINDOW_LOOK ? 4.0 : 5.0;
|
||||
*offset = fLook == B_FLOATING_WINDOW_LOOK ? 4.0 : 5.0;
|
||||
// "+ 2" so that the rects are centered within the solid area
|
||||
// (without the 2 pixels for the top border)
|
||||
*size = tabRect.Height() - 2.0 * *offset + 2.0;
|
||||
@ -789,7 +787,7 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
|
||||
_GetButtonSizeAndOffset(tabRect, &offset, &size);
|
||||
|
||||
// calulate close rect based on the tab rectangle
|
||||
if (GetFlags() & B_NOT_CLOSABLE) {
|
||||
if (Flags() & B_NOT_CLOSABLE) {
|
||||
_closerect.Set(tabRect.left + offset, tabRect.top + offset,
|
||||
tabRect.left + offset, tabRect.top + offset + size);
|
||||
} else {
|
||||
@ -798,7 +796,7 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
|
||||
}
|
||||
|
||||
// calulate zoom rect based on the tab rectangle
|
||||
if (GetFlags() & B_NOT_ZOOMABLE) {
|
||||
if (Flags() & B_NOT_ZOOMABLE) {
|
||||
_zoomrect.Set(tabRect.right, tabRect.top + offset,
|
||||
tabRect.right, tabRect.top + offset + size);
|
||||
} else {
|
||||
@ -811,7 +809,7 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
|
||||
// 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 = Title();
|
||||
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, width);
|
||||
fTruncatedTitleLength = fTruncatedTitle.Length();
|
||||
}
|
||||
|
@ -19,10 +19,13 @@ class Desktop;
|
||||
class DefaultDecorator: public Decorator {
|
||||
public:
|
||||
DefaultDecorator(DesktopSettings& settings, BRect frame,
|
||||
int32 look, int32 feel, int32 flags);
|
||||
window_look look, uint32 flags);
|
||||
virtual ~DefaultDecorator();
|
||||
|
||||
virtual void SetTitle(const char* string, BRegion* updateRegion = NULL);
|
||||
virtual void SetLook(DesktopSettings& settings,
|
||||
window_look look, BRegion* updateRegion = NULL);
|
||||
virtual void SetFlags(uint32 flags, BRegion* updateRegion = NULL);
|
||||
|
||||
virtual void MoveBy(float x, float y);
|
||||
virtual void MoveBy(BPoint pt);
|
||||
|
@ -563,11 +563,19 @@ RootLayer::ResizeWindowBy(WindowLayer* window, float x, float y)
|
||||
void
|
||||
RootLayer::SetWindowLook(WindowLayer *window, window_look newLook)
|
||||
{
|
||||
if (window->Look() == newLook)
|
||||
return;
|
||||
|
||||
BAutolock _(fAllRegionsLock);
|
||||
|
||||
BRegion changed;
|
||||
window->SetLook(newLook, window->Parent() ? &changed : NULL);
|
||||
|
||||
if (window->Parent() != NULL) {
|
||||
MarkForRebuild(changed);
|
||||
TriggerRebuild();
|
||||
}
|
||||
|
||||
_WindowsChanged(changed);
|
||||
|
||||
if (changed.CountRects() > 0) {
|
||||
@ -580,6 +588,9 @@ RootLayer::SetWindowLook(WindowLayer *window, window_look newLook)
|
||||
void
|
||||
RootLayer::SetWindowFeel(WindowLayer *window, window_feel newFeel)
|
||||
{
|
||||
if (window->Feel() == newFeel)
|
||||
return;
|
||||
|
||||
BAutolock _(fAllRegionsLock);
|
||||
|
||||
window->SetFeel(newFeel);
|
||||
@ -591,11 +602,19 @@ RootLayer::SetWindowFeel(WindowLayer *window, window_feel newFeel)
|
||||
void
|
||||
RootLayer::SetWindowFlags(WindowLayer *window, uint32 newFlags)
|
||||
{
|
||||
if (window->WindowFlags() == newFlags)
|
||||
return;
|
||||
|
||||
BAutolock _(fAllRegionsLock);
|
||||
|
||||
BRegion changed;
|
||||
window->SetWindowFlags(newFlags, window->Parent() ? &changed : NULL);
|
||||
|
||||
if (window->Parent() != NULL) {
|
||||
MarkForRebuild(changed);
|
||||
TriggerRebuild();
|
||||
}
|
||||
|
||||
_WindowsChanged(changed);
|
||||
|
||||
if (changed.CountRects() > 0) {
|
||||
|
@ -95,8 +95,8 @@ WindowLayer::WindowLayer(const BRect &frame,
|
||||
fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE;
|
||||
|
||||
if (fLook != B_NO_BORDER_WINDOW_LOOK) {
|
||||
fDecorator = gDecorManager.AllocateDecorator(window->App()->GetDesktop(), frame,
|
||||
name, fLook, fFeel, fWindowFlags);
|
||||
fDecorator = gDecorManager.AllocateDecorator(window->Desktop(), frame,
|
||||
name, fLook, fWindowFlags);
|
||||
if (fDecorator)
|
||||
fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth, &fMaxHeight);
|
||||
}
|
||||
@ -110,8 +110,8 @@ WindowLayer::WindowLayer(const BRect &frame,
|
||||
uint16 width, height;
|
||||
uint32 colorSpace;
|
||||
float frequency;
|
||||
if (window->App()->GetDesktop()->ScreenAt(0)) {
|
||||
window->App()->GetDesktop()->ScreenAt(0)->GetMode(width, height, colorSpace, frequency);
|
||||
if (window->Desktop()->ScreenAt(0)) {
|
||||
window->Desktop()->ScreenAt(0)->GetMode(width, height, colorSpace, frequency);
|
||||
// TODO: MOVE THIS AWAY!!! RemoveBy contains calls to virtual methods! Also, there is not TopLayer()!
|
||||
fFrame.OffsetTo(B_ORIGIN);
|
||||
WindowLayer::ResizeBy(width - frame.Width(), height - frame.Height());
|
||||
@ -669,7 +669,28 @@ WindowLayer::SupportsFront()
|
||||
void
|
||||
WindowLayer::SetLook(window_look look, BRegion* updateRegion)
|
||||
{
|
||||
// TODO: implement settings window look
|
||||
if (fDecorator == NULL && look != B_NO_BORDER_WINDOW_LOOK) {
|
||||
// we need a new decorator
|
||||
fDecorator = gDecorManager.AllocateDecorator(Window()->Desktop(), Frame(),
|
||||
Name(), fLook, fWindowFlags);
|
||||
}
|
||||
|
||||
fLook = look;
|
||||
fRebuildDecRegion = true;
|
||||
|
||||
if (fDecorator != NULL) {
|
||||
DesktopSettings settings(Window()->Desktop());
|
||||
fDecorator->SetLook(settings, look, updateRegion);
|
||||
|
||||
// TODO: we might need to resize the window!
|
||||
//fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth, &fMaxHeight);
|
||||
}
|
||||
|
||||
if (look == B_NO_BORDER_WINDOW_LOOK) {
|
||||
// we don't need a decorator for this window
|
||||
delete fDecorator;
|
||||
fDecorator = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,7 +108,7 @@ WorkspacesLayer::_DrawWindow(const BRect& workspaceFrame,
|
||||
BPoint offset = window->Frame().LeftTop() - windowPosition;
|
||||
BRect frame = _WindowFrame(workspaceFrame, screenFrame, window->Frame(),
|
||||
windowPosition);
|
||||
BRect tabFrame = window->GetDecorator()->GetTabRect();
|
||||
BRect tabFrame = window->GetDecorator()->TabRect();
|
||||
tabFrame = _WindowFrame(workspaceFrame, screenFrame,
|
||||
tabFrame, tabFrame.LeftTop() - offset);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user