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

otk::Widget Class Reference

#include <widget.hh>

Inheritance diagram for otk::Widget:

Inheritance graph
[legend]
Collaboration diagram for otk::Widget:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::list< Widget * > WidgetList
enum  Direction { Horizontal, Vertical }

Public Methods

 Widget (Widget *parent, Direction=Horizontal)
 Widget (EventDispatcher *event_dispatcher, RenderStyle *style, Direction direction=Horizontal, Cursor cursor=0, int bevel_width=1, bool override_redirect=false)
virtual ~Widget ()
virtual void update ()
void exposeHandler (const XExposeEvent &e)
 Called when a window becomes visible to the user.

void configureHandler (const XConfigureEvent &e)
 Called when the window as been reconfigured.

Window window (void) const
const Widget * parent (void) const
const WidgetListchildren (void) const
unsigned int screen (void) const
const Rectrect (void) const
void move (const Point &to)
void move (int x, int y)
virtual void setWidth (int)
virtual void setHeight (int)
virtual int width () const
virtual int height () const
virtual void resize (const Point &to)
virtual void resize (int x, int y)
virtual void setGeometry (const Rect &new_geom)
virtual void setGeometry (const Point &topleft, int width, int height)
virtual void setGeometry (int x, int y, int width, int height)
bool isVisible (void) const
virtual void show (bool recursive=false)
virtual void hide (bool recursive=false)
bool isFocused (void) const
virtual void focus (void)
virtual void unfocus (void)
bool hasGrabbedMouse (void) const
bool grabMouse (void)
void ungrabMouse (void)
bool hasGrabbedKeyboard (void) const
bool grabKeyboard (void)
void ungrabKeyboard (void)
RenderTexturetexture (void) const
virtual void setTexture (RenderTexture *texture)
const RenderColorborderColor (void) const
virtual void setBorderColor (const RenderColor *color)
int borderWidth (void) const
void setBorderWidth (int width)
virtual void addChild (Widget *child, bool front=false)
virtual void removeChild (Widget *child)
bool isStretchableHorz (void) const
void setStretchableHorz (bool s_horz=true)
bool isStretchableVert (void) const
void setStretchableVert (bool s_vert=true)
Cursor cursor (void) const
void setCursor (Cursor cursor)
int bevelWidth (void) const
void setBevelWidth (int bevel_width)
Direction direction (void) const
void setDirection (Direction dir)
RenderStylestyle (void) const
virtual void setStyle (RenderStyle *style)
EventDispatchereventDispatcher (void)
void setEventDispatcher (EventDispatcher *disp)

Protected Methods

virtual void adjust (void)
virtual void create (bool override_redirect=false)
virtual void adjustHorz (void)
virtual void adjustVert (void)
virtual void internalResize (int width, int height)
virtual void render (void)
virtual void renderForeground ()

Protected Attributes

bool _dirty
bool _focused
Window _window
Widget * _parent
WidgetList _children
RenderStyle_style
Direction _direction
Cursor _cursor
int _bevel_width
int _ignore_config
bool _visible
bool _grabbed_mouse
bool _grabbed_keyboard
bool _stretchable_vert
bool _stretchable_horz
RenderTexture_texture
Pixmap _bg_pixmap
unsigned int _bg_pixel
const RenderColor_bcolor
unsigned int _bwidth
Rect _rect
unsigned int _screen
bool _fixed_width
bool _fixed_height
Surface_surface
EventDispatcher_event_dispatcher

Member Typedef Documentation

typedef std::list<Widget *> otk::Widget::WidgetList
 

Definition at line 28 of file widget.hh.

Referenced by adjustHorz(), and adjustVert().


Member Enumeration Documentation

enum otk::Widget::Direction
 

Enumeration values:
Horizontal 
Vertical 

Definition at line 26 of file widget.hh.

Referenced by direction().

00026 { Horizontal, Vertical };


Constructor & Destructor Documentation

otk::Widget::Widget Widget *    parent,
Direction    = Horizontal
 

Definition at line 17 of file widget.cc.

References _event_dispatcher, addChild(), create(), and otk::EventDispatcher::registerHandler().

00018   : EventHandler(),
00019     _dirty(false), _focused(false),
00020     _parent(parent), _style(parent->style()), _direction(direction),
00021     _cursor(parent->cursor()), _bevel_width(parent->bevelWidth()),
00022     _ignore_config(0),
00023     _visible(false), _grabbed_mouse(false),
00024     _grabbed_keyboard(false), _stretchable_vert(false),
00025     _stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0),
00026     _bcolor(0), _bwidth(0), _rect(0, 0, 1, 1), _screen(parent->screen()),
00027     _fixed_width(false), _fixed_height(false),
00028     _surface(0),
00029     _event_dispatcher(parent->eventDispatcher())
00030 {
00031   assert(parent);
00032   parent->addChild(this);
00033   create();
00034   _event_dispatcher->registerHandler(_window, this);
00035 }

otk::Widget::Widget EventDispatcher   event_dispatcher,
RenderStyle   style,
Direction    direction = Horizontal,
Cursor    cursor = 0,
int    bevel_width = 1,
bool    override_redirect = false
 

