2003-01-20 23:38:49 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2005-06-03 23:50:30 +04:00
|
|
|
// Copyright (c) 2001-2005, Haiku, Inc.
|
2003-01-20 23:38:49 +03:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
// File Name: Decorator.cpp
|
|
|
|
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
2005-06-03 23:50:30 +04:00
|
|
|
// Stephan Aßmus <superstippi@gmx.de>
|
2003-01-20 23:38:49 +03:00
|
|
|
// Description: Base class for window decorators
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
#include <Region.h>
|
|
|
|
#include "ColorSet.h"
|
|
|
|
#include "Decorator.h"
|
|
|
|
#include "DisplayDriver.h"
|
2003-08-31 21:38:34 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2003-01-20 23:38:49 +03:00
|
|
|
/*!
|
|
|
|
\brief Constructor
|
|
|
|
\param rect Size of client area
|
|
|
|
\param wlook style of window look. See Window.h
|
|
|
|
\param wfeel style of window feel. See Window.h
|
|
|
|
\param wflags various window flags. See Window.h
|
|
|
|
|
|
|
|
Does general initialization of internal data members and creates a colorset
|
|
|
|
object.
|
|
|
|
*/
|
|
|
|
Decorator::Decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
|
2005-06-03 23:50:30 +04:00
|
|
|
: _colors(new ColorSet()),
|
|
|
|
_driver(NULL),
|
|
|
|
_drawdata(),
|
|
|
|
|
|
|
|
_look(wlook),
|
|
|
|
_feel(wfeel),
|
|
|
|
_flags(wflags),
|
|
|
|
|
|
|
|
_zoomrect(),
|
|
|
|
_closerect(),
|
|
|
|
_minimizerect(),
|
|
|
|
_tabrect(),
|
|
|
|
_frame(rect),
|
|
|
|
_resizerect(),
|
|
|
|
_borderrect(),
|
|
|
|
|
|
|
|
fClosePressed(false),
|
|
|
|
fZoomPressed(false),
|
|
|
|
fMinimizePressed(false),
|
|
|
|
fIsFocused(false),
|
|
|
|
fTitle("")
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Destructor
|
|
|
|
|
|
|
|
Frees the color set and the title string
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
Decorator::~Decorator()
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
delete _colors;
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Updates the decorator's color set
|
|
|
|
\param cset The color set to update from
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::SetColors(const ColorSet &cset)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
_colors->SetColors(cset);
|
2003-07-07 17:09:42 +04:00
|
|
|
_SetColors();
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Assigns a display driver to the decorator
|
|
|
|
\param driver A valid DisplayDriver object
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::SetDriver(DisplayDriver *driver)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
_driver = driver;
|
2003-01-20 23:38:49 +03:00
|
|
|
// lots of subclasses will depend on the driver for text support, so call
|
2005-06-03 23:50:30 +04:00
|
|
|
// _DoLayout() after we have it
|
|
|
|
if (_driver) {
|
|
|
|
_DoLayout();
|
|
|
|
}
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\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.
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::SetFlags(int32 wflags)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
_flags = wflags;
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Sets the decorator's window feel
|
|
|
|
\param wflags New value for the feel
|
|
|
|
|
|
|
|
While this call will not update the screen, it will affect how future
|
|
|
|
updates work and immediately affects input handling.
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::SetFeel(int32 wfeel)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
_feel = wfeel;
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
/*
|
|
|
|
\brief Sets the decorator's font
|
|
|
|
\param font The new font object to copy from
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::SetFont(ServerFont *font)
|
2003-07-24 23:38:24 +04:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
if (font) {
|
|
|
|
_drawdata.SetFont(*font);
|
|
|
|
}
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
|
|
|
|
2003-01-20 23:38:49 +03:00
|
|
|
/*!
|
|
|
|
\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.
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::SetLook(int32 wlook)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
_look = wlook;
|
|
|
|
// TODO: relayout and redraw, no?
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2005-06-03 23:50:30 +04:00
|
|
|
\brief Sets the close button's value.
|
|
|
|
\param is_down Whether the button is down or not
|
|
|
|
|
|
|
|
Note that this does not update the button's look - it just updates the
|
|
|
|
internal button value
|
2003-01-20 23:38:49 +03:00
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::SetClose(bool is_down)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
if (is_down != fClosePressed) {
|
|
|
|
fClosePressed = is_down;
|
|
|
|
DrawClose();
|
|
|
|
}
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2005-06-03 23:50:30 +04:00
|
|
|
\brief Sets the minimize button's value.
|
|
|
|
\param is_down Whether the button is down or not
|
|
|
|
|
|
|
|
Note that this does not update the button's look - it just updates the
|
|
|
|
internal button value
|
2003-01-20 23:38:49 +03:00
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::SetMinimize(bool is_down)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
if (is_down != fMinimizePressed) {
|
|
|
|
fMinimizePressed = is_down;
|
|
|
|
DrawMinimize();
|
|
|
|
}
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2005-06-03 23:50:30 +04:00
|
|
|
\brief Sets the zoom button's value.
|
|
|
|
\param is_down Whether the button is down or not
|
|
|
|
|
|
|
|
Note that this does not update the button's look - it just updates the
|
|
|
|
internal button value
|
2003-01-20 23:38:49 +03:00
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::SetZoom(bool is_down)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
if (is_down != fZoomPressed) {
|
|
|
|
fZoomPressed = is_down;
|
|
|
|
DrawZoom();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Updates the value of the decorator title
|
|
|
|
\param string New title value
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Decorator::SetTitle(const char *string)
|
|
|
|
{
|
|
|
|
fTitle.SetTo(string);
|
|
|
|
_DoLayout();
|
|
|
|
// TODO: redraw?
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Returns the decorator's window look
|
|
|
|
\return the decorator's window look
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
int32
|
|
|
|
Decorator::GetLook() const
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
return _look;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Returns the decorator's window feel
|
|
|
|
\return the decorator's window feel
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
int32
|
|
|
|
Decorator::GetFeel() const
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
return _feel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Returns the decorator's window flags
|
|
|
|
\return the decorator's window flags
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
int32
|
|
|
|
Decorator::GetFlags() const
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
return _flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Returns the decorator's title
|
|
|
|
\return the decorator's title
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
const char*
|
|
|
|
Decorator::GetTitle() const
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
return fTitle.String();
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
2003-08-31 21:38:34 +04:00
|
|
|
/*!
|
|
|
|
\brief Returns the decorator's border rectangle
|
|
|
|
\return the decorator's border rectangle
|
|
|
|
*/
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
BRect
|
|
|
|
Decorator::GetBorderRect() const
|
|
|
|
{
|
2003-08-31 21:38:34 +04:00
|
|
|
return _borderrect;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Returns the decorator's tab rectangle
|
|
|
|
\return the decorator's tab rectangle
|
|
|
|
*/
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
BRect
|
|
|
|
Decorator::GetTabRect() const
|
|
|
|
{
|
2003-08-31 21:38:34 +04:00
|
|
|
return _tabrect;
|
|
|
|
}
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
/*!
|
|
|
|
\brief Returns the value of the close button
|
|
|
|
\return true if down, false if up
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
Decorator::GetClose()
|
|
|
|
{
|
|
|
|
return fClosePressed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Returns the value of the minimize button
|
|
|
|
\return true if down, false if up
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
Decorator::GetMinimize()
|
|
|
|
{
|
|
|
|
return fMinimizePressed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Returns the value of the zoom button
|
|
|
|
\return true if down, false if up
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
Decorator::GetZoom()
|
|
|
|
{
|
|
|
|
return fZoomPressed;
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSizeLimits
|
|
|
|
void
|
|
|
|
Decorator::GetSizeLimits(float* minWidth, float* minHeight,
|
|
|
|
float* maxWidth, float* maxHeight) const
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-01-20 23:38:49 +03:00
|
|
|
/*!
|
|
|
|
\brief Changes the focus value of the decorator
|
|
|
|
\param is_active True if active, false if not
|
|
|
|
|
|
|
|
While this call will not update the screen, it will affect how future
|
|
|
|
updates work.
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::SetFocus(bool is_active)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
fIsFocused = is_active;
|
2003-01-20 23:38:49 +03:00
|
|
|
_SetFocus();
|
2005-06-03 23:50:30 +04:00
|
|
|
// TODO: maybe it would be cleaner to handle the redraw here.
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Virtual Methods
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2003-01-20 23:38:49 +03:00
|
|
|
/*!
|
2005-06-03 23:50:30 +04:00
|
|
|
\brief Returns the "footprint" of the entire window, including decorator
|
|
|
|
\param region Region to be changed to represent the window's screen footprint
|
|
|
|
|
|
|
|
This function is required by all subclasses.
|
2003-01-20 23:38:49 +03:00
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::GetFootprint(BRegion *region)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
}
|
2004-01-20 01:18:37 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
/*!
|
|
|
|
\brief Performs hit-testing for the decorator
|
|
|
|
\return The type of area clicked
|
2004-01-20 01:18:37 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
Clicked is called whenever it has been determined that the window has received a
|
|
|
|
mouse click. The default version returns DEC_NONE. A subclass may use any or all
|
|
|
|
of them.
|
|
|
|
|
|
|
|
Click type : Action taken by the server
|
|
|
|
|
|
|
|
- \c DEC_NONE : Do nothing
|
|
|
|
- \c DEC_ZOOM : Handles the zoom button (setting states, etc)
|
|
|
|
- \c DEC_CLOSE : Handles the close button (setting states, etc)
|
|
|
|
- \c DEC_MINIMIZE : Handles the minimize button (setting states, etc)
|
|
|
|
- \c DEC_TAB : Currently unused
|
|
|
|
- \c DEC_DRAG : Moves the window to the front and prepares to move the window
|
|
|
|
- \c DEC_MOVETOBACK : Moves the window to the back of the stack
|
|
|
|
- \c DEC_MOVETOFRONT : Moves the window to the front of the stack
|
2005-06-16 16:32:42 +04:00
|
|
|
- \c DEC_SLIDETAB : Initiates tab-sliding
|
2003-01-20 23:38:49 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
- \c DEC_RESIZE : Handle window resizing as appropriate
|
|
|
|
- \c DEC_RESIZE_L
|
|
|
|
- \c DEC_RESIZE_T
|
|
|
|
- \c DEC_RESIZE_R
|
|
|
|
- \c DEC_RESIZE_B
|
|
|
|
- \c DEC_RESIZE_LT
|
|
|
|
- \c DEC_RESIZE_RT
|
|
|
|
- \c DEC_RESIZE_LB
|
|
|
|
- \c DEC_RESIZE_RB
|
|
|
|
|
|
|
|
This function is required by all subclasses.
|
|
|
|
|
|
|
|
*/
|
|
|
|
click_type
|
|
|
|
Decorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
|
|
|
|
{
|
|
|
|
return DEC_NONE;
|
|
|
|
}
|
2003-01-20 23:38:49 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Moves the decorator frame and all default rectangles
|
|
|
|
\param x X Offset
|
|
|
|
\param y y Offset
|
|
|
|
|
|
|
|
If a subclass implements this method, be sure to call Decorator::MoveBy
|
|
|
|
to ensure that internal members are also updated. All members of the Decorator
|
|
|
|
class are automatically moved in this method
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::MoveBy(float x, float y)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
_zoomrect.OffsetBy(x, y);
|
|
|
|
_closerect.OffsetBy(x, y);
|
|
|
|
_minimizerect.OffsetBy(x, y);
|
|
|
|
_minimizerect.OffsetBy(x, y);
|
|
|
|
_tabrect.OffsetBy(x, y);
|
|
|
|
_frame.OffsetBy(x, y);
|
|
|
|
_resizerect.OffsetBy(x, y);
|
|
|
|
_borderrect.OffsetBy(x, y);
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Moves the decorator frame and all default rectangles
|
|
|
|
\param pt Point containing the offsets
|
|
|
|
|
|
|
|
If a subclass implements this method, be sure to call Decorator::MoveBy
|
|
|
|
to ensure that internal members are also updated. All members of the Decorator
|
|
|
|
class are automatically moved in this method
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::MoveBy(BPoint pt)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
MoveBy(pt.x, pt.y);
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Resizes the decorator frame
|
|
|
|
\param dx x offset
|
|
|
|
\param dy y offset
|
|
|
|
|
|
|
|
This is a required function for subclasses to implement - the default does nothing.
|
|
|
|
Note that window resize flags should be followed and _frame should be resized
|
|
|
|
accordingly. It would also be a wise idea to ensure that the window's rectangles
|
|
|
|
are not inverted.
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::ResizeBy(float x, float y)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Resizes the decorator frame
|
|
|
|
\param pt Point containing the offsets
|
|
|
|
|
|
|
|
This is a required function for subclasses to implement - the default does nothing.
|
|
|
|
Note that window resize flags should be followed and _frame should be resized
|
|
|
|
accordingly. It would also be a wise idea to ensure that the window's rectangles
|
|
|
|
are not inverted.
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::ResizeBy(BPoint pt)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Updates the decorator's look in the area r
|
|
|
|
\param r The area to update.
|
|
|
|
|
|
|
|
The default version updates all areas which intersect the frame and tab.
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::Draw(BRect r)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
_DrawFrame(r & _frame);
|
2005-06-03 23:50:30 +04:00
|
|
|
_DrawTab(r & _tabrect);
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Forces a complete decorator update
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::Draw()
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
_DrawFrame(_frame);
|
2005-06-03 23:50:30 +04:00
|
|
|
_DrawTab(_tabrect);
|
2003-01-20 23:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Draws the close button
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::DrawClose()
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
_DrawClose(_closerect);
|
|
|
|
}
|
|
|
|
|
|
|
|
//! draws the frame
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::DrawFrame()
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
_DrawFrame(_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
//! draws the minimize button
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::DrawMinimize(void)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
_DrawTab(_minimizerect);
|
|
|
|
}
|
|
|
|
|
|
|
|
//! draws the tab, title, and buttons
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::DrawTab()
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
_DrawTab(_tabrect);
|
|
|
|
_DrawZoom(_zoomrect);
|
|
|
|
_DrawMinimize(_minimizerect);
|
|
|
|
_DrawTitle(_tabrect);
|
|
|
|
_DrawClose(_closerect);
|
|
|
|
}
|
|
|
|
|
|
|
|
// draws the title
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::DrawTitle()
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
_DrawTitle(_tabrect);
|
|
|
|
}
|
|
|
|
|
|
|
|
//! draws the zoom button
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::DrawZoom(void)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
_DrawZoom(_zoomrect);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2005-06-03 23:50:30 +04:00
|
|
|
\brief Provides the number of characters that will fit in the given width
|
|
|
|
\param width Maximum number of pixels the title can be
|
|
|
|
\return the number of characters that will fit in the given width
|
2003-01-20 23:38:49 +03:00
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
int32
|
|
|
|
Decorator::_ClipTitle(float width)
|
|
|
|
{
|
|
|
|
// TODO: eventually, use ServerFont::TruncateString()
|
|
|
|
// when it exists (if it doesn't already)
|
|
|
|
if (_driver) {
|
|
|
|
int32 strlength = fTitle.CountChars();
|
|
|
|
float pixwidth=_driver->StringWidth(fTitle.String(),strlength,&_drawdata);
|
|
|
|
|
|
|
|
while (strlength >= 0) {
|
|
|
|
if (pixwidth < width)
|
|
|
|
return strlength;
|
|
|
|
|
|
|
|
strlength--;
|
|
|
|
pixwidth=_driver->StringWidth(fTitle.String(), strlength, &_drawdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Function for calculating layout for the decorator
|
|
|
|
void
|
|
|
|
Decorator::_DoLayout()
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Actually draws the frame
|
|
|
|
\param r Area of the frame to update
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::_DrawFrame(BRect r)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2005-06-03 23:50:30 +04:00
|
|
|
\brief Actually draws the tab
|
|
|
|
\param r Area of the tab to update
|
2003-01-20 23:38:49 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
This function is called when the tab itself needs drawn. Other items, like the
|
|
|
|
window title or buttons, should not be drawn here.
|
2003-01-20 23:38:49 +03:00
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::_DrawTab(BRect r)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2005-06-03 23:50:30 +04:00
|
|
|
\brief Actually draws the close button
|
|
|
|
\param r Area of the button to update
|
2003-01-20 23:38:49 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
Unless a subclass has a particularly large button, it is probably unnecessary
|
|
|
|
to check the update rectangle.
|
2003-01-20 23:38:49 +03:00
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::_DrawClose(BRect r)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Actually draws the title
|
|
|
|
\param r area of the title to update
|
|
|
|
|
|
|
|
The main tasks for this function are to ensure that the decorator draws the title
|
|
|
|
only in its own area and drawing the title itself. Using B_OP_COPY for drawing
|
|
|
|
the title is recommended because of the marked performance hit of the other
|
|
|
|
drawing modes, but it is not a requirement.
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::_DrawTitle(BRect r)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Actually draws the zoom button
|
|
|
|
\param r Area of the button to update
|
|
|
|
|
|
|
|
Unless a subclass has a particularly large button, it is probably unnecessary
|
|
|
|
to check the update rectangle.
|
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::_DrawZoom(BRect r)
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-07-07 17:09:42 +04:00
|
|
|
/*!
|
2005-06-03 23:50:30 +04:00
|
|
|
\brief Actually draws the minimize button
|
|
|
|
\param r Area of the button to update
|
2003-07-07 17:09:42 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
Unless a subclass has a particularly large button, it is probably unnecessary
|
|
|
|
to check the update rectangle.
|
2003-07-07 17:09:42 +04:00
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::_DrawMinimize(BRect r)
|
2003-07-07 17:09:42 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
//! Hook function called when the decorator changes focus
|
|
|
|
void
|
|
|
|
Decorator::_SetFocus()
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2005-06-03 23:50:30 +04:00
|
|
|
\brief Hook function for when the color set is updated
|
2003-01-20 23:38:49 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
This function is called after the decorator's color set is updated. Quite useful
|
|
|
|
if the decorator uses colors based on those in the system.
|
2003-01-20 23:38:49 +03:00
|
|
|
*/
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
Decorator::_SetColors()
|
2003-01-20 23:38:49 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-07-10 00:40:10 +04:00
|
|
|
|