Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BWidget Class Reference

#include <BWidget.h>

Inheritance diagram for BWidget:

Inheritance graph
[legend]
Collaboration diagram for BWidget:

Collaboration graph
[legend]
List of all members.

Detailed Description

Widget base class.

All widgets inherit from this.


Public Types

enum  State { STATE_DISABLED, STATE_ENABLED, STATE_SELECTED, STATE_ACTIVE }
 Widget state. More...

enum  Rotation { ROT_0 = 0, ROT_90 = 1, ROT_180 = 2, ROT_270 = 3 }
 Rotation of the widget coordinate system relative to parent. More...

enum  TextDirection { DIR_LEFTTORIGHT = 0, DIR_TOPTOBOTTOM = 1, DIR_RIGHTTOLEFT = 2, DIR_BOTTOMTOTOP = 3 }
 Direction for text drawing. More...

enum  TextAlignment { ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT }
 Horizontal alignment for text drawing. More...

enum  ReliefType { RELIEF_NONE, RELIEF_SIMPLE, RELIEF_RAISED, RELIEF_SUNKEN }
 Relief (border) type. More...


Public Member Functions

 BWidget (BWidget *parent, const BRect &frame)
 Construct a widget.

virtual ~BWidget ()
const BRectframe () const
 Return the frame in parent coordinates.

virtual void setFrame (const BRect &frame)
 Set the frame in parent coordinates.

virtual State state () const
 Return the widget's current state.

virtual void setState (State state)
 Set the widget's current state.

void setTag (int tag)
int tag ()
virtual TextDirection textDirectionRelativeToScreen () const
virtual TextDirection textDirection () const
virtual void setTextDirection (TextDirection dir)
TextAlignment textAlignment () const
virtual void setTextAlignment (TextAlignment align)
ReliefType reliefType () const
virtual void setReliefType (ReliefType relief)
unsigned int vPadding () const
virtual void setVPadding (unsigned int padding)
unsigned int hPadding () const
virtual void setHPadding (unsigned int padding)
virtual void draw (BImage &img)
 Draw the widget onto the given image.

virtual void setNeedsRedraw (bool needs)
 Set or reset the redraw flag.

virtual bool needsRedraw ()
 Returns true if the widget or one of its children needs redraw.

virtual bool isShown ()
virtual void hide ()
virtual void show ()
void handleEvent (const BEvent &event)
 Handle the given event. Override if necessary.

Coordinate transforms in the widget hierarchy
virtual Rotation rotation () const
virtual void setRotation (Rotation rot)
virtual Rotation accumulatedRotation () const
BPoint transformUp (BPoint pt, bool global=true) const
 Transform the given point up in the widget hierarchy.

BPoint transformDown (const BPoint &pt, bool global=true) const
 Transform the given point down in the widget hierarchy.

BRect transformUp (const BRect &r, bool global=true) const
 Transform the given rect up in the widget hierarchy.

BRect transformDown (const BRect &r, bool global=true) const
 Transform the given rect down in the widget hierarchy.

Debug drawing
This flag causes a 5-pixel grid and a widget coordinate system (red axis = x, green axis = y) to be drawn in the widget, for easier draw debugging and children positioning

bool drawsDebugStuff () const
virtual void setDrawsDebugStuff (bool debug)
Drawing attributes
uint16 backgroundColor () const
virtual void setBackgroundColor (uint16 color, bool recursive=false)
uint8 backgroundAlpha () const
virtual void setBackgroundAlpha (uint8 alpha)
uint8 widgetAlpha () const
virtual void setWidgetAlpha (uint8 alpha)
BFontfont () const
virtual void setFont (BFont *font)
uint16 textColor ()
virtual void setTextColor (uint16 color, bool recursive=false)
uint16 selectedTextColor ()
virtual void setSelectedTextColor (uint16 color)
Children, parents, and screens
std::vector< BWidget * > & children ()
 Return the widget's children vector.

bool deletesChildren ()
 Whether the widget deletes its children.

void setDeletesChildren (bool yesno)
 Set the widget to delete its children upon destruction.

void deleteChildren ()
 Tell the widget to delete its children now.

BWidget * parent ()
 Return the widget's parent, or NULL.

BScreenscreen ()
 Return the widget's screen (or it's parent's screen, recursively), or NULL.