Definition at line 37 of file widget.cc.

References _event_dispatcher, create(), and otk::EventDispatcher::registerHandler().

00040   : EventHandler(),
00041     _dirty(false),_focused(false),
00042     _parent(0), _style(style), _direction(direction), _cursor(cursor),
00043     _bevel_width(bevel_width), _ignore_config(0), _visible(false),
00044     _grabbed_mouse(false), _grabbed_keyboard(false),
00045     _stretchable_vert(false), _stretchable_horz(false), _texture(0),
00046     _bg_pixmap(0), _bg_pixel(0), _bcolor(0), _bwidth(0), _rect(0, 0, 1, 1),
00047     _screen(style->screen()), _fixed_width(false), _fixed_height(false),
00048     _surface(0),
00049     _event_dispatcher(event_dispatcher)
00050 {
00051   assert(event_dispatcher);
00052   assert(style);
00053   create(override_redirect);
00054   _event_dispatcher->registerHandler(_window, this);
00055 }

otk::Widget::~Widget   [virtual]
 

Definition at line 57 of file widget.cc.

References _children, _event_dispatcher, _parent, _surface, otk::EventDispatcher::clearHandler(), hide(), and removeChild().

00058 {
00059   if (_visible)
00060     hide();
00061 
00062   if (_surface)
00063     delete _surface;
00064   
00065   _event_dispatcher->clearHandler(_window);
00066 
00067   std::for_each(_children.begin(), _children.end(), PointerAssassin());
00068 
00069   if (_parent)
00070     _parent->removeChild(this);
00071 
00072   XDestroyWindow(**display, _window);
00073 }


Member Function Documentation

void otk::Widget::addChild Widget *    child,
bool    front = false
[virtual]
 

Definition at line 442 of file widget.cc.

References _children.

Referenced by Widget().

00443 {
00444   assert(child);
00445   if (front)
00446     _children.push_front(child);
00447   else
00448     _children.push_back(child);
00449 }

void otk::Widget::adjust void    [protected, virtual]
 

Reimplemented in ob::BackgroundWidget, ob::ButtonWidget, ob::Frame, and ob::LabelWidget.

Definition at line 287 of file widget.cc.

References _direction, adjustHorz(), adjustVert(), and Horizontal.

Referenced by update().

00288 {
00289   if (_direction == Horizontal)
00290     adjustHorz();
00291   else
00292     adjustVert();
00293 }

void otk::Widget::adjustHorz void    [protected, virtual]
 

Definition at line 295 of file widget.cc.

References _bevel_width, _children, _rect, otk::Rect::height(), internalResize(), isStretchableHorz(), isStretchableVert(), move(), setHeight(), WidgetList, otk::Rect::width(), width(), and otk::Rect::x().

Referenced by adjust().

00296 {
00297   if (_children.size() == 0)
00298     return;
00299 
00300   Widget *tmp;
00301   WidgetList::iterator it, end = _children.end();
00302 
00303   int tallest = 0;
00304   int width = _bevel_width;
00305   WidgetList stretchable;
00306 
00307   for (it = _children.begin(); it != end; ++it) {
00308     tmp = *it;
00309     if (tmp->isStretchableVert())
00310       tmp->setHeight(_rect.height() > _bevel_width * 2 ?
00311                      _rect.height() - _bevel_width * 2 : _bevel_width);
00312     if (tmp->isStretchableHorz())
00313       stretchable.push_back(tmp);
00314     else
00315       width += tmp->_rect.width() + _bevel_width;
00316 
00317     if (tmp->_rect.height() > tallest)
00318       tallest = tmp->_rect.height();
00319   }
00320 
00321   if (stretchable.size() > 0) {
00322     WidgetList::iterator str_it = stretchable.begin(),
00323       str_end = stretchable.end();
00324 
00325     int str_width = _rect.width() - width / stretchable.size();
00326 
00327     for (; str_it != str_end; ++str_it)
00328       (*str_it)->setWidth(str_width > _bevel_width ? str_width - _bevel_width
00329                           : _bevel_width);
00330   }
00331 
00332   Widget *prev_widget = 0;
00333 
00334   for (it = _children.begin(); it != end; ++it) {
00335     tmp = *it;
00336     int x, y;
00337 
00338     if (prev_widget)
00339       x = prev_widget->_rect.x() + prev_widget->_rect.width() + _bevel_width;
00340     else
00341       x = _bevel_width;
00342     y = (tallest - tmp->_rect.height()) / 2 + _bevel_width;
00343 
00344     tmp->move(x, y);
00345 
00346     prev_widget = tmp;
00347   }
00348   internalResize(width, tallest + _bevel_width * 2);
00349 }

void otk::Widget::adjustVert void    [protected, virtual]
 

Definition at line 351 of file widget.cc.

References _bevel_width, _children, _rect, otk::Rect::height(), height(), internalResize(), isStretchableHorz(), isStretchableVert(), move(), setWidth(), WidgetList, otk::Rect::width(), and otk::Rect::y().

Referenced by adjust().

