api cleanups
This commit is contained in:
parent
711d4a342f
commit
723739dafe
7 changed files with 42 additions and 42 deletions
|
@ -27,7 +27,7 @@ OtkAppWidget::OtkAppWidget(OtkApplication *app, Direction direction,
|
|||
Atom protocols[2];
|
||||
protocols[0] = _wm_protocols;
|
||||
protocols[1] = _wm_delete;
|
||||
XSetWMProtocols(OBDisplay::display, getWindow(), protocols, 2);
|
||||
XSetWMProtocols(OBDisplay::display, window(), protocols, 2);
|
||||
}
|
||||
|
||||
OtkAppWidget::~OtkAppWidget()
|
||||
|
|
|
@ -23,10 +23,10 @@ void OtkButton::setStyle(Style *style)
|
|||
{
|
||||
OtkFocusLabel::setStyle(style);
|
||||
|
||||
setTexture(getStyle()->getButtonFocus());
|
||||
setUnfocusTexture(getStyle()->getButtonUnfocus());
|
||||
_pressed_focus_tx = getStyle()->getButtonPressedFocus();
|
||||
_pressed_unfocus_tx = getStyle()->getButtonPressedUnfocus();
|
||||
setTexture(style->getButtonFocus());
|
||||
setUnfocusTexture(style->getButtonUnfocus());
|
||||
_pressed_focus_tx = style->getButtonPressedFocus();
|
||||
_pressed_unfocus_tx = style->getButtonPressedUnfocus();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ namespace otk {
|
|||
OtkFocusLabel::OtkFocusLabel(OtkWidget *parent)
|
||||
: OtkFocusWidget(parent), _text("")
|
||||
{
|
||||
const ScreenInfo *info = OBDisplay::screenInfo(getScreen());
|
||||
_xftdraw = XftDrawCreate(OBDisplay::display, getWindow(), info->getVisual(),
|
||||
const ScreenInfo *info = OBDisplay::screenInfo(screen());
|
||||
_xftdraw = XftDrawCreate(OBDisplay::display, window(), info->getVisual(),
|
||||
info->getColormap());
|
||||
}
|
||||
|
||||
|
@ -28,18 +28,18 @@ void OtkFocusLabel::setStyle(Style *style)
|
|||
{
|
||||
OtkFocusWidget::setStyle(style);
|
||||
|
||||
setTexture(getStyle()->getLabelFocus());
|
||||
setUnfocusTexture(getStyle()->getLabelUnfocus());
|
||||
setTexture(style->getLabelFocus());
|
||||
setUnfocusTexture(style->getLabelUnfocus());
|
||||
}
|
||||
|
||||
|
||||
void OtkFocusLabel::update(void)
|
||||
{
|
||||
if (_dirty) {
|
||||
const BFont &ft = getStyle()->getFont();
|
||||
BColor *text_color = (isFocused() ? getStyle()->getTextFocus()
|
||||
: getStyle()->getTextUnfocus());
|
||||
unsigned int sidemargin = getStyle()->getBevelWidth() * 2;
|
||||
const BFont &ft = style()->getFont();
|
||||
BColor *text_color = (isFocused() ? style()->getTextFocus()
|
||||
: style()->getTextUnfocus());
|
||||
unsigned int sidemargin = style()->getBevelWidth() * 2;
|
||||
|
||||
std::string t = _text; // the actual text to draw
|
||||
int x = sidemargin; // x coord for the text
|
||||
|
@ -58,7 +58,7 @@ void OtkFocusLabel::update(void)
|
|||
} while (length > max_length && text_len-- > 0);
|
||||
|
||||
// justify the text
|
||||
switch (getStyle()->textJustify()) {
|
||||
switch (style()->textJustify()) {
|
||||
case Style::RightJustify:
|
||||
x += max_length - length;
|
||||
break;
|
||||
|
|
|
@ -12,8 +12,8 @@ OtkFocusWidget::OtkFocusWidget(OtkWidget *parent, Direction direction)
|
|||
: OtkWidget(parent, direction), _unfocus_texture(0), _unfocus_bcolor(0)
|
||||
{
|
||||
_focused = true;
|
||||
_focus_texture = parent->getTexture();
|
||||
_focus_bcolor = parent->getBorderColor();
|
||||
_focus_texture = parent->texture();
|
||||
_focus_bcolor = parent->borderColor();
|
||||
}
|
||||
|
||||
OtkFocusWidget::~OtkFocusWidget()
|
||||
|
@ -50,7 +50,7 @@ void OtkFocusWidget::unfocus(void)
|
|||
OtkWidget::setTexture(_unfocus_texture);
|
||||
OtkWidget::update();
|
||||
|
||||
OtkWidget::OtkWidgetList children = OtkWidget::getChildren();
|
||||
OtkWidget::OtkWidgetList children = OtkWidget::children();
|
||||
|
||||
OtkWidget::OtkWidgetList::iterator it = children.begin(),
|
||||
end = children.end();
|
||||
|
|
14
otk/label.cc
14
otk/label.cc
|
@ -11,8 +11,8 @@ namespace otk {
|
|||
OtkLabel::OtkLabel(OtkWidget *parent)
|
||||
: OtkWidget(parent), _text("")
|
||||
{
|
||||
const ScreenInfo *info = OBDisplay::screenInfo(getScreen());
|
||||
_xftdraw = XftDrawCreate(OBDisplay::display, getWindow(), info->getVisual(),
|
||||
const ScreenInfo *info = OBDisplay::screenInfo(screen());
|
||||
_xftdraw = XftDrawCreate(OBDisplay::display, window(), info->getVisual(),
|
||||
info->getColormap());
|
||||
}
|
||||
|
||||
|
@ -25,15 +25,15 @@ void OtkLabel::setStyle(Style *style)
|
|||
{
|
||||
OtkWidget::setStyle(style);
|
||||
|
||||
setTexture(getStyle()->getLabelUnfocus());
|
||||
setTexture(style->getLabelUnfocus());
|
||||
}
|
||||
|
||||
|
||||
void OtkLabel::update(void)
|
||||
{
|
||||
if (_dirty) {
|
||||
const BFont &ft = getStyle()->getFont();
|
||||
unsigned int sidemargin = getStyle()->getBevelWidth() * 2;
|
||||
const BFont &ft = style()->getFont();
|
||||
unsigned int sidemargin = style()->getBevelWidth() * 2;
|
||||
|
||||
std::string t = _text; // the actual text to draw
|
||||
int x = sidemargin; // x coord for the text
|
||||
|
@ -52,7 +52,7 @@ void OtkLabel::update(void)
|
|||
} while (length > max_length && text_len-- > 0);
|
||||
|
||||
// justify the text
|
||||
switch (getStyle()->textJustify()) {
|
||||
switch (style()->textJustify()) {
|
||||
case Style::RightJustify:
|
||||
x += max_length - length;
|
||||
break;
|
||||
|
@ -66,7 +66,7 @@ void OtkLabel::update(void)
|
|||
|
||||
OtkWidget::update();
|
||||
|
||||
ft.drawString(_xftdraw, x, 0, *getStyle()->getTextUnfocus(), t);
|
||||
ft.drawString(_xftdraw, x, 0, *style()->getTextUnfocus(), t);
|
||||
} else
|
||||
OtkWidget::update();
|
||||
}
|
||||
|
|
|
@ -17,14 +17,14 @@ namespace otk {
|
|||
OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
|
||||
: OtkEventHandler(),
|
||||
_dirty(false), _focused(false),
|
||||
_parent(parent), _style(parent->getStyle()), _direction(direction),
|
||||
_cursor(parent->getCursor()), _bevel_width(parent->getBevelWidth()),
|
||||
_parent(parent), _style(parent->style()), _direction(direction),
|
||||
_cursor(parent->cursor()), _bevel_width(parent->bevelWidth()),
|
||||
_ignore_config(0),
|
||||
_visible(false), _grabbed_mouse(false),
|
||||
_grabbed_keyboard(false), _stretchable_vert(false),
|
||||
_stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0),
|
||||
_bcolor(0), _bwidth(0), _screen(parent->getScreen()), _fixed_width(false),
|
||||
_fixed_height(false), _event_dispatcher(parent->getEventDispatcher())
|
||||
_bcolor(0), _bwidth(0), _screen(parent->screen()), _fixed_width(false),
|
||||
_fixed_height(false), _event_dispatcher(parent->eventDispatcher())
|
||||
{
|
||||
assert(parent);
|
||||
parent->addChild(this);
|
||||
|
@ -70,7 +70,7 @@ OtkWidget::~OtkWidget()
|
|||
void OtkWidget::create(void)
|
||||
{
|
||||
const ScreenInfo *scr_info = otk::OBDisplay::screenInfo(_screen);
|
||||
Window p_window = _parent ? _parent->getWindow() : scr_info->getRootWindow();
|
||||
Window p_window = _parent ? _parent->window() : scr_info->getRootWindow();
|
||||
|
||||
_rect.setRect(0, 0, 1, 1); // just some initial values
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@ public:
|
|||
void exposeHandler(const XExposeEvent &e);
|
||||
void configureHandler(const XConfigureEvent &e);
|
||||
|
||||
inline Window getWindow(void) const { return _window; }
|
||||
inline const OtkWidget *getParent(void) const { return _parent; }
|
||||
inline const OtkWidgetList &getChildren(void) const { return _children; }
|
||||
inline unsigned int getScreen(void) const { return _screen; }
|
||||
inline const Rect &getRect(void) const { return _rect; }
|
||||
inline Window window(void) const { return _window; }
|
||||
inline const OtkWidget *parent(void) const { return _parent; }
|
||||
inline const OtkWidgetList &children(void) const { return _children; }
|
||||
inline unsigned int screen(void) const { return _screen; }
|
||||
inline const Rect &rect(void) const { return _rect; }
|
||||
|
||||
void move(const Point &to);
|
||||
void move(int x, int y);
|
||||
|
@ -75,17 +75,17 @@ public:
|
|||
bool grabKeyboard(void);
|
||||
void ungrabKeyboard(void);
|
||||
|
||||
inline BTexture *getTexture(void) const { return _texture; }
|
||||
inline BTexture *texture(void) const { return _texture; }
|
||||
virtual void setTexture(BTexture *texture)
|
||||
{ _texture = texture; _dirty = true; }
|
||||
|
||||
inline const BColor *getBorderColor(void) const { return _bcolor; }
|
||||
inline const BColor *borderColor(void) const { return _bcolor; }
|
||||
virtual void setBorderColor(const BColor *color) {
|
||||
assert(color); _bcolor = color;
|
||||
XSetWindowBorder(OBDisplay::display, _window, color->pixel());
|
||||
}
|
||||
|
||||
inline int getBorderWidth(void) const { return _bwidth; }
|
||||
inline int borderWidth(void) const { return _bwidth; }
|
||||
void setBorderWidth(int width) {
|
||||
_bwidth = width;
|
||||
XSetWindowBorderWidth(OBDisplay::display, _window, width);
|
||||
|
@ -100,23 +100,23 @@ public:
|
|||
inline bool isStretchableVert(void) const { return _stretchable_vert; }
|
||||
void setStretchableVert(bool s_vert = true) { _stretchable_vert = s_vert; }
|
||||
|
||||
inline Cursor getCursor(void) const { return _cursor; }
|
||||
inline Cursor cursor(void) const { return _cursor; }
|
||||
void setCursor(Cursor cursor) {
|
||||
_cursor = cursor;
|
||||
XDefineCursor(OBDisplay::display, _window, _cursor);
|
||||
}
|
||||
|
||||
inline int getBevelWidth(void) const { return _bevel_width; }
|
||||
inline int bevelWidth(void) const { return _bevel_width; }
|
||||
void setBevelWidth(int bevel_width)
|
||||
{ assert(bevel_width > 0); _bevel_width = bevel_width; }
|
||||
|
||||
inline Direction getDirection(void) const { return _direction; }
|
||||
inline Direction direction(void) const { return _direction; }
|
||||
void setDirection(Direction dir) { _direction = dir; }
|
||||
|
||||
inline Style *getStyle(void) const { return _style; }
|
||||
inline Style *style(void) const { return _style; }
|
||||
virtual void setStyle(Style *style);
|
||||
|
||||
inline OtkEventDispatcher *getEventDispatcher(void)
|
||||
inline OtkEventDispatcher *eventDispatcher(void)
|
||||
{ return _event_dispatcher; }
|
||||
void setEventDispatcher(OtkEventDispatcher *disp);
|
||||
|
||||
|
|
Loading…
Reference in a new issue