void setScreen (BScreen *screen)
 Set the widget's screen. Don't use directly.


Protected Member Functions

virtual void addChild (BWidget *w)
virtual void removeChild (BWidget *w)

Protected Attributes

std::vector< BWidget * > _children
BRect _frame
ReliefType _relief
unsigned int _vpadding
unsigned int _hpadding
uint16 _bgcolor
uint16 _textcolor
uint16 _selectedtextcolor
uint8 _bgalpha
uint8 _widgetalpha
bool _needsRedraw
bool _debug
bool _shown
BFont_font
BWidget * _parent
BScreen_screen
State _state
TextDirection _tdir
Rotation _rot
TextAlignment _align
int _tag
bool _deleteChildren


Member Enumeration Documentation

enum BWidget::ReliefType
 

Relief (border) type.

Enumeration values:
RELIEF_NONE 
RELIEF_SIMPLE  No border at all.
RELIEF_RAISED  Plain rectangle.
RELIEF_SUNKEN  "Sunken 3D" border

enum BWidget::Rotation
 

Rotation of the widget coordinate system relative to parent.

Enumeration values:
ROT_0 
ROT_90 
ROT_180 
ROT_270 

enum BWidget::State
 

Widget state.

Enumeration values:
STATE_DISABLED 
STATE_ENABLED  non-selectable, greyed out, ...
STATE_SELECTED  regular, sitting there waiting
STATE_ACTIVE  performing some action

enum BWidget::TextAlignment
 

Horizontal alignment for text drawing.

Enumeration values:
ALIGN_CENTER 
ALIGN_LEFT 
ALIGN_RIGHT 

enum BWidget::TextDirection
 

Direction for text drawing.

Enumeration values:
DIR_LEFTTORIGHT 
DIR_TOPTOBOTTOM 
DIR_RIGHTTOLEFT 
DIR_BOTTOMTOTOP 


Constructor & Destructor Documentation

BWidget::BWidget BWidget *    parent,
const BRect   frame
 

Construct a widget.

If this is a toplevel widget, specify NULL as the parent. The frame is given in parent coordinates.

virtual BWidget::~BWidget   [virtual]
 


Member Function Documentation

virtual Rotation BWidget::accumulatedRotation   const [virtual]
 

virtual void BWidget::addChild BWidget *    w [protected, virtual]
 

uint8 BWidget::backgroundAlpha   const [inline]
 

uint16 BWidget::backgroundColor   const [inline]
 

std::vector<BWidget*>& BWidget::children   [inline]
 

Return the widget's children vector.

void BWidget::deleteChildren  
 

Tell the widget to delete its children now.

bool BWidget::deletesChildren   [inline]
 

Whether the widget deletes its children.

virtual void BWidget::draw BImage   img [virtual]
 

Draw the widget onto the given image.

Reimplemented in BButton, BLabel, BListbox, BProgressBar, BScroller, and BText.

bool BWidget::drawsDebugStuff   const [inline]
 

BFont* BWidget::font   const [inline]
 

const BRect& BWidget::frame   const [inline]
 

Return the frame in parent coordinates.

void BWidget::handleEvent const BEvent   event [virtual]
 

Handle the given event. Override if necessary.

Reimplemented from BResponder.

Reimplemented in BButton, BLabel, BListbox, BMenu, and BScroller.

virtual void BWidget::hide   [inline, virtual]
 

unsigned int BWidget::hPadding   const [inline]
 

virtual bool BWidget::isShown   [inline, virtual]
 

virtual bool BWidget::needsRedraw   [virtual]
 

Returns true if the widget or one of its children needs redraw.

BWidget* BWidget::parent   [inline]
 

Return the widget's parent, or NULL.

ReliefType BWidget::reliefType   const [inline]
 

virtual void BWidget::removeChild BWidget *    w [protected, virtual]
 

virtual Rotation BWidget::rotation   const [inline, virtual]
 

BScreen* BWidget::screen  
 

Return the widget's screen (or it's parent's screen, recursively), or NULL.

uint16 BWidget::selectedTextColor   [inline]
 

virtual void BWidget::setBackgroundAlpha uint8    alpha [virtual]
 

virtual void BWidget::setBackgroundColor uint16    color,
bool    recursive = false
[virtual]
 