00352 {
00353   if (_children.size() == 0)
00354     return;
00355 
00356   Widget *tmp;
00357   WidgetList::iterator it, end = _children.end();
00358 
00359   int widest = 0;
00360   int height = _bevel_width;
00361   WidgetList stretchable;
00362 
00363   for (it = _children.begin(); it != end; ++it) {
00364     tmp = *it;
00365     if (tmp->isStretchableHorz())
00366       tmp->setWidth(_rect.width() > _bevel_width * 2 ?
00367                     _rect.width() - _bevel_width * 2 : _bevel_width);
00368     if (tmp->isStretchableVert())
00369       stretchable.push_back(tmp);
00370     else
00371       height += tmp->_rect.height() + _bevel_width;
00372 
00373     if (tmp->_rect.width() > widest)
00374       widest = tmp->_rect.width();
00375   }
00376 
00377   if (stretchable.size() > 0) {
00378     WidgetList::iterator str_it = stretchable.begin(),
00379       str_end = stretchable.end();
00380 
00381     int str_height = _rect.height() - height / stretchable.size();
00382 
00383     for (; str_it != str_end; ++str_it)
00384       (*str_it)->setHeight(str_height > _bevel_width ?
00385                            str_height - _bevel_width : _bevel_width);
00386   }
00387   if (stretchable.size() > 0)
00388     height = _rect.height();
00389 
00390   Widget *prev_widget = 0;
00391 
00392   for (it = _children.begin(); it != end; ++it) {
00393     tmp = *it;
00394     int x, y;
00395 
00396     if (prev_widget)
00397       y = prev_widget->_rect.y() + prev_widget->_rect.height() + _bevel_width;
00398     else
00399       y = _bevel_width;
00400     x = (widest - tmp->_rect.width()) / 2 + _bevel_width;
00401 
00402     tmp->move(x, y);
00403 
00404     prev_widget = tmp;
00405   }
00406 
00407   internalResize(widest + _bevel_width * 2, height);
00408 }

int otk::Widget::bevelWidth void    const [inline]
 

Definition at line 111 of file widget.hh.

References _bevel_width.

00111 { return _bevel_width; }

const RenderColor* otk::Widget::borderColor void    const [inline]
 

Definition at line 84 of file widget.hh.

References _bcolor.

Referenced by otk::FocusWidget::FocusWidget().

00084 { return _bcolor; }

int otk::Widget::borderWidth void    const [inline]
 

Definition at line 90 of file widget.hh.

References _bwidth.

00090 { return _bwidth; }

const WidgetList& otk::Widget::children void    const [inline]
 

Definition at line 44 of file widget.hh.

References _children.

00044 { return _children; }

void otk::Widget::configureHandler const XConfigureEvent &    e [virtual]
 

Called when the window as been reconfigured.

Reimplemented from otk::EventHandler.

Definition at line 490 of file widget.cc.

References _dirty, _ignore_config, _rect, otk::Rect::height(), height(), otk::Rect::setSize(), update(), otk::Rect::width(), and width().

00491 {
00492   EventHandler::configureHandler(e);
00493 
00494   if (_ignore_config) {
00495     _ignore_config--;
00496   } else {
00497     int width = e.width;
00498     int height = e.height;
00499 
00500     XEvent ev;
00501     while (XCheckTypedWindowEvent(**display, _window, ConfigureNotify, &ev)) {
00502       width = ev.xconfigure.width;
00503       height = ev.xconfigure.height;
00504     }
00505 
00506     if (!(width == _rect.width() && height == _rect.height())) {
00507       _dirty = true;
00508       _rect.setSize(width, height);
00509     }
00510     update();
00511   }
00512 }

void otk::Widget::create bool    override_redirect = false [protected, virtual]
 

Definition at line 75 of file widget.cc.

References _cursor, _ignore_config, _parent, _rect, _window, otk::ScreenInfo::colormap(), otk::ScreenInfo::depth(), otk::display, otk::Rect::height(), otk::ScreenInfo::rootWindow(), otk::Display::screenInfo(), otk::Rect::setRect(), otk::ScreenInfo::visual(), otk::Rect::width(), window(), otk::Rect::x(), and otk::Rect::y().

Referenced by Widget().

00076 {
00077   const ScreenInfo *scr_info = display->screenInfo(_screen);
00078   Window p_window = _parent ? _parent->window() : scr_info->rootWindow();
00079 
00080   _rect.setRect(0, 0, 1, 1); // just some initial values
00081 
00082   XSetWindowAttributes attrib_create;
00083   unsigned long create_mask = CWBackPixmap | CWBorderPixel | CWEventMask;
00084 
00085   attrib_create.background_pixmap = None;
00086   attrib_create.colormap = scr_info->colormap();
00087   attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask |
00088     ButtonMotionMask | ExposureMask | StructureNotifyMask;
00089 
00090   if (override_redirect) {
00091     create_mask |= CWOverrideRedirect;
00092     attrib_create.override_redirect = true;
00093   }
00094 
00095   if (_cursor) {
00096     create_mask |= CWCursor;
00097     attrib_create.cursor = _cursor;
00098   }
00099 
00100   _window = XCreateWindow(**display, p_window, _rect.x(),
00101                           _rect.y(), _rect.width(), _rect.height(), 0,
00102                           scr_info->depth(), InputOutput,
00103                           scr_info->visual(), create_mask, &attrib_create);
00104   _ignore_config++;
00105 }

