rm prefixes for all elements in the otk namepsace

This commit is contained in:
Dana Jansens 2003-01-11 19:17:13 +00:00
parent 684405eec8
commit 8f8acc2493
49 changed files with 877 additions and 16528 deletions

View file

@ -18,37 +18,37 @@ extern "C" {
namespace otk {
OtkApplication::OtkApplication(int argc, char **argv)
: OtkEventDispatcher(),
Application::Application(int argc, char **argv)
: EventDispatcher(),
_dockable(false),
_appwidget_count(0)
{
argc = argc;
argv = argv;
(void)argc;
(void)argv;
OBDisplay::initialize(0);
Display::initialize(0);
const ScreenInfo *s_info =
OBDisplay::screenInfo(DefaultScreen(OBDisplay::display));
Display::screenInfo(DefaultScreen(Display::display));
_timer_manager = new OBTimerQueueManager();
_img_ctrl = new BImageControl(_timer_manager, s_info, True, 4, 5, 200);
_timer_manager = new TimerQueueManager();
_img_ctrl = new ImageControl(_timer_manager, s_info, True, 4, 5, 200);
_style_conf = new Configuration(False);
_style = new Style(_img_ctrl);
loadStyle();
}
OtkApplication::~OtkApplication()
Application::~Application()
{
delete _style_conf;
delete _img_ctrl;
delete _timer_manager;
delete _style;
OBDisplay::destroy();
Display::destroy();
}
void OtkApplication::loadStyle(void)
void Application::loadStyle(void)
{
// find the style name as a property
std::string style = "/usr/local/share/openbox/styles/artwiz";
@ -60,12 +60,12 @@ void OtkApplication::loadStyle(void)
_style->load(*_style_conf);
}
void OtkApplication::run(void)
void Application::run(void)
{
if (_appwidget_count <= 0) {
std::cerr << "ERROR: No main widgets exist. You must create and show() " <<
"an OtkAppWidget for the OtkApplication before calling " <<
"OtkApplication::run().\n";
"an AppWidget for the Application before calling " <<
"Application::run().\n";
::exit(1);
}

View file

@ -1,3 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __application_hh
#define __application_hh
@ -10,14 +11,14 @@
namespace otk {
class OtkAppWidget;
class AppWidget;
class OtkApplication : public OtkEventDispatcher {
class Application : public EventDispatcher {
public:
OtkApplication(int argc, char **argv);
virtual ~OtkApplication();
Application(int argc, char **argv);
virtual ~Application();
virtual void run(void);
// more bummy cool functionality
@ -25,21 +26,21 @@ public:
void setDockable(bool dockable) { _dockable = dockable; }
inline bool isDockable(void) const { return _dockable; }
inline otk::Style *getStyle(void) const { return _style; }
inline Style *getStyle(void) const { return _style; }
// more accessors
private:
void loadStyle(void);
OBTimerQueueManager *_timer_manager;
BImageControl *_img_ctrl;
TimerQueueManager *_timer_manager;
ImageControl *_img_ctrl;
Configuration *_style_conf;
Style *_style;
bool _dockable;
int _appwidget_count;
friend class OtkAppWidget;
friend class AppWidget;
};
}

View file

@ -13,44 +13,44 @@ extern "C" {
namespace otk {
OtkAppWidget::OtkAppWidget(OtkApplication *app, Direction direction,
AppWidget::AppWidget(Application *app, Direction direction,
Cursor cursor, int bevel_width)
: OtkWidget(app, app->getStyle(), direction, cursor, bevel_width),
: Widget(app, app->getStyle(), direction, cursor, bevel_width),
_application(app)
{
assert(app);
_wm_protocols = XInternAtom(OBDisplay::display, "WM_PROTOCOLS", false);
_wm_delete = XInternAtom(OBDisplay::display, "WM_DELETE_WINDOW", false);
_wm_protocols = XInternAtom(Display::display, "WM_PROTOCOLS", false);
_wm_delete = XInternAtom(Display::display, "WM_DELETE_WINDOW", false);
// set WM Protocols on the window
Atom protocols[2];
protocols[0] = _wm_protocols;
protocols[1] = _wm_delete;
XSetWMProtocols(OBDisplay::display, window(), protocols, 2);
XSetWMProtocols(Display::display, window(), protocols, 2);
}
OtkAppWidget::~OtkAppWidget()
AppWidget::~AppWidget()
{
}
void OtkAppWidget::show(void)
void AppWidget::show(void)
{
OtkWidget::show(true);
Widget::show(true);
_application->_appwidget_count++;
}
void OtkAppWidget::hide(void)
void AppWidget::hide(void)
{
OtkWidget::hide();
Widget::hide();
_application->_appwidget_count--;
}
void OtkAppWidget::clientMessageHandler(const XClientMessageEvent &e)
void AppWidget::clientMessageHandler(const XClientMessageEvent &e)
{
OtkEventHandler::clientMessageHandler(e);
EventHandler::clientMessageHandler(e);
if (e.message_type == _wm_protocols &&
static_cast<Atom>(e.data.l[0]) == _wm_delete)
hide();

View file

@ -1,3 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __appwidget_hh
#define __appwidget_hh
@ -5,14 +6,14 @@
namespace otk {
class OtkApplication;
class Application;
class OtkAppWidget : public OtkWidget {
class AppWidget : public Widget {
public:
OtkAppWidget(OtkApplication *app, Direction direction = Horizontal,
AppWidget(Application *app, Direction direction = Horizontal,
Cursor cursor = 0, int bevel_width = 1);
virtual ~OtkAppWidget();
virtual ~AppWidget();
virtual void show(void);
virtual void hide(void);
@ -21,7 +22,7 @@ public:
private:
OtkApplication *_application;
Application *_application;
Atom _wm_protocols;
Atom _wm_delete;
};

View file

@ -1,3 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __assassin_hh
#define __assassin_hh

View file

@ -8,20 +8,20 @@
namespace otk {
OtkButton::OtkButton(OtkWidget *parent)
: OtkFocusLabel(parent), _pressed(false), _pressed_focus_tx(0),
Button::Button(Widget *parent)
: FocusLabel(parent), _pressed(false), _pressed_focus_tx(0),
_pressed_unfocus_tx(0), _unpr_focus_tx(0), _unpr_unfocus_tx(0)
{
}
OtkButton::~OtkButton()
Button::~Button()
{
}
void OtkButton::setStyle(Style *style)
void Button::setStyle(Style *style)
{
OtkFocusLabel::setStyle(style);
FocusLabel::setStyle(style);
setTexture(style->getButtonFocus());
setUnfocusTexture(style->getButtonUnfocus());
@ -30,51 +30,51 @@ void OtkButton::setStyle(Style *style)
}
void OtkButton::press(unsigned int mouse_button)
void Button::press(unsigned int mouse_button)
{
if (_pressed) return;
if (_pressed_focus_tx)
OtkFocusWidget::setTexture(_pressed_focus_tx);
FocusWidget::setTexture(_pressed_focus_tx);
if (_pressed_unfocus_tx)
OtkFocusWidget::setUnfocusTexture(_pressed_unfocus_tx);
FocusWidget::setUnfocusTexture(_pressed_unfocus_tx);
_pressed = true;
_mouse_button = mouse_button;
}
void OtkButton::release(unsigned int mouse_button)
void Button::release(unsigned int mouse_button)
{
if (_mouse_button != mouse_button) return; // wrong button
OtkFocusWidget::setTexture(_unpr_focus_tx);
OtkFocusWidget::setUnfocusTexture(_unpr_unfocus_tx);
FocusWidget::setTexture(_unpr_focus_tx);
FocusWidget::setUnfocusTexture(_unpr_unfocus_tx);
_pressed = false;
}
void OtkButton::setTexture(BTexture *texture)
void Button::setTexture(Texture *texture)
{
OtkFocusWidget::setTexture(texture);
FocusWidget::setTexture(texture);
_unpr_focus_tx = texture;
}
void OtkButton::setUnfocusTexture(BTexture *texture)
void Button::setUnfocusTexture(Texture *texture)
{
OtkFocusWidget::setUnfocusTexture(texture);
FocusWidget::setUnfocusTexture(texture);
_unpr_unfocus_tx = texture;
}
void OtkButton::buttonPressHandler(const XButtonEvent &e)
void Button::buttonPressHandler(const XButtonEvent &e)
{
press(e.button);
update();
OtkFocusWidget::buttonPressHandler(e);
FocusWidget::buttonPressHandler(e);
}
void OtkButton::buttonReleaseHandler(const XButtonEvent &e)
void Button::buttonReleaseHandler(const XButtonEvent &e)
{
release(e.button);
update();
OtkFocusWidget::buttonReleaseHandler(e);
FocusWidget::buttonReleaseHandler(e);
}
}

View file

@ -1,3 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __button_hh
#define __button_hh
@ -5,25 +6,25 @@
namespace otk {
class OtkButton : public OtkFocusLabel {
class Button : public FocusLabel {
public:
OtkButton(OtkWidget *parent);
~OtkButton();
Button(Widget *parent);
~Button();
inline const otk::BTexture *getPressedFocusTexture(void) const
inline const Texture *getPressedFocusTexture(void) const
{ return _pressed_focus_tx; }
void setPressedFocusTexture(otk::BTexture *texture)
void setPressedFocusTexture(Texture *texture)
{ _pressed_focus_tx = texture; }
inline const otk::BTexture *getPressedUnfocusTexture(void) const
inline const Texture *getPressedUnfocusTexture(void) const
{ return _pressed_unfocus_tx; }
void setPressedUnfocusTexture(otk::BTexture *texture)
void setPressedUnfocusTexture(Texture *texture)
{ _pressed_unfocus_tx = texture; }
void setTexture(otk::BTexture *texture);
void setUnfocusTexture(otk::BTexture *texture);
void setTexture(Texture *texture);
void setUnfocusTexture(Texture *texture);
inline bool isPressed(void) const { return _pressed; }
void press(unsigned int mouse_button);
@ -32,18 +33,18 @@ public:
void buttonPressHandler(const XButtonEvent &e);
void buttonReleaseHandler(const XButtonEvent &e);
virtual void setStyle(otk::Style *style);
virtual void setStyle(Style *style);
private:
bool _pressed;
unsigned int _mouse_button;
BTexture *_pressed_focus_tx;
BTexture *_pressed_unfocus_tx;
Texture *_pressed_focus_tx;
Texture *_pressed_unfocus_tx;
BTexture *_unpr_focus_tx;
BTexture *_unpr_unfocus_tx;
Texture *_unpr_focus_tx;
Texture *_unpr_unfocus_tx;
};
}

View file

@ -16,31 +16,31 @@ extern "C" {
namespace otk {
BColor::ColorCache BColor::colorcache;
bool BColor::cleancache = false;
Color::ColorCache Color::colorcache;
bool Color::cleancache = false;
BColor::BColor(unsigned int _screen)
Color::Color(unsigned int _screen)
: allocated(false), r(-1), g(-1), b(-1), p(0), scrn(_screen)
{}
BColor::BColor(int _r, int _g, int _b, unsigned int _screen)
Color::Color(int _r, int _g, int _b, unsigned int _screen)
: allocated(false), r(_r), g(_g), b(_b), p(0), scrn(_screen)
{}
BColor::BColor(const std::string &_name, unsigned int _screen)
Color::Color(const std::string &_name, unsigned int _screen)
: allocated(false), r(-1), g(-1), b(-1), p(0), scrn(_screen),
colorname(_name) {
parseColorName();
}
BColor::~BColor(void) {
Color::~Color(void) {
deallocate();
}
void BColor::setScreen(unsigned int _screen) {
void Color::setScreen(unsigned int _screen) {
if (_screen == screen()) {
// nothing to do
return;
@ -56,10 +56,10 @@ void BColor::setScreen(unsigned int _screen) {
}
unsigned long BColor::pixel(void) const {
unsigned long Color::pixel(void) const {
if (! allocated) {
// mutable
BColor *that = (BColor *) this;
Color *that = (Color *) this;
that->allocate();
}
@ -67,15 +67,15 @@ unsigned long BColor::pixel(void) const {
}
void BColor::parseColorName(void) {
void Color::parseColorName(void) {
if (colorname.empty()) {
fprintf(stderr, "BColor: empty colorname, cannot parse (using black)\n");
fprintf(stderr, "Color: empty colorname, cannot parse (using black)\n");
setRGB(0, 0, 0);
}
if (scrn == ~(0u))
scrn = DefaultScreen(OBDisplay::display);
Colormap colormap = OBDisplay::screenInfo(scrn)->colormap();
scrn = DefaultScreen(Display::display);
Colormap colormap = Display::screenInfo(scrn)->colormap();
// get rgb values from colorname
XColor xcol;
@ -84,9 +84,9 @@ void BColor::parseColorName(void) {
xcol.blue = 0;
xcol.pixel = 0;
if (! XParseColor(OBDisplay::display, colormap,
if (! XParseColor(Display::display, colormap,
colorname.c_str(), &xcol)) {
fprintf(stderr, "BColor::allocate: color parse error: \"%s\"\n",
fprintf(stderr, "Color::allocate: color parse error: \"%s\"\n",
colorname.c_str());
setRGB(0, 0, 0);
return;
@ -96,13 +96,13 @@ void BColor::parseColorName(void) {
}
void BColor::allocate(void) {
if (scrn == ~(0u)) scrn = DefaultScreen(OBDisplay::display);
Colormap colormap = OBDisplay::screenInfo(scrn)->colormap();
void Color::allocate(void) {
if (scrn == ~(0u)) scrn = DefaultScreen(Display::display);
Colormap colormap = Display::screenInfo(scrn)->colormap();
if (! isValid()) {
if (colorname.empty()) {
fprintf(stderr, "BColor: cannot allocate invalid color (using black)\n");
fprintf(stderr, "Color: cannot allocate invalid color (using black)\n");
setRGB(0, 0, 0);
} else {
parseColorName();
@ -127,8 +127,8 @@ void BColor::allocate(void) {
xcol.blue = b | b << 8;
xcol.pixel = 0;
if (! XAllocColor(OBDisplay::display, colormap, &xcol)) {
fprintf(stderr, "BColor::allocate: color alloc error: rgb:%x/%x/%x\n",
if (! XAllocColor(Display::display, colormap, &xcol)) {
fprintf(stderr, "Color::allocate: color alloc error: rgb:%x/%x/%x\n",
r, g, b);
xcol.pixel = 0;
}
@ -143,7 +143,7 @@ void BColor::allocate(void) {
}
void BColor::deallocate(void) {
void Color::deallocate(void) {
if (! allocated)
return;
@ -160,7 +160,7 @@ void BColor::deallocate(void) {
}
BColor &BColor::operator=(const BColor &c) {
Color &Color::operator=(const Color &c) {
deallocate();
setRGB(c.r, c.g, c.b);
@ -170,12 +170,12 @@ BColor &BColor::operator=(const BColor &c) {
}
void BColor::cleanupColorCache(void) {
void Color::cleanupColorCache(void) {
cleancache = true;
}
void BColor::doCacheCleanup(void) {
void Color::doCacheCleanup(void) {
// ### TODO - support multiple displays!
ColorCache::iterator it = colorcache.begin();
if (it == colorcache.end()) {
@ -187,7 +187,7 @@ void BColor::doCacheCleanup(void) {
int i;
unsigned count;
for (i = 0; i < ScreenCount(OBDisplay::display); i++) {
for (i = 0; i < ScreenCount(Display::display); i++) {
count = 0;
it = colorcache.begin();
@ -204,8 +204,8 @@ void BColor::doCacheCleanup(void) {
}
if (count > 0)
XFreeColors(OBDisplay::display,
OBDisplay::screenInfo(i)->colormap(),
XFreeColors(Display::display,
Display::screenInfo(i)->colormap(),
pixels, count, 0);
}

View file

@ -1,6 +1,6 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef COLOR_HH
#define COLOR_HH
#ifndef __color_hh
#define __color_hh
extern "C" {
#include <X11/Xlib.h>
@ -11,12 +11,12 @@ extern "C" {
namespace otk {
class BColor {
class Color {
public:
BColor(unsigned int _screen = ~(0u));
BColor(int _r, int _g, int _b, unsigned int _screen = ~(0u));
BColor(const std::string &_name, unsigned int _screen = ~(0u));
~BColor(void);
Color(unsigned int _screen = ~(0u));
Color(int _r, int _g, int _b, unsigned int _screen = ~(0u));
Color(const std::string &_name, unsigned int _screen = ~(0u));
~Color(void);
inline const std::string &name(void) const { return colorname; }
@ -41,11 +41,11 @@ public:
// operators
#ifndef SWIG
BColor &operator=(const BColor &c);
Color &operator=(const Color &c);
#endif
inline bool operator==(const BColor &c) const
inline bool operator==(const Color &c) const
{ return (r == c.r && b == c.b && b == c.b); }
inline bool operator!=(const BColor &c) const
inline bool operator!=(const Color &c) const
{ return (! operator==(c)); }
static void cleanupColorCache(void);
@ -99,4 +99,4 @@ private:
}
#endif // COLOR_HH
#endif // __color_hh

View file

@ -48,22 +48,22 @@ extern "C" {
namespace otk {
Display *OBDisplay::display = (Display*) 0;
bool OBDisplay::_xkb = false;
int OBDisplay::_xkb_event_basep = 0;
bool OBDisplay::_shape = false;
int OBDisplay::_shape_event_basep = 0;
bool OBDisplay::_xinerama = false;
int OBDisplay::_xinerama_event_basep = 0;
unsigned int OBDisplay::_mask_list[8];
unsigned int OBDisplay::_scrollLockMask = 0;
unsigned int OBDisplay::_numLockMask = 0;
OBDisplay::ScreenInfoList OBDisplay::_screenInfoList;
BGCCache *OBDisplay::_gccache = (BGCCache*) 0;
int OBDisplay::_grab_count = 0;
::Display *Display::display = (::Display*) 0;
bool Display::_xkb = false;
int Display::_xkb_event_basep = 0;
bool Display::_shape = false;
int Display::_shape_event_basep = 0;
bool Display::_xinerama = false;
int Display::_xinerama_event_basep = 0;
unsigned int Display::_mask_list[8];
unsigned int Display::_scrollLockMask = 0;
unsigned int Display::_numLockMask = 0;
Display::ScreenInfoList Display::_screenInfoList;
GCCache *Display::_gccache = (GCCache*) 0;
int Display::_grab_count = 0;
int OBDisplay::xerrorHandler(Display *d, XErrorEvent *e)
int Display::xerrorHandler(::Display *d, XErrorEvent *e)
{
#ifdef DEBUG
char errtxt[128];
@ -84,7 +84,7 @@ int OBDisplay::xerrorHandler(Display *d, XErrorEvent *e)
}
void OBDisplay::initialize(char *name)
void Display::initialize(char *name)
{
int junk;
(void)junk;
@ -166,11 +166,11 @@ line argument.\n\n"));
for (int i = 0; i < ScreenCount(display); ++i)
_screenInfoList.push_back(ScreenInfo(i));
_gccache = new BGCCache(_screenInfoList.size());
_gccache = new GCCache(_screenInfoList.size());
}
void OBDisplay::destroy()
void Display::destroy()
{
delete _gccache;
while (_grab_count > 0)
@ -179,14 +179,14 @@ void OBDisplay::destroy()
}
const ScreenInfo* OBDisplay::screenInfo(int snum) {
const ScreenInfo* Display::screenInfo(int snum) {
assert(snum >= 0);
assert(snum < static_cast<int>(_screenInfoList.size()));
return &_screenInfoList[snum];
}
const ScreenInfo* OBDisplay::findScreen(Window root)
const ScreenInfo* Display::findScreen(Window root)
{
ScreenInfoList::iterator it, end = _screenInfoList.end();
for (it = _screenInfoList.begin(); it != end; ++it)
@ -196,7 +196,7 @@ const ScreenInfo* OBDisplay::findScreen(Window root)
}
void OBDisplay::grab()
void Display::grab()
{
if (_grab_count == 0)
XGrabServer(display);
@ -204,7 +204,7 @@ void OBDisplay::grab()
}
void OBDisplay::ungrab()
void Display::ungrab()
{
if (_grab_count == 0) return;
_grab_count--;
@ -225,7 +225,7 @@ void OBDisplay::ungrab()
* if allow_scroll_lock is true then only the top half of the lock mask
* table is used and scroll lock is ignored. This value defaults to false.
*/
void OBDisplay::grabButton(unsigned int button, unsigned int modifiers,
void Display::grabButton(unsigned int button, unsigned int modifiers,
Window grab_window, bool owner_events,
unsigned int event_mask, int pointer_mode,
int keyboard_mode, Window confine_to,
@ -233,7 +233,7 @@ void OBDisplay::grabButton(unsigned int button, unsigned int modifiers,
unsigned int length = (allow_scroll_lock) ? 8 / 2:
8;
for (size_t cnt = 0; cnt < length; ++cnt)
XGrabButton(otk::OBDisplay::display, button, modifiers | _mask_list[cnt],
XGrabButton(Display::display, button, modifiers | _mask_list[cnt],
grab_window, owner_events, event_mask, pointer_mode,
keyboard_mode, confine_to, cursor);
}
@ -243,14 +243,14 @@ void OBDisplay::grabButton(unsigned int button, unsigned int modifiers,
* Releases the grab on a button, and ungrabs all possible combinations of the
* keyboard lock keys.
*/
void OBDisplay::ungrabButton(unsigned int button, unsigned int modifiers,
void Display::ungrabButton(unsigned int button, unsigned int modifiers,
Window grab_window) {
for (size_t cnt = 0; cnt < 8; ++cnt)
XUngrabButton(otk::OBDisplay::display, button, modifiers | _mask_list[cnt],
XUngrabButton(Display::display, button, modifiers | _mask_list[cnt],
grab_window);
}
void OBDisplay::grabKey(unsigned int keycode, unsigned int modifiers,
void Display::grabKey(unsigned int keycode, unsigned int modifiers,
Window grab_window, bool owner_events,
int pointer_mode, int keyboard_mode,
bool allow_scroll_lock)
@ -258,15 +258,15 @@ void OBDisplay::grabKey(unsigned int keycode, unsigned int modifiers,
unsigned int length = (allow_scroll_lock) ? 8 / 2:
8;
for (size_t cnt = 0; cnt < length; ++cnt)
XGrabKey(otk::OBDisplay::display, keycode, modifiers | _mask_list[cnt],
XGrabKey(Display::display, keycode, modifiers | _mask_list[cnt],
grab_window, owner_events, pointer_mode, keyboard_mode);
}
void OBDisplay::ungrabKey(unsigned int keycode, unsigned int modifiers,
void Display::ungrabKey(unsigned int keycode, unsigned int modifiers,
Window grab_window)
{
for (size_t cnt = 0; cnt < 8; ++cnt)
XUngrabKey(otk::OBDisplay::display, keycode, modifiers | _mask_list[cnt],
XUngrabKey(Display::display, keycode, modifiers | _mask_list[cnt],
grab_window);
}

View file

@ -1,4 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __display_hh
#define __display_hh
@ -11,7 +11,7 @@ extern "C" {
namespace otk {
class ScreenInfo;
class BGCCache;
class GCCache;
//! Manages a single X11 display.
/*!
@ -19,11 +19,11 @@ class BGCCache;
Use the initialize() method to open the display and ready it for use.
Use the destroy() method to close it and clean up the class' data.
*/
class OBDisplay
class Display
{
public:
//! The X display
static Display *display;
static ::Display *display;
//! A List of ScreenInfo instances
typedef std::vector<ScreenInfo> ScreenInfoList;
@ -61,27 +61,27 @@ private:
//! A cache for re-using GCs, used by the drawing objects
/*!
@see BPen
@see BFont
@see BImage
@see BImageControl
@see BTexture
@see Pen
@see Font
@see Image
@see ImageControl
@see Texture
*/
static BGCCache *_gccache;
static GCCache *_gccache;
//! Handles X errors on the display
/*!
Displays the error if compiled for debugging.
*/
static int xerrorHandler(Display *d, XErrorEvent *e);
static int xerrorHandler(::Display *d, XErrorEvent *e);
//! Prevents instantiation of the class
OBDisplay();
Display();
public:
//! Initializes the class, opens the X display
/*!
@see OBDisplay::display
@see Display::display
@param name The name of the X display to open. If it is null, the DISPLAY
environment variable is used instead.
*/
@ -90,7 +90,7 @@ public:
static void destroy();
//! Returns the GC cache for the application
inline static BGCCache *gcCache() { return _gccache; }
inline static GCCache *gcCache() { return _gccache; }
//! Gets information on a specific screen
/*!

View file

@ -10,36 +10,36 @@
namespace otk {
OtkEventDispatcher::OtkEventDispatcher()
EventDispatcher::EventDispatcher()
: _fallback(0), _master(0)
{
}
OtkEventDispatcher::~OtkEventDispatcher()
EventDispatcher::~EventDispatcher()
{
}
void OtkEventDispatcher::clearAllHandlers(void)
void EventDispatcher::clearAllHandlers(void)
{
_map.clear();
}
void OtkEventDispatcher::registerHandler(Window id, OtkEventHandler *handler)
void EventDispatcher::registerHandler(Window id, EventHandler *handler)
{
_map.insert(std::pair<Window, OtkEventHandler*>(id, handler));
_map.insert(std::pair<Window, EventHandler*>(id, handler));
}
void OtkEventDispatcher::clearHandler(Window id)
void EventDispatcher::clearHandler(Window id)
{
_map.erase(id);
}
void OtkEventDispatcher::dispatchEvents(void)
void EventDispatcher::dispatchEvents(void)
{
XEvent e;
while (XPending(OBDisplay::display)) {
XNextEvent(OBDisplay::display, &e);
while (XPending(Display::display)) {
XNextEvent(Display::display, &e);
#if 0//defined(DEBUG)
printf("Event %d window %lx\n", e.type, e.xany.window);
@ -71,17 +71,17 @@ void OtkEventDispatcher::dispatchEvents(void)
case ButtonPress:
case ButtonRelease:
_lasttime = e.xbutton.time;
e.xbutton.state &= ~(LockMask | OBDisplay::numLockMask() |
OBDisplay::scrollLockMask());
e.xbutton.state &= ~(LockMask | Display::numLockMask() |
Display::scrollLockMask());
break;
case KeyPress:
e.xkey.state &= ~(LockMask | OBDisplay::numLockMask() |
OBDisplay::scrollLockMask());
e.xkey.state &= ~(LockMask | Display::numLockMask() |
Display::scrollLockMask());
break;
case MotionNotify:
_lasttime = e.xmotion.time;
e.xmotion.state &= ~(LockMask | OBDisplay::numLockMask() |
OBDisplay::scrollLockMask());
e.xmotion.state &= ~(LockMask | Display::numLockMask() |
Display::scrollLockMask());
break;
case PropertyNotify:
_lasttime = e.xproperty.time;
@ -97,7 +97,7 @@ void OtkEventDispatcher::dispatchEvents(void)
}
}
void OtkEventDispatcher::dispatchFocus(const XEvent &e)
void EventDispatcher::dispatchFocus(const XEvent &e)
{
if (e.type == FocusIn) {
//printf("Got FocusIn!\n");
@ -116,7 +116,7 @@ void OtkEventDispatcher::dispatchFocus(const XEvent &e)
// FocusOut events just make us look for FocusIn events. They are ignored
// otherwise.
XEvent fi;
if (XCheckTypedEvent(OBDisplay::display, FocusIn, &fi)) {
if (XCheckTypedEvent(Display::display, FocusIn, &fi)) {
//printf("Found FocusIn\n");
dispatchFocus(fi);
// dont unfocus the window we just focused!
@ -129,10 +129,10 @@ void OtkEventDispatcher::dispatchFocus(const XEvent &e)
}
}
void OtkEventDispatcher::dispatch(Window win, const XEvent &e)
void EventDispatcher::dispatch(Window win, const XEvent &e)
{
OtkEventHandler *handler = 0;
OtkEventMap::iterator it;
EventHandler *handler = 0;
EventMap::iterator it;
// master gets everything first
if (_master)
@ -157,7 +157,7 @@ void OtkEventDispatcher::dispatch(Window win, const XEvent &e)
xwc.sibling = e.xconfigurerequest.above;
xwc.stack_mode = e.xconfigurerequest.detail;
XConfigureWindow(otk::OBDisplay::display, e.xconfigurerequest.window,
XConfigureWindow(otk::Display::display, e.xconfigurerequest.window,
e.xconfigurerequest.value_mask, &xwc);
} else {
// grab a falback if it exists
@ -168,9 +168,9 @@ void OtkEventDispatcher::dispatch(Window win, const XEvent &e)
handler->handle(e);
}
OtkEventHandler *OtkEventDispatcher::findHandler(Window win)
EventHandler *EventDispatcher::findHandler(Window win)
{
OtkEventMap::iterator it = _map.find(win);
EventMap::iterator it = _map.find(win);
if (it != _map.end())
return it->second;
return 0;

View file

@ -1,3 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __eventdispatcher
#define __eventdispatcher
@ -7,37 +8,37 @@
namespace otk {
typedef std::map<unsigned int, OtkEventHandler *> OtkEventMap;
typedef std::map<unsigned int, EventHandler *> EventMap;
class OtkEventDispatcher {
class EventDispatcher {
public:
OtkEventDispatcher();
virtual ~OtkEventDispatcher();
EventDispatcher();
virtual ~EventDispatcher();
virtual void clearAllHandlers(void);
virtual void registerHandler(Window id, otk::OtkEventHandler *handler);
virtual void registerHandler(Window id, EventHandler *handler);
virtual void clearHandler(Window id);
virtual void dispatchEvents(void);
inline void setFallbackHandler(otk::OtkEventHandler *fallback)
inline void setFallbackHandler(EventHandler *fallback)
{ _fallback = fallback; }
otk::OtkEventHandler *getFallbackHandler(void) const { return _fallback; }
EventHandler *getFallbackHandler(void) const { return _fallback; }
//! Sets an event handler that gets all events for all handlers after
//! any specific handlers have received them
inline void setMasterHandler(otk::OtkEventHandler *master)
inline void setMasterHandler(EventHandler *master)
{ _master = master; }
otk::OtkEventHandler *getMasterHandler(void) const { return _master; }
EventHandler *getMasterHandler(void) const { return _master; }
otk::OtkEventHandler *findHandler(Window win);
EventHandler *findHandler(Window win);
inline Time lastTime() const { return _lasttime; }
private:
OtkEventMap _map;
OtkEventHandler *_fallback;
OtkEventHandler *_master;
EventMap _map;
EventHandler *_fallback;
EventHandler *_master;
//! The time at which the last XEvent with a time was received
Time _lasttime;

View file

@ -9,17 +9,17 @@
namespace otk {
OtkEventHandler::OtkEventHandler()
EventHandler::EventHandler()
{
}
OtkEventHandler::~OtkEventHandler()
EventHandler::~EventHandler()
{
}
void OtkEventHandler::handle(const XEvent &e)
void EventHandler::handle(const XEvent &e)
{
switch(e.type){
case KeyPress:
@ -88,11 +88,11 @@ void OtkEventHandler::handle(const XEvent &e)
return selectionRequestHandler(e.xselectionrequest);
default:
#ifdef SHAPE
if (e.type == otk::OBDisplay::shapeEventBase())
if (e.type == Display::shapeEventBase())
return shapeHandler((*(XShapeEvent*)&e));
#endif // SHAPE
#ifdef XKB
if (e.type == otk::OBDisplay::xkbEventBase())
if (e.type == Display::xkbEventBase())
return xkbHandler((*(XkbEvent*)&e));
#endif // XKB
;
@ -100,7 +100,7 @@ void OtkEventHandler::handle(const XEvent &e)
}
void OtkEventHandler::clientMessageHandler(const XClientMessageEvent &)
void EventHandler::clientMessageHandler(const XClientMessageEvent &)
{
}

View file

@ -1,3 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __eventhandler__hh
#define __eventhandler__hh
@ -16,7 +17,7 @@ extern "C" {
namespace otk {
class OtkEventHandler {
class EventHandler {
public:
//! Dispatches events to one of the other handlers based on their type.
virtual void handle(const XEvent &e);
@ -134,14 +135,14 @@ public:
virtual void xkbHandler(const XkbEvent &) {}
#endif // XKB
virtual ~OtkEventHandler();
virtual ~EventHandler();
protected:
/*! Constructor for the OtkEventHandler class.
This is protected so that OtkEventHandlers can't be instantiated on their
/*! Constructor for the EventHandler class.
This is protected so that EventHandlers can't be instantiated on their
own.
*/
OtkEventHandler();
EventHandler();
private:
};

View file

@ -10,34 +10,34 @@
namespace otk {
OtkFocusLabel::OtkFocusLabel(OtkWidget *parent)
: OtkFocusWidget(parent), _text("")
FocusLabel::FocusLabel(Widget *parent)
: FocusWidget(parent), _text("")
{
const ScreenInfo *info = OBDisplay::screenInfo(screen());
_xftdraw = XftDrawCreate(OBDisplay::display, window(), info->visual(),
const ScreenInfo *info = Display::screenInfo(screen());
_xftdraw = XftDrawCreate(Display::display, window(), info->visual(),
info->colormap());
}
OtkFocusLabel::~OtkFocusLabel()
FocusLabel::~FocusLabel()
{
XftDrawDestroy(_xftdraw);
}
void OtkFocusLabel::setStyle(Style *style)
void FocusLabel::setStyle(Style *style)
{
OtkFocusWidget::setStyle(style);
FocusWidget::setStyle(style);
setTexture(style->getLabelFocus());
setUnfocusTexture(style->getLabelUnfocus());
}
void OtkFocusLabel::update(void)
void FocusLabel::update(void)
{
if (_dirty) {
const BFont *ft = style()->getFont();
BColor *text_color = (isFocused() ? style()->getTextFocus()
const Font *ft = style()->getFont();
Color *text_color = (isFocused() ? style()->getTextFocus()
: style()->getTextUnfocus());
unsigned int sidemargin = style()->getBevelWidth() * 2;
@ -70,11 +70,11 @@ void OtkFocusLabel::update(void)
}
}
OtkFocusWidget::update();
FocusWidget::update();
ft->drawString(_xftdraw, x, 0, *text_color, t);
} else
OtkFocusWidget::update();
FocusWidget::update();
}
}

View file

@ -1,3 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __label_hh
#define __label_hh
@ -6,19 +7,19 @@
namespace otk {
class OtkFocusLabel : public OtkFocusWidget {
class FocusLabel : public FocusWidget {
public:
OtkFocusLabel(OtkWidget *parent);
~OtkFocusLabel();
FocusLabel(Widget *parent);
~FocusLabel();
inline const std::string &getText(void) const { return _text; }
void setText(const std::string &text) { _text = text; _dirty = true; }
void update(void);
virtual void setStyle(otk::Style *style);
virtual void setStyle(Style *style);
private:
//! Object used by Xft to render to the drawable

View file

@ -8,56 +8,56 @@
namespace otk {
OtkFocusWidget::OtkFocusWidget(OtkWidget *parent, Direction direction)
: OtkWidget(parent, direction), _unfocus_texture(0), _unfocus_bcolor(0)
FocusWidget::FocusWidget(Widget *parent, Direction direction)
: Widget(parent, direction), _unfocus_texture(0), _unfocus_bcolor(0)
{
_focused = true;
_focus_texture = parent->texture();
_focus_bcolor = parent->borderColor();
}
OtkFocusWidget::~OtkFocusWidget()
FocusWidget::~FocusWidget()
{
}
#include <stdio.h>
void OtkFocusWidget::focus(void)
void FocusWidget::focus(void)
{
if (_focused)
return;
OtkWidget::focus();
Widget::focus();
if (_focus_bcolor)
OtkWidget::setBorderColor(_focus_bcolor);
Widget::setBorderColor(_focus_bcolor);
OtkWidget::setTexture(_focus_texture);
Widget::setTexture(_focus_texture);
update();
}
void OtkFocusWidget::unfocus(void)
void FocusWidget::unfocus(void)
{
if (!_focused)
return;
OtkWidget::unfocus();
Widget::unfocus();
if (_unfocus_bcolor)
OtkWidget::setBorderColor(_unfocus_bcolor);
Widget::setBorderColor(_unfocus_bcolor);
OtkWidget::setTexture(_unfocus_texture);
Widget::setTexture(_unfocus_texture);
update();
}
void OtkFocusWidget::setTexture(BTexture *texture)
void FocusWidget::setTexture(Texture *texture)
{
OtkWidget::setTexture(texture);
Widget::setTexture(texture);
_focus_texture = texture;
}
void OtkFocusWidget::setBorderColor(const BColor *color)
void FocusWidget::setBorderColor(const Color *color)
{
OtkWidget::setBorderColor(color);
Widget::setBorderColor(color);
_focus_bcolor = color;
}

View file

@ -1,3 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __focuswidget_hh
#define __focuswidget_hh
@ -6,27 +7,27 @@
namespace otk {
class OtkFocusWidget : public OtkWidget {
class FocusWidget : public Widget {
public:
OtkFocusWidget(otk::OtkWidget *parent, Direction = Horizontal);
virtual ~OtkFocusWidget();
FocusWidget(Widget *parent, Direction = Horizontal);
virtual ~FocusWidget();
virtual void focus(void);
virtual void unfocus(void);
virtual void setTexture(otk::BTexture *texture);
virtual void setBorderColor(const otk::BColor *color);
virtual void setTexture(Texture *texture);
virtual void setBorderColor(const Color *color);
inline void setUnfocusTexture(otk::BTexture *texture)
inline void setUnfocusTexture(Texture *texture)
{ _unfocus_texture = texture; }
inline otk::BTexture *getUnfocusTexture(void) const
inline Texture *getUnfocusTexture(void) const
{ return _unfocus_texture; }
inline void setUnfocusBorderColor(const otk::BColor *color)
inline void setUnfocusBorderColor(const Color *color)
{ _unfocus_bcolor = color; }
inline const otk::BColor *getUnfocusBorderColor(void) const
inline const Color *getUnfocusBorderColor(void) const
{ return _unfocus_bcolor; }
inline bool isFocused(void) const { return _focused; }
@ -34,11 +35,11 @@ public:
private:
BTexture *_unfocus_texture;
BTexture *_focus_texture;
Texture *_unfocus_texture;
Texture *_focus_texture;
const BColor *_unfocus_bcolor;
const BColor *_focus_bcolor;
const Color *_unfocus_bcolor;
const Color *_focus_bcolor;
};
}

View file

@ -34,10 +34,10 @@ extern "C" {
namespace otk {
string BFont::_fallback_font = "fixed";
bool BFont::_xft_init = false;
string Font::_fallback_font = "fixed";
bool Font::_xft_init = false;
BFont::BFont(int screen_num, const string &fontstring,
Font::Font(int screen_num, const string &fontstring,
bool shadow, unsigned char offset, unsigned char tint)
: _screen_num(screen_num),
_fontstring(fontstring),
@ -60,14 +60,14 @@ BFont::BFont(int screen_num, const string &fontstring,
_xft_init = true;
}
if ((_xftfont = XftFontOpenName(OBDisplay::display, _screen_num,
if ((_xftfont = XftFontOpenName(Display::display, _screen_num,
_fontstring.c_str())))
return;
printf(_("Unable to load font: %s\n"), _fontstring.c_str());
printf(_("Trying fallback font: %s\n"), _fallback_font.c_str());
if ((_xftfont = XftFontOpenName(OBDisplay::display, _screen_num,
if ((_xftfont = XftFontOpenName(Display::display, _screen_num,
_fallback_font.c_str())))
return;
@ -78,14 +78,14 @@ BFont::BFont(int screen_num, const string &fontstring,
}
BFont::~BFont(void)
Font::~Font(void)
{
if (_xftfont)
XftFontClose(OBDisplay::display, _xftfont);
XftFontClose(Display::display, _xftfont);
}
void BFont::drawString(XftDraw *d, int x, int y, const BColor &color,
void Font::drawString(XftDraw *d, int x, int y, const Color &color,
const string &string, bool utf8) const
{
assert(d);
@ -96,7 +96,7 @@ void BFont::drawString(XftDraw *d, int x, int y, const BColor &color,
c.color.green = 0;
c.color.blue = 0;
c.color.alpha = _tint | _tint << 8; // transparent shadow
c.pixel = BlackPixel(OBDisplay::display, _screen_num);
c.pixel = BlackPixel(Display::display, _screen_num);
if (utf8)
XftDrawStringUtf8(d, &c, _xftfont, x + _offset,
@ -113,7 +113,7 @@ void BFont::drawString(XftDraw *d, int x, int y, const BColor &color,
c.color.green = color.green() | color.green() << 8;
c.color.blue = color.blue() | color.blue() << 8;
c.pixel = color.pixel();
c.color.alpha = 0xff | 0xff << 8; // no transparency in BColor yet
c.color.alpha = 0xff | 0xff << 8; // no transparency in Color yet
if (utf8)
XftDrawStringUtf8(d, &c, _xftfont, x, _xftfont->ascent + y,
@ -126,28 +126,28 @@ void BFont::drawString(XftDraw *d, int x, int y, const BColor &color,
}
unsigned int BFont::measureString(const string &string, bool utf8) const
unsigned int Font::measureString(const string &string, bool utf8) const
{
XGlyphInfo info;
if (utf8)
XftTextExtentsUtf8(OBDisplay::display, _xftfont,
XftTextExtentsUtf8(Display::display, _xftfont,
(FcChar8*)string.c_str(), string.size(), &info);
else
XftTextExtents8(OBDisplay::display, _xftfont,
XftTextExtents8(Display::display, _xftfont,
(FcChar8*)string.c_str(), string.size(), &info);
return info.xOff + (_shadow ? _offset : 0);
}
unsigned int BFont::height(void) const
unsigned int Font::height(void) const
{
return _xftfont->height + (_shadow ? _offset : 0);
}
unsigned int BFont::maxCharWidth(void) const
unsigned int Font::maxCharWidth(void) const
{
return _xftfont->max_advance_width;
}

View file

@ -1,6 +1,6 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
#ifndef __Font_hh
#define __Font_hh
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __font_hh
#define __font_hh
extern "C" {
#include <X11/Xlib.h>
@ -13,12 +13,9 @@ extern "C" {
namespace otk {
class BGCCache;
class BGCCacheItem;
class BColor;
class ScreenInfo;
class Color;
class BFont {
class Font {
/*
* static members
*/
@ -51,9 +48,9 @@ private:
public:
// loads an Xft font
BFont(int screen_num, const std::string &fontstring, bool shadow,
Font(int screen_num, const std::string &fontstring, bool shadow,
unsigned char offset, unsigned char tint);
virtual ~BFont();
virtual ~Font();
inline const std::string &fontstring() const { return _fontstring; }
@ -68,10 +65,10 @@ public:
Be Warned: If you use an XftDraw object and a color, or a font from
different screens, you WILL have unpredictable results! :)
*/
void drawString(XftDraw *d, int x, int y, const BColor &color,
void drawString(XftDraw *d, int x, int y, const Color &color,
const std::string &string, bool utf8 = false) const;
};
}
#endif // __Font_hh
#endif // __font_hh

View file

@ -17,13 +17,13 @@ extern "C" {
namespace otk {
BGCCacheContext::~BGCCacheContext(void) {
GCCacheContext::~GCCacheContext(void) {
if (gc)
XFreeGC(OBDisplay::display, gc);
XFreeGC(Display::display, gc);
}
void BGCCacheContext::set(const BColor &_color,
void GCCacheContext::set(const Color &_color,
const XFontStruct * const _font,
const int _function, const int _subwindow,
int _linewidth) {
@ -44,11 +44,11 @@ void BGCCacheContext::set(const BColor &_color,
fontid = 0;
}
XChangeGC(OBDisplay::display, gc, mask, &gcv);
XChangeGC(Display::display, gc, mask, &gcv);
}
void BGCCacheContext::set(const XFontStruct * const _font) {
void GCCacheContext::set(const XFontStruct * const _font) {
if (! _font) {
fontid = 0;
return;
@ -56,28 +56,28 @@ void BGCCacheContext::set(const XFontStruct * const _font) {
XGCValues gcv;
fontid = gcv.font = _font->fid;
XChangeGC(OBDisplay::display, gc, GCFont, &gcv);
XChangeGC(Display::display, gc, GCFont, &gcv);
}
BGCCache::BGCCache(unsigned int screen_count)
GCCache::GCCache(unsigned int screen_count)
: context_count(128u), cache_size(16u), cache_buckets(8u * screen_count),
cache_total_size(cache_size * cache_buckets) {
contexts = new BGCCacheContext*[context_count];
contexts = new GCCacheContext*[context_count];
unsigned int i;
for (i = 0; i < context_count; i++) {
contexts[i] = new BGCCacheContext();
contexts[i] = new GCCacheContext();
}
cache = new BGCCacheItem*[cache_total_size];
cache = new GCCacheItem*[cache_total_size];
for (i = 0; i < cache_total_size; ++i) {
cache[i] = new BGCCacheItem;
cache[i] = new GCCacheItem;
}
}
BGCCache::~BGCCache(void) {
GCCache::~GCCache(void) {
std::for_each(contexts, contexts + context_count, PointerAssassin());
std::for_each(cache, cache + cache_total_size, PointerAssassin());
delete [] cache;
@ -85,16 +85,16 @@ BGCCache::~BGCCache(void) {
}
BGCCacheContext *BGCCache::nextContext(unsigned int scr) {
Window hd = OBDisplay::screenInfo(scr)->rootWindow();
GCCacheContext *GCCache::nextContext(unsigned int scr) {
Window hd = Display::screenInfo(scr)->rootWindow();
BGCCacheContext *c;
GCCacheContext *c;
for (unsigned int i = 0; i < context_count; ++i) {
c = contexts[i];
if (! c->gc) {
c->gc = XCreateGC(OBDisplay::display, hd, 0, 0);
c->gc = XCreateGC(Display::display, hd, 0, 0);
c->used = false;
c->screen = scr;
}
@ -102,18 +102,18 @@ BGCCacheContext *BGCCache::nextContext(unsigned int scr) {
return c;
}
fprintf(stderr, "BGCCache: context fault!\n");
fprintf(stderr, "GCCache: context fault!\n");
abort();
return (BGCCacheContext*) 0; // not reached
return (GCCacheContext*) 0; // not reached
}
void BGCCache::release(BGCCacheContext *ctx) {
void GCCache::release(GCCacheContext *ctx) {
ctx->used = false;
}
BGCCacheItem *BGCCache::find(const BColor &_color,
GCCacheItem *GCCache::find(const Color &_color,
const XFontStruct * const _font,
int _function, int _subwindow, int _linewidth) {
const unsigned long pixel = _color.pixel();
@ -121,7 +121,7 @@ BGCCacheItem *BGCCache::find(const BColor &_color,
const int key = _color.red() ^ _color.green() ^ _color.blue();
int k = (key % cache_size) * cache_buckets;
unsigned int i = 0; // loop variable
BGCCacheItem *c = cache[ k ], *prev = 0;
GCCacheItem *c = cache[ k ], *prev = 0;
/*
this will either loop cache_buckets times then return/abort or
@ -146,7 +146,7 @@ BGCCacheItem *BGCCache::find(const BColor &_color,
return c;
}
// cache fault!
fprintf(stderr, "BGCCache: cache fault, count: %d, screen: %d, item screen: %d\n", c->count, screen, c->ctx->screen);
fprintf(stderr, "GCCache: cache fault, count: %d, screen: %d, item screen: %d\n", c->count, screen, c->ctx->screen);
abort();
}
@ -172,14 +172,14 @@ BGCCacheItem *BGCCache::find(const BColor &_color,
}
void BGCCache::release(BGCCacheItem *_item) {
void GCCache::release(GCCacheItem *_item) {
_item->count--;
}
void BGCCache::purge(void) {
void GCCache::purge(void) {
for (unsigned int i = 0; i < cache_total_size; ++i) {
BGCCacheItem *d = cache[ i ];
GCCacheItem *d = cache[ i ];
if (d->ctx && d->count == 0) {
release(d->ctx);

View file

@ -1,6 +1,6 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef GCCACHE_HH
#define GCCACHE_HH
#ifndef __gccache_hh
#define __gccache_hh
extern "C" {
#include <X11/Xlib.h>
@ -11,18 +11,18 @@ extern "C" {
namespace otk {
class BGCCacheItem;
class GCCacheItem;
class BGCCacheContext {
class GCCacheContext {
public:
void set(const BColor &_color, const XFontStruct * const _font,
void set(const Color &_color, const XFontStruct * const _font,
const int _function, const int _subwindow, const int _linewidth);
void set(const XFontStruct * const _font);
~BGCCacheContext(void);
~GCCacheContext(void);
private:
BGCCacheContext()
GCCacheContext()
: gc(0), pixel(0ul), fontid(0ul),
function(0), subwindow(0), used(false), screen(~(0u)), linewidth(0) {}
@ -35,47 +35,47 @@ private:
unsigned int screen;
int linewidth;
BGCCacheContext(const BGCCacheContext &_nocopy);
BGCCacheContext &operator=(const BGCCacheContext &_nocopy);
GCCacheContext(const GCCacheContext &_nocopy);
GCCacheContext &operator=(const GCCacheContext &_nocopy);
friend class BGCCache;
friend class BGCCacheItem;
friend class GCCache;
friend class GCCacheItem;
};
class BGCCacheItem {
class GCCacheItem {
public:
inline const GC &gc(void) const { return ctx->gc; }
private:
BGCCacheItem(void) : ctx(0), count(0), hits(0), fault(false) { }
GCCacheItem(void) : ctx(0), count(0), hits(0), fault(false) { }
BGCCacheContext *ctx;
GCCacheContext *ctx;
unsigned int count;
unsigned int hits;
bool fault;
BGCCacheItem(const BGCCacheItem &_nocopy);
BGCCacheItem &operator=(const BGCCacheItem &_nocopy);
GCCacheItem(const GCCacheItem &_nocopy);
GCCacheItem &operator=(const GCCacheItem &_nocopy);
friend class BGCCache;
friend class GCCache;
};
class BGCCache {
class GCCache {
public:
BGCCache(unsigned int screen_count);
~BGCCache(void);
GCCache(unsigned int screen_count);
~GCCache(void);
// cleans up the cache
void purge(void);
BGCCacheItem *find(const BColor &_color, const XFontStruct * const _font = 0,
GCCacheItem *find(const Color &_color, const XFontStruct * const _font = 0,
int _function = GXcopy, int _subwindow = ClipByChildren,
int _linewidth = 0);
void release(BGCCacheItem *_item);
void release(GCCacheItem *_item);
private:
BGCCacheContext *nextContext(unsigned int _screen);
void release(BGCCacheContext *ctx);
GCCacheContext *nextContext(unsigned int _screen);
void release(GCCacheContext *ctx);
// this is closely modelled after the Qt GC cache, but with some of the
// complexity stripped out
@ -83,19 +83,19 @@ private:
const unsigned int cache_size;
const unsigned int cache_buckets;
const unsigned int cache_total_size;
BGCCacheContext **contexts;
BGCCacheItem **cache;
GCCacheContext **contexts;
GCCacheItem **cache;
};
class BPen {
class Pen {
public:
inline BPen(const BColor &_color, const XFontStruct * const _font = 0,
inline Pen(const Color &_color, const XFontStruct * const _font = 0,
int _linewidth = 0, int _function = GXcopy,
int _subwindow = ClipByChildren)
: color(_color), font(_font), linewidth(_linewidth), function(_function),
subwindow(_subwindow), cache(OBDisplay::gcCache()), item(0) { }
subwindow(_subwindow), cache(Display::gcCache()), item(0) { }
inline ~BPen(void) { if (item) cache->release(item); }
inline ~Pen(void) { if (item) cache->release(item); }
inline const GC &gc(void) const {
if (! item) item = cache->find(color, font, function, subwindow,
@ -104,16 +104,16 @@ public:
}
private:
const BColor &color;
const Color &color;
const XFontStruct *font;
int linewidth;
int function;
int subwindow;
mutable BGCCache *cache;
mutable BGCCacheItem *item;
mutable GCCache *cache;
mutable GCCacheItem *item;
};
}
#endif // GCCACHE_HH
#endif // __gccache_hh

View file

@ -19,7 +19,7 @@ using std::min;
namespace otk {
BImage::BImage(BImageControl *c, int w, int h) {
Image::Image(ImageControl *c, int w, int h) {
control = c;
width = (w > 0) ? w : 1;
@ -43,95 +43,95 @@ BImage::BImage(BImageControl *c, int w, int h) {
}
BImage::~BImage(void) {
Image::~Image(void) {
delete [] red;
delete [] green;
delete [] blue;
}
Pixmap BImage::render(const BTexture &texture) {
if (texture.texture() & BTexture::Parent_Relative)
Pixmap Image::render(const Texture &texture) {
if (texture.texture() & Texture::Parent_Relative)
return ParentRelative;
else if (texture.texture() & BTexture::Solid)
else if (texture.texture() & Texture::Solid)
return render_solid(texture);
else if (texture.texture() & BTexture::Gradient)
else if (texture.texture() & Texture::Gradient)
return render_gradient(texture);
return None;
}
Pixmap BImage::render_solid(const BTexture &texture) {
Pixmap pixmap = XCreatePixmap(OBDisplay::display,
Pixmap Image::render_solid(const Texture &texture) {
Pixmap pixmap = XCreatePixmap(Display::display,
control->getDrawable(), width,
height, control->getDepth());
if (pixmap == None) {
fprintf(stderr, "BImage::render_solid: error creating pixmap\n");
fprintf(stderr, "Image::render_solid: error creating pixmap\n");
return None;
}
BPen pen(texture.color());
BPen penlight(texture.lightColor());
BPen penshadow(texture.shadowColor());
Pen pen(texture.color());
Pen penlight(texture.lightColor());
Pen penshadow(texture.shadowColor());
XFillRectangle(OBDisplay::display, pixmap, pen.gc(), 0, 0, width, height);
XFillRectangle(Display::display, pixmap, pen.gc(), 0, 0, width, height);
if (texture.texture() & BTexture::Interlaced) {
BPen peninterlace(texture.colorTo());
if (texture.texture() & Texture::Interlaced) {
Pen peninterlace(texture.colorTo());
for (unsigned int i = 0; i < height; i += 2)
XDrawLine(OBDisplay::display, pixmap, peninterlace.gc(), 0, i, width, i);
XDrawLine(Display::display, pixmap, peninterlace.gc(), 0, i, width, i);
}
int left = 0, top = 0, right = width - 1, bottom = height - 1;
if (texture.texture() & BTexture::Border) {
BPen penborder(texture.borderColor());
XDrawRectangle(OBDisplay::display, pixmap, penborder.gc(),
if (texture.texture() & Texture::Border) {
Pen penborder(texture.borderColor());
XDrawRectangle(Display::display, pixmap, penborder.gc(),
left, top, right, bottom);
}
if (texture.texture() & BTexture::Bevel1) {
if (texture.texture() & BTexture::Raised) {
XDrawLine(OBDisplay::display, pixmap, penshadow.gc(),
if (texture.texture() & Texture::Bevel1) {
if (texture.texture() & Texture::Raised) {
XDrawLine(Display::display, pixmap, penshadow.gc(),
left, bottom, right, bottom);
XDrawLine(OBDisplay::display, pixmap, penshadow.gc(),
XDrawLine(Display::display, pixmap, penshadow.gc(),
right, bottom, right, top);
XDrawLine(OBDisplay::display, pixmap, penlight.gc(),
XDrawLine(Display::display, pixmap, penlight.gc(),
left, top, right, top);
XDrawLine(OBDisplay::display, pixmap, penlight.gc(),
XDrawLine(Display::display, pixmap, penlight.gc(),
left, bottom, left, top);
} else if (texture.texture() & BTexture::Sunken) {
XDrawLine(OBDisplay::display, pixmap, penlight.gc(),
} else if (texture.texture() & Texture::Sunken) {
XDrawLine(Display::display, pixmap, penlight.gc(),
left, bottom, right, bottom);
XDrawLine(OBDisplay::display, pixmap, penlight.gc(),
XDrawLine(Display::display, pixmap, penlight.gc(),
right, bottom, right, top);
XDrawLine(OBDisplay::display, pixmap, penshadow.gc(),
XDrawLine(Display::display, pixmap, penshadow.gc(),
left, top, right, top);
XDrawLine(OBDisplay::display, pixmap, penshadow.gc(),
XDrawLine(Display::display, pixmap, penshadow.gc(),
left, bottom, left, top);
}
} else if (texture.texture() & BTexture::Bevel2) {
if (texture.texture() & BTexture::Raised) {
XDrawLine(OBDisplay::display, pixmap, penshadow.gc(),
} else if (texture.texture() & Texture::Bevel2) {
if (texture.texture() & Texture::Raised) {
XDrawLine(Display::display, pixmap, penshadow.gc(),
left + 1, bottom - 2, right - 2, bottom - 2);
XDrawLine(OBDisplay::display, pixmap, penshadow.gc(),
XDrawLine(Display::display, pixmap, penshadow.gc(),
right - 2, bottom - 2, right - 2, top + 1);
XDrawLine(OBDisplay::display, pixmap, penlight.gc(),
XDrawLine(Display::display, pixmap, penlight.gc(),
left + 1, top + 1, right - 2, top + 1);
XDrawLine(OBDisplay::display, pixmap, penlight.gc(),
XDrawLine(Display::display, pixmap, penlight.gc(),
left + 1, bottom - 2, left + 1, top + 1);
} else if (texture.texture() & BTexture::Sunken) {
XDrawLine(OBDisplay::display, pixmap, penlight.gc(),
} else if (texture.texture() & Texture::Sunken) {
XDrawLine(Display::display, pixmap, penlight.gc(),
left + 1, bottom - 2, right - 2, bottom - 2);
XDrawLine(OBDisplay::display, pixmap, penlight.gc(),
XDrawLine(Display::display, pixmap, penlight.gc(),
right - 2, bottom - 2, right - 2, top + 1);
XDrawLine(OBDisplay::display, pixmap, penshadow.gc(),
XDrawLine(Display::display, pixmap, penshadow.gc(),
left + 1, top + 1, right - 2, top + 1);
XDrawLine(OBDisplay::display, pixmap, penshadow.gc(),
XDrawLine(Display::display, pixmap, penshadow.gc(),
left + 1, bottom - 2, left + 1, top + 1);
}
}
@ -140,38 +140,38 @@ Pixmap BImage::render_solid(const BTexture &texture) {
}
Pixmap BImage::render_gradient(const BTexture &texture) {
Pixmap Image::render_gradient(const Texture &texture) {
bool inverted = False;
interlaced = texture.texture() & BTexture::Interlaced;
interlaced = texture.texture() & Texture::Interlaced;
if (texture.texture() & BTexture::Sunken) {
if (texture.texture() & Texture::Sunken) {
from = texture.colorTo();
to = texture.color();
if (! (texture.texture() & BTexture::Invert)) inverted = True;
if (! (texture.texture() & Texture::Invert)) inverted = True;
} else {
from = texture.color();
to = texture.colorTo();
if (texture.texture() & BTexture::Invert) inverted = True;
if (texture.texture() & Texture::Invert) inverted = True;
}
control->getGradientBuffers(width, height, &xtable, &ytable);
if (texture.texture() & BTexture::Diagonal) dgradient();
else if (texture.texture() & BTexture::Elliptic) egradient();
else if (texture.texture() & BTexture::Horizontal) hgradient();
else if (texture.texture() & BTexture::Pyramid) pgradient();
else if (texture.texture() & BTexture::Rectangle) rgradient();
else if (texture.texture() & BTexture::Vertical) vgradient();
else if (texture.texture() & BTexture::CrossDiagonal) cdgradient();
else if (texture.texture() & BTexture::PipeCross) pcgradient();
if (texture.texture() & Texture::Diagonal) dgradient();
else if (texture.texture() & Texture::Elliptic) egradient();
else if (texture.texture() & Texture::Horizontal) hgradient();
else if (texture.texture() & Texture::Pyramid) pgradient();
else if (texture.texture() & Texture::Rectangle) rgradient();
else if (texture.texture() & Texture::Vertical) vgradient();
else if (texture.texture() & Texture::CrossDiagonal) cdgradient();
else if (texture.texture() & Texture::PipeCross) pcgradient();
if (texture.texture() & BTexture::Bevel1) bevel1();
else if (texture.texture() & BTexture::Bevel2) bevel2();
if (texture.texture() & Texture::Bevel1) bevel1();
else if (texture.texture() & Texture::Bevel2) bevel2();
if (texture.texture() & BTexture::Border) border(texture);
if (texture.texture() & Texture::Border) border(texture);
if (inverted) invert();
@ -246,7 +246,7 @@ void assignPixelData(unsigned int bit_depth, unsigned char **data,
// algorithm: ordered dithering... many many thanks to rasterman
// (raster@rasterman.com) for telling me about this... portions of this
// code is based off of his code in Imlib
void BImage::TrueColorDither(unsigned int bit_depth, int bytes_per_line,
void Image::TrueColorDither(unsigned int bit_depth, int bytes_per_line,
unsigned char *pixel_data) {
unsigned int x, y, dithx, dithy, r, g, b, er, eg, eb, offset;
unsigned char *ppixel_data = pixel_data;
@ -293,7 +293,7 @@ const static unsigned char dither8[8][8] = {
{ 63, 31, 55, 23, 61, 29, 53, 21}
};
void BImage::OrderedPseudoColorDither(int bytes_per_line,
void Image::OrderedPseudoColorDither(int bytes_per_line,
unsigned char *pixel_data) {
unsigned int x, y, dithx, dithy, r, g, b, er, eg, eb, offset;
unsigned long pixel;
@ -330,7 +330,7 @@ void BImage::OrderedPseudoColorDither(int bytes_per_line,
}
#endif
void BImage::PseudoColorDither(int bytes_per_line, unsigned char *pixel_data) {
void Image::PseudoColorDither(int bytes_per_line, unsigned char *pixel_data) {
short *terr,
*rerr = new short[width + 2],
*gerr = new short[width + 2],
@ -423,14 +423,14 @@ void BImage::PseudoColorDither(int bytes_per_line, unsigned char *pixel_data) {
delete [] nberr;
}
XImage *BImage::renderXImage(void) {
XImage *Image::renderXImage(void) {
XImage *image =
XCreateImage(OBDisplay::display,
XCreateImage(Display::display,
control->getVisual(), control->getDepth(), ZPixmap, 0, 0,
width, height, 32, 0);
if (! image) {
fprintf(stderr, "BImage::renderXImage: error creating XImage\n");
fprintf(stderr, "Image::renderXImage: error creating XImage\n");
return (XImage *) 0;
}
@ -525,7 +525,7 @@ XImage *BImage::renderXImage(void) {
}
if (unsupported) {
fprintf(stderr, "BImage::renderXImage: unsupported visual\n");
fprintf(stderr, "Image::renderXImage: unsupported visual\n");
delete [] d;
XDestroyImage(image);
return (XImage *) 0;
@ -537,31 +537,31 @@ XImage *BImage::renderXImage(void) {
}
Pixmap BImage::renderPixmap(void) {
Pixmap Image::renderPixmap(void) {
Pixmap pixmap =
XCreatePixmap(OBDisplay::display,
XCreatePixmap(Display::display,
control->getDrawable(), width, height, control->getDepth());
if (pixmap == None) {
fprintf(stderr, "BImage::renderPixmap: error creating pixmap\n");
fprintf(stderr, "Image::renderPixmap: error creating pixmap\n");
return None;
}
XImage *image = renderXImage();
if (! image) {
XFreePixmap(OBDisplay::display, pixmap);
XFreePixmap(Display::display, pixmap);
return None;
}
if (! image->data) {
XDestroyImage(image);
XFreePixmap(OBDisplay::display, pixmap);
XFreePixmap(Display::display, pixmap);
return None;
}
XPutImage(OBDisplay::display, pixmap,
DefaultGC(OBDisplay::display,
XPutImage(Display::display, pixmap,
DefaultGC(Display::display,
control->getScreenInfo()->screen()),
image, 0, 0, 0, 0, width, height);
@ -576,7 +576,7 @@ Pixmap BImage::renderPixmap(void) {
}
void BImage::bevel1(void) {
void Image::bevel1(void) {
if (width > 2 && height > 2) {
unsigned char *pr = red, *pg = green, *pb = blue;
@ -714,7 +714,7 @@ void BImage::bevel1(void) {
}
void BImage::bevel2(void) {
void Image::bevel2(void) {
if (width > 4 && height > 4) {
unsigned char r, g, b, rr ,gg ,bb, *pr = red + width + 1,
*pg = green + width + 1, *pb = blue + width + 1;
@ -793,7 +793,7 @@ void BImage::bevel2(void) {
}
void BImage::border(const BTexture &texture) {
void Image::border(const Texture &texture) {
if (width < 2 || height < 2) return;
register unsigned int i;
@ -837,7 +837,7 @@ void BImage::border(const BTexture &texture) {
}
void BImage::invert(void) {
void Image::invert(void) {
register unsigned int i, j, wh = (width * height) - 1;
unsigned char tmp;
@ -857,7 +857,7 @@ void BImage::invert(void) {
}
void BImage::dgradient(void) {
void Image::dgradient(void) {
// diagonal gradient code was written by Mike Cole <mike@mydot.com>
// modified for interlacing by Brad Hughes
@ -958,7 +958,7 @@ void BImage::dgradient(void) {
}
void BImage::hgradient(void) {
void Image::hgradient(void) {
float drx, dgx, dbx,
xr = (float) from.red(),
xg = (float) from.green(),
@ -1050,7 +1050,7 @@ void BImage::hgradient(void) {
}
void BImage::vgradient(void) {
void Image::vgradient(void) {
float dry, dgy, dby,
yr = (float) from.red(),
yg = (float) from.green(),
@ -1123,7 +1123,7 @@ void BImage::vgradient(void) {
}
void BImage::pgradient(void) {
void Image::pgradient(void) {
// pyramid gradient - based on original dgradient, written by
// Mosfet (mosfet@kde.org)
// adapted from kde sources for Blackbox by Brad Hughes
@ -1233,7 +1233,7 @@ void BImage::pgradient(void) {
}
void BImage::rgradient(void) {
void Image::rgradient(void) {
// rectangle gradient - based on original dgradient, written by
// Mosfet (mosfet@kde.org)
// adapted from kde sources for Blackbox by Brad Hughes
@ -1342,7 +1342,7 @@ void BImage::rgradient(void) {
}
void BImage::egradient(void) {
void Image::egradient(void) {
// elliptic gradient - based on original dgradient, written by
// Mosfet (mosfet@kde.org)
// adapted from kde sources for Blackbox by Brad Hughes
@ -1462,7 +1462,7 @@ void BImage::egradient(void) {
}
void BImage::pcgradient(void) {
void Image::pcgradient(void) {
// pipe cross gradient - based on original dgradient, written by
// Mosfet (mosfet@kde.org)
// adapted from kde sources for Blackbox by Brad Hughes
@ -1573,7 +1573,7 @@ void BImage::pcgradient(void) {
}
void BImage::cdgradient(void) {
void Image::cdgradient(void) {
// cross diagonal gradient - based on original dgradient, written by
// Mosfet (mosfet@kde.org)
// adapted from kde sources for Blackbox by Brad Hughes

View file

@ -1,6 +1,6 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
#ifndef __Image_hh
#define __Image_hh
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __image_hh
#define __image_hh
extern "C" {
#include <X11/Xlib.h>
@ -15,17 +15,17 @@ extern "C" {
namespace otk {
class BImageControl;
class BTexture;
class ImageControl;
class Texture;
class ScreenInfo;
class BImage {
class Image {
private:
BImageControl *control;
ImageControl *control;
bool interlaced;
XColor *colors;
BColor from, to;
Color from, to;
int red_offset, green_offset, blue_offset, red_bits, green_bits, blue_bits,
ncolors, cpc, cpccpc;
unsigned char *red, *green, *blue, *red_table, *green_table, *blue_table;
@ -39,15 +39,15 @@ private:
#endif
Pixmap renderPixmap(void);
Pixmap render_solid(const BTexture &texture);
Pixmap render_gradient(const BTexture &texture);
Pixmap render_solid(const Texture &texture);
Pixmap render_gradient(const Texture &texture);
XImage *renderXImage(void);
void invert(void);
void bevel1(void);
void bevel2(void);
void border(const BTexture &texture);
void border(const Texture &texture);
void dgradient(void);
void egradient(void);
void hgradient(void);
@ -59,14 +59,14 @@ private:
public:
BImage(BImageControl *c, int w, int h);
~BImage(void);
Image(ImageControl *c, int w, int h);
~Image(void);
Pixmap render(const BTexture &texture);
Pixmap render(const Texture &texture);
};
class BImageControl {
class ImageControl {
public:
#ifndef SWIG
struct CachedImage {
@ -77,12 +77,12 @@ public:
};
#endif
BImageControl(otk::OBTimerQueueManager *timermanager,
ImageControl(otk::TimerQueueManager *timermanager,
const otk::ScreenInfo *scrn,
bool _dither= False, int _cpc = 4,
unsigned long cache_timeout = 300000l,
unsigned long cmax = 200l);
virtual ~BImageControl(void);
virtual ~ImageControl(void);
inline bool doDither(void) { return dither; }
@ -100,7 +100,7 @@ public:
unsigned long getSqrt(unsigned int x);
Pixmap renderImage(unsigned int width, unsigned int height,
const otk::BTexture &texture);
const Texture &texture);
void installRootColormap(void);
void removeImage(Pixmap pixmap);
@ -114,12 +114,12 @@ public:
void setDither(bool d) { dither = d; }
void setColorsPerChannel(int cpc);
static void timeout(BImageControl *t);
static void timeout(ImageControl *t);
private:
bool dither;
const ScreenInfo *screeninfo;
OBTimer *timer;
Timer *timer;
Colormap colormap;
@ -139,10 +139,10 @@ private:
Pixmap searchCache(const unsigned int width, const unsigned int height,
const unsigned long texture,
const BColor &c1, const BColor &c2);
const Color &c1, const Color &c2);
};
}
#endif // __Image_hh
#endif // __image_hh

View file

@ -39,9 +39,9 @@ static unsigned long bsqrt(unsigned long x) {
}
}
BImageControl *ctrl = 0;
ImageControl *ctrl = 0;
BImageControl::BImageControl(OBTimerQueueManager *timermanager,
ImageControl::ImageControl(TimerQueueManager *timermanager,
const ScreenInfo *scrn,
bool _dither, int _cpc,
unsigned long cache_timeout,
@ -54,11 +54,11 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
cache_max = cmax;
if (cache_timeout) {
timer = new OBTimer(timermanager, (OBTimeoutHandler)timeout, this);
timer = new Timer(timermanager, (TimeoutHandler)timeout, this);
timer->setTimeout(cache_timeout);
timer->start();
} else {
timer = (OBTimer *) 0;
timer = (Timer *) 0;
}
colors = (XColor *) 0;
@ -75,7 +75,7 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
colormap = screeninfo->colormap();
int count;
XPixmapFormatValues *pmv = XListPixmapFormats(OBDisplay::display,
XPixmapFormatValues *pmv = XListPixmapFormats(Display::display,
&count);
if (pmv) {
bits_per_pixel = 0;
@ -129,7 +129,7 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
if (colors_per_channel < 2 || ncolors > (1 << screen_depth)) {
fprintf(stderr,
"BImageControl::BImageControl: invalid colormap size %d "
"ImageControl::ImageControl: invalid colormap size %d "
"(%d/%d/%d) - reducing",
ncolors, colors_per_channel, colors_per_channel,
colors_per_channel);
@ -139,7 +139,7 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
colors = new XColor[ncolors];
if (! colors) {
fprintf(stderr, "BImageControl::BImageControl: error allocating "
fprintf(stderr, "ImageControl::ImageControl: error allocating "
"colormap\n");
exit(1);
}
@ -168,7 +168,7 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
}
for (i = 0; i < ncolors; i++) {
if (! XAllocColor(OBDisplay::display, colormap, &colors[i])) {
if (! XAllocColor(Display::display, colormap, &colors[i])) {
fprintf(stderr, "couldn't alloc color %i %i %i\n",
colors[i].red, colors[i].green, colors[i].blue);
colors[i].flags = 0;
@ -183,7 +183,7 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
for (i = 0; i < incolors; i++)
icolors[i].pixel = i;
XQueryColors(OBDisplay::display, colormap, icolors, incolors);
XQueryColors(Display::display, colormap, icolors, incolors);
for (i = 0; i < ncolors; i++) {
if (! colors[i].flags) {
unsigned long chk = 0xffffffff, pixel, close = 0;
@ -205,7 +205,7 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
colors[i].green = icolors[close].green;
colors[i].blue = icolors[close].blue;
if (XAllocColor(OBDisplay::display, colormap,
if (XAllocColor(Display::display, colormap,
&colors[i])) {
colors[i].flags = DoRed|DoGreen|DoBlue;
break;
@ -234,7 +234,7 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
if (colors_per_channel < 2 || ncolors > (1 << screen_depth)) {
fprintf(stderr,
"BImageControl::BImageControl: invalid colormap size %d "
"ImageControl::ImageControl: invalid colormap size %d "
"(%d/%d/%d) - reducing",
ncolors, colors_per_channel, colors_per_channel,
colors_per_channel);
@ -245,7 +245,7 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
colors = new XColor[ncolors];
if (! colors) {
fprintf(stderr,
"BImageControl::BImageControl: error allocating colormap\n");
"ImageControl::ImageControl: error allocating colormap\n");
exit(1);
}
@ -262,7 +262,7 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
colors[i].blue = (i * 0xffff) / (colors_per_channel - 1);;
colors[i].flags = DoRed|DoGreen|DoBlue;
if (! XAllocColor(OBDisplay::display, colormap,
if (! XAllocColor(Display::display, colormap,
&colors[i])) {
fprintf(stderr, "couldn't alloc color %i %i %i\n",
colors[i].red, colors[i].green, colors[i].blue);
@ -279,7 +279,7 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
for (i = 0; i < incolors; i++)
icolors[i].pixel = i;
XQueryColors(OBDisplay::display, colormap, icolors, incolors);
XQueryColors(Display::display, colormap, icolors, incolors);
for (i = 0; i < ncolors; i++) {
if (! colors[i].flags) {
unsigned long chk = 0xffffffff, pixel, close = 0;
@ -301,7 +301,7 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
colors[i].green = icolors[close].green;
colors[i].blue = icolors[close].blue;
if (XAllocColor(OBDisplay::display, colormap,
if (XAllocColor(Display::display, colormap,
&colors[i])) {
colors[i].flags = DoRed|DoGreen|DoBlue;
break;
@ -315,14 +315,14 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
}
default:
fprintf(stderr, "BImageControl::BImageControl: unsupported visual %d\n",
fprintf(stderr, "ImageControl::ImageControl: unsupported visual %d\n",
getVisual()->c_class);
exit(1);
}
}
BImageControl::~BImageControl(void) {
ImageControl::~ImageControl(void) {
delete [] sqrt_table;
delete [] grad_xbuffer;
@ -335,20 +335,20 @@ BImageControl::~BImageControl(void) {
for (int i = 0; i < ncolors; i++)
*(pixels + i) = (*(colors + i)).pixel;
XFreeColors(OBDisplay::display, colormap, pixels, ncolors, 0);
XFreeColors(Display::display, colormap, pixels, ncolors, 0);
delete [] colors;
}
if (! cache.empty()) {
//#ifdef DEBUG
fprintf(stderr, "BImageContol::~BImageControl: pixmap cache - "
fprintf(stderr, "ImageContol::~ImageControl: pixmap cache - "
"releasing %d pixmaps\n", cache.size());
//#endif
CacheContainer::iterator it = cache.begin();
const CacheContainer::iterator end = cache.end();
for (; it != end; ++it)
XFreePixmap(OBDisplay::display, it->pixmap);
XFreePixmap(Display::display, it->pixmap);
}
if (timer) {
timer->stop();
@ -357,10 +357,10 @@ BImageControl::~BImageControl(void) {
}
Pixmap BImageControl::searchCache(const unsigned int width,
Pixmap ImageControl::searchCache(const unsigned int width,
const unsigned int height,
const unsigned long texture,
const BColor &c1, const BColor &c2) {
const Color &c1, const Color &c2) {
if (cache.empty())
return None;
@ -370,7 +370,7 @@ Pixmap BImageControl::searchCache(const unsigned int width,
CachedImage& tmp = *it;
if (tmp.width == width && tmp.height == height &&
tmp.texture == texture && tmp.pixel1 == c1.pixel())
if (texture & BTexture::Gradient) {
if (texture & Texture::Gradient) {
if (tmp.pixel2 == c2.pixel()) {
tmp.count++;
return tmp.pixmap;
@ -384,15 +384,15 @@ Pixmap BImageControl::searchCache(const unsigned int width,
}
Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
const BTexture &texture) {
if (texture.texture() & BTexture::Parent_Relative) return ParentRelative;
Pixmap ImageControl::renderImage(unsigned int width, unsigned int height,
const Texture &texture) {
if (texture.texture() & Texture::Parent_Relative) return ParentRelative;
Pixmap pixmap = searchCache(width, height, texture.texture(),
texture.color(), texture.colorTo());
if (pixmap) return pixmap;
BImage image(this, width, height);
Image image(this, width, height);
pixmap = image.render(texture);
if (! pixmap)
@ -407,7 +407,7 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
tmp.texture = texture.texture();
tmp.pixel1 = texture.color().pixel();
if (texture.texture() & BTexture::Gradient)
if (texture.texture() & Texture::Gradient)
tmp.pixel2 = texture.colorTo().pixel();
else
tmp.pixel2 = 0l;
@ -416,7 +416,7 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
if (cache.size() > cache_max) {
#ifdef DEBUG
fprintf(stderr, "BImageControl::renderImage: cache is large, "
fprintf(stderr, "ImageControl::renderImage: cache is large, "
"forcing cleanout\n");
#endif // DEBUG
@ -427,7 +427,7 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
}
void BImageControl::removeImage(Pixmap pixmap) {
void ImageControl::removeImage(Pixmap pixmap) {
if (! pixmap)
return;
@ -444,7 +444,7 @@ void BImageControl::removeImage(Pixmap pixmap) {
}
void BImageControl::getColorTables(unsigned char **rmt, unsigned char **gmt,
void ImageControl::getColorTables(unsigned char **rmt, unsigned char **gmt,
unsigned char **bmt,
int *roff, int *goff, int *boff,
int *rbit, int *gbit, int *bbit) {
@ -462,13 +462,13 @@ void BImageControl::getColorTables(unsigned char **rmt, unsigned char **gmt,
}
void BImageControl::getXColorTable(XColor **c, int *n) {
void ImageControl::getXColorTable(XColor **c, int *n) {
if (c) *c = colors;
if (n) *n = ncolors;
}
void BImageControl::getGradientBuffers(unsigned int w,
void ImageControl::getGradientBuffers(unsigned int w,
unsigned int h,
unsigned int **xbuf,
unsigned int **ybuf)
@ -496,10 +496,10 @@ void BImageControl::getGradientBuffers(unsigned int w,
}
void BImageControl::installRootColormap(void) {
void ImageControl::installRootColormap(void) {
int ncmap = 0;
Colormap *cmaps =
XListInstalledColormaps(OBDisplay::display, window, &ncmap);
XListInstalledColormaps(Display::display, window, &ncmap);
if (cmaps) {
bool install = True;
@ -508,14 +508,14 @@ void BImageControl::installRootColormap(void) {
install = False;
if (install)
XInstallColormap(OBDisplay::display, colormap);
XInstallColormap(Display::display, colormap);
XFree(cmaps);
}
}
void BImageControl::setColorsPerChannel(int cpc) {
void ImageControl::setColorsPerChannel(int cpc) {
if (cpc < 2) cpc = 2;
if (cpc > 6) cpc = 6;
@ -523,7 +523,7 @@ void BImageControl::setColorsPerChannel(int cpc) {
}
unsigned long BImageControl::getSqrt(unsigned int x) {
unsigned long ImageControl::getSqrt(unsigned int x) {
if (! sqrt_table) {
// build sqrt table for use with elliptic gradient
@ -538,7 +538,7 @@ unsigned long BImageControl::getSqrt(unsigned int x) {
struct ZeroRefCheck {
inline bool operator()(const BImageControl::CachedImage &image) const {
inline bool operator()(const ImageControl::CachedImage &image) const {
return (image.count == 0);
}
};
@ -546,14 +546,14 @@ struct ZeroRefCheck {
struct CacheCleaner {
ZeroRefCheck ref_check;
CacheCleaner() {}
inline void operator()(const BImageControl::CachedImage& image) const {
inline void operator()(const ImageControl::CachedImage& image) const {
if (ref_check(image))
XFreePixmap(OBDisplay::display, image.pixmap);
XFreePixmap(Display::display, image.pixmap);
}
};
void BImageControl::timeout(BImageControl *t) {
void ImageControl::timeout(ImageControl *t) {
CacheCleaner cleaner;
std::for_each(t->cache.begin(), t->cache.end(), cleaner);
t->cache.remove_if(cleaner.ref_check);

View file

@ -8,31 +8,31 @@
namespace otk {
OtkLabel::OtkLabel(OtkWidget *parent)
: OtkWidget(parent), _text("")
Label::Label(Widget *parent)
: Widget(parent), _text("")
{
const ScreenInfo *info = OBDisplay::screenInfo(screen());
_xftdraw = XftDrawCreate(OBDisplay::display, window(), info->visual(),
const ScreenInfo *info = Display::screenInfo(screen());
_xftdraw = XftDrawCreate(Display::display, window(), info->visual(),
info->colormap());
}
OtkLabel::~OtkLabel()
Label::~Label()
{
XftDrawDestroy(_xftdraw);
}
void OtkLabel::setStyle(Style *style)
void Label::setStyle(Style *style)
{
OtkWidget::setStyle(style);
Widget::setStyle(style);
setTexture(style->getLabelUnfocus());
}
void OtkLabel::update(void)
void Label::update(void)
{
if (_dirty) {
const BFont *ft = style()->getFont();
const Font *ft = style()->getFont();
unsigned int sidemargin = style()->getBevelWidth() * 2;
std::string t = _text; // the actual text to draw
@ -64,11 +64,11 @@ void OtkLabel::update(void)
}
}
OtkWidget::update();
Widget::update();
ft->drawString(_xftdraw, x, 0, *style()->getTextUnfocus(), t);
} else
OtkWidget::update();
Widget::update();
}
}

View file

@ -1,3 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __label_hh
#define __label_hh
@ -6,12 +7,12 @@
namespace otk {
class OtkLabel : public OtkWidget {
class Label : public Widget {
public:
OtkLabel(OtkWidget *parent);
~OtkLabel();
Label(Widget *parent);
~Label();
inline const std::string &getText(void) const { return _text; }
void setText(const std::string &text) { _text = text; _dirty = true; }

View file

@ -1,3 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __otk_hh
#define __otk_hh

1675
otk/otk.py

File diff suppressed because it is too large Load diff

View file

@ -10,38 +10,38 @@
#include "button.hh"
int main(int argc, char **argv) {
otk::OtkApplication app(argc, argv);
otk::Application app(argc, argv);
otk::OtkAppWidget foo(&app);
otk::AppWidget foo(&app);
foo.resize(600, 500);
foo.setTexture(app.getStyle()->getTitleFocus());
// foo.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
foo.setBevelWidth(2);
foo.setDirection(otk::OtkWidget::Horizontal);
foo.setDirection(otk::Widget::Horizontal);
otk::OtkFocusWidget left(&foo);
otk::OtkFocusWidget right(&foo);
otk::FocusWidget left(&foo);
otk::FocusWidget right(&foo);
left.setDirection(otk::OtkWidget::Horizontal);
left.setDirection(otk::Widget::Horizontal);
left.setStretchableVert(true);
left.setStretchableHorz(true);
left.setTexture(app.getStyle()->getTitleFocus());
left.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
right.setDirection(otk::OtkWidget::Vertical);
right.setDirection(otk::Widget::Vertical);
right.setBevelWidth(10);
right.setStretchableVert(true);
right.setWidth(300);
right.setTexture(app.getStyle()->getTitleFocus());
right.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
otk::OtkButton iconb(&left);
otk::Button iconb(&left);
iconb.resize(40,20);
otk::OtkFocusWidget label(&left);
otk::OtkButton maxb(&left);
otk::OtkButton closeb(&left);
otk::FocusWidget label(&left);
otk::Button maxb(&left);
otk::Button closeb(&left);
// fixed size
iconb.setText("foo");
@ -60,9 +60,9 @@ int main(int argc, char **argv) {
// fixed size
closeb.setText("fuubar");
otk::OtkFocusWidget rblef(&right);
otk::OtkButton rbutt1(&right);
otk::OtkButton rbutt2(&right);
otk::FocusWidget rblef(&right);
otk::Button rbutt1(&right);
otk::Button rbutt2(&right);
rblef.setStretchableHorz(true);
rblef.setHeight(50);

File diff suppressed because it is too large Load diff

View file

@ -15,9 +15,9 @@ extern "C" {
namespace otk {
OBProperty::OBProperty()
Property::Property()
{
assert(OBDisplay::display);
assert(Display::display);
// make sure asserts fire if there is a problem
memset(_atoms, 0, sizeof(_atoms));
@ -153,7 +153,7 @@ OBProperty::OBProperty()
/*
* clean up the class' members
*/
OBProperty::~OBProperty()
Property::~Property()
{
}
@ -161,9 +161,9 @@ OBProperty::~OBProperty()
/*
* Returns an atom from the Xserver, creating it if necessary.
*/
Atom OBProperty::create(const char *name) const
Atom Property::create(const char *name) const
{
Atom a = XInternAtom(OBDisplay::display, name, False);
Atom a = XInternAtom(Display::display, name, False);
assert(a);
return a;
}
@ -174,14 +174,14 @@ Atom OBProperty::create(const char *name) const
* Sets a window property on a window, optionally appending to the existing
* value.
*/
void OBProperty::set(Window win, Atom atom, Atom type,
void Property::set(Window win, Atom atom, Atom type,
unsigned char* data, int size, int nelements,
bool append) const
{
assert(win != None); assert(atom != None); assert(type != None);
assert(nelements == 0 || (nelements > 0 && data != (unsigned char *) 0));
assert(size == 8 || size == 16 || size == 32);
XChangeProperty(OBDisplay::display, win, atom, type, size,
XChangeProperty(Display::display, win, atom, type, size,
(append ? PropModeAppend : PropModeReplace),
data, nelements);
}
@ -190,7 +190,7 @@ void OBProperty::set(Window win, Atom atom, Atom type,
/*
* Set a 32-bit property value on a window.
*/
void OBProperty::set(Window win, Atoms atom, Atoms type,
void Property::set(Window win, Atoms atom, Atoms type,
unsigned long value) const
{
assert(atom >= 0 && atom < NUM_ATOMS);
@ -203,7 +203,7 @@ void OBProperty::set(Window win, Atoms atom, Atoms type,
/*
* Set an array of 32-bit properties value on a window.
*/
void OBProperty::set(Window win, Atoms atom, Atoms type,
void Property::set(Window win, Atoms atom, Atoms type,
unsigned long value[], int elements) const
{
assert(atom >= 0 && atom < NUM_ATOMS);
@ -216,7 +216,7 @@ void OBProperty::set(Window win, Atoms atom, Atoms type,
/*
* Set an string property value on a window.
*/
void OBProperty::set(Window win, Atoms atom, StringType type,
void Property::set(Window win, Atoms atom, StringType type,
const std::string &value) const
{
assert(atom >= 0 && atom < NUM_ATOMS);
@ -237,7 +237,7 @@ void OBProperty::set(Window win, Atoms atom, StringType type,
/*
* Set an array of string property values on a window.
*/
void OBProperty::set(Window win, Atoms atom, StringType type,
void Property::set(Window win, Atoms atom, StringType type,
const StringVect &strings) const
{
assert(atom >= 0 && atom < NUM_ATOMS);
@ -270,7 +270,7 @@ void OBProperty::set(Window win, Atoms atom, StringType type,
* property did not exist on the window, or has a different type/size format
* than the user tried to retrieve.
*/
bool OBProperty::get(Window win, Atom atom, Atom type,
bool Property::get(Window win, Atom atom, Atom type,
unsigned long *nelements, unsigned char **value,
int size) const
{
@ -286,7 +286,7 @@ bool OBProperty::get(Window win, Atom atom, Atom type,
bool ret = False;
// try get the first element
result = XGetWindowProperty(OBDisplay::display, win, atom, 0l, 1l,
result = XGetWindowProperty(Display::display, win, atom, 0l, 1l,
False, AnyPropertyType, &ret_type, &ret_size,
nelements, &ret_bytes, &c_val);
ret = (result == Success && ret_type == type && ret_size == size &&
@ -304,7 +304,7 @@ bool OBProperty::get(Window win, Atom atom, Atom type,
int remain = (ret_bytes - 1)/sizeof(long) + 1 + 1;
if (remain > size/8 * (signed)maxread) // dont get more than the max
remain = size/8 * (signed)maxread;
result = XGetWindowProperty(OBDisplay::display, win, atom, 0l,
result = XGetWindowProperty(Display::display, win, atom, 0l,
remain, False, type, &ret_type, &ret_size,
nelements, &ret_bytes, &c_val);
ret = (result == Success && ret_type == type && ret_size == size &&
@ -329,7 +329,7 @@ bool OBProperty::get(Window win, Atom atom, Atom type,
/*
* Gets a 32-bit property's value from a window.
*/
bool OBProperty::get(Window win, Atoms atom, Atoms type,
bool Property::get(Window win, Atoms atom, Atoms type,
unsigned long *nelements,
unsigned long **value) const
{
@ -343,7 +343,7 @@ bool OBProperty::get(Window win, Atoms atom, Atoms type,
/*
* Gets a single 32-bit property's value from a window.
*/
bool OBProperty::get(Window win, Atoms atom, Atoms type,
bool Property::get(Window win, Atoms atom, Atoms type,
unsigned long *value) const
{
assert(atom >= 0 && atom < NUM_ATOMS);
@ -362,7 +362,7 @@ bool OBProperty::get(Window win, Atoms atom, Atoms type,
/*
* Gets an string property's value from a window.
*/
bool OBProperty::get(Window win, Atoms atom, StringType type,
bool Property::get(Window win, Atoms atom, StringType type,
std::string *value) const
{
unsigned long n = 1;
@ -375,7 +375,7 @@ bool OBProperty::get(Window win, Atoms atom, StringType type,
}
bool OBProperty::get(Window win, Atoms atom, StringType type,
bool Property::get(Window win, Atoms atom, StringType type,
unsigned long *nelements, StringVect *strings) const
{
assert(atom >= 0 && atom < NUM_ATOMS);
@ -419,10 +419,10 @@ bool OBProperty::get(Window win, Atoms atom, StringType type,
/*
* Removes a property entirely from a window.
*/
void OBProperty::erase(Window win, Atoms atom) const
void Property::erase(Window win, Atoms atom) const
{
assert(atom >= 0 && atom < NUM_ATOMS);
XDeleteProperty(OBDisplay::display, win, _atoms[atom]);
XDeleteProperty(Display::display, win, _atoms[atom]);
}
}

View file

@ -1,4 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __atom_hh
#define __atom_hh
@ -21,7 +21,7 @@ extern "C" {
namespace otk {
//! Provides easy access to window properties.
class OBProperty {
class Property {
public:
//! The atoms on the X server which this class will cache
enum Atoms {
@ -160,7 +160,7 @@ public:
private:
//! The value of all atoms on the X server that exist in the
//! OBProperty::Atoms enum
//! Property::Atoms enum
Atom _atoms[NUM_ATOMS];
//! Gets the value of an Atom from the X server, creating it if nessesary
@ -178,21 +178,21 @@ public:
//! A list of strings
typedef std::vector<std::string> StringVect;
//! Constructs a new OBAtom object
//! Constructs a new Atom object
/*!
CAUTION: This constructor uses OBDisplay::display, so ensure that it is
CAUTION: This constructor uses Display::display, so ensure that it is
initialized before initializing this class!
*/
OBProperty();
//! Destroys the OBAtom object
virtual ~OBProperty();
Property();
//! Destroys the Atom object
virtual ~Property();
//! Sets a single-value property on a window to a new value
/*!
@param win The window id of the window on which to set the property's value
@param atom A member of the OBProperty::Atoms enum that specifies which
@param atom A member of the Property::Atoms enum that specifies which
property to set
@param type A member of the OBProperty::Atoms enum that specifies the type
@param type A member of the Property::Atoms enum that specifies the type
of the property to set
@param value The value to set the property to
*/
@ -200,9 +200,9 @@ public:
//! Sets an multiple-value property on a window to a new value
/*!
@param win The window id of the window on which to set the property's value
@param atom A member of the OBProperty::Atoms enum that specifies which
@param atom A member of the Property::Atoms enum that specifies which
property to set
@param type A member of the OBProperty::Atoms enum that specifies the type
@param type A member of the Property::Atoms enum that specifies the type
of the property to set
@param value Any array of values to set the property to. The array must
contain <i>elements</i> number of elements
@ -213,9 +213,9 @@ public:
//! Sets a string property on a window to a new value
/*!
@param win The window id of the window on which to set the property's value
@param atom A member of the OBProperty::Atoms enum that specifies which
@param atom A member of the Property::Atoms enum that specifies which
property to set
@param type A member of the OBProperty::StringType enum that specifies the
@param type A member of the Property::StringType enum that specifies the
type of the string the property is being set to
@param value The string to set the property to
*/
@ -224,9 +224,9 @@ public:
//! Sets a string-array property on a window to a new value
/*!
@param win The window id of the window on which to set the property's value
@param atom A member of the OBProperty::Atoms enum that specifies which
@param atom A member of the Property::Atoms enum that specifies which
property to set
@param type A member of the OBProperty::StringType enum that specifies the
@param type A member of the Property::StringType enum that specifies the
type of the string the property is being set to
@param strings A list of strings to set the property to
*/
@ -236,9 +236,9 @@ public:
//! Gets the value of a property on a window
/*!
@param win The window id of the window to get the property value from
@param atom A member of the OBProperty::Atoms enum that specifies which
@param atom A member of the Property::Atoms enum that specifies which
property to retrieve
@param type A member of the OBProperty::Atoms enum that specifies the type
@param type A member of the Property::Atoms enum that specifies the type
of the property to retrieve
@param nelements The maximum number of elements to retrieve from the
property (assuming it has more than 1 value in it). To
@ -260,9 +260,9 @@ public:
//! Gets a single element from the value of a property on a window
/*!
@param win The window id of the window to get the property value from
@param atom A member of the OBProperty::Atoms enum that specifies which
@param atom A member of the Property::Atoms enum that specifies which
property to retrieve
@param type A member of the OBProperty::Atoms enum that specifies the type
@param type A member of the Property::Atoms enum that specifies the type
of the property to retrieve
@param value If the function returns true, then this contains the first
(and possibly only) element in the value of the specified
@ -274,9 +274,9 @@ public:
//! Gets a single string from the value of a property on a window
/*!
@param win The window id of the window to get the property value from
@param atom A member of the OBProperty::Atoms enum that specifies which
@param atom A member of the Property::Atoms enum that specifies which
property to retrieve
@param type A member of the OBProperty::StringType enum that specifies the
@param type A member of the Property::StringType enum that specifies the
type of the string property to retrieve
@param value If the function returns true, then this contains the first
(and possibly only) string in the value of the specified
@ -288,9 +288,9 @@ public:
//! Gets strings from the value of a property on a window
/*!
@param win The window id of the window to get the property value from
@param atom A member of the OBProperty::Atoms enum that specifies which
@param atom A member of the Property::Atoms enum that specifies which
property to retrieve
@param type A member of the OBProperty::StringType enum that specifies the
@param type A member of the Property::StringType enum that specifies the
type of the string property to retrieve
@param nelements The maximum number of strings to retrieve from the
property (assuming it has more than 1 string in it). To
@ -308,14 +308,14 @@ public:
//! Removes a property from a window
/*!
@param win The window id of the window to remove the property from
@param atom A member of the OBProperty::Atoms enum that specifies which
@param atom A member of the Property::Atoms enum that specifies which
property to remove from the window
*/
void erase(Window win, Atoms atom) const;
//! Gets the value of an atom on the X server
/*!
@param a A member of the OBProperty::Atoms enum that specifies which Atom's
@param a A member of the Property::Atoms enum that specifies which Atom's
value to return
@return The value of the specified Atom
*/

View file

@ -1,4 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __rect_hh
#define __rect_hh

View file

@ -1,4 +1,5 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifdef HAVE_CONFIG_H
# include "../config.h"
@ -20,11 +21,11 @@ namespace otk {
ScreenInfo::ScreenInfo(unsigned int num) {
_screen = num;
_root_window = RootWindow(OBDisplay::display, _screen);
_root_window = RootWindow(Display::display, _screen);
_rect.setSize(WidthOfScreen(ScreenOfDisplay(OBDisplay::display,
_rect.setSize(WidthOfScreen(ScreenOfDisplay(Display::display,
_screen)),
HeightOfScreen(ScreenOfDisplay(OBDisplay::display,
HeightOfScreen(ScreenOfDisplay(Display::display,
_screen)));
/*
If the default depth is at least 8 we will use that,
@ -32,9 +33,9 @@ ScreenInfo::ScreenInfo(unsigned int num) {
Preference is given to 24 bit over larger depths if 24 bit is an option.
*/
_depth = DefaultDepth(OBDisplay::display, _screen);
_visual = DefaultVisual(OBDisplay::display, _screen);
_colormap = DefaultColormap(OBDisplay::display, _screen);
_depth = DefaultDepth(Display::display, _screen);
_visual = DefaultVisual(Display::display, _screen);
_colormap = DefaultColormap(Display::display, _screen);
if (_depth < 8) {
// search for a TrueColor Visual... if we can't find one...
@ -46,7 +47,7 @@ ScreenInfo::ScreenInfo(unsigned int num) {
vinfo_template.screen = _screen;
vinfo_template.c_class = TrueColor;
vinfo_return = XGetVisualInfo(OBDisplay::display,
vinfo_return = XGetVisualInfo(Display::display,
VisualScreenMask | VisualClassMask,
&vinfo_template, &vinfo_nitems);
if (vinfo_return) {
@ -65,7 +66,7 @@ ScreenInfo::ScreenInfo(unsigned int num) {
if (best != -1) {
_depth = vinfo_return[best].depth;
_visual = vinfo_return[best].visual;
_colormap = XCreateColormap(OBDisplay::display, _root_window, _visual,
_colormap = XCreateColormap(Display::display, _root_window, _visual,
AllocNone);
}
@ -73,13 +74,13 @@ ScreenInfo::ScreenInfo(unsigned int num) {
}
// get the default display string and strip the screen number
string default_string = DisplayString(OBDisplay::display);
string default_string = DisplayString(Display::display);
const string::size_type pos = default_string.rfind(".");
if (pos != string::npos)
default_string.resize(pos);
_display_string = string("DISPLAY=") + default_string + '.' +
otk::itostring(static_cast<unsigned long>(_screen));
itostring(static_cast<unsigned long>(_screen));
#if 0 //def XINERAMA
_xinerama_active = False;
@ -93,7 +94,7 @@ ScreenInfo::ScreenInfo(unsigned int num) {
in future versions we should be able, so the 'activeness' is checked
on a pre-screen basis anyways.
*/
if (XineramaIsActive(OBDisplay::display)) {
if (XineramaIsActive(Display::display)) {
/*
If Xinerama is being used, there there is only going to be one screen
present. We still, of course, want to use the screen class, but that
@ -101,7 +102,7 @@ ScreenInfo::ScreenInfo(unsigned int num) {
never be more than one screen present with Xinerama active.
*/
int num;
XineramaScreenInfo *info = XineramaQueryScreens(OBDisplay::display,
XineramaScreenInfo *info = XineramaQueryScreens(Display::display,
&num);
if (num > 0 && info) {
_xinerama_areas.reserve(num);

View file

@ -1,4 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __screeninfo_hh
#define __screeninfo_hh

View file

@ -17,7 +17,7 @@ Style::Style() : font(NULL)
{
}
Style::Style(BImageControl *ctrl)
Style::Style(ImageControl *ctrl)
: image_control(ctrl), font(0),
screen_number(ctrl->getScreenInfo()->screen())
{
@ -28,13 +28,13 @@ Style::~Style() {
delete font;
if (close_button.mask != None)
XFreePixmap(OBDisplay::display, close_button.mask);
XFreePixmap(Display::display, close_button.mask);
if (max_button.mask != None)
XFreePixmap(OBDisplay::display, max_button.mask);
XFreePixmap(Display::display, max_button.mask);
if (icon_button.mask != None)
XFreePixmap(OBDisplay::display, icon_button.mask);
XFreePixmap(Display::display, icon_button.mask);
if (stick_button.mask != None)
XFreePixmap(OBDisplay::display, stick_button.mask);
XFreePixmap(Display::display, stick_button.mask);
max_button.mask = None;
close_button.mask = None;
@ -70,26 +70,26 @@ void Style::load(const Configuration &style) {
//if neither of these can be found, we will use the previous resource
b_pressed_focus = readDatabaseTexture("window.button.pressed.focus",
"black", style, true);
if (b_pressed_focus.texture() == BTexture::NoTexture) {
if (b_pressed_focus.texture() == Texture::NoTexture) {
b_pressed_focus = readDatabaseTexture("window.button.pressed", "black",
style);
}
b_pressed_unfocus = readDatabaseTexture("window.button.pressed.unfocus",
"black", style, true);
if (b_pressed_unfocus.texture() == BTexture::NoTexture) {
if (b_pressed_unfocus.texture() == Texture::NoTexture) {
b_pressed_unfocus = readDatabaseTexture("window.button.pressed", "black",
style);
}
if (close_button.mask != None)
XFreePixmap(OBDisplay::display, close_button.mask);
XFreePixmap(Display::display, close_button.mask);
if (max_button.mask != None)
XFreePixmap(OBDisplay::display, max_button.mask);
XFreePixmap(Display::display, max_button.mask);
if (icon_button.mask != None)
XFreePixmap(OBDisplay::display, icon_button.mask);
XFreePixmap(Display::display, icon_button.mask);
if (stick_button.mask != None)
XFreePixmap(OBDisplay::display, stick_button.mask);
XFreePixmap(Display::display, stick_button.mask);
close_button.mask = max_button.mask = icon_button.mask
= icon_button.mask = None;
@ -101,13 +101,13 @@ void Style::load(const Configuration &style) {
// we create the window.frame texture by hand because it exists only to
// make the code cleaner and is not actually used for display
BColor color = readDatabaseColor("window.frame.focusColor", "white",
Color color = readDatabaseColor("window.frame.focusColor", "white",
style);
f_focus = BTexture("solid flat", screen_number, image_control);
f_focus = Texture("solid flat", screen_number, image_control);
f_focus.setColor(color);
color = readDatabaseColor("window.frame.unfocusColor", "white", style);
f_unfocus = BTexture("solid flat", screen_number, image_control);
f_unfocus = Texture("solid flat", screen_number, image_control);
f_unfocus.setColor(color);
l_text_focus = readDatabaseColor("window.label.focus.textColor",
@ -130,20 +130,20 @@ void Style::load(const Configuration &style) {
}
// sanity checks
if (t_focus.texture() == BTexture::Parent_Relative)
if (t_focus.texture() == Texture::Parent_Relative)
t_focus = f_focus;
if (t_unfocus.texture() == BTexture::Parent_Relative)
if (t_unfocus.texture() == Texture::Parent_Relative)
t_unfocus = f_unfocus;
if (h_focus.texture() == BTexture::Parent_Relative)
if (h_focus.texture() == Texture::Parent_Relative)
h_focus = f_focus;
if (h_unfocus.texture() == BTexture::Parent_Relative)
if (h_unfocus.texture() == Texture::Parent_Relative)
h_unfocus = f_unfocus;
border_color = readDatabaseColor("borderColor", "black", style);
// load bevel, border and handle widths
const ScreenInfo *s_info = OBDisplay::screenInfo(screen_number);
const ScreenInfo *s_info = Display::screenInfo(screen_number);
unsigned int width = s_info->rect().width();
if (! style.getValue("handleWidth", handle_width) ||
@ -168,7 +168,7 @@ void Style::load(const Configuration &style) {
void Style::readDatabaseMask(const std::string &rname, PixmapMask &pixmapMask,
const Configuration &style) {
Window root_window = OBDisplay::screenInfo(screen_number)->rootWindow();
Window root_window = Display::screenInfo(screen_number)->rootWindow();
std::string s;
int hx, hy; //ignored
int ret = BitmapOpenFailed; //default to failure.
@ -176,17 +176,17 @@ void Style::readDatabaseMask(const std::string &rname, PixmapMask &pixmapMask,
if (style.getValue(rname, s)) {
if (s[0] != '/' && s[0] != '~') {
std::string xbmFile = std::string("~/.openbox/buttons/") + s;
ret = XReadBitmapFile(OBDisplay::display, root_window,
ret = XReadBitmapFile(Display::display, root_window,
expandTilde(xbmFile).c_str(), &pixmapMask.w,
&pixmapMask.h, &pixmapMask.mask, &hx, &hy);
if (ret != BitmapSuccess) {
xbmFile = std::string(BUTTONSDIR) + "/" + s;
ret = XReadBitmapFile(OBDisplay::display, root_window,
ret = XReadBitmapFile(Display::display, root_window,
xbmFile.c_str(), &pixmapMask.w,
&pixmapMask.h, &pixmapMask.mask, &hx, &hy);
}
} else
ret = XReadBitmapFile(OBDisplay::display, root_window,
ret = XReadBitmapFile(Display::display, root_window,
expandTilde(s).c_str(), &pixmapMask.w,
&pixmapMask.h, &pixmapMask.mask, &hx, &hy);
@ -199,26 +199,26 @@ void Style::readDatabaseMask(const std::string &rname, PixmapMask &pixmapMask,
}
BTexture Style::readDatabaseTexture(const std::string &rname,
Texture Style::readDatabaseTexture(const std::string &rname,
const std::string &default_color,
const Configuration &style,
bool allowNoTexture)
{
BTexture texture;
Texture texture;
std::string s;
if (style.getValue(rname, s))
texture = BTexture(s);
texture = Texture(s);
else if (allowNoTexture) //no default
texture.setTexture(BTexture::NoTexture);
texture.setTexture(Texture::NoTexture);
else
texture.setTexture(BTexture::Solid | BTexture::Flat);
texture.setTexture(Texture::Solid | Texture::Flat);
// associate this texture with this screen
texture.setScreen(screen_number);
texture.setImageControl(image_control);
if (texture.texture() != BTexture::NoTexture) {
if (texture.texture() != Texture::NoTexture) {
texture.setColor(readDatabaseColor(rname + ".color", default_color,
style));
texture.setColorTo(readDatabaseColor(rname + ".colorTo", default_color,
@ -231,20 +231,20 @@ BTexture Style::readDatabaseTexture(const std::string &rname,
}
BColor Style::readDatabaseColor(const std::string &rname,
Color Style::readDatabaseColor(const std::string &rname,
const std::string &default_color,
const Configuration &style) {
BColor color;
Color color;
std::string s;
if (style.getValue(rname, s))
color = BColor(s, screen_number);
color = Color(s, screen_number);
else
color = BColor(default_color, screen_number);
color = Color(default_color, screen_number);
return color;
}
BFont *Style::readDatabaseFont(const std::string &rbasename,
Font *Style::readDatabaseFont(const std::string &rbasename,
const Configuration &style) {
std::string fontstring, s;
@ -267,7 +267,7 @@ BFont *Style::readDatabaseFont(const std::string &rbasename,
fontstring = "Arial,Sans-9:bold";
// if this fails, it ::exit()'s
return new BFont(screen_number, fontstring, dropShadow, offset, tint);
return new Font(screen_number, fontstring, dropShadow, offset, tint);
}
}

View file

@ -1,3 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __style_hh
#define __style_hh
@ -31,17 +32,17 @@ public:
// private:
BImageControl *image_control;
ImageControl *image_control;
BColor
Color
l_text_focus, l_text_unfocus,
b_pic_focus, b_pic_unfocus;
BColor border_color;
Color border_color;
BFont *font;
Font *font;
BTexture
Texture
f_focus, f_unfocus,
t_focus, t_unfocus,
l_focus, l_unfocus,
@ -63,23 +64,23 @@ public:
public:
Style();
Style(BImageControl *);
Style(ImageControl *);
~Style();
void readDatabaseMask(const std::string &rname,
PixmapMask &pixmapMask,
const Configuration &style);
BTexture readDatabaseTexture(const std::string &rname,
Texture readDatabaseTexture(const std::string &rname,
const std::string &default_color,
const Configuration &style,
bool allowNoTexture = false);
BColor readDatabaseColor(const std::string &rname,
Color readDatabaseColor(const std::string &rname,
const std::string &default_color,
const Configuration &style);
BFont *readDatabaseFont(const std::string &rbasename,
Font *readDatabaseFont(const std::string &rbasename,
const Configuration &style);
void load(const Configuration &style);
@ -89,38 +90,38 @@ public:
inline PixmapMask *getIconifyButtonMask(void) { return &icon_button; }
inline PixmapMask *getStickyButtonMask(void) { return &stick_button; }
inline BColor *getTextFocus(void) { return &l_text_focus; }
inline BColor *getTextUnfocus(void) { return &l_text_unfocus; }
inline Color *getTextFocus(void) { return &l_text_focus; }
inline Color *getTextUnfocus(void) { return &l_text_unfocus; }
inline BColor *getButtonPicFocus(void) { return &b_pic_focus; }
inline BColor *getButtonPicUnfocus(void) { return &b_pic_unfocus; }
inline Color *getButtonPicFocus(void) { return &b_pic_focus; }
inline Color *getButtonPicUnfocus(void) { return &b_pic_unfocus; }
inline BTexture *getTitleFocus(void) { return &t_focus; }
inline BTexture *getTitleUnfocus(void) { return &t_unfocus; }
inline Texture *getTitleFocus(void) { return &t_focus; }
inline Texture *getTitleUnfocus(void) { return &t_unfocus; }
inline BTexture *getLabelFocus(void) { return &l_focus; }
inline BTexture *getLabelUnfocus(void) { return &l_unfocus; }
inline Texture *getLabelFocus(void) { return &l_focus; }
inline Texture *getLabelUnfocus(void) { return &l_unfocus; }
inline BTexture *getHandleFocus(void) { return &h_focus; }
inline BTexture *getHandleUnfocus(void) { return &h_unfocus; }
inline Texture *getHandleFocus(void) { return &h_focus; }
inline Texture *getHandleUnfocus(void) { return &h_unfocus; }
inline BTexture *getButtonFocus(void) { return &b_focus; }
inline BTexture *getButtonUnfocus(void) { return &b_unfocus; }
inline Texture *getButtonFocus(void) { return &b_focus; }
inline Texture *getButtonUnfocus(void) { return &b_unfocus; }
inline BTexture *getButtonPressedFocus(void)
inline Texture *getButtonPressedFocus(void)
{ return &b_pressed_focus; }
inline BTexture *getButtonPressedUnfocus(void)
inline Texture *getButtonPressedUnfocus(void)
{ return &b_pressed_unfocus; }
inline BTexture *getGripFocus(void) { return &g_focus; }
inline BTexture *getGripUnfocus(void) { return &g_unfocus; }
inline Texture *getGripFocus(void) { return &g_focus; }
inline Texture *getGripUnfocus(void) { return &g_unfocus; }
inline unsigned int getHandleWidth(void) const { return handle_width; }
inline unsigned int getBevelWidth(void) const { return bevel_width; }
inline unsigned int getFrameWidth(void) const { return frame_width; }
inline unsigned int getBorderWidth(void) const { return border_width; }
inline const BFont *getFont() const { return font; }
inline const Font *getFont() const { return font; }
inline void setShadowFonts(bool fonts) { shadow_fonts = fonts; }
inline bool hasShadowFonts(void) const { return shadow_fonts; }
@ -131,12 +132,12 @@ public:
inline TextJustify textJustify(void) { return justify; }
inline BulletType bulletType(void) { return bullet_type; }
inline const BColor *getBorderColor() const { return &border_color; }
inline const Color *getBorderColor() const { return &border_color; }
inline const BTexture *getFrameFocus() const { return &f_focus; }
inline const BTexture *getFrameUnfocus() const { return &f_unfocus; }
inline const Texture *getFrameFocus() const { return &f_focus; }
inline const Texture *getFrameUnfocus() const { return &f_unfocus; }
inline void setImageControl(BImageControl *c) {
inline void setImageControl(ImageControl *c) {
image_control = c;
screen_number = c->getScreenInfo()->screen();
}

View file

@ -21,13 +21,13 @@ using std::string;
namespace otk {
BTexture::BTexture(unsigned int _screen, BImageControl* _ctrl)
Texture::Texture(unsigned int _screen, ImageControl* _ctrl)
: c(_screen), ct(_screen),
lc(_screen), sc(_screen), bc(_screen), t(0),
ctrl(_ctrl), scrn(_screen) { }
BTexture::BTexture(const string &d,unsigned int _screen, BImageControl* _ctrl)
Texture::Texture(const string &d,unsigned int _screen, ImageControl* _ctrl)
: c(_screen), ct(_screen),
lc(_screen), sc(_screen), bc(_screen), t(0),
ctrl(_ctrl), scrn(_screen) {
@ -35,7 +35,7 @@ BTexture::BTexture(const string &d,unsigned int _screen, BImageControl* _ctrl)
}
void BTexture::setColor(const BColor &cc) {
void Texture::setColor(const Color &cc) {
c = cc;
c.setScreen(screen());
@ -51,7 +51,7 @@ void BTexture::setColor(const BColor &cc) {
if (rr < r) rr = ~0;
if (gg < g) gg = ~0;
if (bb < b) bb = ~0;
lc = BColor(rr, gg, bb, screen());
lc = Color(rr, gg, bb, screen());
// calculate the shadow color
r = c.red();
@ -63,11 +63,11 @@ void BTexture::setColor(const BColor &cc) {
if (rr > r) rr = 0;
if (gg > g) gg = 0;
if (bb > b) bb = 0;
sc = BColor(rr, gg, bb, screen());
sc = Color(rr, gg, bb, screen());
}
void BTexture::setDescription(const string &d) {
void Texture::setDescription(const string &d) {
descr.erase();
descr.reserve(d.length());
@ -76,55 +76,55 @@ void BTexture::setDescription(const string &d) {
descr += tolower(*it);
if (descr.find("parentrelative") != string::npos) {
setTexture(BTexture::Parent_Relative);
setTexture(Texture::Parent_Relative);
} else {
setTexture(0);
if (descr.find("gradient") != string::npos) {
addTexture(BTexture::Gradient);
addTexture(Texture::Gradient);
if (descr.find("crossdiagonal") != string::npos)
addTexture(BTexture::CrossDiagonal);
addTexture(Texture::CrossDiagonal);
else if (descr.find("rectangle") != string::npos)
addTexture(BTexture::Rectangle);
addTexture(Texture::Rectangle);
else if (descr.find("pyramid") != string::npos)
addTexture(BTexture::Pyramid);
addTexture(Texture::Pyramid);
else if (descr.find("pipecross") != string::npos)
addTexture(BTexture::PipeCross);
addTexture(Texture::PipeCross);
else if (descr.find("elliptic") != string::npos)
addTexture(BTexture::Elliptic);
addTexture(Texture::Elliptic);
else if (descr.find("horizontal") != string::npos)
addTexture(BTexture::Horizontal);
addTexture(Texture::Horizontal);
else if (descr.find("vertical") != string::npos)
addTexture(BTexture::Vertical);
addTexture(Texture::Vertical);
else
addTexture(BTexture::Diagonal);
addTexture(Texture::Diagonal);
} else {
addTexture(BTexture::Solid);
addTexture(Texture::Solid);
}
if (descr.find("sunken") != string::npos)
addTexture(BTexture::Sunken);
addTexture(Texture::Sunken);
else if (descr.find("flat") != string::npos)
addTexture(BTexture::Flat);
addTexture(Texture::Flat);
else
addTexture(BTexture::Raised);
addTexture(Texture::Raised);
if (texture() & BTexture::Flat) {
if (texture() & Texture::Flat) {
if (descr.find("border") != string::npos)
addTexture(BTexture::Border);
addTexture(Texture::Border);
} else {
if (descr.find("bevel2") != string::npos)
addTexture(BTexture::Bevel2);
addTexture(Texture::Bevel2);
else
addTexture(BTexture::Bevel1);
addTexture(Texture::Bevel1);
}
if (descr.find("interlaced") != string::npos)
addTexture(BTexture::Interlaced);
addTexture(Texture::Interlaced);
}
}
void BTexture::setScreen(const unsigned int _screen) {
void Texture::setScreen(const unsigned int _screen) {
if (_screen == screen()) {
// nothing to do
return;
@ -139,7 +139,7 @@ void BTexture::setScreen(const unsigned int _screen) {
}
BTexture& BTexture::operator=(const BTexture &tt) {
Texture& Texture::operator=(const Texture &tt) {
c = tt.c;
ct = tt.ct;
lc = tt.lc;
@ -154,17 +154,17 @@ BTexture& BTexture::operator=(const BTexture &tt) {
}
Pixmap BTexture::render(const unsigned int width, const unsigned int height,
Pixmap Texture::render(const unsigned int width, const unsigned int height,
const Pixmap old) {
assert(texture() != BTexture::NoTexture);
assert(texture() != Texture::NoTexture);
// if (texture() == (BTexture::Flat | BTexture::Solid))
// if (texture() == (Texture::Flat | Texture::Solid))
// return None;
if (texture() == BTexture::Parent_Relative)
if (texture() == Texture::Parent_Relative)
return ParentRelative;
if (screen() == ~(0u))
scrn = DefaultScreen(OBDisplay::display);
scrn = DefaultScreen(Display::display);
assert(ctrl != 0);
Pixmap ret = ctrl->renderImage(width, height, *this);

View file

@ -9,9 +9,9 @@
namespace otk {
class BImageControl;
class ImageControl;
class BTexture {
class Texture {
public:
enum Type {
// No texture
@ -45,36 +45,36 @@ public:
Interlaced = (1l<<18)
};
BTexture(unsigned int _screen = ~(0u), BImageControl* _ctrl = 0);
BTexture(const std::string &_description,
unsigned int _screen = ~(0u), BImageControl* _ctrl = 0);
Texture(unsigned int _screen = ~(0u), ImageControl* _ctrl = 0);
Texture(const std::string &_description,
unsigned int _screen = ~(0u), ImageControl* _ctrl = 0);
void setColor(const BColor &_color);
void setColorTo(const BColor &_colorTo) { ct = _colorTo; }
void setBorderColor(const BColor &_borderColor) { bc = _borderColor; }
void setColor(const Color &_color);
void setColorTo(const Color &_colorTo) { ct = _colorTo; }
void setBorderColor(const Color &_borderColor) { bc = _borderColor; }
const BColor &color(void) const { return c; }
const BColor &colorTo(void) const { return ct; }
const BColor &lightColor(void) const { return lc; }
const BColor &shadowColor(void) const { return sc; }
const BColor &borderColor(void) const { return bc; }
const Color &color(void) const { return c; }
const Color &colorTo(void) const { return ct; }
const Color &lightColor(void) const { return lc; }
const Color &shadowColor(void) const { return sc; }
const Color &borderColor(void) const { return bc; }
unsigned long texture(void) const { return t; }
void setTexture(const unsigned long _texture) { t = _texture; }
void addTexture(const unsigned long _texture) { t |= _texture; }
#ifndef SWIG
BTexture &operator=(const BTexture &tt);
Texture &operator=(const Texture &tt);
#endif
inline bool operator==(const BTexture &tt)
inline bool operator==(const Texture &tt)
{ return (c == tt.c && ct == tt.ct && lc == tt.lc &&
sc == tt.sc && t == tt.t); }
inline bool operator!=(const BTexture &tt)
inline bool operator!=(const Texture &tt)
{ return (! operator==(tt)); }
unsigned int screen(void) const { return scrn; }
void setScreen(const unsigned int _screen);
void setImageControl(BImageControl* _ctrl) { ctrl = _ctrl; }
void setImageControl(ImageControl* _ctrl) { ctrl = _ctrl; }
const std::string &description(void) const { return descr; }
void setDescription(const std::string &d);
@ -82,10 +82,10 @@ public:
const Pixmap old = 0);
private:
BColor c, ct, lc, sc, bc;
Color c, ct, lc, sc, bc;
std::string descr;
unsigned long t;
BImageControl *ctrl;
ImageControl *ctrl;
unsigned int scrn;
};

View file

@ -33,7 +33,7 @@ static timeval normalizeTimeval(const timeval &tm)
}
OBTimer::OBTimer(OBTimerQueueManager *m, OBTimeoutHandler h, OBTimeoutData d)
Timer::Timer(TimerQueueManager *m, TimeoutHandler h, TimeoutData d)
{
_manager = m;
_handler = h;
@ -43,13 +43,13 @@ OBTimer::OBTimer(OBTimerQueueManager *m, OBTimeoutHandler h, OBTimeoutData d)
}
OBTimer::~OBTimer(void)
Timer::~Timer(void)
{
if (_timing) stop();
}
void OBTimer::setTimeout(long t)
void Timer::setTimeout(long t)
{
_timeout.tv_sec = t / 1000;
_timeout.tv_usec = t % 1000;
@ -57,14 +57,14 @@ void OBTimer::setTimeout(long t)
}
void OBTimer::setTimeout(const timeval &t)
void Timer::setTimeout(const timeval &t)
{
_timeout.tv_sec = t.tv_sec;
_timeout.tv_usec = t.tv_usec;
}
void OBTimer::start(void)
void Timer::start(void)
{
gettimeofday(&_start, 0);
@ -75,7 +75,7 @@ void OBTimer::start(void)
}
void OBTimer::stop(void)
void Timer::stop(void)
{
if (_timing) {
_timing = false;
@ -85,14 +85,14 @@ void OBTimer::stop(void)
}
void OBTimer::fire(void)
void Timer::fire(void)
{
if (_handler)
_handler(_data);
}
timeval OBTimer::remainingTime(const timeval &tm) const
timeval Timer::remainingTime(const timeval &tm) const
{
timeval ret = endTime();
@ -103,7 +103,7 @@ timeval OBTimer::remainingTime(const timeval &tm) const
}
timeval OBTimer::endTime(void) const
timeval Timer::endTime(void) const
{
timeval ret;
@ -114,7 +114,7 @@ timeval OBTimer::endTime(void) const
}
bool OBTimer::shouldFire(const timeval &tm) const
bool Timer::shouldFire(const timeval &tm) const
{
timeval end = endTime();

View file

@ -1,4 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __timer_hh
#define __timer_hh
@ -17,26 +17,26 @@ extern "C" {
namespace otk {
class OBTimerQueueManager;
class TimerQueueManager;
//! The data passed to the OBTimeoutHandler function.
//! The data passed to the TimeoutHandler function.
/*!
Note: this is a very useful place to put an object instance, and set the
event handler to a static function in the same class.
*/
typedef void *OBTimeoutData;
//! The type of function which can be set as the callback for an OBTimer firing
typedef void (*OBTimeoutHandler)(OBTimeoutData);
typedef void *TimeoutData;
//! The type of function which can be set as the callback for a Timer firing
typedef void (*TimeoutHandler)(TimeoutData);
//! A Timer class which will fire a function when its time elapses
class OBTimer {
class Timer {
private:
//! The manager which to add ourself to and remove ourself after we are done
OBTimerQueueManager *_manager;
TimerQueueManager *_manager;
//! The function to call when the time elapses
OBTimeoutHandler _handler;
//! The data which gets passed along to the OBTimeoutHandler
OBTimeoutData _data;
TimeoutHandler _handler;
//! The data which gets passed along to the TimeoutHandler
TimeoutData _data;
//! Determines if the timer is currently started
bool _timing;
//! When this is true, the timer will reset itself to fire again every time
@ -47,57 +47,57 @@ private:
//! The time at which the timer is going to fire
timeval _timeout;
//! Disallows copying of OBTimer objects
OBTimer(const OBTimer&);
//! Disallows copying of OBTimer objects
OBTimer& operator=(const OBTimer&);
//! Disallows copying of Timer objects
Timer(const Timer&);
//! Disallows copying of Timer objects
Timer& operator=(const Timer&);
public:
//! Constructs a new OBTimer object
//! Constructs a new Timer object
/*!
@param m The OBTimerQueueManager with which to associate. The manager
@param m The TimerQueueManager with which to associate. The manager
specified will be resposible for making this timer fire.
@param h The function to call when the timer fires
@param d The data to pass along to the function call when the timer fires
*/
OBTimer(OBTimerQueueManager *m, OBTimeoutHandler h, OBTimeoutData d);
//! Destroys the OBTimer object
virtual ~OBTimer();
Timer(TimerQueueManager *m, TimeoutHandler h, TimeoutData d);
//! Destroys the Timer object
virtual ~Timer();
//! Fires the timer, calling its OBTimeoutHandler
//! Fires the timer, calling its TimeoutHandler
void fire();
//! Returns if the OBTimer is started and timing
//! Returns if the Timer is started and timing
inline bool timing() const { return _timing; }
//! Returns if the OBTimer is going to repeat
//! Returns if the Timer is going to repeat
inline bool recurring() const { return _recur; }
//! Gets the amount of time the OBTimer should last before firing
//! Gets the amount of time the Timer should last before firing
inline const timeval &timeout() const { return _timeout; }
//! Gets the time at which the OBTimer started
//! Gets the time at which the Timer started
inline const timeval &startTime() const { return _start; }
//! Gets the amount of time left before the OBTimer fires
//! Gets the amount of time left before the Timer fires
timeval remainingTime(const timeval &tm) const;
//! Returns if the OBTimer is past its timeout time, and should fire
//! Returns if the Timer is past its timeout time, and should fire
bool shouldFire(const timeval &tm) const;
//! Gets the time at which the OBTimer will fire
//! Gets the time at which the Timer will fire
timeval endTime() const;
//! Sets the OBTimer to repeat or not
//! Sets the Timer to repeat or not
/*!
@param b If true, the timer is set to repeat; otherwise, it will fire only
once
*/
inline void setRecurring(bool b) { _recur = b; }
//! Sets the amount of time for the OBTimer to last in milliseconds
//! Sets the amount of time for the Timer to last in milliseconds
/*!
@param t The number of milliseconds the timer should last
*/
void setTimeout(long t);
//! Sets the amount of time the OBTimer should last before firing
//! Sets the amount of time the Timer should last before firing
/*!
@param t The amount of time the timer should last
*/
@ -105,7 +105,7 @@ public:
//! Causes the timer to begin
/*!
The timer fires after the time in OBTimer::getTimeout has passed since this
The timer fires after the time in Timer::getTimeout has passed since this
function was called.
Calling this function while the timer is already started will cause it to
restart its countdown.
@ -118,12 +118,12 @@ public:
*/
void stop(); // manager releases timer
//! Determines if this OBTimer will fire before a second OBTimer object
//! Determines if this Timer will fire before a second Timer object
/*!
@param other The second OBTimer with which to compare
@return true if this OBTimer will fire before 'other'; otherwise, false
@param other The second Timer with which to compare
@return true if this Timer will fire before 'other'; otherwise, false
*/
bool operator<(const OBTimer& other) const
bool operator<(const Timer& other) const
{ return shouldFire(other.endTime()); }
};

View file

@ -1,4 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __timerqueue_hh
#define __timerqueue_hh
@ -37,13 +37,12 @@ private:
};
struct TimerLessThan {
bool operator()(const OBTimer* const l, const OBTimer* const r) const {
bool operator()(const Timer* const l, const Timer* const r) const {
return *r < *l;
}
};
typedef _timer_queue<OBTimer*,
std::vector<OBTimer*>, TimerLessThan> TimerQueue;
typedef _timer_queue<Timer*, std::vector<Timer*>, TimerLessThan> TimerQueue;
}

View file

@ -9,19 +9,19 @@
namespace otk {
void OBTimerQueueManager::fire(bool wait)
void TimerQueueManager::fire(bool wait)
{
fd_set rfds;
timeval now, tm, *timeout = (timeval *) 0;
const int xfd = ConnectionNumber(otk::OBDisplay::display);
const int xfd = ConnectionNumber(Display::display);
FD_ZERO(&rfds);
FD_SET(xfd, &rfds); // break on any x events
if (wait) {
if (! timerList.empty()) {
const OBTimer* const timer = timerList.top();
const Timer* const timer = timerList.top();
gettimeofday(&now, 0);
tm = timer->remainingTime(now);
@ -40,7 +40,7 @@ void OBTimerQueueManager::fire(bool wait)
// timer->start() and timer->shouldFire() is within the timer's period
// then the timer will keep firing. This should be VERY near impossible.
while (! timerList.empty()) {
OBTimer *timer = timerList.top();
Timer *timer = timerList.top();
if (! timer->shouldFire(now))
break;
@ -53,13 +53,13 @@ void OBTimerQueueManager::fire(bool wait)
}
void OBTimerQueueManager::addTimer(OBTimer *timer)
void TimerQueueManager::addTimer(Timer *timer)
{
assert(timer);
timerList.push(timer);
}
void OBTimerQueueManager::removeTimer(OBTimer* timer)
void TimerQueueManager::removeTimer(Timer* timer)
{
assert(timer);
timerList.release(timer);

View file

@ -1,4 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __timerqueuemanager_hh
#define __timerqueuemanager_hh
@ -6,21 +6,21 @@
namespace otk {
//! Manages a queue of OBTimer objects
//! Manages a queue of Timer objects
/*!
All OBTimer objects add themself to an OBTimerQueueManager. The manager is
All Timer objects add themself to a TimerQueueManager. The manager is
what fires the timers when their time has elapsed. This is done by having the
application call the OBTimerQueueManager::fire class in its main event loop.
application call the TimerQueueManager::fire class in its main event loop.
*/
class OBTimerQueueManager {
class TimerQueueManager {
private:
//! A priority queue of all timers being managed by this class.
TimerQueue timerList;
public:
//! Constructs a new OBTimerQueueManager
OBTimerQueueManager() {}
//! Destroys the OBTimerQueueManager
virtual ~OBTimerQueueManager() {}
//! Constructs a new TimerQueueManager
TimerQueueManager() {}
//! Destroys the TimerQueueManager
virtual ~TimerQueueManager() {}
//! Fire the next timer in the queue.
/*!
@ -31,14 +31,14 @@ public:
//! Adds a new timer to the queue
/*!
@param timer An OBTimer to add to the queue
@param timer An Timer to add to the queue
*/
virtual void addTimer(OBTimer* timer);
virtual void addTimer(Timer* timer);
//! Removes a timer from the queue
/*!
@param timer An OBTimer already in the queue to remove
@param timer An Timer already in the queue to remove
*/
virtual void removeTimer(OBTimer* timer);
virtual void removeTimer(Timer* timer);
};
}

View file

@ -1,6 +1,6 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef _BLACKBOX_UTIL_HH
#define _BLACKBOX_UTIL_HH
#ifndef __util_hh
#define __util_hh
extern "C" {
#include <X11/Xlib.h>
@ -18,7 +18,6 @@ extern "C" {
#endif // TIME_WITH_SYS_TIME
}
#include <string>
#include <vector>
@ -46,4 +45,4 @@ std::string basename(const std::string& path);
}
#endif
#endif // __util_hh

View file

@ -14,8 +14,8 @@
namespace otk {
OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
: OtkEventHandler(),
Widget::Widget(Widget *parent, Direction direction)
: EventHandler(),
_dirty(false), _focused(false),
_parent(parent), _style(parent->style()), _direction(direction),
_cursor(parent->cursor()), _bevel_width(parent->bevelWidth()),
@ -33,10 +33,10 @@ OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
setStyle(_style); // let the widget initialize stuff
}
OtkWidget::OtkWidget(OtkEventDispatcher *event_dispatcher, Style *style,
Widget::Widget(EventDispatcher *event_dispatcher, Style *style,
Direction direction, Cursor cursor, int bevel_width,
bool override_redirect)
: OtkEventHandler(),
: EventHandler(),
_dirty(false),_focused(false),
_parent(0), _style(style), _direction(direction), _cursor(cursor),
_bevel_width(bevel_width), _ignore_config(0), _visible(false),
@ -53,7 +53,7 @@ OtkWidget::OtkWidget(OtkEventDispatcher *event_dispatcher, Style *style,
setStyle(_style); // let the widget initialize stuff
}
OtkWidget::~OtkWidget()
Widget::~Widget()
{
if (_visible)
hide();
@ -65,12 +65,12 @@ OtkWidget::~OtkWidget()
if (_parent)
_parent->removeChild(this);
XDestroyWindow(otk::OBDisplay::display, _window);
XDestroyWindow(Display::display, _window);
}
void OtkWidget::create(bool override_redirect)
void Widget::create(bool override_redirect)
{
const ScreenInfo *scr_info = otk::OBDisplay::screenInfo(_screen);
const ScreenInfo *scr_info = Display::screenInfo(_screen);
Window p_window = _parent ? _parent->window() : scr_info->rootWindow();
_rect.setRect(0, 0, 1, 1); // just some initial values
@ -93,71 +93,71 @@ void OtkWidget::create(bool override_redirect)
attrib_create.cursor = _cursor;
}
_window = XCreateWindow(otk::OBDisplay::display, p_window, _rect.x(),
_window = XCreateWindow(Display::display, p_window, _rect.x(),
_rect.y(), _rect.width(), _rect.height(), 0,
scr_info->depth(), InputOutput,
scr_info->visual(), create_mask, &attrib_create);
_ignore_config++;
}
void OtkWidget::setWidth(int w)
void Widget::setWidth(int w)
{
assert(w > 0);
_fixed_width = true;
setGeometry(_rect.x(), _rect.y(), w, _rect.height());
}
void OtkWidget::setHeight(int h)
void Widget::setHeight(int h)
{
assert(h > 0);
_fixed_height = true;
setGeometry(_rect.x(), _rect.y(), _rect.width(), h);
}
void OtkWidget::move(const Point &to)
void Widget::move(const Point &to)
{
move(to.x(), to.y());
}
void OtkWidget::move(int x, int y)
void Widget::move(int x, int y)
{
_rect.setPos(x, y);
XMoveWindow(otk::OBDisplay::display, _window, x, y);
XMoveWindow(Display::display, _window, x, y);
_ignore_config++;
}
void OtkWidget::resize(const Point &to)
void Widget::resize(const Point &to)
{
resize(to.x(), to.y());
}
void OtkWidget::resize(int w, int h)
void Widget::resize(int w, int h)
{
assert(w > 0 && h > 0);
_fixed_width = _fixed_height = true;
setGeometry(_rect.x(), _rect.y(), w, h);
}
void OtkWidget::setGeometry(const Rect &new_geom)
void Widget::setGeometry(const Rect &new_geom)
{
setGeometry(new_geom.x(), new_geom.y(), new_geom.width(), new_geom.height());
}
void OtkWidget::setGeometry(const Point &topleft, int width, int height)
void Widget::setGeometry(const Point &topleft, int width, int height)
{
setGeometry(topleft.x(), topleft.y(), width, height);
}
void OtkWidget::setGeometry(int x, int y, int width, int height)
void Widget::setGeometry(int x, int y, int width, int height)
{
_rect = Rect(x, y, width, height);
_dirty = true;
XMoveResizeWindow(otk::OBDisplay::display, _window, x, y, width, height);
XMoveResizeWindow(Display::display, _window, x, y, width, height);
_ignore_config++;
}
void OtkWidget::show(bool recursive)
void Widget::show(bool recursive)
{
if (_visible)
return;
@ -167,53 +167,53 @@ void OtkWidget::show(bool recursive)
update();
if (recursive) {
OtkWidgetList::iterator it = _children.begin(), end = _children.end();
WidgetList::iterator it = _children.begin(), end = _children.end();
for (; it != end; ++it)
(*it)->show();
}
XMapWindow(otk::OBDisplay::display, _window);
XMapWindow(Display::display, _window);
_visible = true;
}
void OtkWidget::hide(bool recursive)
void Widget::hide(bool recursive)
{
if (! _visible)
return;
if (recursive) {
OtkWidgetList::iterator it = _children.begin(), end = _children.end();
WidgetList::iterator it = _children.begin(), end = _children.end();
for (; it != end; ++it)
(*it)->hide();
}
XUnmapWindow(otk::OBDisplay::display, _window);
XUnmapWindow(Display::display, _window);
_visible = false;
}
void OtkWidget::focus(void)
void Widget::focus(void)
{
_focused = true;
OtkWidget::OtkWidgetList::iterator it = _children.begin(),
Widget::WidgetList::iterator it = _children.begin(),
end = _children.end();
for (; it != end; ++it)
(*it)->focus();
}
void OtkWidget::unfocus(void)
void Widget::unfocus(void)
{
_focused = false;
OtkWidget::OtkWidgetList::iterator it = _children.begin(),
Widget::WidgetList::iterator it = _children.begin(),
end = _children.end();
for (; it != end; ++it)
(*it)->unfocus();
}
bool OtkWidget::grabMouse(void)
bool Widget::grabMouse(void)
{
Status ret = XGrabPointer(otk::OBDisplay::display, _window, True,
Status ret = XGrabPointer(Display::display, _window, True,
(ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | EnterWindowMask |
LeaveWindowMask | PointerMotionMask),
@ -223,52 +223,52 @@ bool OtkWidget::grabMouse(void)
return _grabbed_mouse;
}
void OtkWidget::ungrabMouse(void)
void Widget::ungrabMouse(void)
{
if (! _grabbed_mouse)
return;
XUngrabPointer(otk::OBDisplay::display, CurrentTime);
XUngrabPointer(Display::display, CurrentTime);
_grabbed_mouse = false;
}
bool OtkWidget::grabKeyboard(void)
bool Widget::grabKeyboard(void)
{
Status ret = XGrabKeyboard(otk::OBDisplay::display, _window, True,
Status ret = XGrabKeyboard(Display::display, _window, True,
GrabModeSync, GrabModeAsync, CurrentTime);
_grabbed_keyboard = (ret == GrabSuccess);
return _grabbed_keyboard;
}
void OtkWidget::ungrabKeyboard(void)
void Widget::ungrabKeyboard(void)
{
if (! _grabbed_keyboard)
return;
XUngrabKeyboard(otk::OBDisplay::display, CurrentTime);
XUngrabKeyboard(Display::display, CurrentTime);
_grabbed_keyboard = false;
}
void OtkWidget::render(void)
void Widget::render(void)
{
if (!_texture) return;
_bg_pixmap = _texture->render(_rect.width(), _rect.height(), _bg_pixmap);
if (_bg_pixmap) {
XSetWindowBackgroundPixmap(otk::OBDisplay::display, _window, _bg_pixmap);
XSetWindowBackgroundPixmap(Display::display, _window, _bg_pixmap);
_bg_pixel = None;
} else {
unsigned int pix = _texture->color().pixel();
if (pix != _bg_pixel) {
_bg_pixel = pix;
XSetWindowBackground(otk::OBDisplay::display, _window, pix);
XSetWindowBackground(Display::display, _window, pix);
}
}
}
void OtkWidget::adjust(void)
void Widget::adjust(void)
{
if (_direction == Horizontal)
adjustHorz();
@ -276,17 +276,17 @@ void OtkWidget::adjust(void)
adjustVert();
}
void OtkWidget::adjustHorz(void)
void Widget::adjustHorz(void)
{
if (_children.size() == 0)
return;
OtkWidget *tmp;
OtkWidgetList::iterator it, end = _children.end();
Widget *tmp;
WidgetList::iterator it, end = _children.end();
int tallest = 0;
int width = _bevel_width;
OtkWidgetList stretchable;
WidgetList stretchable;
for (it = _children.begin(); it != end; ++it) {
tmp = *it;
@ -303,7 +303,7 @@ void OtkWidget::adjustHorz(void)
}
if (stretchable.size() > 0) {
OtkWidgetList::iterator str_it = stretchable.begin(),
WidgetList::iterator str_it = stretchable.begin(),
str_end = stretchable.end();
int str_width = _rect.width() - width / stretchable.size();
@ -313,7 +313,7 @@ void OtkWidget::adjustHorz(void)
: _bevel_width);
}
OtkWidget *prev_widget = 0;
Widget *prev_widget = 0;
for (it = _children.begin(); it != end; ++it) {
tmp = *it;
@ -333,17 +333,17 @@ void OtkWidget::adjustHorz(void)
internalResize(width, tallest + _bevel_width * 2);
}
void OtkWidget::adjustVert(void)
void Widget::adjustVert(void)
{
if (_children.size() == 0)
return;
OtkWidget *tmp;
OtkWidgetList::iterator it, end = _children.end();
Widget *tmp;
WidgetList::iterator it, end = _children.end();
int widest = 0;
int height = _bevel_width;
OtkWidgetList stretchable;
WidgetList stretchable;
for (it = _children.begin(); it != end; ++it) {
tmp = *it;
@ -360,7 +360,7 @@ void OtkWidget::adjustVert(void)
}
if (stretchable.size() > 0) {
OtkWidgetList::iterator str_it = stretchable.begin(),
WidgetList::iterator str_it = stretchable.begin(),
str_end = stretchable.end();
int str_height = _rect.height() - height / stretchable.size();
@ -370,7 +370,7 @@ void OtkWidget::adjustVert(void)
str_height - _bevel_width : _bevel_width);
}
OtkWidget *prev_widget = 0;
Widget *prev_widget = 0;
for (it = _children.begin(); it != end; ++it) {
tmp = *it;
@ -390,22 +390,22 @@ void OtkWidget::adjustVert(void)
internalResize(widest + _bevel_width * 2, height);
}
void OtkWidget::update(void)
void Widget::update(void)
{
if (_dirty) {
adjust();
render();
XClearWindow(OBDisplay::display, _window);
XClearWindow(Display::display, _window);
}
OtkWidgetList::iterator it = _children.begin(), end = _children.end();
WidgetList::iterator it = _children.begin(), end = _children.end();
for (; it != end; ++it)
(*it)->update();
_dirty = false;
}
void OtkWidget::internalResize(int w, int h)
void Widget::internalResize(int w, int h)
{
assert(w > 0 && h > 0);
@ -417,7 +417,7 @@ void OtkWidget::internalResize(int w, int h)
resize(_rect.width(), h);
}
void OtkWidget::addChild(OtkWidget *child, bool front)
void Widget::addChild(Widget *child, bool front)
{
assert(child);
if (front)
@ -426,10 +426,10 @@ void OtkWidget::addChild(OtkWidget *child, bool front)
_children.push_back(child);
}
void OtkWidget::removeChild(OtkWidget *child)
void Widget::removeChild(Widget *child)
{
assert(child);
OtkWidgetList::iterator it, end = _children.end();
WidgetList::iterator it, end = _children.end();
for (it = _children.begin(); it != end; ++it) {
if ((*it) == child)
break;
@ -439,19 +439,19 @@ void OtkWidget::removeChild(OtkWidget *child)
_children.erase(it);
}
void OtkWidget::setStyle(Style *style)
void Widget::setStyle(Style *style)
{
assert(style);
_style = style;
_dirty = true;
OtkWidgetList::iterator it, end = _children.end();
WidgetList::iterator it, end = _children.end();
for (it = _children.begin(); it != end; ++it)
(*it)->setStyle(style);
}
void OtkWidget::setEventDispatcher(OtkEventDispatcher *disp)
void Widget::setEventDispatcher(EventDispatcher *disp)
{
if (_event_dispatcher)
_event_dispatcher->clearHandler(_window);
@ -459,16 +459,16 @@ void OtkWidget::setEventDispatcher(OtkEventDispatcher *disp)
_event_dispatcher->registerHandler(_window, this);
}
void OtkWidget::exposeHandler(const XExposeEvent &e)
void Widget::exposeHandler(const XExposeEvent &e)
{
OtkEventHandler::exposeHandler(e);
EventHandler::exposeHandler(e);
_dirty = true;
update();
}
void OtkWidget::configureHandler(const XConfigureEvent &e)
void Widget::configureHandler(const XConfigureEvent &e)
{
OtkEventHandler::configureHandler(e);
EventHandler::configureHandler(e);
if (_ignore_config) {
_ignore_config--;
} else {

View file

@ -1,3 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __widget_hh
#define __widget_hh
@ -17,20 +18,20 @@ extern "C" {
namespace otk {
class OtkWidget : public OtkEventHandler {
class Widget : public EventHandler {
public:
enum Direction { Horizontal, Vertical };
typedef std::list<OtkWidget *> OtkWidgetList;
typedef std::list<Widget *> WidgetList;
OtkWidget(otk::OtkWidget *parent, Direction = Horizontal);
OtkWidget(otk::OtkEventDispatcher *event_dispatcher, otk::Style *style,
Widget(Widget *parent, Direction = Horizontal);
Widget(EventDispatcher *event_dispatcher, Style *style,
Direction direction = Horizontal, Cursor cursor = 0,
int bevel_width = 1, bool override_redirect = false);
virtual ~OtkWidget();
virtual ~Widget();
virtual void update(void);
@ -38,12 +39,12 @@ public:
void configureHandler(const XConfigureEvent &e);
inline Window window(void) const { return _window; }
inline const otk::OtkWidget *parent(void) const { return _parent; }
inline const OtkWidgetList &children(void) const { return _children; }
inline const Widget *parent(void) const { return _parent; }
inline const WidgetList &children(void) const { return _children; }
inline unsigned int screen(void) const { return _screen; }
inline const otk::Rect &rect(void) const { return _rect; }
inline const Rect &rect(void) const { return _rect; }
void move(const otk::Point &to);
void move(const Point &to);
void move(int x, int y);
virtual void setWidth(int);
@ -52,11 +53,11 @@ public:
virtual int width() const { return _rect.width(); }
virtual int height() const { return _rect.height(); }
virtual void resize(const otk::Point &to);
virtual void resize(const Point &to);
virtual void resize(int x, int y);
virtual void setGeometry(const otk::Rect &new_geom);
virtual void setGeometry(const otk::Point &topleft, int width, int height);
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);
inline bool isVisible(void) const { return _visible; };
@ -75,24 +76,24 @@ public:
bool grabKeyboard(void);
void ungrabKeyboard(void);
inline otk::BTexture *texture(void) const { return _texture; }
virtual void setTexture(otk::BTexture *texture)
inline Texture *texture(void) const { return _texture; }
virtual void setTexture(Texture *texture)
{ _texture = texture; _dirty = true; }
inline const otk::BColor *borderColor(void) const { return _bcolor; }
virtual void setBorderColor(const otk::BColor *color) {
inline const Color *borderColor(void) const { return _bcolor; }
virtual void setBorderColor(const Color *color) {
assert(color); _bcolor = color;
XSetWindowBorder(OBDisplay::display, _window, color->pixel());
XSetWindowBorder(Display::display, _window, color->pixel());
}
inline int borderWidth(void) const { return _bwidth; }
void setBorderWidth(int width) {
_bwidth = width;
XSetWindowBorderWidth(otk::OBDisplay::display, _window, width);
XSetWindowBorderWidth(Display::display, _window, width);
}
virtual void addChild(OtkWidget *child, bool front = false);
virtual void removeChild(OtkWidget *child);
virtual void addChild(Widget *child, bool front = false);
virtual void removeChild(Widget *child);
inline bool isStretchableHorz(void) const { return _stretchable_horz; }
void setStretchableHorz(bool s_horz = true) { _stretchable_horz = s_horz; }
@ -103,7 +104,7 @@ public:
inline Cursor cursor(void) const { return _cursor; }
void setCursor(Cursor cursor) {
_cursor = cursor;
XDefineCursor(OBDisplay::display, _window, _cursor);
XDefineCursor(Display::display, _window, _cursor);
}
inline int bevelWidth(void) const { return _bevel_width; }
@ -113,12 +114,12 @@ public:
inline Direction direction(void) const { return _direction; }
void setDirection(Direction dir) { _direction = dir; }
inline otk::Style *style(void) const { return _style; }
virtual void setStyle(otk::Style *style);
inline Style *style(void) const { return _style; }
virtual void setStyle(Style *style);
inline otk::OtkEventDispatcher *eventDispatcher(void)
inline EventDispatcher *eventDispatcher(void)
{ return _event_dispatcher; }
void setEventDispatcher(otk::OtkEventDispatcher *disp);
void setEventDispatcher(EventDispatcher *disp);
protected:
@ -134,8 +135,8 @@ protected:
Window _window;
OtkWidget *_parent;
OtkWidgetList _children;
Widget *_parent;
WidgetList _children;
Style *_style;
Direction _direction;
@ -151,11 +152,11 @@ protected:
bool _stretchable_vert;
bool _stretchable_horz;
BTexture *_texture;
Texture *_texture;
Pixmap _bg_pixmap;
unsigned int _bg_pixel;
const BColor *_bcolor;
const Color *_bcolor;
unsigned int _bwidth;
Rect _rect;
@ -164,7 +165,7 @@ protected:
bool _fixed_width;
bool _fixed_height;
OtkEventDispatcher *_event_dispatcher;
EventDispatcher *_event_dispatcher;
};
}