void BWidget::setDeletesChildren bool    yesno [inline]
 

Set the widget to delete its children upon destruction.

virtual void BWidget::setDrawsDebugStuff bool    debug [virtual]
 

virtual void BWidget::setFont BFont   font [virtual]
 

Reimplemented in BFontSelector, and BText.

virtual void BWidget::setFrame const BRect   frame [virtual]
 

Set the frame in parent coordinates.

virtual void BWidget::setHPadding unsigned int    padding [virtual]
 

virtual void BWidget::setNeedsRedraw bool    needs [virtual]
 

Set or reset the redraw flag.

virtual void BWidget::setReliefType ReliefType    relief [virtual]
 

virtual void BWidget::setRotation Rotation    rot [virtual]
 

Reimplemented in BOnScreenKeyboard.

void BWidget::setScreen BScreen   screen
 

Set the widget's screen. Don't use directly.

virtual void BWidget::setSelectedTextColor uint16    color [virtual]
 

virtual void BWidget::setState State    state [inline, virtual]
 

Set the widget's current state.

void BWidget::setTag int    tag [inline]
 

virtual void BWidget::setTextAlignment TextAlignment    align [virtual]
 

virtual void BWidget::setTextColor uint16    color,
bool    recursive = false
[virtual]
 

virtual void BWidget::setTextDirection TextDirection    dir [inline, virtual]
 

virtual void BWidget::setVPadding unsigned int    padding [virtual]
 

virtual void BWidget::setWidgetAlpha uint8    alpha [virtual]
 

virtual void BWidget::show   [virtual]
 

virtual State BWidget::state   const [inline, virtual]
 

Return the widget's current state.

int BWidget::tag   [inline]
 

TextAlignment BWidget::textAlignment   const [inline]
 

uint16 BWidget::textColor   [inline]
 

virtual TextDirection BWidget::textDirection   const [inline, virtual]
 

virtual TextDirection BWidget::textDirectionRelativeToScreen   const [virtual]
 

BRect BWidget::transformDown const BRect   r,
bool    global = true
const [inline]
 

Transform the given rect down in the widget hierarchy.

This will transform the rect, given in the parent's (global==false) or root (global==true) coordinates, into widget coordinates.

BPoint BWidget::transformDown const BPoint   pt,
bool    global = true
const [inline]
 

Transform the given point down in the widget hierarchy.

This will transform the point, given in the parent's (global==false) or root (global==true) coordinates, into widget coordinates.

BRect BWidget::transformUp const BRect   r,
bool    global = true
const [inline]
 

Transform the given rect up in the widget hierarchy.

This will transform the rect, given in widget coordinates, into parent (global==false) or root (global==true) coordinates.

BPoint BWidget::transformUp BPoint    pt,
bool    global = true
const [inline]
 

Transform the given point up in the widget hierarchy.

This will transform the point, given in widget coordinates, into parent (global==false) or root (global==true) coordinates.

unsigned int BWidget::vPadding   const [inline]
 

uint8 BWidget::widgetAlpha   const [inline]
 


Member Data Documentation

TextAlignment BWidget::_align [protected]
 

uint8 BWidget::_bgalpha [protected]
 

uint16 BWidget::_bgcolor [protected]
 

std::vector<BWidget*> BWidget::_children [protected]
 

bool BWidget::_debug [protected]
 

bool BWidget::_deleteChildren [protected]
 

BFont* BWidget::_font [protected]
 

BRect BWidget::_frame [protected]
 

unsigned int BWidget::_hpadding [protected]
 

bool BWidget::_needsRedraw [protected]
 

BWidget* BWidget::_parent [protected]
 

ReliefType BWidget::_relief [protected]
 

Rotation BWidget::_rot [protected]
 

BScreen* BWidget::_screen [protected]
 

uint16 BWidget::_selectedtextcolor [protected]
 

bool BWidget::_shown [protected]
 

State BWidget::_state [protected]
 

int BWidget::_tag [protected]
 

TextDirection BWidget::_tdir [protected]
 

uint16 BWidget::_textcolor [protected]
 

unsigned int BWidget::_vpadding [protected]
 

uint8 BWidget::_widgetalpha [protected]
 


The documentation for this class was generated from the following file:
Generated on Sat Dec 29 10:01:03 2007 for DSGUI by doxygen1.3-rc3