Cursor otk::Widget::cursor void    const [inline]
 

Definition at line 105 of file widget.hh.

References _cursor.

00105 { return _cursor; }

Direction otk::Widget::direction void    const [inline]
 

Definition at line 115 of file widget.hh.

References _direction, and Direction.

00115 { return _direction; }

EventDispatcher* otk::Widget::eventDispatcher void    [inline]
 

Definition at line 121 of file widget.hh.

References _event_dispatcher.

00122     { return _event_dispatcher; }

void otk::Widget::exposeHandler const XExposeEvent &    e [virtual]
 

Called when a window becomes visible to the user.

Reimplemented from otk::EventHandler.

Definition at line 484 of file widget.cc.

00485 {
00486   EventHandler::exposeHandler(e);
00487 //  XClearArea(**display, _window, e.x, e.y, e.width, e.height, false);
00488 }

void otk::Widget::focus void    [virtual]
 

Reimplemented in ob::BackgroundWidget, ob::ButtonWidget, ob::Frame, ob::LabelWidget, and otk::FocusWidget.

Definition at line 208 of file widget.cc.

References _children, and _focused.

Referenced by ob::LabelWidget::focus(), ob::Frame::focus(), ob::ButtonWidget::focus(), and ob::BackgroundWidget::focus().

00209 {
00210   _focused = true;
00211   
00212   Widget::WidgetList::iterator it = _children.begin(),
00213     end = _children.end();
00214   for (; it != end; ++it)
00215     (*it)->focus();
00216 }

bool otk::Widget::grabKeyboard void   
 

Definition at line 249 of file widget.cc.

References _grabbed_keyboard.

00250 {
00251   Status ret = XGrabKeyboard(**display, _window, True,
00252                              GrabModeSync, GrabModeAsync, CurrentTime);
00253   _grabbed_keyboard = (ret == GrabSuccess);
00254   return _grabbed_keyboard;
00255 
00256 }

bool otk::Widget::grabMouse void   
 

Definition at line 228 of file widget.cc.

References _grabbed_mouse.

00229 {
00230   Status ret = XGrabPointer(**display, _window, True,
00231                             (ButtonPressMask | ButtonReleaseMask |
00232                              ButtonMotionMask | EnterWindowMask |
00233                              LeaveWindowMask | PointerMotionMask),
00234                             GrabModeSync, GrabModeAsync, None, None,
00235                             CurrentTime);
00236   _grabbed_mouse = (ret == GrabSuccess);
00237   return _grabbed_mouse;
00238 }

bool otk::Widget::hasGrabbedKeyboard void    const [inline]
 

Definition at line 76 of file widget.hh.

References _grabbed_keyboard.

00076 { return _grabbed_keyboard; }

bool otk::Widget::hasGrabbedMouse void    const [inline]
 

Definition at line 72 of file widget.hh.

References _grabbed_mouse.

00072 { return _grabbed_mouse; }

virtual int otk::Widget::height void    const [inline, virtual]
 

Definition at line 55 of file widget.hh.

References _rect, and otk::Rect::height().

Referenced by ob::Frame::adjustShape(), ob::Frame::adjustSize(), adjustVert(), and configureHandler().

00055 { return _rect.height(); }

void otk::Widget::hide bool    recursive = false [virtual]
 

Definition at line 193 of file widget.cc.

References _children, and _visible.

Referenced by ob::Frame::adjustSize(), ob::Client::setDesktop(), ob::Screen::unmanageWindow(), and ~Widget().

00194 {
00195   if (! _visible)
00196     return;
00197 
00198   if (recursive) {
00199     WidgetList::iterator it = _children.begin(), end = _children.end();
00200     for (; it != end; ++it)
00201       (*it)->hide();
00202   }
00203   
00204   XUnmapWindow(**display, _window);
00205   _visible = false;
00206 }

void otk::Widget::internalResize int    width,
int    height
[protected, virtual]
 

Definition at line 425 of file widget.cc.

References _fixed_height, _fixed_width, _rect, otk::Rect::height(), resize(), and otk::Rect::width().

Referenced by adjustHorz(), adjustVert(), otk::Label::update(), and otk::FocusLabel::update().

00426 {
00427   assert(w > 0 && h > 0);
00428 
00429   bool fw = _fixed_width, fh = _fixed_height;
00430   
00431   if (! fw && ! fh)
00432     resize(w, h);
00433   else if (! fw)
00434     resize(w, _rect.height());
00435   else if (! fh)
00436     resize(_rect.width(), h);
00437 
00438   _fixed_width = fw;
00439   _fixed_height = fh;
00440 }

bool otk::Widget::isFocused void    const [inline]
 

Reimplemented in otk::FocusWidget.

Definition at line 68 of file widget.hh.

References _focused.

00068 { return _focused; };

bool otk::Widget::isStretchableHorz void    const [inline]
 

Definition at line 99 of file widget.hh.

References _stretchable_horz.

Referenced by adjustHorz(), and adjustVert().

00099 { return _stretchable_horz; }

bool otk::Widget::isStretchableVert void    const [inline]
 

Definition at line 102 of file widget.hh.

References _stretchable_vert.

Referenced by adjustHorz(), and adjustVert().

00102 { return _stretchable_vert; }

bool otk::Widget::isVisible void    const [inline]
 

Definition at line 64 of file widget.hh.

References _visible.

Referenced by ob::Client::focus().

00064 { return _visible; };

void otk::Widget::move int    x,
int    y
 

Definition at line 126 of file widget.cc.

References _ignore_config, _rect, and otk::Rect::setPos().

00127 {
00128   _rect.setPos(x, y);
00129   XMoveWindow(**display, _window, x, y);
00130   _ignore_config++;
00131 }

void otk::Widget::move const Point   to
 

Definition at line 121 of file widget.cc.

References otk::Point::x(), and otk::Point::y().

Referenced by adjustHorz(), ob::Frame::adjustPosition(), ob::Frame::adjustSize(), and adjustVert().

00122 {
00123   move(to.x(), to.y());
00124 }

const Widget* otk::Widget::parent void    const [inline]
 

Definition at line 43 of file widget.hh.

References _parent.

00043 { return _parent; }

const Rect& otk::Widget::rect void    const [inline]
 

Definition at line 46 of file widget.hh.

References _rect.

Referenced by ob::Frame::adjustShape(), ob::Frame::adjustSize(), ob::Client::maximize(), and ob::Client::updateNormalHints().

00046 { return _rect; }

void otk::Widget::removeChild Widget *    child [virtual]
 

Definition at line 451 of file widget.cc.

References _children.

Referenced by ~Widget().

00452 {
00453   assert(child);
00454   WidgetList::iterator it, end = _children.end();
00455   for (it = _children.begin(); it != end; ++it) {
00456     if ((*it) == child)
00457       break;
00458   }
00459 
00460   if (it != _children.end())
00461     _children.erase(it);
00462 }

void otk::Widget::render void    [protected, virtual]
 

Definition at line 267 of file widget.cc.

References _rect, _surface, _texture, otk::display, otk::RenderControl::drawBackground(), otk::Surface::pixmap(), otk::Display::renderControl(), renderForeground(), and otk::Rect::size().

Referenced by update().

00268 {
00269   if (!_texture) {
00270     XSetWindowBackgroundPixmap(**display, _window, ParentRelative);
00271     return;
00272   }
00273 
00274   Surface *s = _surface; // save the current surface
00275   
00276   _surface = new Surface(_screen, _rect.size());
00277   display->renderControl(_screen)->drawBackground(*_surface, *_texture);
00278 
00279   renderForeground(); // for inherited types to render onto the _surface
00280 
00281   XSetWindowBackgroundPixmap(**display, _window, _surface->pixmap());
00282 
00283   if (s)
00284     delete s; // delete the old surface *after* its pixmap isn't in use anymore
00285 }

virtual void otk::Widget::renderForeground void    [inline, protected, virtual]
 

Reimplemented in ob::ButtonWidget, ob::LabelWidget, otk::FocusLabel, and otk::Label.

Definition at line 136 of file widget.hh.

Referenced by render(), ob::LabelWidget::renderForeground(), and ob::ButtonWidget::renderForeground().

00136 {} // for overriding

void otk::Widget::resize int    x,
int    y
[virtual]
 

Definition at line 138 of file widget.cc.

References _fixed_height, _fixed_width, _rect, setGeometry(), otk::Rect::x(), and otk::Rect::y().

00139 {
00140   assert(w > 0 && h > 0);
00141   _fixed_width = _fixed_height = true;
00142   setGeometry(_rect.x(), _rect.y(), w, h);
00143 }

void otk::Widget::resize const Point   to [virtual]
 

Definition at line 133 of file widget.cc.

References otk::Point::x(), and otk::Point::y().

Referenced by ob::Frame::adjustSize(), otk::Label::fitSize(), otk::FocusLabel::fitSize(), internalResize(), and main().

00134 {
00135   resize(to.x(), to.y());
00136 }

unsigned int otk::Widget::screen void    const [inline]
 

Definition at line 45 of file widget.hh.

References _screen.

00045 { return _screen; }

void otk::Widget::setBevelWidth int    bevel_width [inline]
 

Definition at line 112 of file widget.hh.

References _bevel_width.

Referenced by main().

00113     { assert(bevel_width > 0); _bevel_width = bevel_width; }

virtual void otk::Widget::setBorderColor const RenderColor   color [inline, virtual]
 

Reimplemented in otk::FocusWidget.

Definition at line 85 of file widget.hh.

References _bcolor.

Referenced by ob::Frame::setStyle(), ob::ButtonWidget::setStyle(), ob::BackgroundWidget::setStyle(), and ob::BackgroundWidget::setTextures().

00085                                                         {
00086     assert(color); _bcolor = color;
00087     XSetWindowBorder(**display, _window, color->pixel());
00088   }

void otk::Widget::setBorderWidth int    width [inline]
 

Definition at line 91 of file widget.hh.

References _bwidth.

Referenced by ob::Frame::adjustSize().

00091                                  {
00092     _bwidth = width;
00093     XSetWindowBorderWidth(**display, _window, width);
00094   }

void otk::Widget::setCursor Cursor    cursor [inline]
 

Definition at line 106 of file widget.hh.

References _cursor.

Referenced by ob::Frame::Frame().

00106                                 {
00107     _cursor = cursor;
00108     XDefineCursor(**display, _window, _cursor);
00109   }

void otk::Widget::setDirection Direction    dir [inline]
 

Definition at line 116 of file widget.hh.

References _direction.

Referenced by main().

00116 { _direction = dir; }

void otk::Widget::setEventDispatcher EventDispatcher   disp
 

Definition at line 476 of file widget.cc.

References _event_dispatcher, otk::EventDispatcher::clearHandler(), and otk::EventDispatcher::registerHandler().

00477 {
00478   if (_event_dispatcher)
00479     _event_dispatcher->clearHandler(_window);
00480   _event_dispatcher = disp;
00481   _event_dispatcher->registerHandler(_window, this);
00482 }

void otk::Widget::setGeometry int    x,
int    y,
int    width,
int    height
[virtual]
 

Definition at line 155 of file widget.cc.

References _dirty, _ignore_config, _parent, and _rect.

00156 {
00157   _rect = Rect(x, y, width, height);
00158   _dirty = true;
00159 
00160   // make all parents dirty too
00161   Widget *p = _parent;
00162   while (p) {
00163     p->_dirty = true;
00164     p = p->_parent;
00165   }
00166 
00167   // don't use an XMoveResizeWindow here, because it doesn't seem to move
00168   // windows with StaticGravity? This works, that didn't.
00169   XResizeWindow(**display, _window, width, height);
00170   XMoveWindow(**display, _window, x, y);
00171   _ignore_config+=2;
00172 }

void otk::Widget::setGeometry const Point   topleft,
int    width,
int    height
[virtual]
 

Definition at line 150 of file widget.cc.

References setGeometry(), otk::Point::x(), and otk::Point::y().

00151 {
00152   setGeometry(topleft.x(), topleft.y(), width, height);
00153 }

void otk::Widget::setGeometry const Rect   new_geom [virtual]
 

Definition at line 145 of file widget.cc.

References otk::Rect::height(), otk::Rect::width(), otk::Rect::x(), and otk::Rect::y().

Referenced by ob::Frame::adjustSize(), resize(), setGeometry(), setHeight(), and setWidth().

00146 {
00147   setGeometry(new_geom.x(), new_geom.y(), new_geom.width(), new_geom.height());
00148 }

void otk::Widget::setHeight int    [virtual]
 

Definition at line 114 of file widget.cc.

References _fixed_height, _rect, setGeometry(), otk::Rect::width(), otk::Rect::x(), and otk::Rect::y().

Referenced by adjustHorz(), and main().

00115 {
00116   assert(h > 0);
00117   _fixed_height = true;
00118   setGeometry(_rect.x(), _rect.y(), _rect.width(), h);
00119 }

void otk::Widget::setStretchableHorz bool    s_horz = true [inline]
 

Definition at line 100 of file widget.hh.

References _stretchable_horz.

Referenced by main().

00100 { _stretchable_horz = s_horz; }

void otk::Widget::setStretchableVert bool    s_vert = true [inline]
 

Definition at line 103 of file widget.hh.

References _stretchable_vert.

Referenced by main().

00103 { _stretchable_vert = s_vert; }

void otk::Widget::setStyle RenderStyle   style [virtual]
 

Reimplemented in ob::BackgroundWidget, ob::ButtonWidget, ob::Frame, ob::LabelWidget, otk::AppWidget, otk::Button, otk::FocusLabel, and otk::Label.

Definition at line 464 of file widget.cc.

References _children, _dirty, and _style.

Referenced by ob::LabelWidget::setStyle(), ob::Frame::setStyle(), and ob::ButtonWidget::setStyle().

00465 {
00466   assert(style);
00467   _style = style;
00468   _dirty = true;
00469 
00470   WidgetList::iterator it, end = _children.end();
00471   for (it = _children.begin(); it != end; ++it)
00472     (*it)->setStyle(style);
00473 }

virtual void otk::Widget::setTexture RenderTexture   texture [inline, virtual]
 

Reimplemented in otk::Button, and otk::FocusWidget.

Definition at line 81 of file widget.hh.

References _dirty, and _texture.

Referenced by main(), otk::Label::setStyle(), otk::AppWidget::setStyle(), ob::LabelWidget::setTextures(), ob::ButtonWidget::setTextures(), and ob::BackgroundWidget::setTextures().

00082     { _texture = texture; _dirty = true; }

void otk::Widget::setWidth int    [virtual]
 

Definition at line 107 of file widget.cc.

References _fixed_width, _rect, otk::Rect::height(), setGeometry(), otk::Rect::x(), and otk::Rect::y().

Referenced by ob::Frame::adjustSize(), adjustVert(), and main().

00108 {
00109   assert(w > 0);
00110   _fixed_width = true;  
00111   setGeometry(_rect.x(), _rect.y(), w, _rect.height());
00112 }

void otk::Widget::show bool    recursive = false [virtual]
 

Definition at line 174 of file widget.cc.

References _children, _visible, and update().

Referenced by ob::Frame::adjustSize(), ob::Frame::Frame(), ob::Screen::manageWindow(), and ob::Client::setDesktop().

00175 {
00176   if (_visible)
00177     return;
00178 
00179   // make sure the internal state isn't mangled
00180   if (_dirty)
00181     update();
00182 
00183   if (recursive) {
00184     WidgetList::iterator it = _children.begin(), end = _children.end();
00185     for (; it != end; ++it)
00186       (*it)->show(recursive);
00187   }
00188 
00189   XMapWindow(**display, _window);
00190   _visible = true;
00191 }

RenderStyle* otk::Widget::style void    const [inline]
 

Definition at line 118 of file widget.hh.

References _style.

Referenced by otk::Label::fitSize(), otk::FocusLabel::fitSize(), otk::Label::fitString(), otk::FocusLabel::fitString(), otk::Label::renderForeground(), otk::FocusLabel::renderForeground(), otk::Label::update(), and otk::FocusLabel::update().

00118 { return _style; }

RenderTexture* otk::Widget::texture void    const [inline]
 

Definition at line 80 of file widget.hh.

References _texture.

Referenced by otk::FocusWidget::FocusWidget().

00080 { return _texture; }

void otk::Widget::unfocus void    [virtual]
 

Reimplemented in ob::BackgroundWidget, ob::ButtonWidget, ob::Frame, ob::LabelWidget, and otk::FocusWidget.

Definition at line 218 of file widget.cc.

References _children, and _focused.

Referenced by ob::Frame::Frame(), ob::LabelWidget::unfocus(), ob::Frame::unfocus(), ob::ButtonWidget::unfocus(), and ob::BackgroundWidget::unfocus().

00219 {
00220   _focused = false;
00221   
00222   Widget::WidgetList::iterator it = _children.begin(),
00223     end = _children.end();
00224   for (; it != end; ++it)
00225     (*it)->unfocus();
00226 }

void otk::Widget::ungrabKeyboard void   
 

Definition at line 258 of file widget.cc.

References _grabbed_keyboard.

00259 {
00260   if (! _grabbed_keyboard)
00261     return;
00262 
00263   XUngrabKeyboard(**display, CurrentTime);
00264   _grabbed_keyboard = false;
00265 }

void otk::Widget::ungrabMouse void   
 

Definition at line 240 of file widget.cc.

References _grabbed_mouse.

00241 {
00242   if (! _grabbed_mouse)
00243     return;
00244 
00245   XUngrabPointer(**display, CurrentTime);
00246   _grabbed_mouse = false;
00247 }

void otk::Widget::update   [virtual]
 

Reimplemented in ob::ButtonWidget, otk::FocusLabel, and otk::Label.

Definition at line 410 of file widget.cc.

References _children, _dirty, adjust(), and render().

Referenced by ob::Frame::adjustSize(), configureHandler(), ob::Frame::focus(), otk::FocusWidget::focus(), ob::Frame::setTitle(), show(), ob::Frame::unfocus(), otk::FocusWidget::unfocus(), and ob::ButtonWidget::update().

00411 {
00412   WidgetList::iterator it = _children.begin(), end = _children.end();
00413   for (; it != end; ++it)
00414     (*it)->update();
00415 
00416   if (_dirty) {
00417     adjust();
00418     render();
00419     XClearWindow(**display, _window);
00420   }
00421 
00422   _dirty = false;
00423 }

virtual int otk::Widget::width void    const [inline, virtual]
 

Definition at line 54 of file widget.hh.

References _rect, and otk::Rect::width().

Referenced by adjustHorz(), ob::Frame::adjustShape(), ob::Frame::adjustSize(), configureHandler(), ob::LabelWidget::renderForeground(), ob::ButtonWidget::renderForeground(), otk::Label::renderForeground(), and otk::FocusLabel::renderForeground().

00054 { return _rect.width(); }

Window otk::Widget::window void    const [inline]
 

Definition at line 42 of file widget.hh.

References _window.

Referenced by ob::Frame::adjustShape(), otk::AppWidget::AppWidget(), ob::Frame::button_alldesk(), ob::Frame::button_close(), ob::Frame::button_iconify(), ob::Frame::button_max(), create(), ob::Bindings::grabButton(), ob::Frame::grabClient(), ob::Frame::grip_left(), ob::Frame::grip_right(), ob::Frame::handle(), ob::Frame::label(), ob::Screen::lowerWindow(), ob::Screen::manageWindow(), ob::Frame::plate(), ob::Screen::raiseWindow(), ob::Frame::titlebar(), and ob::Screen::unmanageWindow().

00042 { return _window; }


Member Data Documentation

const RenderColor* otk::Widget::_bcolor [protected]
 

Definition at line 161 of file widget.hh.

Referenced by borderColor(), and setBorderColor().

int otk::Widget::_bevel_width [protected]
 

Definition at line 146 of file widget.hh.

Referenced by adjustHorz(), adjustVert(), bevelWidth(), and setBevelWidth().

unsigned int otk::Widget::_bg_pixel [protected]
 

Definition at line 159 of file widget.hh.

Pixmap otk::Widget::_bg_pixmap [protected]
 

Definition at line 158 of file widget.hh.

unsigned int otk::Widget::_bwidth [protected]
 

Definition at line 162 of file widget.hh.

Referenced by borderWidth(), and setBorderWidth().

WidgetList otk::Widget::_children [protected]
 

Definition at line 141 of file widget.hh.

Referenced by addChild(), adjustHorz(), adjustVert(), children(), focus(), hide(), removeChild(), setStyle(), show(), unfocus(), update(), and ~Widget().

Cursor otk::Widget::_cursor [protected]
 

Definition at line 145 of file widget.hh.

Referenced by create(), cursor(), and setCursor().

Direction otk::Widget::_direction [protected]
 

Definition at line 144 of file widget.hh.

Referenced by adjust(), direction(), and setDirection().

bool otk::Widget::_dirty [protected]
 

Definition at line 127 of file widget.hh.

Referenced by configureHandler(), ob::LabelWidget::renderForeground(), ob::ButtonWidget::renderForeground(), setGeometry(), setStyle(), ob::LabelWidget::setText(), otk::Label::setText(), otk::FocusLabel::setText(), setTexture(), and update().

EventDispatcher* otk::Widget::_event_dispatcher [protected]
 

Definition at line 172 of file widget.hh.

Referenced by eventDispatcher(), setEventDispatcher(), Widget(), and ~Widget().

bool otk::Widget::_fixed_height [protected]
 

Definition at line 168 of file widget.hh.

Referenced by internalResize(), resize(), setHeight(), otk::Label::update(), and otk::FocusLabel::update().

bool otk::Widget::_fixed_width [protected]
 

Definition at line 167 of file widget.hh.

Referenced by internalResize(), resize(), setWidth(), otk::Label::update(), and otk::FocusLabel::update().

bool otk::Widget::_focused [protected]
 

Definition at line 128 of file widget.hh.

Referenced by focus(), otk::FocusWidget::FocusWidget(), isFocused(), otk::FocusWidget::isFocused(), otk::FocusWidget::isUnfocused(), ob::ButtonWidget::renderForeground(), unfocus(), and otk::FocusWidget::unfocus().

bool otk::Widget::_grabbed_keyboard [protected]
 

Definition at line 152 of file widget.hh.

Referenced by grabKeyboard(), hasGrabbedKeyboard(), and ungrabKeyboard().

bool otk::Widget::_grabbed_mouse [protected]
 

Definition at line 151 of file widget.hh.

Referenced by grabMouse(), hasGrabbedMouse(), and ungrabMouse().

int otk::Widget::_ignore_config [protected]
 

Definition at line 147 of file widget.hh.

Referenced by configureHandler(), create(), move(), and setGeometry().

Widget* otk::Widget::_parent [protected]
 

Definition at line 140 of file widget.hh.

Referenced by create(), parent(), setGeometry(), and ~Widget().

Rect otk::Widget::_rect [protected]
 

Definition at line 164 of file widget.hh.

Referenced by adjustHorz(), adjustVert(), configureHandler(), create(), height(), internalResize(), move(), rect(), render(), ob::ButtonWidget::renderForeground(), resize(), setGeometry(), setHeight(), setWidth(), otk::Label::update(), otk::FocusLabel::update(), and width().

unsigned int otk::Widget::_screen [protected]
 

Reimplemented in ob::Frame.

Definition at line 165 of file widget.hh.

Referenced by screen().

bool otk::Widget::_stretchable_horz [protected]
 

Definition at line 155 of file widget.hh.

Referenced by isStretchableHorz(), and setStretchableHorz().

bool otk::Widget::_stretchable_vert [protected]
 

Definition at line 154 of file widget.hh.

Referenced by isStretchableVert(), and setStretchableVert().

RenderStyle* otk::Widget::_style [protected]
 

Definition at line 143 of file widget.hh.

Referenced by ob::Frame::adjustShape(), ob::Frame::adjustSize(), ob::Frame::Frame(), ob::ButtonWidget::renderForeground(), ob::ButtonWidget::setStyle(), ob::BackgroundWidget::setStyle(), setStyle(), ob::LabelWidget::setTextures(), ob::ButtonWidget::setTextures(), ob::BackgroundWidget::setTextures(), and style().

Surface* otk::Widget::_surface [protected]
 

Definition at line 170 of file widget.hh.

Referenced by render(), ob::LabelWidget::renderForeground(), ob::ButtonWidget::renderForeground(), and ~Widget().

RenderTexture* otk::Widget::_texture [protected]
 

Definition at line 157 of file widget.hh.

Referenced by render(), setTexture(), and texture().

bool otk::Widget::_visible [protected]
 

Definition at line 149 of file widget.hh.

Referenced by hide(), isVisible(), and show().

Window otk::Widget::_window [protected]
 

Definition at line 138 of file widget.hh.

Referenced by create(), and window().


The documentation for this class was generated from the following files:
Generated on Tue Feb 4 23:00:31 2003 for Openbox by doxygen1.3-rc2