summaryrefslogtreecommitdiff
path: root/otk
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-03-21 18:42:39 +0000
committerDana Jansens <danakj@orodu.net>2003-03-21 18:42:39 +0000
commita52a6d96d701c993896f276e4198003317632aaf (patch)
treebe2f51e6a433d1fdf9a7c8248b343cb3f6297212 /otk
parenta36c7543d4eedaa9e10bfd9f4d9b81279b1bb7e6 (diff)
rm the old code including the .pys and the c++ shit
Diffstat (limited to 'otk')
-rw-r--r--otk/.cvsignore45
-rw-r--r--otk/Makefile.am51
-rw-r--r--otk/TODO38
-rw-r--r--otk/application.cc65
-rw-r--r--otk/application.hh39
-rw-r--r--otk/appwidget.cc56
-rw-r--r--otk/appwidget.hh29
-rw-r--r--otk/assassin.hh16
-rw-r--r--otk/button.cc77
-rw-r--r--otk/button.hh34
-rw-r--r--otk/display.cc306
-rw-r--r--otk/display.hh126
-rw-r--r--otk/eventdispatcher.cc217
-rw-r--r--otk/eventdispatcher.hh62
-rw-r--r--otk/eventhandler.cc106
-rw-r--r--otk/eventhandler.hh152
-rw-r--r--otk/font.cc102
-rw-r--r--otk/font.hh60
-rw-r--r--otk/label.cc176
-rw-r--r--otk/label.hh66
-rw-r--r--otk/messagedialog.cc187
-rw-r--r--otk/messagedialog.hh66
-rw-r--r--otk/otk.cc25
-rw-r--r--otk/otk.hh39
-rw-r--r--otk/otk.pc.in11
-rw-r--r--otk/otk_test.cc36
-rw-r--r--otk/point.hh23
-rw-r--r--otk/property.cc342
-rw-r--r--otk/property.hh303
-rw-r--r--otk/pseudorendercontrol.cc157
-rw-r--r--otk/pseudorendercontrol.hh28
-rw-r--r--otk/rect.hh39
-rw-r--r--otk/rendercolor.cc101
-rw-r--r--otk/rendercolor.hh64
-rw-r--r--otk/rendercontrol.cc596
-rw-r--r--otk/rendercontrol.hh85
-rw-r--r--otk/renderstyle.cc697
-rw-r--r--otk/renderstyle.hh157
-rw-r--r--otk/rendertest.cc45
-rw-r--r--otk/rendertexture.hh169
-rw-r--r--otk/screeninfo.cc81
-rw-r--r--otk/screeninfo.hh42
-rw-r--r--otk/size.hh25
-rw-r--r--otk/strut.hh35
-rw-r--r--otk/surface.cc97
-rw-r--r--otk/surface.hh88
-rw-r--r--otk/timer.cc145
-rw-r--r--otk/timer.hh114
-rw-r--r--otk/truerendercontrol.cc114
-rw-r--r--otk/truerendercontrol.hh35
-rw-r--r--otk/ustring.cc263
-rw-r--r--otk/ustring.hh177
-rw-r--r--otk/util.cc97
-rw-r--r--otk/util.hh32
-rw-r--r--otk/widget.cc547
-rw-r--r--otk/widget.hh141
56 files changed, 0 insertions, 7026 deletions
diff --git a/otk/.cvsignore b/otk/.cvsignore
deleted file mode 100644
index a563c2af..00000000
--- a/otk/.cvsignore
+++ /dev/null
@@ -1,45 +0,0 @@
-Makefile
-Makefile.in
-.deps
-otk_test
-otk_wrap.cc
-.libs
-application.lo
-appwidget.lo
-button.lo
-color.lo
-configuration.lo
-display.lo
-eventdispatcher.lo
-eventhandler.lo
-focuslabel.lo
-focuswidget.lo
-font.lo
-gccache.lo
-image.lo
-imagecontrol.lo
-label.lo
-libotk.la
-otk_wrap.lo
-property.lo
-rect.lo
-screeninfo.lo
-style.lo
-texture.lo
-timer.lo
-timerqueuemanager.lo
-truerendercontrol.lo
-pseudorendercontrol.lo
-util.lo
-widget.lo
-ustring.lo
-surface.lo
-rendertexture.lo
-rendertest
-renderstyle.lo
-messagedialog.lo
-rendercontrol.lo
-rendercolor.lo
-otk.py
-otk.pc
-otk.lo
diff --git a/otk/Makefile.am b/otk/Makefile.am
deleted file mode 100644
index 58fe305d..00000000
--- a/otk/Makefile.am
+++ /dev/null
@@ -1,51 +0,0 @@
-buttonsdir = $(pkgdatadir)/buttons
-includeotkdir = $(includedir)/otk
-pkgconfigdir = $(libdir)/pkgconfig
-
-CPPFLAGS=$(XFT_CFLAGS) @CPPFLAGS@ -DBUTTONSDIR=\"$(buttonsdir)\"
-
-lib_LTLIBRARIES=libotk.la
-
-libotk_la_SOURCES=rendercontrol.cc truerendercontrol.cc surface.cc util.cc \
- renderstyle.cc rendercolor.cc pseudorendercontrol.cc \
- display.cc font.cc property.cc timer.cc \
- eventdispatcher.cc eventhandler.cc ustring.cc \
- widget.cc application.cc label.cc appwidget.cc button.cc \
- otk.cc messagedialog.cc
-
-#focuswidget.cc focuslabel.cc
-
-includeotk_HEADERS=application.hh appwidget.hh assassin.hh button.hh \
- display.hh eventdispatcher.hh eventhandler.hh font.hh \
- label.hh otk.hh point.hh property.hh pseudorendercontrol.hh\
- rect.hh rendercolor.hh rendercontrol.hh renderstyle.hh \
- rendertexture.hh size.hh strut.hh surface.hh \
- timer.hh truerendercontrol.hh ustring.hh util.hh widget.hh \
- messagedialog.hh ../config.h
-
-EXTRA_DIST = otk.pc.in
-
-DISTCLEANFILES = otk.pc
-MAINTAINERCLEANFILES= Makefile.in
-
-pkgconfig_DATA = otk.pc
-
-otk.pc: otk.pc.in
- @regex_cmd@ -e "s,\@prefix\@,$(prefix)," \
- -e "s,\@version\@,$(VERSION)," \
- @srcdir@/$^ > $@
-
-distclean-local:
- $(RM) *\~ *.orig *.rej .\#*
-
-uninstall-am:
- -rmdir -p $(includeotkdir)
- -rmdir -p $(pkgconfigdir)
-
-otk_test: libotk.la otk_test.cc
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) -DHAVE_CONFIG_H -I. -I. -I.. -I../src $(XFT_CFLAGS) -Wall -W -pedantic -DNDEBUG -g -O2 -o otk_test otk_test.cc $(XFT_LIBS) -L. -lotk @LIBS@
-
-rendertest: libotk.la rendertest.cc
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) -DHAVE_CONFIG_H -I. -I. -I.. -I../src $(XFT_CFLAGS) -Wall -W -pedantic -DNDEBUG -g -O2 -o $@ rendertest.cc $(XFT_LIBS) -L. -lotk @LIBS@
-
-# local dependencies
diff --git a/otk/TODO b/otk/TODO
deleted file mode 100644
index 1a380c13..00000000
--- a/otk/TODO
+++ /dev/null
@@ -1,38 +0,0 @@
-* Implement borders and border overlapping in widget
- the widget has a outer geometry(that of the border) and a inner one
- (the current geometry)
- if the overlap flag is true, the inner widgets' borders are overlapped
- as much as possible while the widgets are still entirely visible.
-
-* make OtkButton do pixmaps
-
-* OtkMenu
- this can wait, probably
-
-* OtkWidget
- see about focus()
- focus() on widgets means 'highlight', not take Focus. solve this mess
-
-* OtkTextWidget
- widget that holds text that can be justified and whatnot
- the button should prolly be modified to subclass this
-
-* OtkApplication
- do all derty work init display/screen/style/image control etc
- event loop
- do docking
- close app, clean up crap
- watch for style properties on the root window, update crap
- on the fly.
-
-* widget factory for openbox
- singleton that fetches widgets to openbox so that openbox
- doesn't need to do useless work in creating/initializing/etc
-
-* cleanup image code
- less deps on screen and display
- what's this thing about 8bpp being busticatered
-
-* cleanups
- name classes OtkBummy instead of OB... or B...
- make Style hold pointers to colors and textures
diff --git a/otk/application.cc b/otk/application.cc
deleted file mode 100644
index 1f65046b..00000000
--- a/otk/application.cc
+++ /dev/null
@@ -1,65 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "application.hh"
-#include "eventhandler.hh"
-#include "timer.hh"
-#include "property.hh"
-#include "rendercolor.hh"
-#include "renderstyle.hh"
-#include "display.hh"
-
-#include <cstdlib>
-#include <iostream>
-
-namespace otk {
-
-extern void initialize();
-extern void destroy();
-
-Application::Application(int argc, char **argv)
- : EventDispatcher(),
- _dockable(false),
- _appwidget_count(0)
-{
- (void)argc;
- (void)argv;
-
- otk::initialize();
-
- _screen = DefaultScreen(**display);
-
- loadStyle();
-}
-
-Application::~Application()
-{
- otk::destroy();
-}
-
-void Application::loadStyle(void)
-{
- // XXX: find the style name as a property
- std::string style = "/usr/local/share/openbox/styles/artwiz";
- //_style->load(style);
- otk::RenderStyle::setStyle(_screen, style);
-}
-
-void Application::run(void)
-{
- if (_appwidget_count <= 0) {
- std::cerr << "ERROR: No main widgets exist. You must create and show() " <<
- "an AppWidget for the Application before calling " <<
- "Application::run().\n";
- ::exit(1);
- }
-
- while (_appwidget_count > 0) {
- dispatchEvents();
- if (_appwidget_count > 0)
- Timer::dispatchTimers(); // fire pending events
- }
-}
-
-}
diff --git a/otk/application.hh b/otk/application.hh
deleted file mode 100644
index 6da36d28..00000000
--- a/otk/application.hh
+++ /dev/null
@@ -1,39 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __application_hh
-#define __application_hh
-
-#include "eventdispatcher.hh"
-
-namespace otk {
-
-class AppWidget;
-
-class Application : public EventDispatcher {
-
-public:
-
- Application(int argc, char **argv);
- virtual ~Application();
-
- inline int screen() const { return _screen; }
-
- virtual void run(void);
- // more bummy cool functionality
-
- void setDockable(bool dockable) { _dockable = dockable; }
- inline bool isDockable(void) const { return _dockable; }
-
-private:
- void loadStyle(void);
-
- int _screen;
- bool _dockable;
-
- int _appwidget_count;
-
- friend class AppWidget;
-};
-
-}
-
-#endif
diff --git a/otk/appwidget.cc b/otk/appwidget.cc
deleted file mode 100644
index 5dcad7ae..00000000
--- a/otk/appwidget.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "appwidget.hh"
-#include "application.hh"
-#include "property.hh"
-#include "renderstyle.hh"
-#include "display.hh"
-
-extern "C" {
-#include <X11/Xlib.h>
-}
-
-namespace otk {
-
-AppWidget::AppWidget(Application *app, Direction direction, int bevel)
- : Widget(app->screen(), app, direction, bevel),
- _application(app)
-{
- assert(app);
-
- // set WM Protocols on the window
- Atom protocols[2];
- protocols[0] = Property::atoms.wm_protocols;
- protocols[1] = Property::atoms.wm_delete_window;
- XSetWMProtocols(**display, window(), protocols, 2);
-}
-
-AppWidget::~AppWidget()
-{
-}
-
-void AppWidget::show()
-{
- if (!visible())
- _application->_appwidget_count++;
- Widget::show(true);
-}
-
-void AppWidget::hide()
-{
- if (visible())
- _application->_appwidget_count--;
- Widget::hide();
-}
-
-void AppWidget::clientMessageHandler(const XClientMessageEvent &e)
-{
- EventHandler::clientMessageHandler(e);
- if (e.message_type == Property::atoms.wm_protocols &&
- static_cast<Atom>(e.data.l[0]) == Property::atoms.wm_delete_window)
- hide();
-}
-
-}
diff --git a/otk/appwidget.hh b/otk/appwidget.hh
deleted file mode 100644
index 5595e88e..00000000
--- a/otk/appwidget.hh
+++ /dev/null
@@ -1,29 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __appwidget_hh
-#define __appwidget_hh
-
-#include "widget.hh"
-
-namespace otk {
-
-class Application;
-
-class AppWidget : public Widget {
-
-public:
- AppWidget(Application *app, Direction direction = Horizontal, int bevel = 0);
- virtual ~AppWidget();
-
- virtual void show();
- virtual void hide();
-
- virtual void clientMessageHandler(const XClientMessageEvent &e);
-
-private:
-
- Application *_application;
-};
-
-}
-
-#endif // __appwidget_hh
diff --git a/otk/assassin.hh b/otk/assassin.hh
deleted file mode 100644
index 5caf17f0..00000000
--- a/otk/assassin.hh
+++ /dev/null
@@ -1,16 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __assassin_hh
-#define __assassin_hh
-
-namespace otk {
-
-struct PointerAssassin {
- template<typename T>
- inline void operator()(const T ptr) const {
- delete ptr;
- }
-};
-
-}
-
-#endif // __assassin_hh
diff --git a/otk/button.cc b/otk/button.cc
deleted file mode 100644
index 313d8acf..00000000
--- a/otk/button.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "button.hh"
-
-namespace otk {
-
-Button::Button(Widget *parent)
- : Label(parent),
- _pressed(false)
-{
- setHorizontalJustify(RenderStyle::CenterJustify);
- setVerticalJustify(RenderStyle::CenterJustify);
- styleChanged(*RenderStyle::style(screen()));
-}
-
-Button::~Button()
-{
-}
-
-void Button::press(unsigned int mouse_button)
-{
- if (_pressed) return;
-
- _pressed = true;
- _mouse_button = mouse_button;
-
- styleChanged(*RenderStyle::style(screen()));
- refresh();
-}
-
-void Button::release(unsigned int mouse_button)
-{
- if (!_pressed || _mouse_button != mouse_button) return; // wrong button
-
- _pressed = false;
-
- styleChanged(*RenderStyle::style(screen()));
- refresh();
-}
-
-void Button::buttonPressHandler(const XButtonEvent &e)
-{
- Widget::buttonPressHandler(e);
- press(e.button);
-}
-
-void Button::buttonReleaseHandler(const XButtonEvent &e)
-{
- Widget::buttonReleaseHandler(e);
- bool p = _pressed;
- release(e.button);
- if (p && !_pressed && e.x > 0 && e.y > 0 &&
- e.x < area().width() && e.y < area().height())
- clickHandler(_mouse_button);
-}
-
-void Button::styleChanged(const RenderStyle &style)
-{
- if (isHighlighted()) {
- if (_pressed)
- _texture = style.buttonPressFocusBackground();
- else
- _texture = style.buttonUnpressFocusBackground();
- _forecolor = style.buttonFocusColor();
- } else {
- if (_pressed)
- _texture = style.buttonPressUnfocusBackground();
- else
- _texture = style.buttonUnpressUnfocusBackground();
- _forecolor = style.buttonUnfocusColor();
- }
- refresh();
-}
-
-}
diff --git a/otk/button.hh b/otk/button.hh
deleted file mode 100644
index a3805aa0..00000000
--- a/otk/button.hh
+++ /dev/null
@@ -1,34 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __button_hh
-#define __button_hh
-
-#include "label.hh"
-
-namespace otk {
-
-class Button : public Label {
-
-public:
- Button(Widget *parent);
- virtual ~Button();
-
- virtual inline bool isPressed() const { return _pressed; }
-
- virtual void press(unsigned int mouse_button);
- virtual void release(unsigned int mouse_button);
-
- virtual void buttonPressHandler(const XButtonEvent &e);
- virtual void buttonReleaseHandler(const XButtonEvent &e);
-
- virtual void clickHandler(unsigned int button) {(void)button;}
-
- virtual void styleChanged(const RenderStyle &style);
-
-private:
- bool _pressed;
- unsigned int _mouse_button;
-};
-
-}
-
-#endif
diff --git a/otk/display.cc b/otk/display.cc
deleted file mode 100644
index d4580a0e..00000000
--- a/otk/display.cc
+++ /dev/null
@@ -1,306 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "display.hh"
-#include "util.hh"
-
-extern "C" {
-#include <X11/keysym.h>
-
-#ifdef XKB
-#include <X11/XKBlib.h>
-#endif // XKB
-
-#ifdef SHAPE
-#include <X11/extensions/shape.h>
-#endif // SHAPE
-
-#ifdef XINERAMA
-#include <X11/extensions/Xinerama.h>
-#endif // XINERAMA
-
-#ifdef HAVE_SIGNAL_H
-# include <signal.h>
-#endif // HAVE_SIGNAL_H
-
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif // HAVE_FCNTL_H
-
-#ifdef HAVE_UNISTD_H
-# include <sys/types.h>
-# include <unistd.h>
-#endif // HAVE_UNISTD_H
-
-#include "../src/gettext.h"
-#define _(str) gettext(str)
-}
-
-#include <cstdio>
-
-namespace otk {
-
-
-Display *display = (Display*) 0;
-
-static int xerrorHandler(::Display *d, XErrorEvent *e)
-{
- if (!display->ignoreErrors()) {
-#ifdef DEBUG
- char errtxt[128];
-
- //if (e->error_code != BadWindow)
- {
- XGetErrorText(d, e->error_code, errtxt, 127);
- printf("X Error: %s\n", errtxt);
- if (e->error_code != BadWindow)
- abort();
- }
-#else
- (void)d;
- (void)e;
-#endif
- }
- return false;
-}
-
-
-Display::Display(::Display *d)
- : _display(d),
- _xkb(false),
- _xkb_event_basep(0),
- _shape(false),
- _shape_event_basep(0),
- _xinerama(false),
- _xinerama_event_basep(0),
- _mask_list(),
- _num_lock_mask(0),
- _scroll_lock_mask(0),
- _grab_count(0)
-{
- int junk;
- (void)junk;
-
- assert(_display);
-
- display = this;
-
- if (fcntl(ConnectionNumber(_display), F_SETFD, 1) == -1) {
- printf(_("Couldn't mark display connection as close-on-exec.\n\n"));
- ::exit(1);
- }
- if (!XSupportsLocale())
- printf(_("X server does not support locale.\n"));
- if (!XSetLocaleModifiers(""))
- printf(_("Cannot set locale modifiers for the X server.\n"));
-
- // set our error handler for X errors
- XSetErrorHandler(xerrorHandler);
-
- // set the DISPLAY environment variable for any lauched children, to the
- // display we're using, so they open in the right place.
- putenv(std::string("DISPLAY=") + DisplayString(_display));
-
- // find the availability of X extensions we like to use
-#ifdef XKB
- _xkb = XkbQueryExtension(_display, &junk, &_xkb_event_basep, &junk, NULL,
- NULL);
-#endif
-
-#ifdef SHAPE
- _shape = XShapeQueryExtension(_display, &_shape_event_basep, &junk);
-#endif
-
-#ifdef XINERAMA
- _xinerama = XineramaQueryExtension(_display, &_xinerama_event_basep, &junk);
-#endif // XINERAMA
-
- // get lock masks that are defined by the display (not constant)
- _modmap = XGetModifierMapping(_display);
- assert(_modmap);
- if (_modmap && _modmap->max_keypermod > 0) {
- const int mask_table[] = {
- ShiftMask, LockMask, ControlMask, Mod1Mask,
- Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
- };
- const size_t size = (sizeof(mask_table) / sizeof(mask_table[0])) *
- _modmap->max_keypermod;
- // get the values of the keyboard lock modifiers
- // Note: Caps lock is not retrieved the same way as Scroll and Num lock
- // since it doesn't need to be.
- const KeyCode num_lock = XKeysymToKeycode(_display, XK_Num_Lock);
- const KeyCode scroll_lock = XKeysymToKeycode(_display, XK_Scroll_Lock);
-
- for (size_t cnt = 0; cnt < size; ++cnt) {
- if (! _modmap->modifiermap[cnt]) continue;
-
- if (num_lock == _modmap->modifiermap[cnt])
- _num_lock_mask = mask_table[cnt / _modmap->max_keypermod];
- if (scroll_lock == _modmap->modifiermap[cnt])
- _scroll_lock_mask = mask_table[cnt / _modmap->max_keypermod];
- }
- }
-
- _mask_list[0] = 0;
- _mask_list[1] = LockMask;
- _mask_list[2] = _num_lock_mask;
- _mask_list[3] = LockMask | _num_lock_mask;
- _mask_list[4] = _scroll_lock_mask;
- _mask_list[5] = _scroll_lock_mask | LockMask;
- _mask_list[6] = _scroll_lock_mask | _num_lock_mask;
- _mask_list[7] = _scroll_lock_mask | LockMask | _num_lock_mask;
-
- /*
- If the default depth is at least 8 we will use that,
- otherwise we try to find the largest TrueColor visual.
- Preference is given to 24 bit over larger depths if 24 bit is an option.
- */
-
- int screen = DefaultScreen(_display);
- _depth = DefaultDepth(_display, screen);
- _visual = DefaultVisual(_display, screen);
- _colormap = DefaultColormap(_display, screen);
-
- if (_depth < 8) {
- // search for a TrueColor Visual... if we can't find one...
- // we will use the default visual for the screen
- XVisualInfo vinfo_template, *vinfo_return;
- int vinfo_nitems;
- int best = -1;
-
- vinfo_template.screen = screen;
- vinfo_template.c_class = TrueColor;
-
- vinfo_return = XGetVisualInfo(_display,
- VisualScreenMask | VisualClassMask,
- &vinfo_template, &vinfo_nitems);
- if (vinfo_return) {
- int max_depth = 1;
- for (int i = 0; i < vinfo_nitems; ++i) {
- if (vinfo_return[i].depth > max_depth) {
- if (max_depth == 24 && vinfo_return[i].depth > 24)
- break; // prefer 24 bit over 32
- max_depth = vinfo_return[i].depth;
- best = i;
- }
- }
- if (max_depth < _depth) best = -1;
- }
-
- if (best != -1) {
- _depth = vinfo_return[best].depth;
- _visual = vinfo_return[best].visual;
- _colormap = XCreateColormap(_display, RootWindow(_display, screen),
- _visual, AllocNone);
- }
-
- XFree(vinfo_return);
- }
-}
-
-
-Display::~Display()
-{
- while (_grab_count > 0)
- ungrab();
-
- XFreeModifiermap(_modmap);
-
- XCloseDisplay(_display);
-}
-
-
-void Display::setIgnoreErrors(bool t)
-{
- // sync up so that anything already sent is/isn't ignored!
- XSync(_display, false);
- _ignore_errors = t;
-}
-
-void Display::grab()
-{
- if (_grab_count == 0) {
- XGrabServer(_display);
- XSync(_display, false); // make sure it kicks in
- }
- _grab_count++;
-}
-
-
-void Display::ungrab()
-{
- if (_grab_count == 0) return;
- _grab_count--;
- if (_grab_count == 0) {
- XUngrabServer(_display);
- XFlush(_display); // ungrab as soon as possible
- }
-}
-
-
-
-
-
-
-
-/*
- * Grabs a button, but also grabs the button in every possible combination
- * with the keyboard lock keys, so that they do not cancel out the event.
-
- * 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 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,
- Cursor cursor, bool allow_scroll_lock) const
-{
- unsigned int length = (allow_scroll_lock) ? 8 / 2:
- 8;
- for (size_t cnt = 0; cnt < length; ++cnt)
- XGrabButton(_display, button, modifiers | _mask_list[cnt],
- grab_window, owner_events, event_mask, pointer_mode,
- keyboard_mode, confine_to, cursor);
-}
-
-
-/*
- * Releases the grab on a button, and ungrabs all possible combinations of the
- * keyboard lock keys.
- */
-void Display::ungrabButton(unsigned int button, unsigned int modifiers,
- Window grab_window) const
-{
- for (size_t cnt = 0; cnt < 8; ++cnt)
- XUngrabButton(_display, button, modifiers | _mask_list[cnt],
- grab_window);
-}
-
-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) const
-{
- unsigned int length = (allow_scroll_lock) ? 8 / 2:
- 8;
- for (size_t cnt = 0; cnt < length; ++cnt)
- XGrabKey(_display, keycode, modifiers | _mask_list[cnt],
- grab_window, owner_events, pointer_mode, keyboard_mode);
-}
-
-void Display::ungrabKey(unsigned int keycode, unsigned int modifiers,
- Window grab_window) const
-{
- for (size_t cnt = 0; cnt < 8; ++cnt)
- XUngrabKey(_display, keycode, modifiers | _mask_list[cnt],
- grab_window);
-}
-
-void Display::ungrabAllKeys(Window grab_window) const
-{
- XUngrabKey(_display, AnyKey, AnyModifier, grab_window);
-}
-
-}
diff --git a/otk/display.hh b/otk/display.hh
deleted file mode 100644
index 25c1b45a..00000000
--- a/otk/display.hh
+++ /dev/null
@@ -1,126 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __display_hh
-#define __display_hh
-
-extern "C" {
-#include <X11/Xlib.h>
-}
-
-namespace otk {
-
-class RenderControl;
-
-class Display;
-
-//! The display instance for the library
-extern Display *display;
-
-//! Manages a single X11 display.
-class Display
-{
-private:
- //! The X display
- ::Display *_display;
-
- //! Does the display have the XKB extension?
- bool _xkb;
- //! Base for events for the XKB extension
- int _xkb_event_basep;
-
- //! Does the display have the Shape extension?
- bool _shape;
- //! Base for events for the Shape extension
- int _shape_event_basep;
-
- //! Does the display have the Xinerama extension?
- bool _xinerama;
- //! Base for events for the Xinerama extension
- int _xinerama_event_basep;
-
- //! A list of all possible combinations of keyboard lock masks
- unsigned int _mask_list[8];
-
- //! The value of the mask for the NumLock modifier
- unsigned int _num_lock_mask;
-
- //! The value of the mask for the ScrollLock modifier
- unsigned int _scroll_lock_mask;
-
- //! The key codes for the modifier keys
- XModifierKeymap *_modmap;
-
- //! The number of requested grabs on the display
- int _grab_count;
-
- //! When true, X errors will be ignored. Use with care.
- bool _ignore_errors;
-
- //! The optimal visual for the display
- Visual *_visual;
-
- //! Our colormap built for the optimal visual
- Colormap _colormap;
-
- //! The depth of our optimal visual
- int _depth;
-
-public:
- //! Wraps an open Display connection
- /*!
- @param d An open Display connection.
- */
- Display(::Display *d);
- //! Destroys the class, closes the X display
- ~Display();
-
- //! Returns if the display has the xkb extension available
- inline bool xkb() const { return _xkb; }
- //! Returns the xkb extension's event base
- inline int xkbEventBase() const { return _xkb_event_basep; }
-
- //! Returns if the display has the shape extension available
- inline bool shape() const { return _shape; }
- //! Returns the shape extension's event base
- inline int shapeEventBase() const { return _shape_event_basep; }
- //! Returns if the display has the xinerama extension available
- inline bool xinerama() const { return _xinerama; }
-
- inline unsigned int numLockMask() const { return _num_lock_mask; }
- inline unsigned int scrollLockMask() const { return _scroll_lock_mask; }
- const XModifierKeymap *modifierMap() const { return _modmap; }
-
- inline ::Display* operator*() const { return _display; }
-
- //! When true, X errors will be ignored.
- inline bool ignoreErrors() const { return _ignore_errors; }
- //! Set whether X errors should be ignored. Use with care.
- void setIgnoreErrors(bool t);
-
- //! Grabs the display
- void grab();
-
- //! Ungrabs the display
- void ungrab();
-
-
-
- /* TEMPORARY */
- void 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, Cursor cursor,
- bool allow_scroll_lock) const;
- void ungrabButton(unsigned int button, unsigned int modifiers,
- Window grab_window) const;
- void grabKey(unsigned int keycode, unsigned int modifiers,
- Window grab_window, bool owner_events,
- int pointer_mode, int keyboard_mode,
- bool allow_scroll_lock) const;
- void ungrabKey(unsigned int keycode, unsigned int modifiers,
- Window grab_window) const;
- void ungrabAllKeys(Window grab_window) const;
-};
-
-}
-
-#endif // __display_hh
diff --git a/otk/eventdispatcher.cc b/otk/eventdispatcher.cc
deleted file mode 100644
index 1b90dbc0..00000000
--- a/otk/eventdispatcher.cc
+++ /dev/null
@@ -1,217 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "eventdispatcher.hh"
-#include "display.hh"
-
-#include <cstdio>
-#include <iostream>
-
-namespace otk {
-
-EventDispatcher::EventDispatcher()
- : _fallback(0), _master(0)
-{
-}
-
-EventDispatcher::~EventDispatcher()
-{
-}
-
-void EventDispatcher::clearAllHandlers(void)
-{
- _map.clear();
-}
-
-void EventDispatcher::registerHandler(Window id, EventHandler *handler)
-{
- _map.insert(std::pair<Window, EventHandler*>(id, handler));
-}
-
-void EventDispatcher::clearHandler(Window id)
-{
- _map.erase(id);
-}
-
-void EventDispatcher::dispatchEvents(bool remote)
-{
- XEvent e;
-
- while (true) {
- /*
- There are slightly different event retrieval semantics here for local (or
- high bandwidth) versus remote (or low bandwidth) connections to the
- display/Xserver.
- */
- if (remote) {
- if (!XPending(**display))
- return;
- } else {
- /*
- This XSync allows for far more compression of events, which makes
- things like Motion events perform far far better. Since it also means
- network traffic for every event instead of every X events (where X is
- the number retrieved at a time), it probably should not be used for
- setups where Openbox is running on a remote/low bandwidth
- display/Xserver.
- */
- XSync(**display, false);
- if (!XEventsQueued(**display, QueuedAlready))
- return;
- }
- XNextEvent(**display, &e);
-
-#if 0//defined(DEBUG)
- printf("Event %d window %lx\n", e.type, e.xany.window);
-#endif
-
- if (e.type == FocusIn || e.type == FocusOut) {
- // focus events are a beast all their own.. yuk, hate, etc.
- dispatchFocus(e);
- } else {
- Window win;
-
- // pick a window
- switch (e.type) {
- case UnmapNotify:
- win = e.xunmap.window;
- break;
- case DestroyNotify:
- win = e.xdestroywindow.window;
- break;
- case ConfigureRequest:
- win = e.xconfigurerequest.window;
- break;
- default:
- win = e.xany.window;
- }
-
- // grab the lasttime and hack up the modifiers
- switch (e.type) {
- case ButtonPress:
- case ButtonRelease:
- _lasttime = e.xbutton.time;
- e.xbutton.state &= ~(LockMask | display->numLockMask() |
- display->scrollLockMask());
- break;
- case KeyPress:
- e.xkey.state &= ~(LockMask | display->numLockMask() |
- display->scrollLockMask());
- break;
- case MotionNotify:
- _lasttime = e.xmotion.time;
- e.xmotion.state &= ~(LockMask | display->numLockMask() |
- display->scrollLockMask());
- break;
- case PropertyNotify:
- _lasttime = e.xproperty.time;
- break;
- case EnterNotify:
- case LeaveNotify:
- _lasttime = e.xcrossing.time;
- if (e.xcrossing.mode != NotifyNormal)
- continue; // skip me!
- break;
- }
-
- dispatch(win, e);
- }
- }
-}
-
-void EventDispatcher::dispatchFocus(const XEvent &e)
-{
-// printf("focus %s detail %d -> 0x%lx\n",
-// (e.xfocus.type == FocusIn ? "IN" : "OUT"),
-// e.xfocus.detail, e.xfocus.window);
- // ignore focus changes from grabs
- if (e.xfocus.mode == NotifyGrab) //|| e.xfocus.mode == NotifyUngrab ||
- // From Metacity, from WindowMaker, ignore all funky pointer root events
- // its commented out cuz I don't think we need this at all. If problems
- // arise we can look into it
- //e.xfocus.detail > NotifyNonlinearVirtual)
- return;
-
- if (e.type == FocusIn) {
- //printf("Got FocusIn!\n");
-
- // send a FocusIn to whatever was just focused
- dispatch(e.xfocus.window, e);
- //printf("Sent FocusIn 0x%lx\n", e.xfocus.window);
-
- } else if (e.type == FocusOut) {
- //printf("Got FocusOut!\n");
-
- // FocusOut events just make us look for FocusIn events. They are ignored
- // otherwise.
- XEvent fi;
- if (XCheckTypedEvent(**display, FocusIn, &fi)) {
- //printf("Found FocusIn\n");
- dispatchFocus(fi);
- // dont unfocus the window we just focused!
- if (fi.xfocus.window == e.xfocus.window)
- return;
- }
-
- dispatch(e.xfocus.window, e);
- //printf("Sent FocusOut 0x%lx\n", e.xfocus.window);
- }
-}
-
-void EventDispatcher::dispatch(Window win, const XEvent &e)
-{
- EventHandler *handler = 0;
- EventMap::iterator it;
-
- // master gets everything first
- if (_master)
- _master->handle(e);
-
- // find handler for the chosen window
- it = _map.find(win);
-
- if (it != _map.end()) {
- // if we found a handler
- handler = it->second;
- } else if (e.type == ConfigureRequest) {
- // unhandled configure requests must be used to configure the window
- // directly
- XWindowChanges xwc;
-
- xwc.x = e.xconfigurerequest.x;
- xwc.y = e.xconfigurerequest.y;
- xwc.width = e.xconfigurerequest.width;
- xwc.height = e.xconfigurerequest.height;
- xwc.border_width = e.xconfigurerequest.border_width;
- xwc.sibling = e.xconfigurerequest.above;
- xwc.stack_mode = e.xconfigurerequest.detail;
-
-#ifdef DEBUG
- printf("Proxying configure event for 0x%lx\n", e.xconfigurerequest.window);
-#endif
-
- // we are not to be held responsible if someone sends us an invalid
- // request!
- display->setIgnoreErrors(true);
- XConfigureWindow(**display, e.xconfigurerequest.window,
- e.xconfigurerequest.value_mask, &xwc);
- display->setIgnoreErrors(false);
- } else {
- // grab a falback if it exists
- handler = _fallback;
- }
-
- if (handler)
- handler->handle(e);
-}
-
-EventHandler *EventDispatcher::findHandler(Window win)
-{
- EventMap::iterator it = _map.find(win);
- if (it != _map.end())
- return it->second;
- return 0;
-}
-
-}
diff --git a/otk/eventdispatcher.hh b/otk/eventdispatcher.hh
deleted file mode 100644
index 35c3722e..00000000
--- a/otk/eventdispatcher.hh
+++ /dev/null
@@ -1,62 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __eventdispatcher
-#define __eventdispatcher
-
-#include "eventhandler.hh"
-#include <map>
-#include <utility>
-
-namespace otk {
-
-typedef std::map<unsigned int, EventHandler *> EventMap;
-
-class EventDispatcher {
-public:
-
- EventDispatcher();
- virtual ~EventDispatcher();
-
- virtual void clearAllHandlers(void);
- virtual void registerHandler(Window id, EventHandler *handler);
- virtual void clearHandler(Window id);
- //! Dispatch events from the X server to the appropriate EventHandlers
- /*!
- @param remote Is the Xserver on a remote (low bandwidth) connection or on a
- local (high bandwidth) connection. This allows you to specify
- 'false' in which case slightly different semantics are used
- for event retrieval.<br>
- The default is 'true' since this should generally be used,
- only the Openbox window manager should need to specify
- 'false' here.
- */
- virtual void dispatchEvents(bool remote = true);
-
- inline void setFallbackHandler(EventHandler *fallback)
- { _fallback = 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(EventHandler *master)
- { _master = master; }
- EventHandler *getMasterHandler(void) const { return _master; }
-
- EventHandler *findHandler(Window win);
-
- inline Time lastTime() const { return _lasttime; }
-
-private:
- EventMap _map;
- EventHandler *_fallback;
- EventHandler *_master;
-
- //! The time at which the last XEvent with a time was received
- Time _lasttime;
-
- void dispatch(Window win, const XEvent &e);
- void dispatchFocus(const XEvent &e);
-};
-
-}
-
-#endif
diff --git a/otk/eventhandler.cc b/otk/eventhandler.cc
deleted file mode 100644
index 6539d587..00000000
--- a/otk/eventhandler.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "display.hh"
-#include "eventhandler.hh"
-
-namespace otk {
-
-EventHandler::EventHandler()
-{
-}
-
-
-EventHandler::~EventHandler()
-{
-}
-
-
-void EventHandler::handle(const XEvent &e)
-{
- switch(e.type){
- case KeyPress:
- return keyPressHandler(e.xkey);
- case KeyRelease:
- return keyReleaseHandler(e.xkey);
- case ButtonPress:
- return buttonPressHandler(e.xbutton);
- case ButtonRelease:
- return buttonReleaseHandler(e.xbutton);
- case MotionNotify:
- return motionHandler(e.xmotion);
- case EnterNotify:
- return enterHandler(e.xcrossing);
- case LeaveNotify:
- return leaveHandler(e.xcrossing);
- case FocusIn:
- return focusHandler(e.xfocus);
- case FocusOut:
- return unfocusHandler(e.xfocus);
- case Expose:
- return exposeHandler(e.xexpose);
- case GraphicsExpose:
- return graphicsExposeHandler(e.xgraphicsexpose);
- case NoExpose:
- return noExposeEventHandler(e.xnoexpose);
- case CirculateRequest:
- return circulateRequestHandler(e.xcirculaterequest);
- case ConfigureRequest:
- return configureRequestHandler(e.xconfigurerequest);
- case MapRequest:
- return mapRequestHandler(e.xmaprequest);
- case ResizeRequest:
- return resizeRequestHandler(e.xresizerequest);
- case CirculateNotify:
- return circulateHandler(e.xcirculate);
- case ConfigureNotify:
- return configureHandler(e.xconfigure);
- case CreateNotify:
- return createHandler(e.xcreatewindow);
- case DestroyNotify:
- return destroyHandler(e.xdestroywindow);
- case GravityNotify:
- return gravityHandler(e.xgravity);
- case MapNotify:
- return mapHandler(e.xmap);
- case MappingNotify:
- return mappingHandler(e.xmapping);
- case ReparentNotify:
- return reparentHandler(e.xreparent);
- case UnmapNotify:
- return unmapHandler(e.xunmap);
- case VisibilityNotify:
- return visibilityHandler(e.xvisibility);
- case ColormapNotify:
- return colorMapHandler(e.xcolormap);
- case ClientMessage:
- return clientMessageHandler(e.xclient);
- case PropertyNotify:
- return propertyHandler(e.xproperty);
- case SelectionClear:
- return selectionClearHandler(e.xselectionclear);
- case SelectionNotify:
- return selectionHandler(e.xselection);
- case SelectionRequest:
- return selectionRequestHandler(e.xselectionrequest);
- default:
-#ifdef SHAPE
- if (e.type == display->shapeEventBase())
- return shapeHandler((*(XShapeEvent*)&e));
-#endif // SHAPE
-#ifdef XKB
- if (e.type == display->xkbEventBase())
- return xkbHandler((*(XkbEvent*)&e));
-#endif // XKB
- ;
- }
-}
-
-
-void EventHandler::clientMessageHandler(const XClientMessageEvent &)
-{
-
-}
-
-}
diff --git a/otk/eventhandler.hh b/otk/eventhandler.hh
deleted file mode 100644
index f2457568..00000000
--- a/otk/eventhandler.hh
+++ /dev/null
@@ -1,152 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __eventhandler__hh
-#define __eventhandler__hh
-
-extern "C" {
-#include <X11/Xlib.h>
-
-#ifdef SHAPE
-#include <X11/extensions/shape.h>
-#endif // SHAPE
-
-#ifdef XKB
-#include <X11/XKBlib.h>
-#endif // XKB
-
-}
-
-namespace otk {
-
-class EventHandler {
-public:
- //! Dispatches events to one of the other handlers based on their type.
- virtual void handle(const XEvent &e);
-
- //! Called whenever any key is pressed.
- virtual void keyPressHandler(const XKeyEvent &) {}
-
- //! Called whenever any key is released.
- virtual void keyReleaseHandler(const XKeyEvent &) {}
-
- //! Called whenever a button of the pointer is pressed.
- virtual void buttonPressHandler(const XButtonEvent &) {}
-
- //! Called whenever a button of the pointer is released.
- virtual void buttonReleaseHandler(const XButtonEvent &) {}
-
- //! Called whenever the pointer moved
- virtual void motionHandler(const XMotionEvent &) {}
-
- //! Called whenever the pointer enters a window.
- virtual void enterHandler(const XCrossingEvent &) {}
-
- //! Called whenever the pointer leaves a window.
- virtual void leaveHandler(const XCrossingEvent &) {}
-
- //! Called when a window gains focus.
- virtual void focusHandler(const XFocusChangeEvent &) {}
-
- //! Called when a window looses focus.
- virtual void unfocusHandler(const XFocusChangeEvent &) {}
-
- //! Called when a window becomes visible to the user.
- virtual void exposeHandler(const XExposeEvent &) {}
-
- //! Called to handle GraphicsExpose events.
- virtual void graphicsExposeHandler(const XGraphicsExposeEvent &) {}
-
- //! Called to handle NoExpose events.
- virtual void noExposeEventHandler(const XNoExposeEvent &) {}
-
- //! Called when the window requests a change in its z-order.
- virtual void circulateRequestHandler(const XCirculateRequestEvent &)
- {}
-
- //! Called when a different client initiates a configure window request.
- virtual void configureRequestHandler(const XConfigureRequestEvent &)
- {}
-
- //! Called when a different client tries to map a window.
- virtual void mapRequestHandler(const XMapRequestEvent &) {}
-
- //! Called when another client attemps to change the size of a window.
- virtual void resizeRequestHandler(const XResizeRequestEvent &) {}
-
- //! Called when the z-order of the window has changed.
- virtual void circulateHandler(const XCirculateEvent &) {}
-
- //! Called when the window as been reconfigured.
- virtual void configureHandler(const XConfigureEvent &) {}
-
- //! Called when a window is created.
- virtual void createHandler(const XCreateWindowEvent &) {}
-
- //! Called when a window is destroyed.
- virtual void destroyHandler(const XDestroyWindowEvent &) {}
-
- //! Called when a window is moved because of a change in the size of its
- //! parent.
- virtual void gravityHandler(const XGravityEvent &) {}
-
- //! Called when a window is mapped.
- virtual void mapHandler(const XMapEvent &) {}
-
- //! Called when the server generats a MappingNotify event
- virtual void mappingHandler(const XMappingEvent &) {}
-
- //! Called when a window is reparented
- virtual void reparentHandler(const XReparentEvent &) {}
-
- //! Called when a window is unmapped
- virtual void unmapHandler(const XUnmapEvent &) {}
-
- //! Called when a the visibilty of a window changes
- virtual void visibilityHandler(const XVisibilityEvent &) {}
-
- //! Called when the colormap changes, or is installed or unistalled
- virtual void colorMapHandler(const XColormapEvent &) {}
-
- //! Called when a property of a window changes
- virtual void propertyHandler(const XPropertyEvent &) {}
-
- //! Called when the client loses ownership of a selection
- virtual void selectionClearHandler(const XSelectionClearEvent &) {}
-
- //! Called when a ConvertSelection protocol request is sent
- virtual void selectionHandler(const XSelectionEvent &) {}
-
- //! Called when a SelectionEvent occurs
- virtual void selectionRequestHandler(const XSelectionRequestEvent &) {}
-
- //! Called when a client calls XSendEvent
- /*!
- Some types of client messages are filtered out and sent to more specific
- event handler functions.
- */
- virtual void clientMessageHandler(const XClientMessageEvent &);
-
-#if defined(SHAPE) || defined(DOXYGEN_IGNORE)
- //! Called when a shape extension event fires
- virtual void shapeHandler(const XShapeEvent &) {}
-#endif // SHAPE
-
-#if defined(XKB) || defined(DOXYGEN_IGNORE)
- //! Called when an xkb extension event fires
- virtual void xkbHandler(const XkbEvent &) {}
-#endif // XKB
-
- virtual ~EventHandler();
-
-protected:
- /*! Constructor for the EventHandler class.
- This is protected so that EventHandlers can't be instantiated on their
- own.
- */
- EventHandler();
-
-private:
-};
-
-}
-
-#endif
diff --git a/otk/font.cc b/otk/font.cc
deleted file mode 100644
index ee9c37d7..00000000
--- a/otk/font.cc
+++ /dev/null
@@ -1,102 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "font.hh"
-#include "surface.hh"
-#include "util.hh"
-#include "display.hh"
-#include "screeninfo.hh"
-
-extern "C" {
-#include "../src/gettext.h"
-#define _(str) gettext(str)
-}
-
-#include <cstdio>
-#include <cstdlib>
-#include <iostream>
-#include <algorithm>
-
-namespace otk {
-
-bool Font::_xft_init = false;
-
-Font::Font(int screen_num, const std::string &fontstring,
- bool shadow, unsigned char offset, unsigned char tint)
- : _screen_num(screen_num),
- _fontstring(fontstring),
- _shadow(shadow),
- _offset(offset),
- _tint(tint),
- _xftfont(0)
-{
- assert(screen_num >= 0);
- assert(tint <= CHAR_MAX);
-
- if (!_xft_init) {
- if (!XftInit(0)) {
- printf(_("Couldn't initialize Xft.\n\n"));
- ::exit(3);
- }
-#ifdef DEBUG
- int version = XftGetVersion();
- printf("Using Xft %d.%d.%d (Built against %d.%d.%d).\n",
- version / 10000 % 100, version / 100 % 100, version % 100,
- XFT_MAJOR, XFT_MINOR, XFT_REVISION);
-#endif
- _xft_init = true;
- }
-
- if ((_xftfont = XftFontOpenName(**display, _screen_num,
- _fontstring.c_str())))
- return;
-
- printf(_("Unable to load font: %s\n"), _fontstring.c_str());
- printf(_("Trying fallback font: %s\n"), "fixed");
-
- if ((_xftfont = XftFontOpenName(**display, _screen_num,
- "fixed")))
- return;
-
- printf(_("Unable to load font: %s\n"), "fixed");
- printf(_("Aborting!.\n"));
-
- ::exit(3); // can't continue without a font
-}
-
-
-Font::~Font(void)
-{
- if (_xftfont)
- XftFontClose(**display, _xftfont);
-}
-
-
-int Font::measureString(const ustring &string) const
-{
- XGlyphInfo info;
-
- if (string.utf8())
- XftTextExtentsUtf8(**display, _xftfont,
- (FcChar8*)string.c_str(), string.bytes(), &info);
- else
- XftTextExtents8(**display, _xftfont,
- (FcChar8*)string.c_str(), string.bytes(), &info);
-
- return (signed) info.xOff + (_shadow ? _offset : 0);
-}
-
-
-int Font::height(void) const
-{
- return (signed) _xftfont->height + (_shadow ? _offset : 0);
-}
-
-
-int Font::maxCharWidth(void) const
-{
- return (signed) _xftfont->max_advance_width;
-}
-
-}
diff --git a/otk/font.hh b/otk/font.hh
deleted file mode 100644
index 53e48c4e..00000000
--- a/otk/font.hh
+++ /dev/null
@@ -1,60 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __font_hh
-#define __font_hh
-
-#include "ustring.hh"
-#include "truerendercontrol.hh"
-
-extern "C" {
-#include <X11/Xlib.h>
-#define _XFT_NO_COMPAT_ // no Xft 1 API
-#include <X11/Xft/Xft.h>
-}
-
-#include <cassert>
-
-namespace otk {
-
-class Color;
-class Surface;
-
-class Font {
- /*
- * static members
- */
-private:
- static bool _xft_init;
-
- int _screen_num;
-
- std::string _fontstring;
-
- bool _shadow;
- unsigned char _offset;
- unsigned char _tint;
-
- XftFont *_xftfont;
-
- bool createXftFont(void);
-
-public:
- // loads an Xft font
- Font(int screen_num, const std::string &fontstring, bool shadow,
- unsigned char offset, unsigned char tint);
- virtual ~Font();
-
- inline const std::string &fontstring() const { return _fontstring; }
-
- int height() const;
- int maxCharWidth() const;
-
- int measureString(const ustring &string) const;
-
- // The RenderControl classes use the internal data to render the fonts, but
- // noone else needs it, so its private.
- friend class RenderControl;
-};
-
-}
-
-#endif // __font_hh
diff --git a/otk/label.cc b/otk/label.cc
deleted file mode 100644
index 8ec03dd9..00000000
--- a/otk/label.cc
+++ /dev/null
@@ -1,176 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "label.hh"
-#include "display.hh"
-#include "rendercontrol.hh"
-
-#include <string>
-
-namespace otk {
-
-Label::Label(int screen, EventDispatcher *ed, int bevel)
- : Widget(screen, ed, Widget::Horizontal, bevel, true),
- _text(""),
- _font(0),
- _justify_horz(RenderStyle::LeftTopJustify),
- _justify_vert(RenderStyle::LeftTopJustify),
- _highlight(false)
-{
- styleChanged(*RenderStyle::style(screen));
-}
-
-Label::Label(Widget *parent)
- : Widget(parent),
- _text(""),
- _font(0),
- _justify_horz(RenderStyle::LeftTopJustify),
- _justify_vert(RenderStyle::LeftTopJustify),
- _highlight(false)
-{
- styleChanged(*RenderStyle::style(screen()));
-}
-
-Label::~Label()
-{
-}
-
-void Label::setHorizontalJustify(RenderStyle::Justify j)
-{
- _justify_horz = j;
- refresh();
-}
-
-void Label::setVerticalJustify(RenderStyle::Justify j)
-{
- _justify_vert = j;
- refresh();
-}
-
-void Label::setHighlighted(bool h)
-{
- _highlight = h;
- styleChanged(*RenderStyle::style(screen()));
- refresh();
-}
-
-void Label::setText(const ustring &text)
-{
- bool utf = text.utf8();
- std::string s = text.c_str(); // use a normal string, for its functionality
-
- _parsedtext.clear();
- _text = text;
-
- // parse it into multiple lines
- std::string::size_type p = 0;
- while (p != std::string::npos) {
- std::string::size_type p2 = s.find('\n', p);
- std::string s(s.substr(p, (p2==std::string::npos?p2:p2-p)));
-
- // turn tabs into spaces (multiples of 8)
- std::string::size_type t;
- while ((t = s.find('\t')) != std::string::npos)
- s.replace(t, 1, std::string(8 - t % 8, ' '));
-
- _parsedtext.push_back(s);
- _parsedtext.back().setUtf8(utf);
- p = (p2==std::string::npos?p2:p2+1);
- }
- calcDefaultSizes();
-}
-
-void Label::setFont(const Font *f)
-{
- _font = f;
- calcDefaultSizes();
-}
-
-void Label::calcDefaultSizes()
-{
- int longest = 0;
- // find the longest line
- std::vector<ustring>::iterator it, end = _parsedtext.end();
- for (it = _parsedtext.begin(); it != end; ++it) {
- int length = _font->measureString(*it);
- if (length < 0) continue; // lines too long get skipped
- if (length > longest) longest = length;
- }
- setMinSize(Size(longest + borderWidth() * 2 + bevel() * 4,
- _parsedtext.size() * _font->height() + borderWidth() * 2 +
- bevel() * 2));
-}
-
-void Label::styleChanged(const RenderStyle &style)
-{
- if (_highlight) {
- _texture = style.labelFocusBackground();
- _forecolor = style.textFocusColor();
- } else {
- _texture = style.labelUnfocusBackground();
- _forecolor = style.textUnfocusColor();
- }
- if (_font != style.labelFont()) {
- _font = style.labelFont();
- calcDefaultSizes();
- }
-}
-
-void Label::renderForeground(Surface &surface)
-{
- const RenderControl *control = display->renderControl(screen());
- int sidemargin = bevel() * 2;
- int y = bevel();
- int w = area().width() - borderWidth() * 2 - sidemargin * 2;
- int h = area().height() - borderWidth() * 2 - bevel() * 2;
-
- switch (_justify_vert) {
- case RenderStyle::RightBottomJustify:
- y += h - (_parsedtext.size() * _font->height());
- if (y < bevel()) y = bevel();
- break;
- case RenderStyle::CenterJustify:
- y += (h - (_parsedtext.size() * _font->height())) / 2;
- if (y < bevel()) y = bevel();
- break;
- case RenderStyle::LeftTopJustify:
- break;
- }
-
- if (w <= 0) return; // can't fit anything
-
- std::vector<ustring>::iterator it, end = _parsedtext.end();
- for (it = _parsedtext.begin(); it != end; ++it, y += _font->height()) {
- ustring t = *it; // the actual text to draw
- int x = sidemargin; // x coord for the text
-
- // find a string that will fit inside the area for text
- ustring::size_type text_len = t.size();
- int length;
-
- do {
- t.resize(text_len);
- length = _font->measureString(t);
- } while (length > w && text_len-- > 0);
- if (length < 0) continue; // lines too long get skipped
-
- if (text_len <= 0) continue; // won't fit anything
-
- // justify the text
- switch (_justify_horz) {
- case RenderStyle::RightBottomJustify:
- x += w - length;
- break;
- case RenderStyle::CenterJustify:
- x += (w - length) / 2;
- break;
- case RenderStyle::LeftTopJustify:
- break;
- }
-
- control->drawString(surface, *_font, x, y, *_forecolor, t);
- }
-}
-
-}
diff --git a/otk/label.hh b/otk/label.hh
deleted file mode 100644
index cd9ef5a1..00000000
--- a/otk/label.hh
+++ /dev/null
@@ -1,66 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __label_hh
-#define __label_hh
-
-#include "widget.hh"
-#include "ustring.hh"
-#include "renderstyle.hh"
-#include "font.hh"
-
-#include <vector>
-
-namespace otk {
-
-class Label : public Widget {
-
-public:
- Label(int screen, EventDispatcher *ed, int bevel = 3);
- Label(Widget *parent);
- virtual ~Label();
-
- inline const ustring& text(void) const { return _text; }
- void setText(const ustring &text);
-
- virtual inline bool isHighlighted() const { return _highlight; }
- virtual void setHighlighted(bool h);
-
- RenderStyle::Justify horizontalJustify() const { return _justify_horz; }
- virtual void setHorizontalJustify(RenderStyle::Justify j);
- RenderStyle::Justify verticalJustify() const { return _justify_vert; }
- virtual void setVerticalJustify(RenderStyle::Justify j);
-
- const Font *font() const { return _font; }
- virtual void setFont(const Font *f);
-
- virtual void styleChanged(const RenderStyle &style);
-
- virtual void renderForeground(Surface &surface);
-
-protected:
- virtual void calcDefaultSizes();
-
- //! The color the label will use for rendering its text
- RenderColor *_forecolor;
-
-private:
- //! Text to be displayed in the label
- ustring _text;
- //! Text to be displayed, parsed into its separate lines
- std::vector<ustring> _parsedtext;
- //! The actual text being shown, may be a subset of _text
- ustring _drawtext;
- //! The font the text will be rendered with
- const Font *_font;
- //! The horizontal justification used for drawing text
- RenderStyle::Justify _justify_horz;
- //! The vertical justification used for drawing text
- RenderStyle::Justify _justify_vert;
- //! The drawing offset for the text
- int _drawx;
- //! If the widget is highlighted or not
- bool _highlight;
-};
-
-}
-
-#endif
diff --git a/otk/messagedialog.cc b/otk/messagedialog.cc
deleted file mode 100644
index ac468cb3..00000000
--- a/otk/messagedialog.cc
+++ /dev/null
@@ -1,187 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "messagedialog.hh"
-#include "assassin.hh"
-#include "button.hh"
-#include "label.hh"
-#include "display.hh"
-#include "property.hh"
-#include "eventdispatcher.hh"
-#include "timer.hh"
-
-#include <algorithm>
-
-namespace otk {
-
-class DialogButtonWidget : public Button {
- MessageDialog *_dia;
-public:
- DialogButtonWidget(Widget *parent, MessageDialog *dia,
- const DialogButton &b)
- : Button(parent),
- _dia(dia)
- {
- assert(dia);
- setBevel(1);
- setMaxSize(Size(0,0));
- setText(b.label());
- setHighlighted(b.isDefault());
- show();
- }
-
- virtual void buttonPressHandler(const XButtonEvent &e) {
- // limit to the left button
- if (e.button == Button1)
- Button::buttonPressHandler(e);
- }
- virtual void clickHandler(unsigned int) {
- _dia->setResult(DialogButton(text(), isHighlighted()));
- _dia->hide();
- }
-};
-
-MessageDialog::MessageDialog(int screen, EventDispatcher *ed, ustring title,
- ustring caption)
- : Widget(screen, ed, Widget::Vertical),
- _result("", false)
-{
- init(title, caption);
-}
-
-MessageDialog::MessageDialog(EventDispatcher *ed, ustring title,
- ustring caption)
- : Widget(DefaultScreen(**display), ed, Widget::Vertical),
- _result("", false)
-{
- init(title, caption);
-}
-
-MessageDialog::MessageDialog(Widget *parent, ustring title, ustring caption)
- : Widget(parent, Widget::Vertical),
- _result("", false)
-{
- init(title, caption);
-}
-
-void MessageDialog::init(const ustring &title, const ustring &caption)
-{
- _label = new Label(this);
- _label->show();
- _label->setHighlighted(true);
- _button_holder = new Widget(this, Widget::Horizontal);
- _button_holder->show();
- _return = XKeysymToKeycode(**display, XStringToKeysym("Return"));
- _escape = XKeysymToKeycode(**display, XStringToKeysym("Escape"));
-
- setEventMask(eventMask() | KeyPressMask);
- _label->setText(caption);
- if (title.utf8())
- otk::Property::set(window(), otk::Property::atoms.net_wm_name,
- otk::Property::utf8, title);
- otk::Property::set(window(), otk::Property::atoms.wm_name,
- otk::Property::ascii, otk::ustring(title.c_str(), false));
-
- // set WM Protocols on the window
- Atom protocols[2];
- protocols[0] = Property::atoms.wm_protocols;
- protocols[1] = Property::atoms.wm_delete_window;
- XSetWMProtocols(**display, window(), protocols, 2);
-}
-
-MessageDialog::~MessageDialog()
-{
- if (visible()) hide();
- delete _button_holder;
- delete _label;
-}
-
-const DialogButton& MessageDialog::run()
-{
- if (!visible())
- show();
-
- while (visible()) {
- dispatcher()->dispatchEvents();
- if (visible())
- Timer::dispatchTimers(); // fire pending events
- }
- return _result;
-}
-
-void MessageDialog::addButton(const DialogButton &b)
-{
- _button_widgets.push_back(new DialogButtonWidget(_button_holder,
- this, b));
-}
-
-void MessageDialog::focus()
-{
- if (visible())
- XSetInputFocus(**display, window(), None, CurrentTime);
-}
-
-void MessageDialog::show()
-{
- Rect r;
-
- if (parent())
- r = parent()->area();
- else
- r = Rect(Point(0, 0), display->screenInfo(screen())->size());
-
- XSizeHints size;
- size.flags = PMinSize | PPosition | PWinGravity;
- size.min_width = minSize().width();
- size.min_height = minSize().height();
- size.win_gravity = CenterGravity;
-
- Size dest = minSize();
- if (dest.width() < 200 || dest.height() < 100) {
- if (dest.width() < 200 && dest.height() < 100) dest = Size(200, 100);
- else if (dest.width() < 200) dest = Size(200, dest.height());
- else dest = Size(dest.width(), 100);
- resize(dest);
- }
-
- // center it above its parent
- move(Point(r.x() + (r.width() - dest.width()) / 2,
- r.y() + (r.height() - dest.height()) / 2));
-
- XSetWMNormalHints(**display, window(), &size);
-
- Widget::show();
-}
-
-void MessageDialog::hide()
-{
- Widget::hide();
- std::for_each(_button_widgets.begin(), _button_widgets.end(),
- PointerAssassin());
-}
-
-void MessageDialog::keyPressHandler(const XKeyEvent &e)
-{
- if (e.keycode == _return) {
- std::vector<Button *>::const_iterator it, end = _button_widgets.end();
- for (it = _button_widgets.begin(); it != end; ++it)
- if ((*it)->isHighlighted()) {
- _result = DialogButton((*it)->text(), true);
- hide();
- break;
- }
- } else if (e.keycode == _escape) {
- hide();
- }
-}
-
-void MessageDialog::clientMessageHandler(const XClientMessageEvent &e)
-{
- EventHandler::clientMessageHandler(e);
- if (e.message_type == Property::atoms.wm_protocols &&
- static_cast<Atom>(e.data.l[0]) == Property::atoms.wm_delete_window)
- hide();
-}
-
-}
diff --git a/otk/messagedialog.hh b/otk/messagedialog.hh
deleted file mode 100644
index 81894624..00000000
--- a/otk/messagedialog.hh
+++ /dev/null
@@ -1,66 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __messagedialog_hh
-#define __messagedialog_hh
-
-#include "widget.hh"
-#include "ustring.hh"
-
-#include <vector>
-
-namespace otk {
-
-class Button;
-class Label;
-
-class DialogButton {
- ustring _label;
- bool _default;
-public:
- DialogButton(ustring label) : _label(label), _default(false)
- {}
- DialogButton(ustring label, bool def) : _label(label), _default(def)
- {}
- inline const ustring& label() const { return _label; }
- inline const bool& isDefault() const { return _default; }
-
- bool operator==(const DialogButton &o) const { return _label == o._label; }
- bool operator!=(const DialogButton &o) const { return!(_label == o._label); }
-};
-
-class MessageDialog : public Widget {
-public:
- MessageDialog(int screen, EventDispatcher *ed, ustring title,
- ustring caption);
- MessageDialog(EventDispatcher *ed, ustring title, ustring caption);
- MessageDialog(Widget *parent, ustring title, ustring caption);
- virtual ~MessageDialog();
-
- virtual void addButton(const DialogButton &b);
-
- virtual const DialogButton& run();
-
- virtual void show();
- virtual void hide();
- virtual void focus();
-
- virtual const DialogButton& result() const { return _result; }
- virtual void setResult(const DialogButton &result) { _result = result; }
-
- virtual void keyPressHandler(const XKeyEvent &e);
- virtual void clientMessageHandler(const XClientMessageEvent &e);
-
-private:
- void init(const ustring &title, const ustring &caption);
-
-protected:
- std::vector<Button *> _button_widgets;
- Label *_label;
- Widget *_button_holder;
- KeyCode _return;
- KeyCode _escape;
- DialogButton _result;
-};
-
-}
-
-#endif // __messagedialog_hh
diff --git a/otk/otk.cc b/otk/otk.cc
deleted file mode 100644
index 130e3b77..00000000
--- a/otk/otk.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "display.hh"
-#include "timer.hh"
-#include "renderstyle.hh"
-#include "property.hh"
-
-namespace otk {
-
-void initialize()
-{
- new Display();
- Timer::initialize();
- RenderColor::initialize();
- RenderStyle::initialize();
- Property::initialize();
-}
-
-void destroy()
-{
- RenderStyle::destroy();
- RenderColor::destroy();
- Timer::destroy();
- delete display;
-}
-
-}
diff --git a/otk/otk.hh b/otk/otk.hh
deleted file mode 100644
index 9ddf34e9..00000000
--- a/otk/otk.hh
+++ /dev/null
@@ -1,39 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __otk_hh
-#define __otk_hh
-
-#include "config.h"
-
-#include "eventdispatcher.hh"
-#include "eventhandler.hh"
-#include "widget.hh"
-#include "appwidget.hh"
-#include "application.hh"
-#include "assassin.hh"
-#include "label.hh"
-#include "button.hh"
-#include "rendercolor.hh"
-#include "display.hh"
-#include "font.hh"
-#include "messagedialog.hh"
-#include "rendercontrol.hh"
-#include "size.hh"
-#include "point.hh"
-#include "property.hh"
-#include "rect.hh"
-#include "screeninfo.hh"
-#include "strut.hh"
-#include "renderstyle.hh"
-#include "surface.hh"
-#include "rendertexture.hh"
-#include "timer.hh"
-#include "util.hh"
-#include "ustring.hh"
-#include "widget.hh"
-
-namespace otk {
-void initialize();
-void destroy();
-}
-
-#endif // __otk_hh
diff --git a/otk/otk.pc.in b/otk/otk.pc.in
deleted file mode 100644
index 1d4d368a..00000000
--- a/otk/otk.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
-
-Name: otk
-Description: Openbox Toolkit
-Version: @version@
-Requires: xft
-Libs: -L${libdir} -lotk
-Cflags: -I${includedir}
diff --git a/otk/otk_test.cc b/otk/otk_test.cc
deleted file mode 100644
index f10c4b3b..00000000
--- a/otk/otk_test.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "application.hh"
-#include "appwidget.hh"
-#include "label.hh"
-#include "button.hh"
-
-int main(int argc, char **argv) {
- otk::Application app(argc, argv);
-
- otk::AppWidget foo(&app, otk::Widget::Vertical, 3);
- otk::Label lab(&foo);
- otk::Label lab2(&foo);
- otk::Button but(&foo);
- otk::Button but2(&foo);
-
- foo.resize(otk::Size(100, 150));
-
- lab.setText("Hi, I'm a sexy\nlabel!!!");
- lab.setMaxSize(otk::Size(0,0));
- lab2.setText("Me too!!");
- lab2.setBorderWidth(10);
- lab2.setBorderColor(otk::RenderStyle::style(app.screen())->buttonFocusColor());
- but.setText("Im not the default button...");
- but2.setText("But I AM!!");
- but2.setHighlighted(true);
-
-
- foo.show();
-
- app.run();
-
- return 0;
-}
diff --git a/otk/point.hh b/otk/point.hh
deleted file mode 100644
index f438b347..00000000
--- a/otk/point.hh
+++ /dev/null
@@ -1,23 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __point_hh
-#define __point_hh
-
-namespace otk {
-
-class Point {
- int _x, _y;
-public:
- Point() : _x(0), _y(0) {}
- Point(int x, int y) : _x(x), _y(y) {}
- Point(const Point &p) : _x(p._x), _y(p._y) {}
-
- inline int x() const { return _x; }
- inline int y() const { return _y; }
-
- bool operator==(const Point &o) const { return _x == o._x && _y == o._y; }
- bool operator!=(const Point &o) const { return _x != o._x || _y != o._y; }
-};
-
-}
-
-#endif // __point_hh
diff --git a/otk/property.cc b/otk/property.cc
deleted file mode 100644
index 3b075011..00000000
--- a/otk/property.cc
+++ /dev/null
@@ -1,342 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "property.hh"
-#include "display.hh"
-
-extern "C" {
-#include <X11/Xatom.h>
-}
-
-#include <algorithm>
-#include <cassert>
-
-namespace otk {
-
-Atoms Property::atoms;
-
-static Atom create(char *name) { return XInternAtom(**display, name, false); }
-
-void Property::initialize()
-{
- assert(display);
-
- // make sure asserts fire if there is a problem
- memset(&atoms, 0, sizeof(Atoms));
-
- atoms.cardinal = XA_CARDINAL;
- atoms.window = XA_WINDOW;
- atoms.pixmap = XA_PIXMAP;
- atoms.atom = XA_ATOM;
- atoms.string = XA_STRING;
- atoms.utf8 = create("UTF8_STRING");
-
- atoms.openbox_pid = create("_OPENBOX_PID");
-
- atoms.wm_colormap_windows = create("WM_COLORMAP_WINDOWS");
- atoms.wm_protocols = create("WM_PROTOCOLS");
- atoms.wm_state = create("WM_STATE");
- atoms.wm_change_state = create("WM_CHANGE_STATE");
- atoms.wm_delete_window = create("WM_DELETE_WINDOW");
- atoms.wm_take_focus = create("WM_TAKE_FOCUS");
- atoms.wm_name = create("WM_NAME");
- atoms.wm_icon_name = create("WM_ICON_NAME");
- atoms.wm_class = create("WM_CLASS");
- atoms.wm_window_role = create("WM_WINDOW_ROLE");
- atoms.motif_wm_hints = create("_MOTIF_WM_HINTS");
-
- atoms.openbox_show_root_menu = create("_OPENBOX_SHOW_ROOT_MENU");
- atoms.openbox_show_workspace_menu = create("_OPENBOX_SHOW_WORKSPACE_MENU");
-
- atoms.net_supported = create("_NET_SUPPORTED");
- atoms.net_client_list = create("_NET_CLIENT_LIST");
- atoms.net_client_list_stacking = create("_NET_CLIENT_LIST_STACKING");
- atoms.net_number_of_desktops = create("_NET_NUMBER_OF_DESKTOPS");
- atoms.net_desktop_geometry = create("_NET_DESKTOP_GEOMETRY");
- atoms.net_desktop_viewport = create("_NET_DESKTOP_VIEWPORT");
- atoms.net_current_desktop = create("_NET_CURRENT_DESKTOP");
- atoms.net_desktop_names = create("_NET_DESKTOP_NAMES");
- atoms.net_active_window = create("_NET_ACTIVE_WINDOW");
- atoms.net_workarea = create("_NET_WORKAREA");
- atoms.net_supporting_wm_check = create("_NET_SUPPORTING_WM_CHECK");
-// atoms.net_virtual_roots = create("_NET_VIRTUAL_ROOTS");
- atoms.net_desktop_layout = create("_NET_DESKTOP_LAYOUT");
- atoms.net_showing_desktop = create("_NET_SHOWING_DESKTOP");
-
- atoms.net_close_window = create("_NET_CLOSE_WINDOW");
- atoms.net_wm_moveresize = create("_NET_WM_MOVERESIZE");
-
-// atoms.net_properties = create("_NET_PROPERTIES");
- atoms.net_wm_name = create("_NET_WM_NAME");
- atoms.net_wm_visible_name = create("_NET_WM_VISIBLE_NAME");
- atoms.net_wm_icon_name = create("_NET_WM_ICON_NAME");
- atoms.net_wm_visible_icon_name = create("_NET_WM_VISIBLE_ICON_NAME");
- atoms.net_wm_desktop = create("_NET_WM_DESKTOP");
- atoms.net_wm_window_type = create("_NET_WM_WINDOW_TYPE");
- atoms.net_wm_state = create("_NET_WM_STATE");
- atoms.net_wm_strut = create("_NET_WM_STRUT");
-// atoms.net_wm_icon_geometry = create("_NET_WM_ICON_GEOMETRY");
- atoms.net_wm_icon = create("_NET_WM_ICON");
-// atoms.net_wm_pid = create("_NET_WM_PID");
-// atoms.net_wm_handled_icons = create("_NET_WM_HANDLED_ICONS");
- atoms.net_wm_allowed_actions = create("_NET_WM_ALLOWED_ACTIONS");
-
-// atoms.net_wm_ping = create("_NET_WM_PING");
-
- atoms.net_wm_window_type_desktop = create("_NET_WM_WINDOW_TYPE_DESKTOP");
- atoms.net_wm_window_type_dock = create("_NET_WM_WINDOW_TYPE_DOCK");
- atoms.net_wm_window_type_toolbar = create("_NET_WM_WINDOW_TYPE_TOOLBAR");
- atoms.net_wm_window_type_menu = create("_NET_WM_WINDOW_TYPE_MENU");
- atoms.net_wm_window_type_utility = create("_NET_WM_WINDOW_TYPE_UTILITY");
- atoms.net_wm_window_type_splash = create("_NET_WM_WINDOW_TYPE_SPLASH");
- atoms.net_wm_window_type_dialog = create("_NET_WM_WINDOW_TYPE_DIALOG");
- atoms.net_wm_window_type_normal = create("_NET_WM_WINDOW_TYPE_NORMAL");
-
- atoms.net_wm_moveresize_size_topleft =
- create("_NET_WM_MOVERESIZE_SIZE_TOPLEFT");
- atoms.net_wm_moveresize_size_topright =
- create("_NET_WM_MOVERESIZE_SIZE_TOPRIGHT");
- atoms.net_wm_moveresize_size_bottomleft =
- create("_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT");
- atoms.net_wm_moveresize_size_bottomright =
- create("_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT");
- atoms.net_wm_moveresize_move =
- create("_NET_WM_MOVERESIZE_MOVE");
-
- atoms.net_wm_action_move = create("_NET_WM_ACTION_MOVE");
- atoms.net_wm_action_resize = create("_NET_WM_ACTION_RESIZE");
- atoms.net_wm_action_minimize = create("_NET_WM_ACTION_MINIMIZE");
- atoms.net_wm_action_shade = create("_NET_WM_ACTION_SHADE");
- atoms.net_wm_action_stick = create("_NET_WM_ACTION_STICK");
- atoms.net_wm_action_maximize_horz = create("_NET_WM_ACTION_MAXIMIZE_HORZ");
- atoms.net_wm_action_maximize_vert = create("_NET_WM_ACTION_MAXIMIZE_VERT");
- atoms.net_wm_action_fullscreen = create("_NET_WM_ACTION_FULLSCREEN");
- atoms.net_wm_action_change_desktop =
- create("_NET_WM_ACTION_CHANGE_DESKTOP");
- atoms.net_wm_action_close = create("_NET_WM_ACTION_CLOSE");
-
- atoms.net_wm_state_modal = create("_NET_WM_STATE_MODAL");
- atoms.net_wm_state_sticky = create("_NET_WM_STATE_STICKY");
- atoms.net_wm_state_maximized_vert = create("_NET_WM_STATE_MAXIMIZED_VERT");
- atoms.net_wm_state_maximized_horz = create("_NET_WM_STATE_MAXIMIZED_HORZ");
- atoms.net_wm_state_shaded = create("_NET_WM_STATE_SHADED");
- atoms.net_wm_state_skip_taskbar = create("_NET_WM_STATE_SKIP_TASKBAR");
- atoms.net_wm_state_skip_pager = create("_NET_WM_STATE_SKIP_PAGER");
- atoms.net_wm_state_hidden = create("_NET_WM_STATE_HIDDEN");
- atoms.net_wm_state_fullscreen = create("_NET_WM_STATE_FULLSCREEN");
- atoms.net_wm_state_above = create("_NET_WM_STATE_ABOVE");
- atoms.net_wm_state_below = create("_NET_WM_STATE_BELOW");
-
- atoms.net_wm_state_add = 1;
- atoms.net_wm_state_remove = 0;
- atoms.net_wm_state_toggle = 2;
-
- atoms.kde_net_system_tray_windows = create("_KDE_NET_SYSTEM_TRAY_WINDOWS");
- atoms.kde_net_wm_system_tray_window_for =
- create("_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR");
- atoms.kde_net_wm_window_type_override =
- create("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
-
- atoms.kwm_win_icon = create("KWM_WIN_ICON");
-
- atoms.rootpmapid = create("_XROOTPMAP_ID");
- atoms.esetrootid = create("ESETROOT_PMAP_ID");
-
- atoms.openbox_premax = create("_OPENBOX_PREMAX");
- atoms.openbox_active_window = create("_OPENBOX_ACTIVE_WINDOW");
- atoms.openbox_restack_window = create("_OPENBOX_RESTACK_WINDOW");
-}
-
-void Property::set(Window win, Atom atom, Atom type, unsigned char* data,
- int size, int nelements, bool append)
-{
- 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(**display, win, atom, type, size,
- (append ? PropModeAppend : PropModeReplace),
- data, nelements);
-}
-
-void Property::set(Window win, Atom atom, Atom type, unsigned long value)
-{
- set(win, atom, type, (unsigned char*) &value, 32, 1, false);
-}
-
-void Property::set(Window win, Atom atom, Atom type, unsigned long value[],
- int elements)
-{
- set(win, atom, type, (unsigned char*) value, 32, elements, false);
-}
-
-void Property::set(Window win, Atom atom, StringType type,
- const ustring &value)
-{
- Atom t;
- switch (type) {
- case ascii: t = atoms.string; assert(!value.utf8()); break;
- case utf8: t = atoms.utf8; assert(value.utf8()); break;
- default: assert(false); return; // unhandled StringType
- }
-
- // add 1 to the size to include the trailing null
- set(win, atom, t, (unsigned char*) value.c_str(), 8, value.bytes() + 1,
- false);
-}
-
-void Property::set(Window win, Atom atom, StringType type,
- const StringVect &strings)
-{
- Atom t;
- bool u; // utf8 encoded?
- switch (type) {
- case ascii: t = atoms.string; u = false; break;
- case utf8: t = atoms.utf8; u = true; break;
- default: assert(false); return; // unhandled StringType
- }
-
- ustring value(u);
-
- StringVect::const_iterator it = strings.begin();
- const StringVect::const_iterator end = strings.end();
- for (; it != end; ++it) {
- assert(it->utf8() == u); // the ustring is encoded correctly?
- value += *it;
- value += '\0';
- }
-
- // add 1 to the size to include the trailing null
- set(win, atom, t, (unsigned char*)value.c_str(), 8,
- value.bytes() + 1, false);
-}
-
-bool Property::get(Window win, Atom atom, Atom type, unsigned long *nelements,
- unsigned char **value, int size)
-{
- assert(win != None); assert(atom != None); assert(type != None);
- assert(size == 8 || size == 16 || size == 32);
- unsigned char *c_val = 0; // value alloc'd in Xlib, must be XFree()d
- Atom ret_type;
- int ret_size;
- unsigned long ret_bytes;
- int result;
- bool ret = false;
-
- // try get the first element
- result = XGetWindowProperty(**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 &&
- *nelements > 0);
- if (ret) {
- if (ret_bytes == 0) {
- // we got the whole property's value
- *value = new unsigned char[*nelements * size/8 + 1];
- memcpy(*value, c_val, *nelements * size/8 + 1);
- } else {
- // get the entire property since it is larger than one long
- XFree(c_val);
- // the number of longs that need to be retreived to get the property's
- // entire value. The last + 1 is the first long that we retrieved above.
- long remain = (ret_bytes - 1)/sizeof(long) + 1 + 1;
- result = XGetWindowProperty(**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);
- /*
- If the property has changed type/size, or has grown since our first
- read of it, then stop here and try again. If it shrank, then this will
- still work.
- */
- if (! ret) {
- return get(win, atom, type, nelements, value, size);
- }
-
- *value = new unsigned char[*nelements * size/8 + 1];
- memcpy(*value, c_val, *nelements * size/8 + 1);
- }
- }
- if (c_val) XFree(c_val);
- return ret;
-}
-
-bool Property::get(Window win, Atom atom, Atom type, unsigned long *nelements,
- unsigned long **value)
-{
- return get(win, atom, type, nelements, (unsigned char**) value, 32);
-}
-
-bool Property::get(Window win, Atom atom, Atom type, unsigned long *value)
-{
- unsigned long *temp;
- unsigned long num;
- if (! get(win, atom, type, &num, (unsigned char **) &temp, 32))
- return false;
- if (num >= 1) {
- *value = temp[0];
- delete [] temp;
- return true;
- }
- return false;
-}
-
-bool Property::get(Window win, Atom atom, StringType type, ustring *value)
-{
- unsigned long n;
- StringVect s;
-
- if (get(win, atom, type, &n, &s) && n > 0) {
- *value = s[0];
- return true;
- }
- return false;
-}
-
-bool Property::get(Window win, Atom atom, StringType type,
- unsigned long *nelements, StringVect *strings)
-{
- Atom t;
- bool u; // utf8 encoded?
- switch (type) {
- case ascii: t = atoms.string; u = false; break;
- case utf8: t = atoms.utf8; u = true; break;
- default: assert(false); return false; // unhandled StringType
- }
-
- unsigned char *value;
- unsigned long elements;;
- if (!get(win, atom, t, &elements, &value, 8) || elements < 1)
- return false;
-
- std::string s((char*)value, elements);
- delete [] value;
-
- std::string::const_iterator it = s.begin(), end = s.end();
- unsigned long num = 0;
- while(true) {
- std::string::const_iterator tmp = it; // current string.begin()
- it = std::find(tmp, end, '\0'); // look for null between tmp and end
- strings->push_back(std::string(tmp, it)); // s[tmp:it)
- strings->back().setUtf8(u);
- ++num;
- if (it == end) break;
- ++it;
- if (it == end) break;
- }
-
- *nelements = num;
-
- return true;
-}
-
-
-/*
- * Removes a property entirely from a window.
- */
-void Property::erase(Window win, Atom atom)
-{
- XDeleteProperty(**display, win, atom);
-}
-
-}
diff --git a/otk/property.hh b/otk/property.hh
deleted file mode 100644
index 13762692..00000000
--- a/otk/property.hh
+++ /dev/null
@@ -1,303 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __atom_hh
-#define __atom_hh
-
-/*! @file property.hh
- @brief Provides access to window properties
-*/
-
-#include "ustring.hh"
-#include "screeninfo.hh"
-
-extern "C" {
-#include <X11/Xlib.h>
-}
-
-#include <vector>
-#include <cassert>
-
-namespace otk {
-
-//! The atoms on the X server which this class will cache
-struct Atoms {
- // types
- Atom cardinal; //!< The atom which represents the Cardinal data type
- Atom window; //!< The atom which represents window ids
- Atom pixmap; //!< The atom which represents pixmap ids
- Atom atom; //!< The atom which represents atom values
- Atom string; //!< The atom which represents ascii strings
- Atom utf8; //!< The atom which represents utf8-encoded strings
-
- Atom openbox_pid;
-
- // window hints
- Atom wm_colormap_windows;
- Atom wm_protocols;
- Atom wm_state;
- Atom wm_delete_window;
- Atom wm_take_focus;
- Atom wm_change_state;
- Atom wm_name;
- Atom wm_icon_name;
- Atom wm_class;
- Atom wm_window_role;
- Atom motif_wm_hints;
-
- Atom openbox_show_root_menu;
- Atom openbox_show_workspace_menu;
-
- // NETWM atoms
- // root window properties
- Atom net_supported;
- Atom net_client_list;
- Atom net_client_list_stacking;
- Atom net_number_of_desktops;
- Atom net_desktop_geometry;
- Atom net_desktop_viewport;
- Atom net_current_desktop;
- Atom net_desktop_names;
- Atom net_active_window;
- Atom net_workarea;
- Atom net_supporting_wm_check;
-// Atom net_virtual_roots;
- Atom net_desktop_layout;
- Atom net_showing_desktop;
- // root window messages
- Atom net_close_window;
- Atom net_wm_moveresize;
- // application window properties
-// Atom net_properties;
- Atom net_wm_name;
- Atom net_wm_visible_name;
- Atom net_wm_icon_name;
- Atom net_wm_visible_icon_name;
- Atom net_wm_desktop;
- Atom net_wm_window_type;
- Atom net_wm_state;
- Atom net_wm_strut;
-// Atom net_wm_icon_geometry;
- Atom net_wm_icon;
-// Atom net_wm_pid;
-// Atom net_wm_handled_icons;
- Atom net_wm_allowed_actions;
- // application protocols
-// Atom Atom net_wm_ping;
-
- Atom net_wm_window_type_desktop;
- Atom net_wm_window_type_dock;
- Atom net_wm_window_type_toolbar;
- Atom net_wm_window_type_menu;
- Atom net_wm_window_type_utility;
- Atom net_wm_window_type_splash;
- Atom net_wm_window_type_dialog;
- Atom net_wm_window_type_normal;
-
- Atom net_wm_moveresize_size_topleft;
- Atom net_wm_moveresize_size_topright;
- Atom net_wm_moveresize_size_bottomleft;
- Atom net_wm_moveresize_size_bottomright;
- Atom net_wm_moveresize_move;
-
- Atom net_wm_action_move;
- Atom net_wm_action_resize;
- Atom net_wm_action_minimize;
- Atom net_wm_action_shade;
- Atom net_wm_action_stick;
- Atom net_wm_action_maximize_horz;
- Atom net_wm_action_maximize_vert;
- Atom net_wm_action_fullscreen;
- Atom net_wm_action_change_desktop;
- Atom net_wm_action_close;
-
- Atom net_wm_state_modal;
- Atom net_wm_state_sticky;
- Atom net_wm_state_maximized_vert;
- Atom net_wm_state_maximized_horz;
- Atom net_wm_state_shaded;
- Atom net_wm_state_skip_taskbar;
- Atom net_wm_state_skip_pager;
- Atom net_wm_state_hidden;
- Atom net_wm_state_fullscreen;
- Atom net_wm_state_above;
- Atom net_wm_state_below;
-
- Atom net_wm_state_add;
- Atom net_wm_state_remove;
- Atom net_wm_state_toggle;
-
- Atom kde_net_system_tray_windows;
- Atom kde_net_wm_system_tray_window_for;
- Atom kde_net_wm_window_type_override;
-
- Atom kwm_win_icon;
-
- Atom rootpmapid;
- Atom esetrootid;
-
- Atom openbox_premax;
- Atom openbox_active_window;
- Atom openbox_restack_window;
-};
-
-
-//! Provides easy access to window properties.
-class Property {
-public:
-
- //! The possible types/encodings of strings
- enum StringType {
- ascii, //!< Standard 8-bit ascii string
- utf8, //!< Utf8-encoded string
-#ifndef DOXYGEN_IGNORE
- NUM_STRING_TYPE
-#endif
- };
-
- //! A list of ustrings
- typedef std::vector<ustring> StringVect;
-
- //! The value of all atoms on the X server that exist in the
- //! Atoms struct
- static Atoms atoms;
-
-private:
- //! Sets a property on a window
- static void set(Window win, Atom atom, Atom type, unsigned char *data,
- int size, int nelements, bool append);
- //! Gets a property's value from a window
- static bool get(Window win, Atom atom, Atom type,
- unsigned long *nelements, unsigned char **value,
- int size);
-
-public:
- //! Initializes the Property class.
- /*!
- CAUTION: This function uses otk::Display, so ensure that
- otk::Display::initialize has been called before initializing this class!
- */
- static void initialize();
-
- //! 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 The Atom value of the property to set. This can be found in the
- struct returned by Property::atoms.
- @param type The Atom value of the property type. This can be found in the
- struct returned by Property::atoms.
- @param value The value to set the property to
- */
- static void set(Window win, Atom atom, Atom type, unsigned long value);
- //! 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 The Atom value of the property to set. This can be found in the
- struct returned by Property::atoms.
- @param type The Atom value of the property type. This can be found in the
- struct returned by Property::atoms.
- @param value Any array of values to set the property to. The array must
- contain <i>elements</i> number of elements
- @param elements The number of elements in the <i>value</i> array
- */
- static void set(Window win, Atom atom, Atom type,
- unsigned long value[], int elements);
- //! 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 The Atom value of the property to set. This can be found in the
- struct returned by Property::atoms.
- @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
- */
- static void set(Window win, Atom atom, StringType type,
- const ustring &value);
- //! 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 The Atom value of the property to set. This can be found in the
- struct returned by Property::atoms.
- @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
- */
- static void set(Window win, Atom atom, StringType type,
- const StringVect &strings);
-
- //! 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 The Atom value of the property to set. This can be found in the
- struct returned by Property::atoms.
- @param type The Atom value of the property type. This can be found in the
- struct returned by Property::atoms.
- @param nelements When the function returns, if it returns true, this will
- contain the actual number of elements retrieved.<br>
- @param value If the function returns true, then this contains an array of
- retrieved values for the property.<br>
- The <i>value</i> is allocated inside the function and
- <b>delete[]</b> value needs to be called when you are done
- with it.<br>
- The <i>value</i> array returned is null terminated, and has
- <i>nelements</i> elements in it plus the terminating null.
- @return true if retrieval of the specified property with the specified
- type was successful; otherwise, false
- */
- static bool get(Window win, Atom atom, Atom type,
- unsigned long *nelements, unsigned long **value);
- //! 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 The Atom value of the property to set. This can be found in the
- struct returned by Property::atoms.
- @param type The Atom value of the property type. This can be found in the
- struct returned by Property::atoms.
- @param value If the function returns true, then this contains the first
- (and possibly only) element in the value of the specified
- property.
- @return true if retrieval of the specified property with the specified
- type was successful; otherwise, false
- */
- static bool get(Window win, Atom atom, Atom type, unsigned long *value);
- //! 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 The Atom value of the property to set. This can be found in the
- struct returned by Property::atoms.
- @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
- property.
- @return true if retrieval of the specified property with the specified
- type was successful; otherwise, false
- */
- static bool get(Window win, Atom atom, StringType type, ustring *value);
- //! 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 The Atom value of the property to set. This can be found in the
- struct returned by Property::atoms.
- @param type A member of the Property::StringType enum that specifies the
- type of the string property to retrieve
- @param nelements When the function returns, if it returns true, this will
- contain the actual number of strings retrieved.<br>
- @param strings If the function returns true, then this contains all of the
- strings retrieved from the property's value.
- @return true if retrieval of the specified property with the specified
- type was successful; otherwise, false
- */
- static bool get(Window win, Atom atom, StringType type,
- unsigned long *nelements, StringVect *strings);
-
- //! Removes a property from a window
- /*!
- @param win The window id of the window to remove the property from
- @param atom The Atom value of the property to set. This can be found in the
- struct returned by Property::atoms.
- */
- static void erase(Window win, Atom atom);
-};
-
-}
-
-#endif // __atom_hh
diff --git a/otk/pseudorendercontrol.cc b/otk/pseudorendercontrol.cc
deleted file mode 100644
index cf992924..00000000
--- a/otk/pseudorendercontrol.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "pseudorendercontrol.hh"
-#include "display.hh"
-#include "screeninfo.hh"
-#include "surface.hh"
-#include "rendertexture.hh"
-
-extern "C" {
-#include "../src/gettext.h"
-#define _(str) gettext(str)
-}
-
-#include <cstdlib>
-
-namespace otk {
-
-PseudoRenderControl::PseudoRenderControl(int screen)
- : RenderControl(screen)
-{
- printf("Initializing PseudoColor RenderControl\n");
- const ScreenInfo *info = display->screenInfo(_screen);
- int depth = info->depth();
-
- // determine the number of colors and the bits-per-color
- _bpc = 2; // XXX THIS SHOULD BE A USER OPTION
- assert(_bpc >= 1);
- _ncolors = 1 << (_bpc * 3);
-
- if (_ncolors > 1 << depth) {
- fprintf(stderr,
- _("PseudoRenderControl: Invalid colormap size. Resizing.\n"));
- _bpc = 1 << (depth/3) >> 3;
- _ncolors = 1 << (_bpc * 3);
- }
-
- // build a color cube
- _colors = new XColor[_ncolors];
-int tr, tg, tb;
- int cpc = 1 << _bpc; // colors per channel
- for (int n = 0,
- r = 0; r < cpc; r++)
- for (int g = 0; g < cpc; g++)
- for (int b = 0; b < cpc; b++, n++) {
- tr = (int)(((float)(r)/(float)(cpc-1)) * 0xFF);
- tg = (int)(((float)(g)/(float)(cpc-1)) * 0xFF);
- tb = (int)(((float)(b)/(float)(cpc-1)) * 0xFF);
- _colors[n].red = tr | tr << 8;
- _colors[n].green = tg | tg << 8;
- _colors[n].blue = tb | tb << 8;
- _colors[n].flags = DoRed|DoGreen|DoBlue; // used to track allocation
- }
-
- // allocate the colors
- for (int i = 0; i < _ncolors; i++)
- if (!XAllocColor(**display, info->colormap(), &_colors[i]))
- _colors[i].flags = 0; // mark it as unallocated
-
- // try allocate any colors that failed allocation above
-
- // get the allocated values from the X server (only the first 256 XXX why!?)
- XColor icolors[256];
- int incolors = (((1 << depth) > 256) ? 256 : (1 << depth));
- for (int i = 0; i < incolors; i++)
- icolors[i].pixel = i;
- XQueryColors(**display, info->colormap(), icolors, incolors);
-
- // try match unallocated ones
- for (int i = 0; i < _ncolors; i++) {
- if (!_colors[i].flags) { // if it wasn't allocated...
- unsigned long closest = 0xffffffff, close = 0;
- for (int ii = 0; ii < incolors; ii++) {
- // find deviations
- int r = (_colors[i].red - icolors[ii].red) & 0xff;
- int g = (_colors[i].green - icolors[ii].green) & 0xff;
- int b = (_colors[i].blue - icolors[ii].blue) & 0xff;
- // find a weighted absolute deviation
- unsigned long dev = (r * r) + (g * g) + (b * b);
-
- if (dev < closest) {
- closest = dev;
- close = ii;
- }
- }
-
- _colors[i].red = icolors[close].red;
- _colors[i].green = icolors[close].green;
- _colors[i].blue = icolors[close].blue;
- _colors[i].pixel = icolors[close].pixel;
-
- // try alloc this closest color, it had better succeed!
- if (XAllocColor(**display, info->colormap(), &_colors[i]))
- _colors[i].flags = DoRed|DoGreen|DoBlue; // mark as alloced
- else
- assert(false); // wtf has gone wrong, its already alloced for chissake!
- }
- }
-}
-
-PseudoRenderControl::~PseudoRenderControl()
-{
- printf("Destroying PseudoColor RenderControl\n");
-
- unsigned long *pixels = new unsigned long [_ncolors], *p = pixels;
- for (int i = 0; i < _ncolors; ++i, ++p)
- *p = _colors[i].pixel;
- XFreeColors(**display, display->screenInfo(_screen)->colormap(), pixels,
- _ncolors, 0);
- delete [] _colors;
-}
-
-inline const XColor *PseudoRenderControl::pickColor(int r, int g, int b) const
-{
- r = (r & 0xff) >> (8-_bpc);
- g = (g & 0xff) >> (8-_bpc);
- b = (b & 0xff) >> (8-_bpc);
- return &_colors[(r << (2*_bpc)) + (g << (1*_bpc)) + b];
-}
-
-void PseudoRenderControl::reduceDepth(Surface &sf, XImage *im) const
-{
- pixel32 *data = sf.pixelData();
- pixel32 *ret = (pixel32*)malloc(im->width * im->height * 4);
- char *p = (char *)ret;
- int x, y;
- for (y = 0; y < im->height; y++) {
- for (x = 0; x < im->width; x++) {
- p[x] = pickColor(data[x] >> default_red_shift,
- data[x] >> default_green_shift,
- data[x] >> default_blue_shift)->pixel;
- }
- data += im->width;
- p += im->bytes_per_line;
- }
- im->data = (char*)ret;
-}
-
-void PseudoRenderControl::allocateColor(XColor *color) const
-{
- const XColor *c = pickColor(color->red, color->blue, color->green);
-
- color->red = c->red;
- color->green = c->green;
- color->blue = c->blue;
- color->pixel = c->pixel;
-
- if (XAllocColor(**display, display->screenInfo(_screen)->colormap(), color))
- color->flags = DoRed|DoGreen|DoBlue; // mark as alloced
- else
- assert(false); // wtf has gone wrong, its already alloced for chissake!
-
- return;
-}
-
-}
diff --git a/otk/pseudorendercontrol.hh b/otk/pseudorendercontrol.hh
deleted file mode 100644
index b6d60371..00000000
--- a/otk/pseudorendercontrol.hh
+++ /dev/null
@@ -1,28 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __pseudorendercontrol_hh
-#define __pseudorendercontrol_hh
-
-#include "rendercontrol.hh"
-
-namespace otk {
-
-class PseudoRenderControl : public RenderControl {
-private:
- int _bpc; // number of bits per color
- int _ncolors; // number of allocated colors, size of the XColor array
- XColor *_colors; // the valid allocated colors
-
- virtual void reduceDepth(Surface &sf, XImage *im) const;
-
- const XColor *pickColor(int r, int g, int b) const;
-
-public:
- PseudoRenderControl(int screen);
- virtual ~PseudoRenderControl();
-
- virtual void allocateColor(XColor *color) const;
-};
-
-}
-
-#endif // __pseudorendercontrol_hh
diff --git a/otk/rect.hh b/otk/rect.hh
deleted file mode 100644
index f5e755cc..00000000
--- a/otk/rect.hh
+++ /dev/null
@@ -1,39 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __rect_hh
-#define __rect_hh
-
-#include "point.hh"
-#include "size.hh"
-
-namespace otk {
-
-class Rect {
- Point _p;
- Size _s;
-public:
- Rect() : _p(), _s() {}
- Rect(const Point &p, const Size &s) : _p(p), _s(s) {}
- Rect(const Rect &r) : _p(r._p), _s(r._s) {}
- Rect(int x, int y, int w, int h)
- : _p(x, y), _s(w, h) {}
-
- inline int x() const { return _p.x(); }
- inline int y() const { return _p.y(); }
- inline int width() const { return _s.width(); }
- inline int height() const { return _s.height(); }
-
- inline int left() const { return _p.x(); }
- inline int top() const { return _p.y(); }
- inline int right() const { return _p.x() + _s.width() - 1; }
- inline int bottom() const { return _p.y() + _s.height() - 1; }
-
- inline const Point& position() const { return _p; }
- inline const Size& size() const { return _s; }
-
- bool operator==(const Rect &o) const { return _p == o._p && _s == o._s; }
- bool operator!=(const Rect &o) const { return _p != o._p || _s != o._s; }
-};
-
-}
-
-#endif // __rect_hh
diff --git a/otk/rendercolor.cc b/otk/rendercolor.cc
deleted file mode 100644
index 5da218ea..00000000
--- a/otk/rendercolor.cc
+++ /dev/null
@@ -1,101 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "rendercolor.hh"
-#include "display.hh"
-#include "screeninfo.hh"
-#include "rendercontrol.hh"
-
-#include <cstdio>
-
-namespace otk {
-
-std::map<unsigned long, RenderColor::CacheItem*> *RenderColor::_cache = 0;
-
-void RenderColor::initialize()
-{
- _cache = new std::map<unsigned long, CacheItem*>[ScreenCount(**display)];
-}
-
-void RenderColor::destroy()
-{
- delete [] _cache;
-}
-
-RenderColor::RenderColor(int screen, unsigned char red,
- unsigned char green, unsigned char blue)
- : _screen(screen),
- _red(red),
- _green(green),
- _blue(blue)
-{
- create();
-}
-
-RenderColor::RenderColor(int screen, RGB rgb)
- : _screen(screen),
- _red(rgb.r),
- _green(rgb.g),
- _blue(rgb.b)
-{
- create();
-}
-
-void RenderColor::create()
-{
- unsigned long color = _blue | _green << 8 | _red << 16;
-
- // try get a gc from the cache
- CacheItem *item = _cache[_screen][color];
-
- if (item) {
- _gc = item->gc;
- _pixel = item->pixel;
- ++item->count;
- } else {
- XGCValues gcv;
-
- // allocate a color and GC from the server
- const ScreenInfo *info = display->screenInfo(_screen);
-
- XColor xcol; // convert from 0-0xff to 0-0xffff
- xcol.red = (_red << 8) | _red;
- xcol.green = (_green << 8) | _green;
- xcol.blue = (_blue << 8) | _blue;
-
- display->renderControl(_screen)->allocateColor(&xcol);
-
- _pixel = xcol.pixel;
- gcv.foreground = _pixel;
- gcv.cap_style = CapProjecting;
- _gc = XCreateGC(**display, info->rootWindow(),
- GCForeground | GCCapStyle, &gcv);
- assert(_gc);
-
- // insert into the cache
- item = new CacheItem(_gc, _pixel);
- _cache[_screen][color] = item;
- ++item->count;
- }
-}
-
-RenderColor::~RenderColor()
-{
- unsigned long color = _blue | _green << 8 | _red << 16;
-
- CacheItem *item = _cache[_screen][color];
- assert(item); // better be...
-
- if (--item->count <= 0) {
- // remove from the cache
- XFreeGC(**display, _gc);
- _cache[_screen][color] = 0;
- delete item;
-
- const ScreenInfo *info = display->screenInfo(_screen);
- XFreeColors(**display, info->colormap(), &_pixel, 1, 0);
- }
-}
-
-}
diff --git a/otk/rendercolor.hh b/otk/rendercolor.hh
deleted file mode 100644
index 5076167f..00000000
--- a/otk/rendercolor.hh
+++ /dev/null
@@ -1,64 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __rendercolor_hh
-#define __rendercolor_hh
-
-extern "C" {
-#include <X11/Xlib.h>
-}
-
-#include <map>
-
-namespace otk {
-
-struct RGB {
- int r;
- int g;
- int b;
- RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
- // color is in ARGB format
- RGB(unsigned long color)
- : r((color >> 16) & 0xff),
- g((color >> 8) & 0xff),
- b((color) & 0xff) {}
-};
-
-class RenderColor {
-private:
- struct CacheItem {
- GC gc;
- unsigned long pixel;
- int count;
- CacheItem(GC g, unsigned long p) : gc(g), pixel(p), count(0) {}
- };
- static std::map<unsigned long, CacheItem*> *_cache;
-
- int _screen;
- unsigned char _red;
- unsigned char _green;
- unsigned char _blue;
-
- unsigned long _pixel;
- GC _gc;
-
- void create();
-
-public:
- static void initialize();
- static void destroy();
-
- RenderColor(int screen, unsigned char red,
- unsigned char green, unsigned char blue);
- RenderColor(int screen, RGB rgb);
- virtual ~RenderColor();
-
- inline int screen() const { return _screen; }
- inline unsigned char red() const { return _red; }
- inline unsigned char green() const { return _green; }
- inline unsigned char blue() const { return _blue; }
- unsigned long pixel() const { return _pixel; }
- GC gc() const { return _gc; }
-};
-
-}
-
-#endif // __rendercolor_hh
diff --git a/otk/rendercontrol.cc b/otk/rendercontrol.cc
deleted file mode 100644
index 6386b035..00000000
--- a/otk/rendercontrol.cc
+++ /dev/null
@@ -1,596 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "rendercontrol.hh"
-#include "truerendercontrol.hh"
-#include "pseudorendercontrol.hh"
-#include "rendertexture.hh"
-#include "rendercolor.hh"
-#include "renderstyle.hh"
-#include "display.hh"
-#include "screeninfo.hh"
-#include "surface.hh"
-#include "font.hh"
-#include "ustring.hh"
-#include "property.hh"
-
-extern "C" {
-#ifdef HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif // HAVE_SYS_WAIT_H
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif // HAVE_UNISTD_H
-
-#include "../src/gettext.h"
-#define _(str) gettext(str)
-}
-
-#include <cstdlib>
-
-namespace otk {
-
-RenderControl *RenderControl::createRenderControl(int screen)
-{
- // get the visual on the screen and return the correct type of RenderControl
- int vclass = display->screenInfo(screen)->visual()->c_class;
- switch (vclass) {
- case TrueColor:
- return new TrueRenderControl(screen);
- case PseudoColor:
- case StaticColor:
- return new PseudoRenderControl(screen);
- case GrayScale:
- case StaticGray:
- return new PseudoRenderControl(screen);
- default:
- printf(_("RenderControl: Unsupported visual %d specified. Aborting.\n"),
- vclass);
- ::exit(1);
- }
-}
-
-RenderControl::RenderControl(int screen)
- : _screen(screen)
-
-{
- printf("Initializing RenderControl\n");
-
-}
-
-RenderControl::~RenderControl()
-{
- printf("Destroying RenderControl\n");
-}
-
-void RenderControl::drawString(Surface& sf, const Font &font, int x, int y,
- const RenderColor &color,
- const ustring &string) const
-{
- assert(sf._screen == _screen);
- XftDraw *d = sf._xftdraw;
- assert(d); // this means that the background hasn't been rendered yet!
-
- if (font._shadow) {
- XftColor c;
- c.color.red = 0;
- c.color.green = 0;
- c.color.blue = 0;
- c.color.alpha = font._tint | font._tint << 8; // transparent shadow
- c.pixel = BlackPixel(**display, _screen);
-
- if (string.utf8())
- XftDrawStringUtf8(d, &c, font._xftfont, x + font._offset,
- font._xftfont->ascent + y + font._offset,
- (FcChar8*)string.c_str(), string.bytes());
- else
- XftDrawString8(d, &c, font._xftfont, x + font._offset,
- font._xftfont->ascent + y + font._offset,
- (FcChar8*)string.c_str(), string.bytes());
- }
-
- XftColor c;
- c.color.red = color.red() | color.red() << 8;
- 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 Color yet
-
- if (string.utf8())
- XftDrawStringUtf8(d, &c, font._xftfont, x, font._xftfont->ascent + y,
- (FcChar8*)string.c_str(), string.bytes());
- else
- XftDrawString8(d, &c, font._xftfont, x, font._xftfont->ascent + y,
- (FcChar8*)string.c_str(), string.bytes());
- return;
-}
-
-void RenderControl::drawSolidBackground(Surface& sf,
- const RenderTexture& texture) const
-{
- assert(_screen == sf._screen);
- assert(_screen == texture.color().screen());
-
- if (texture.parentRelative()) return;
-
- sf.setPixmap(texture.color());
-
- int width = sf.size().width(), height = sf.size().height();
- int left = 0, top = 0, right = width - 1, bottom = height - 1;
-
- if (texture.interlaced())
- for (int i = 0; i < height; i += 2)
- XDrawLine(**display, sf.pixmap(), texture.interlaceColor().gc(),
- 0, i, width, i);
-
- switch (texture.relief()) {
- case RenderTexture::Raised:
- switch (texture.bevel()) {
- case RenderTexture::Bevel1:
- XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(),
- left, bottom, right, bottom);
- XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(),
- right, bottom, right, top);
-
- XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(),
- left, top, right, top);
- XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(),
- left, bottom, left, top);
- break;
- case RenderTexture::Bevel2:
- XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(),
- left + 1, bottom - 2, right - 2, bottom - 2);
- XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(),
- right - 2, bottom - 2, right - 2, top + 1);
-
- XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(),
- left + 1, top + 1, right - 2, top + 1);
- XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(),
- left + 1, bottom - 2, left + 1, top + 1);
- break;
- default:
- assert(false); // unhandled RenderTexture::BevelType
- }
- break;
- case RenderTexture::Sunken:
- switch (texture.bevel()) {
- case RenderTexture::Bevel1:
- XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(),
- left, bottom, right, bottom);
- XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(),
- right, bottom, right, top);
-
- XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(),
- left, top, right, top);
- XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(),
- left, bottom, left, top);
- break;
- case RenderTexture::Bevel2:
- XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(),
- left + 1, bottom - 2, right - 2, bottom - 2);
- XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(),
- right - 2, bottom - 2, right - 2, top + 1);
-
- XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(),
- left + 1, top + 1, right - 2, top + 1);
- XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(),
- left + 1, bottom - 2, left + 1, top + 1);
- break;
- default:
- assert(false); // unhandled RenderTexture::BevelType
- }
- break;
- case RenderTexture::Flat:
- if (texture.border())
- XDrawRectangle(**display, sf.pixmap(), texture.borderColor().gc(),
- left, top, right, bottom);
- break;
- default:
- assert(false); // unhandled RenderTexture::ReliefType
- }
-}
-
-void RenderControl::drawMask(Surface &sf, const RenderColor &color,
- const PixmapMask &mask) const
-{
- assert(_screen == sf._screen);
- assert(_screen == color.screen());
-
- if (mask.mask == None) return; // no mask given
-
- int width = sf.size().width(), height = sf.size().height();
-
- // set the clip region
- int x = (width - mask.w) / 2, y = (height - mask.h) / 2;
- XSetClipMask(**display, color.gc(), mask.mask);
- XSetClipOrigin(**display, color.gc(), x, y);
-
- // fill in the clipped region
- XFillRectangle(**display, sf.pixmap(), color.gc(), x, y,
- x + mask.w, y + mask.h);
-
- // unset the clip region
- XSetClipMask(**display, color.gc(), None);
- XSetClipOrigin(**display, color.gc(), 0, 0);
-}
-
-void RenderControl::drawGradientBackground(
- Surface &sf, const RenderTexture &texture) const
-{
- unsigned int r,g,b;
- int w = sf.size().width(), h = sf.size().height();
- int off, x;
-
- const ScreenInfo *info = display->screenInfo(_screen);
- XImage *im = XCreateImage(**display, info->visual(), info->depth(),
- ZPixmap, 0, NULL, w, h, 32, 0);
- im->byte_order = endian;
-
- switch (texture.gradient()) {
- case RenderTexture::Vertical:
- verticalGradient(sf, texture);
- break;
- case RenderTexture::Horizontal:
- horizontalGradient(sf, texture);
- break;
- case RenderTexture::Diagonal:
- diagonalGradient(sf, texture);
- break;
- case RenderTexture::CrossDiagonal:
- crossDiagonalGradient(sf, texture);
- break;
- default:
- printf("unhandled gradient\n");
- }
-
- pixel32 *data = sf.pixelData();
- pixel32 current;
-
- if (texture.relief() == RenderTexture::Flat && texture.border()) {
- r = texture.borderColor().red();
- g = texture.borderColor().green();
- b = texture.borderColor().blue();
- current = (r << default_red_shift)
- + (g << default_green_shift)
- + (b << default_blue_shift);
- for (off = 0, x = 0; x < w; ++x, off++) {
- *(data + off) = current;
- *(data + off + ((h-1) * w)) = current;
- }
- for (off = 0, x = 0; x < h; ++x, off++) {
- *(data + (off * w)) = current;
- *(data + (off * w) + w - 1) = current;
- }
- }
-
- if (texture.relief() != RenderTexture::Flat) {
- if (texture.bevel() == RenderTexture::Bevel1) {
- for (off = 1, x = 1; x < w - 1; ++x, off++)
- highlight(data + off,
- data + off + (h-1) * w,
- texture.relief()==RenderTexture::Raised);
- for (off = 0, x = 0; x < h; ++x, off++)
- highlight(data + off * w,
- data + off * w + w - 1,
- texture.relief()==RenderTexture::Raised);
- }
-
- if (texture.bevel() == RenderTexture::Bevel2) {
- for (off = 2, x = 2; x < w - 2; ++x, off++)
- highlight(data + off + w,
- data + off + (h-2) * w,
- texture.relief()==RenderTexture::Raised);
- for (off = 1, x = 1; x < h-1; ++x, off++)
- highlight(data + off * w + 1,
- data + off * w + w - 2,
- texture.relief()==RenderTexture::Raised);
- }
- }
-
- reduceDepth(sf, im);
- sf.setPixmap(im);
- XDestroyImage(im);
-}
-
-void RenderControl::verticalGradient(Surface &sf,
- const RenderTexture &texture) const
-{
- pixel32 *data = sf.pixelData();
- pixel32 current;
- float dr, dg, db;
- unsigned int r,g,b;
- int w = sf.size().width(), h = sf.size().height();
-
- dr = (float)(texture.secondary_color().red() - texture.color().red());
- dr/= (float)h;
-
- dg = (float)(texture.secondary_color().green() - texture.color().green());
- dg/= (float)h;
-
- db = (float)(texture.secondary_color().blue() - texture.color().blue());
- db/= (float)h;
-
- for (int y = 0; y < h; ++y) {
- r = texture.color().red() + (int)(dr * y);
- g = texture.color().green() + (int)(dg * y);
- b = texture.color().blue() + (int)(db * y);
- current = (r << default_red_shift)
- + (g << default_green_shift)
- + (b << default_blue_shift);
- for (int x = 0; x < w; ++x, ++data)
- *data = current;
- }
-}
-
-void RenderControl::horizontalGradient(Surface &sf,
- const RenderTexture &texture) const
-{
- pixel32 *data = sf.pixelData();
- pixel32 current;
- float dr, dg, db;
- unsigned int r,g,b;
- int w = sf.size().width(), h = sf.size().height();
-
- dr = (float)(texture.secondary_color().red() - texture.color().red());
- dr/= (float)w;
-
- dg = (float)(texture.secondary_color().green() - texture.color().green());
- dg/= (float)w;
-
- db = (float)(texture.secondary_color().blue() - texture.color().blue());
- db/= (float)w;
-
- for (int x = 0; x < w; ++x, ++data) {
- r = texture.color().red() + (int)(dr * x);
- g = texture.color().green() + (int)(dg * x);
- b = texture.color().blue() + (int)(db * x);
- current = (r << default_red_shift)
- + (g << default_green_shift)
- + (b << default_blue_shift);
- for (int y = 0; y < h; ++y)
- *(data + y*w) = current;
- }
-}
-
-void RenderControl::diagonalGradient(Surface &sf,
- const RenderTexture &texture) const
-{
- pixel32 *data = sf.pixelData();
- pixel32 current;
- float drx, dgx, dbx, dry, dgy, dby;
- unsigned int r,g,b;
- int w = sf.size().width(), h = sf.size().height();
-
- for (int y = 0; y < h; ++y) {
- drx = (float)(texture.secondary_color().red() - texture.color().red());
- dry = drx/(float)h;
- drx/= (float)w;
-
- dgx = (float)(texture.secondary_color().green() - texture.color().green());
- dgy = dgx/(float)h;
- dgx/= (float)w;
-
- dbx = (float)(texture.secondary_color().blue() - texture.color().blue());
- dby = dbx/(float)h;
- dbx/= (float)w;
- for (int x = 0; x < w; ++x, ++data) {
- r = texture.color().red() + ((int)(drx * x) + (int)(dry * y))/2;
- g = texture.color().green() + ((int)(dgx * x) + (int)(dgy * y))/2;
- b = texture.color().blue() + ((int)(dbx * x) + (int)(dby * y))/2;
- current = (r << default_red_shift)
- + (g << default_green_shift)
- + (b << default_blue_shift);
- *data = current;
- }
- }
-}
-
-void RenderControl::crossDiagonalGradient(
- Surface &sf, const RenderTexture &texture) const
-{
- pixel32 *data = sf.pixelData();
- pixel32 current;
- float drx, dgx, dbx, dry, dgy, dby;
- unsigned int r,g,b;
- int w = sf.size().width(), h = sf.size().height();
-
- for (int y = 0; y < h; ++y) {
- drx = (float)(texture.secondary_color().red() - texture.color().red());
- dry = drx/(float)h;
- drx/= (float)w;
-
- dgx = (float)(texture.secondary_color().green() - texture.color().green());
- dgy = dgx/(float)h;
- dgx/= (float)w;
-
- dbx = (float)(texture.secondary_color().blue() - texture.color().blue());
- dby = dbx/(float)h;
- dbx/= (float)w;
- for (int x = w; x > 0; --x, ++data) {
- r = texture.color().red() + ((int)(drx * (x-1)) + (int)(dry * y))/2;
- g = texture.color().green() + ((int)(dgx * (x-1)) + (int)(dgy * y))/2;
- b = texture.color().blue() + ((int)(dbx * (x-1)) + (int)(dby * y))/2;
- current = (r << default_red_shift)
- + (g << default_green_shift)
- + (b << default_blue_shift);
- *data = current;
- }
- }
-}
-
-void RenderControl::highlight(pixel32 *x, pixel32 *y, bool raised) const
-{
- int r, g, b;
-
- pixel32 *up, *down;
- if (raised) {
- up = x;
- down = y;
- } else {
- up = y;
- down = x;
- }
- r = (*up >> default_red_shift) & 0xFF;
- r += r >> 1;
- g = (*up >> default_green_shift) & 0xFF;
- g += g >> 1;
- b = (*up >> default_blue_shift) & 0xFF;
- b += b >> 1;
- if (r > 255) r = 255;
- if (g > 255) g = 255;
- if (b > 255) b = 255;
- *up = (r << default_red_shift) + (g << default_green_shift)
- + (b << default_blue_shift);
-
- r = (*down >> default_red_shift) & 0xFF;
- r = (r >> 1) + (r >> 2);
- g = (*down >> default_green_shift) & 0xFF;
- g = (g >> 1) + (g >> 2);
- b = (*down >> default_blue_shift) & 0xFF;
- b = (b >> 1) + (b >> 2);
- *down = (r << default_red_shift) + (g << default_green_shift)
- + (b << default_blue_shift);
-}
-
-void RenderControl::drawBackground(Surface& sf,
- const RenderTexture &texture) const
-{
- assert(_screen == sf._screen);
- assert(_screen == texture.color().screen());
-
- if (texture.gradient() == RenderTexture::Solid)
- drawSolidBackground(sf, texture);
- else
- drawGradientBackground(sf, texture);
-}
-
-
-void RenderControl::drawImage(Surface &sf, int w, int h,
- unsigned long *data) const
-{
- pixel32 *bg = sf.pixelData();
- int c, sfw, sfh;
- unsigned int i, e, bgi;
- sfw = sf.size().width();
- sfh = sf.size().height();
-
- if (w && h) {
- // scale it
- unsigned long *olddata = data;
- unsigned long newdata[sfw*sfh];
- double dx = w / (double)sfw;
- double dy = h / (double)sfh;
- double px = 0.0;
- double py = 0.0;
- int iy = 0;
- for (i = 0, c = 0, e = sfw*sfh; i < e; ++i) {
- newdata[i] = olddata[(int)px + iy];
- if (++c >= sfw) {
- c = 0;
- px = 0;
- py += dy;
- iy = (int)py * w;
- } else
- px += dx;
- }
- data = newdata;
-
- // apply the alpha channel
- for (i = 0, c = 0, e = sfw*sfh; i < e; ++i, ++bgi) {
- unsigned char alpha = data[i] >> 24;
- unsigned char r = data[i] >> 16;
- unsigned char g = data[i] >> 8;
- unsigned char b = data[i];
-
- // background color
- unsigned char bgr = bg[i] >> default_red_shift;
- unsigned char bgg = bg[i] >> default_green_shift;
- unsigned char bgb = bg[i] >> default_blue_shift;
-
- r = bgr + (((r - bgr) * alpha) >> 8);
- g = bgg + (((g - bgg) * alpha) >> 8);
- b = bgb + (((b - bgb) * alpha) >> 8);
-
- bg[i] = (r << default_red_shift) | (g << default_green_shift) |
- (b << default_blue_shift);
- }
- }
-
- const ScreenInfo *info = display->screenInfo(_screen);
- XImage *im = XCreateImage(**display, info->visual(), info->depth(),
- ZPixmap, 0, NULL, sf.size().width(),
- sf.size().height(), 32, 0);
- im->byte_order = endian;
-
- reduceDepth(sf, im);
- sf.setPixmap(im);
- XDestroyImage(im);
-}
-
-void RenderControl::drawImage(Surface &sf, Pixmap pixmap, Pixmap mask) const
-{
- int junk, sfw, sfh, w, h, depth, mw, mh, mdepth;
- Window wjunk;
- const ScreenInfo *info = display->screenInfo(_screen);
- GC mgc = 0;
-
- assert(pixmap != None);
-
- sfw = sf.size().width();
- sfh = sf.size().height();
-
- XGetGeometry(**display, pixmap, &wjunk, &junk, &junk,
- (unsigned int*)&w, (unsigned int*)&h,
- (unsigned int*)&junk, (unsigned int*)&depth);
- if (mask != None) {
- XGetGeometry(**display, mask, &wjunk, &junk, &junk,
- (unsigned int*)&mw, (unsigned int*)&mh,
- (unsigned int*)&junk, (unsigned int*)&mdepth);
- if (mw != w || mh != h || mdepth != 1)
- return;
- }
-
- Pixmap p = XCreatePixmap(**display, info->rootWindow(), sfw, sfh,
- info->depth());
- Pixmap m;
- if (mask == None)
- m = None;
- else {
- m = XCreatePixmap(**display, info->rootWindow(), sfw, sfh, 1);
- XGCValues gcv;
- gcv.subwindow_mode = IncludeInferiors;
- gcv.graphics_exposures = false;
- mgc = XCreateGC(**display, m, GCGraphicsExposures |
- GCSubwindowMode, &gcv);
- }
-
- // scale it
- for (int y = sfh - 1; y >= 0; --y) {
- int yy = y * h / sfh;
- for (int x = sfw - 1; x >= 0; --x) {
- int xx = x * w / sfw;
- if (depth != info->depth()) {
- XCopyPlane(**display, pixmap, p, DefaultGC(**display, _screen),
- xx, yy, 1, 1, x, y, 1);
- } else {
- XCopyArea(**display, pixmap, p, DefaultGC(**display, _screen),
- xx, yy, 1, 1, x, y);
- }
- if (mask != None)
- XCopyArea(**display, mask, m, mgc, xx, yy, 1, 1, x, y);
- }
- }
-
- XSetClipMask(**display, DefaultGC(**display, _screen), m);
- XSetClipOrigin(**display, DefaultGC(**display, _screen), 0, 0);
- XCopyArea(**display, p, sf.pixmap(), DefaultGC(**display, _screen), 0, 0,
- sfw, sfh, 0, 0);
- XSetClipMask(**display, DefaultGC(**display, _screen), None);
-
- XFreePixmap(**display, p);
- if (m != None) XFreePixmap(**display, m);
-}
-
-}
diff --git a/otk/rendercontrol.hh b/otk/rendercontrol.hh
deleted file mode 100644
index 9e140db0..00000000
--- a/otk/rendercontrol.hh
+++ /dev/null
@@ -1,85 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __rendercontrol_hh
-#define __rendercontrol_hh
-
-extern "C" {
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-}
-
-#include "surface.hh"
-
-namespace otk {
-
-class ScreenInfo;
-class RenderTexture;
-class Font;
-class RenderColor;
-class ustring;
-class PixmapMask;
-
-class RenderControl {
-protected:
- int _screen;
-
-// bool _dither;
-
- RenderControl(int screen);
-
- inline void highlight(pixel32 *x, pixel32 *y, bool raised) const;
- void verticalGradient(Surface &sf, const RenderTexture &texture) const;
- void horizontalGradient(Surface &sf, const RenderTexture &texture) const;
- void diagonalGradient(Surface &sf, const RenderTexture &texture) const;
- void crossDiagonalGradient(Surface &sf, const RenderTexture &texture) const;
- virtual void drawGradientBackground(Surface &sf,
- const RenderTexture &texture) const;
- virtual void drawSolidBackground(Surface& sf,
- const RenderTexture& texture) const;
-
- //! Reduces a Surface's Surface::pixelData so that it will display correctly
- //! on the screen's depth
- /*!
- This function allocates and sets the im->data member. The allocated memory
- will be freed when XDetroyImage is called on the XImage.
- */
- virtual void reduceDepth(Surface &sf, XImage *im) const = 0;
-
-public:
- virtual ~RenderControl();
-
- static RenderControl *createRenderControl(int screen);
-
- //! Draws a background onto a Surface, as specified by a RenderTexture
- /*!
- This function will overwrite the entire surface.
- */
- virtual void drawBackground(Surface &sf,
- const RenderTexture &texture) const;
-
- //! Draws an image onto the surface
- /*!
- This function will overwrite the entire surface.<br>
- The image must be specified in 32-bit packed ARGB format. The current
- background will be used for applying the alpha.
- */
- virtual void drawImage(Surface &sf, int w, int h,
- unsigned long *data) const;
-
- //! Draws an image onto the surface
- virtual void drawImage(Surface &sf, Pixmap pixmap, Pixmap mask) const;
-
- //! Draws a string onto a Surface
- virtual void drawString(Surface &sf, const Font &font, int x, int y,
- const RenderColor &color,
- const ustring &string) const;
-
- //! Draws a PixmapMask with a specified color onto a Surface
- virtual void drawMask(Surface &sf, const RenderColor &color,
- const PixmapMask &mask) const;
-
- virtual void allocateColor(XColor *color) const = 0;
-};
-
-}
-
-#endif // __rendercontrol_hh
diff --git a/otk/renderstyle.cc b/otk/renderstyle.cc
deleted file mode 100644
index 482f3303..00000000
--- a/otk/renderstyle.cc
+++ /dev/null
@@ -1,697 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "renderstyle.hh"
-#include "display.hh"
-#include "screeninfo.hh"
-
-#include <cassert>
-
-namespace otk {
-
-RenderStyle **RenderStyle::_styles = 0;
-std::list<StyleNotify*> *RenderStyle::_notifies = 0;
-
-void RenderStyle::initialize()
-{
- int screens = ScreenCount(**display);
- _styles = new RenderStyle*[screens];
- for (int i = 0; i < screens; ++i) {
- _styles[i] = new RenderStyle();
- defaultStyle(_styles[i], i);
- }
- _notifies = new std::list<StyleNotify*>[screens];
-}
-
-void RenderStyle::destroy()
-{
- int screens = ScreenCount(**display);
- for (int i = 0; i < screens; ++i)
- delete _styles[i];
- delete [] _styles;
- delete [] _notifies;
-}
-
-void RenderStyle::registerNotify(int screen, StyleNotify *n)
-{
- assert(screen >= 0 && screen < ScreenCount(**display));
- _notifies[screen].push_back(n);
-}
-
-void RenderStyle::unregisterNotify(int screen, StyleNotify *n)
-{
- assert(screen >= 0 && screen < ScreenCount(**display));
- _notifies[screen].remove(n);
-}
-
-RenderStyle *RenderStyle::style(int screen)
-{
- assert(screen >= 0 && screen < ScreenCount(**display));
- return _styles[screen];
-}
-
-bool RenderStyle::setStyle(int screen, const ustring &stylefile)
-{
- RenderStyle *s = new RenderStyle();
- if (!loadStyle(s, screen, stylefile)) {
- delete s;
- return false;
- }
- delete _styles[screen];
- _styles[screen] = s;
-
- std::list<StyleNotify*>::iterator it, end = _notifies[screen].end();
- for (it = _notifies[screen].begin(); it != end; ++it)
- (*it)->styleChanged(*s);
- return true;
-}
-
-bool RenderStyle::loadStyle(RenderStyle *s, int screen,
- const ustring &stylefile)
-{
- s->_screen = screen;
- s->_file = stylefile;
-// pick one..
-#define FIERON
-//#define MERRY
-
-#ifdef FIERON
- s->_root_args = "#272a2f";
-
- s->_text_color_focus = new RenderColor(screen, 0x272a2f);
- s->_text_color_unfocus = new RenderColor(screen, 0x676869);
-
- s->_button_color_focus = new RenderColor(screen, 0x96ba86);
- s->_button_color_unfocus = new RenderColor(screen, 0x676869);
-
- s->_frame_border_color = new RenderColor(screen, 0x181f24);
- s->_frame_border_width = 1;
-
- s->_client_border_color_focus = new RenderColor(screen, 0x858687);
- s->_client_border_color_unfocus = new RenderColor(screen, 0x555657);
- s->_client_border_width = 1;
-
- s->_titlebar_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Vertical,
- false,
- 0x858687,
- 0x373a3f,
- 0x0,
- 0x0);
- s->_titlebar_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Vertical,
- false,
- 0x555657,
- 0x171a1f,
- 0x0,
- 0x0);
-
- s->_label_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- true,
- RenderTexture::Vertical,
- false,
- 0x96ba86,
- 0x5a724c,
- 0x181f24,
- 0x0);
- s->_label_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Sunken,
- RenderTexture::Bevel1,
- false,
- RenderTexture::CrossDiagonal,
- false,
- 0x555657,
- 0x272a2f,
- 0x0,
- 0x0);
-
- s->_handle_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Vertical,
- false,
- 0x858687,
- 0x373a3f,
- 0x0,
- 0x0);
- s->_handle_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Vertical,
- false,
- 0x555657,
- 0x171a1f,
- 0x0,
- 0x0);
-
- s->_button_unpress_focus = new RenderTexture(screen,
- false,
- RenderTexture::Raised,
- RenderTexture::Bevel2,
- false,
- RenderTexture::CrossDiagonal,
- false,
- 0x858687,
- 0x272a2f,
- 0x0,
- 0x0);
- s->_button_unpress_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Raised,
- RenderTexture::Bevel2,
- false,
- RenderTexture::CrossDiagonal,
- false,
- 0x555657,
- 0x171a1f,
- 0x0,
- 0x0);
-
- s->_button_press_focus = new RenderTexture(screen,
- false,
- RenderTexture::Sunken,
- RenderTexture::Bevel2,
- false,
- RenderTexture::CrossDiagonal,
- false,
- 0x96ba86,
- 0x5a724c,
- 0x0,
- 0x0);
- s->_button_press_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Sunken,
- RenderTexture::Bevel2,
- false,
- RenderTexture::CrossDiagonal,
- false,
- 0x555657,
- 0x171a1f,
- 0x0,
- 0x0);
-
- s->_grip_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Vertical,
- false,
- 0x96ba86,
- 0x5a724c,
- 0x0,
- 0x0);
- s->_grip_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Vertical,
- false,
- 0x555657,
- 0x171a1f,
- 0x0,
- 0x0);
-
- s->_label_font = new Font(screen, "Arial,Sans-9:bold", true, 1, 0x40);
- s->_label_justify = RightBottomJustify;
-
- s->_max_mask = new PixmapMask();
- s->_max_mask->w = s->_max_mask->h = 8;
- {
- //char data[] = { 0x7e, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0x7e };
- char data [] = {0x00, 0x00, 0x18, 0x3c, 0x66, 0x42, 0x00, 0x00 };
- s->_max_mask->mask =
- XCreateBitmapFromData(**display,
- display->screenInfo(screen)->rootWindow(),
- data, 8, 8);
- }
-
- s->_icon_mask = new PixmapMask();
- s->_icon_mask->w = s->_icon_mask->h = 8;
- {
- //char data[] = { 0x00, 0x00, 0xc3, 0xe7, 0x7e, 0x3c, 0x18, 0x00 };
- char data[] = { 0x00, 0x00, 0x42, 0x66, 0x3c, 0x18, 0x00, 0x00 };
- s->_icon_mask->mask =
- XCreateBitmapFromData(**display,
- display->screenInfo(screen)->rootWindow(),
- data, 8, 8);
- }
-
- s->_alldesk_mask = new PixmapMask();
- s->_alldesk_mask->w = s->_alldesk_mask->h = 8;
- {
- //char data[] = { 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00 };
- char data[] = { 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00 };
- s->_alldesk_mask->mask =
- XCreateBitmapFromData(**display,
- display->screenInfo(screen)->rootWindow(),
- data, 8, 8);
- }
-
- s->_close_mask = new PixmapMask();
- s->_close_mask->w = s->_close_mask->h = 8;
- {
- //char data[] = { 0xc3, 0xe7, 0x7e, 0x3c, 0x3c, 0x7e, 0xe7, 0xc3 };
- char data[] = { 0x00, 0xc3, 0x66, 0x3c, 0x3c, 0x66, 0xc3, 0x00 };
- s->_close_mask->mask =
- XCreateBitmapFromData(**display,
- display->screenInfo(screen)->rootWindow(),
- data, 8, 8);
- }
-
- s->_bevel_width = 1;
- s->_handle_width = 4;
-#else
-# ifdef MERRY
- s->_root_args = "#7b756a";
-
- s->_text_color_focus = new RenderColor(screen, 0xffffff);
- s->_text_color_unfocus = new RenderColor(screen, 0xffffff);
-
- s->_button_color_focus = new RenderColor(screen, 0x222222);
- s->_button_color_unfocus = new RenderColor(screen, 0x333333);
-
- s->_frame_border_color = new RenderColor(screen, 0x222222);
- s->_frame_border_width = 1;
-
- s->_client_border_color_focus = new RenderColor(screen, 0x858687);
- s->_client_border_color_unfocus = new RenderColor(screen, 0x555657);
- s->_client_border_width = 0;
-
- s->_titlebar_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0xe6e6e6,
- 0xe6e6e6,
- 0x0,
- 0x0);
- s->_titlebar_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0xe6e6e6,
- 0xd9d9d9,
- 0x0,
- 0x0);
-
- s->_label_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- true,
- RenderTexture::Vertical,
- false,
- //0x6a6973,
- //0x6a6973,
- 0x4c59a6,
- 0x5a6dbd,
- 0x222222,
- 0x0);
- //urg this ain't so hot
- s->_label_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- true,
- RenderTexture::Vertical,
- false,
- 0xb4b2ad,
- 0xc3c1bc,
- 0x6a696a,
- 0x0);
-
-
- s->_handle_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Vertical,
- false,
- 0xe6e6e6,
- 0xd9d9d9,
- 0x0,
- 0x0);
- s->_handle_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0xe6e6e6,
- 0xe6e6e6,
- 0x0,
- 0x0);
-
-
- s->_button_unpress_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0xe6e6e6,
- 0xe6e6e6,
- 0x0,
- 0x0);
- s->_button_unpress_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0xe6e6e6,
- 0xe6e6e6,
- 0x0,
- 0x0);
-
- s->_button_press_focus = new RenderTexture(screen,
- false,
- RenderTexture::Sunken,
- RenderTexture::Bevel2,
- false,
- RenderTexture::Vertical,
- false,
- 0xe6e6e6,
- 0xe6e6e6,
- 0x0,
- 0x0);
- s->_button_press_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Sunken,
- RenderTexture::Bevel2,
- false,
- RenderTexture::Vertical,
- false,
- 0xe6e6e6,
- 0xe6e6e6,
- 0x0,
- 0x0);
-
- s->_grip_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Vertical,
- false,
- 0xe6e6e6,
- 0xd9d9d9,
- 0x0,
- 0x0);
- s->_grip_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0xe6e6e6,
- 0xe6e6e6,
- 0x0,
- 0x0);
-
- s->_label_font = new Font(screen, "Arial,Sans-8", true, 1, 0x3e);
- s->_label_justify = CenterJustify;
-
- s->_max_mask = new PixmapMask();
- s->_max_mask->w = s->_max_mask->h = 7;
- {
- char data [] = {0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
- s->_max_mask->mask =
- XCreateBitmapFromData(**display,
- display->screenInfo(screen)->rootWindow(),
- data, 7, 7);
- }
-
- s->_icon_mask = new PixmapMask();
- s->_icon_mask->w = s->_icon_mask->h = 7;
- {
- char data[] = { 0x00, 0x00, 0x00, 0x00, 0x3e, 0x3e, 0x3e };
- s->_icon_mask->mask =
- XCreateBitmapFromData(**display,
- display->screenInfo(screen)->rootWindow(),
- data, 7, 7);
- }
-
- s->_alldesk_mask = new PixmapMask();
- s->_alldesk_mask->w = s->_alldesk_mask->h = 7;
- {
- char data[] = {0x00, 0x36, 0x36, 0x00, 0x36, 0x36, 0x00 };
- s->_alldesk_mask->mask =
- XCreateBitmapFromData(**display,
- display->screenInfo(screen)->rootWindow(),
- data, 7, 7);
- }
-
- s->_close_mask = new PixmapMask();
- s->_close_mask->w = s->_close_mask->h = 7;
- {
- char data[] = { 0x22, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x22 };
- s->_close_mask->mask =
- XCreateBitmapFromData(**display,
- display->screenInfo(screen)->rootWindow(),
- data, 7, 7);
- }
-
- s->_bevel_width = 1;
- s->_handle_width = 3;
-# else
-# error 1
-# endif
-#endif
-
- return true;
-}
-
-void RenderStyle::defaultStyle(RenderStyle *s, int screen)
-{
- s->_screen = screen;
- s->_file = "";
-
- s->_root_args = "#000000";
- s->_text_color_focus = new RenderColor(screen, 0xffffff);
- s->_text_color_unfocus = new RenderColor(screen, 0xffffff);
- s->_button_color_focus = new RenderColor(screen, 0xffffff);
- s->_button_color_unfocus = new RenderColor(screen, 0xffffff);
- s->_frame_border_color = new RenderColor(screen, 0);
- s->_frame_border_width = 1;
- s->_client_border_color_focus = new RenderColor(screen, 0);
- s->_client_border_color_unfocus = new RenderColor(screen, 0);
- s->_client_border_width = 1;
- s->_titlebar_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0, 0, 0, 0);
- s->_titlebar_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0, 0, 0, 0);
-
- s->_label_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- true,
- RenderTexture::Solid,
- false,
- 0, 0, 0, 0);
- s->_label_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0, 0, 0, 0);
-
- s->_handle_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0, 0, 0, 0);
- s->_handle_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0, 0, 0, 0);
-
- s->_button_unpress_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- true,
- RenderTexture::Solid,
- false,
- 0, 0, 0xffffff, 0);
- s->_button_unpress_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0, 0, 0, 0);
-
- s->_button_press_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- true,
- RenderTexture::Solid,
- false,
- 0, 0, 0xffffff, 0);
- s->_button_press_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0, 0, 0, 0);
-
- s->_grip_focus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0, 0, 0, 0);
- s->_grip_unfocus = new RenderTexture(screen,
- false,
- RenderTexture::Flat,
- RenderTexture::Bevel1,
- false,
- RenderTexture::Solid,
- false,
- 0, 0, 0, 0);
-
- s->_label_font = new Font(screen, "Sans-9", false, 0, 0);
- s->_label_justify = LeftTopJustify;
-
- s->_max_mask = new PixmapMask();
- s->_max_mask->w = s->_max_mask->h = 0;
- s->_max_mask->mask = None;
-
- s->_icon_mask = new PixmapMask();
- s->_icon_mask->w = s->_icon_mask->h = 0;
- s->_icon_mask->mask = None;
-
- s->_alldesk_mask = new PixmapMask();
- s->_alldesk_mask->w = s->_alldesk_mask->h = 0;
- s->_alldesk_mask->mask = 0;
-
- s->_close_mask = new PixmapMask();
- s->_close_mask->w = s->_close_mask->h = 8;
- s->_close_mask->mask = 0;
-
- s->_bevel_width = 1;
- s->_handle_width = 4;
-}
-
-RenderStyle::~RenderStyle()
-{
- assert(_text_color_focus);
- delete _text_color_focus;
- assert(_text_color_unfocus);
- delete _text_color_unfocus;
-
- assert(_button_color_focus);
- delete _button_color_focus;
- assert(_button_color_unfocus);
- delete _button_color_unfocus;
-
- assert(_frame_border_color);
- delete _frame_border_color;
-
- assert(_client_border_color_focus);
- delete _client_border_color_focus;
- assert(_client_border_color_unfocus);
- delete _client_border_color_unfocus;
-
- assert(_titlebar_focus);
- delete _titlebar_focus;
- assert(_titlebar_unfocus);
- delete _titlebar_unfocus;
-
- assert(_label_focus);
- delete _label_focus;
- assert(_label_unfocus);
- delete _label_unfocus;
-
- assert(_handle_focus);
- delete _handle_focus;
- assert(_handle_unfocus);
- delete _handle_unfocus;
-
- assert(_button_unpress_focus);
- delete _button_unpress_focus;
- assert(_button_unpress_unfocus);
- delete _button_unpress_unfocus;
- assert(_button_press_focus);
- delete _button_press_focus;
- assert(_button_press_unfocus);
- delete _button_press_unfocus;
-
- assert(_grip_focus);
- delete _grip_focus;
- assert(_grip_unfocus);
- delete _grip_unfocus;
-
- assert(_label_font);
- delete _label_font;
-
- assert(_max_mask);
- delete _max_mask;
- assert(_icon_mask);
- delete _icon_mask;
- assert(_alldesk_mask);
- delete _alldesk_mask;
- assert(_close_mask);
- delete _close_mask;
-}
-
-}
diff --git a/otk/renderstyle.hh b/otk/renderstyle.hh
deleted file mode 100644
index 0f512148..00000000
--- a/otk/renderstyle.hh
+++ /dev/null
@@ -1,157 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __renderstyle_hh
-#define __renderstyle_hh
-
-#include "rendertexture.hh"
-#include "rendercolor.hh"
-#include "font.hh"
-#include "ustring.hh"
-
-#include <list>
-#include <string>
-
-namespace otk {
-
-struct PixmapMask {
- Pixmap mask;
- unsigned int w, h;
- PixmapMask() { mask = None; w = h = 0; }
-};
-
-class RenderStyle;
-
-class StyleNotify {
-public:
- //! Called when the style is changed on the same screen as the handler.
- virtual void styleChanged(const RenderStyle &) {}
-};
-
-class RenderStyle {
- static RenderStyle **_styles;
- static std::list<StyleNotify*> *_notifies;
-public:
- static void initialize();
- static void destroy();
- static void registerNotify(int screen, StyleNotify *n);
- static void unregisterNotify(int screen, StyleNotify *n);
- static RenderStyle *style(int screen);
- static bool setStyle(int screen, const ustring &stylefile);
-
- enum Justify {
- LeftTopJustify,
- RightBottomJustify,
- CenterJustify
- };
-
-private:
- static bool loadStyle(RenderStyle *s, int screen, const ustring &stylefile);
- static void defaultStyle(RenderStyle *s, int screen);
-
- int _screen;
- ustring _file;
-
- std::string _root_args;
-
- RenderColor *_text_color_focus;
- RenderColor *_text_color_unfocus;
-
- RenderColor *_button_color_focus;
- RenderColor *_button_color_unfocus;
-
- RenderColor *_frame_border_color;
- int _frame_border_width;
-
- RenderColor *_client_border_color_focus;
- RenderColor *_client_border_color_unfocus;
- int _client_border_width;
-
- RenderTexture *_titlebar_focus;
- RenderTexture *_titlebar_unfocus;
-
- RenderTexture *_label_focus;
- RenderTexture *_label_unfocus;
-
- RenderTexture *_handle_focus;
- RenderTexture *_handle_unfocus;
-
- RenderTexture *_button_unpress_focus;
- RenderTexture *_button_unpress_unfocus;
- RenderTexture *_button_press_focus;
- RenderTexture *_button_press_unfocus;
-
- RenderTexture *_grip_focus;
- RenderTexture *_grip_unfocus;
-
- Font *_label_font;
- Justify _label_justify;
-
- PixmapMask *_max_mask;
- PixmapMask *_icon_mask;
- PixmapMask *_alldesk_mask;
- PixmapMask *_close_mask;
-
- int _handle_width;
- int _bevel_width;
-
-public:
- virtual ~RenderStyle();
-
- inline int screen() const { return _screen; }
-
- inline const std::string& rootArgs() const { return _root_args; }
-
- inline RenderColor *textFocusColor() const { return _text_color_focus; }
- inline RenderColor *textUnfocusColor() const { return _text_color_unfocus; }
-
- inline RenderColor *buttonFocusColor() const { return _button_color_focus; }
- inline RenderColor *buttonUnfocusColor() const
- { return _button_color_unfocus; }
-
- inline RenderColor *frameBorderColor() const { return _frame_border_color; }
- inline int frameBorderWidth() const { return _frame_border_width; }
-
- inline RenderColor *clientBorderFocusColor() const
- { return _client_border_color_focus; }
- inline RenderColor *clientBorderUnfocusColor() const
- { return _client_border_color_unfocus; }
- inline int clientBorderWidth() const { return _client_border_width; }
-
- inline RenderTexture *titlebarFocusBackground() const
- { return _titlebar_focus; }
- inline RenderTexture *titlebarUnfocusBackground() const
- { return _titlebar_unfocus; }
-
- inline RenderTexture *labelFocusBackground() const { return _label_focus; }
- inline RenderTexture *labelUnfocusBackground() const { return _label_unfocus;}
-
- inline RenderTexture *handleFocusBackground() const { return _handle_focus; }
- inline RenderTexture *handleUnfocusBackground() const
- { return _handle_unfocus; }
-
- inline RenderTexture *buttonUnpressFocusBackground() const
- { return _button_unpress_focus; }
- inline RenderTexture *buttonUnpressUnfocusBackground() const
- { return _button_unpress_unfocus; }
- inline RenderTexture *buttonPressFocusBackground() const
- { return _button_press_focus; }
- inline RenderTexture *buttonPressUnfocusBackground() const
- { return _button_press_unfocus; }
-
- inline RenderTexture *gripFocusBackground() const { return _grip_focus; }
- inline RenderTexture *gripUnfocusBackground() const { return _grip_unfocus; }
-
- inline Font *labelFont() const { return _label_font; }
- inline Justify labelTextJustify() const { return _label_justify; }
-
- inline PixmapMask *maximizeMask() const { return _max_mask; }
- inline PixmapMask *iconifyMask() const { return _icon_mask; }
- inline PixmapMask *alldesktopsMask() const { return _alldesk_mask; }
- inline PixmapMask *closeMask() const { return _close_mask; }
-
- inline int handleWidth() const { return _handle_width; }
- inline int bevelWidth() const { return _bevel_width; }
-};
-
-}
-
-#endif // __renderstyle_hh
diff --git a/otk/rendertest.cc b/otk/rendertest.cc
deleted file mode 100644
index b3a03a03..00000000
--- a/otk/rendertest.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "config.h"
-
-#include "otk.hh"
-#include "rendercontrol.hh"
-#include "rendertexture.hh"
-
-extern "C" {
-#include <X11/Xlib.h>
-}
-
-#include <cstdio>
-
-int main(int argc, char **argv)
-{
- printf("\n");
-
- otk::Application app(argc, argv);
- otk::AppWidget foo(&app);
- foo.resize(600, 500);
-
- otk::RenderColor color(0, 0x96, 0xba, 0x86);
- otk::RenderColor color2(0, 0x5a, 0x72, 0x4c);
- otk::RenderColor colord(0, 0, 0, 0);
- otk::RenderColor colorl(0, 0xff, 0xff, 0xff);
- otk::RenderTexture tex(false,
- otk::RenderTexture::Raised,
- otk::RenderTexture::Bevel1,
- false,
- otk::RenderTexture::Vertical,
- false,
- &color,
- &color2,
- &colord,
- &colorl,
- 0,
- 0);
- foo.setTexture(&tex);
-
- foo.show();
-
- app.run();
-
- printf("\n");
- return 0;
-}
diff --git a/otk/rendertexture.hh b/otk/rendertexture.hh
deleted file mode 100644
index 54fbd9c2..00000000
--- a/otk/rendertexture.hh
+++ /dev/null
@@ -1,169 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __rendertexture_hh
-#define __rendertexture_hh
-
-#include "rendercolor.hh"
-
-namespace otk {
-
-//! Superclass for all the Textures
-class RenderTexture {
-public:
- enum ReliefType {
- Flat,
- Raised,
- Sunken
- };
- enum BevelType {
- Bevel1,
- Bevel2
- };
- enum GradientType {
- Solid,
- Horizontal,
- Vertical,
- Diagonal,
- CrossDiagonal,
- PipeCross,
- Rectangle,
- Pyramid,
- Elliptic
- };
-
-private:
- int _screen;
-
- //! If true, the texture is not rendered at all, so all options are ignored
- bool _parent_relative;
- //! The relief type of the texture
- ReliefType _relief;
- //! The way the bevel should be drawn
- BevelType _bevel;
- //! If a flat border is drawn on the outside, ignored for all ReliefType
- //! values except ReliefType::Flat
- bool _border;
- //! The type of gradient to fill the texture with (if any)
- GradientType _gradient;
- //! If interlace lines should be drawn over the texture
- bool _interlaced;
-
- //! The base color for the texture, the only color when the texture is solid.
- //! This must always be defined
- const RenderColor *_color;
- //! The secondary color for a gradient texture.
- //! This is only defined for gradients
- const RenderColor *_secondary_color;
- //! The shadow color for the bevel. This must be defined if
- //! RenderTexture::_relief is not RenderTexture::ReliefType::Flat
- const RenderColor *_bevel_dark_color;
- //! The light color for the bevel. This must be defined if
- //! RenderTexture::_relief is not RenderTexture::ReliefType::Flat
- const RenderColor *_bevel_light_color;
- //! The color for the flat border if RenderTexture::_border is true. This
- //! must be defined if it is true
- const RenderColor *_border_color;
- //! The color for the interlace lines if RenderTexture. This must be defined
- //! if it is true
- const RenderColor *_interlace_color;
-
-public:
- RenderTexture(int screen,
- bool parent_relative, ReliefType relief, BevelType bevel,
- bool border, GradientType gradient, bool interlaced,
- const RGB &color,
- const RGB &secondary_color,
- const RGB &border_color,
- const RGB &interlace_color)
- : _screen(screen),
- _parent_relative(parent_relative),
- _relief(relief),
- _bevel(bevel),
- _border(border),
- _gradient(gradient),
- _interlaced(interlaced),
- _color(new RenderColor(screen, color)),
- _secondary_color(new RenderColor(screen, secondary_color)),
- _bevel_dark_color(0),
- _bevel_light_color(0),
- _border_color(new RenderColor(screen, border_color)),
- _interlace_color(new RenderColor(screen, interlace_color))
- {
- if (_relief != Flat) {
- unsigned char r, g, b;
-
- // calculate the light bevel color
- r = _color->red() + _color->red() / 2;
- g = _color->green() + _color->green() / 2;
- b = _color->blue() + _color->blue() / 2;
- // watch for wraparound
- if (r < _color->red()) r = 0xff;
- if (g < _color->green()) g = 0xff;
- if (b < _color->blue()) b = 0xff;
- _bevel_dark_color = new RenderColor(screen, r, g, b);
-
- // calculate the dark bevel color
- r = _color->red() / 4 + _color->red() / 2;
- g = _color->green() / 4 + _color->green() / 2;
- b = _color->blue() / 4 + _color->blue() / 2;
- _bevel_light_color = new RenderColor(screen, r, g, b);
- }
-
- assert(_relief == Flat || (_bevel_dark_color && _bevel_light_color));
- //assert(!_border || _border_color);
- //assert(!_interlaced || _interlace_color);
- assert(_color);
- assert(_secondary_color);
- assert(_border_color);
- assert(_interlace_color);
- }
-
- virtual ~RenderTexture() {
- delete _color;
- delete _secondary_color;
- if (_bevel_dark_color) delete _bevel_dark_color;
- if (_bevel_dark_color) delete _bevel_light_color;
- delete _border_color;
- delete _interlace_color;
- }
-
- //! If true, the texture is not rendered at all, so all options are ignored
- inline bool parentRelative() const { return _parent_relative; }
- //! The relief type of the texture
- inline ReliefType relief() const { return _relief; }
- //! The way the bevel should be drawn
- inline BevelType bevel() const { return _bevel; }
- //! If a flat border is drawn on the outside, ignored for all ReliefType
- //! values except ReliefType::Flat
- inline bool border() const { return _border; }
- //! The type of gradient to fill the texture with (if any)
- inline GradientType gradient() const { return _gradient; }
- //! If interlace lines should be drawn over the texture
- inline bool interlaced() const { return _interlaced; }
-
- //! The base color for the texture, the only color when the texture is solid.
- //! This must always be defined
- inline const RenderColor& color() const { return *_color; }
- //! The secondary color for gradient textures.
- //! This is only defined for gradients
- inline const RenderColor& secondary_color() const
- { return *_secondary_color; }
- //! The shadow color for the bevel. This must be defined if
- //! RenderTexture::_relief is not RenderTexture::ReliefType::Flat
- inline const RenderColor& bevelDarkColor() const
- { return *_bevel_dark_color; }
- //! The light color for the bevel. This must be defined if
- //! RenderTexture::)relief is not RenderTexture::ReliefType::Flat
- inline const RenderColor& bevelLightColor() const
- { return *_bevel_light_color; }
- //! The color for the flat border if RenderTexture::_border is true. This
- //! must be defined if it is true
- inline const RenderColor& borderColor() const { return *_border_color; }
- //! The color for the interlace lines if RenderTexture. This must be defined
- //! if it is true
- inline const RenderColor& interlaceColor() const
- { return *_interlace_color; }
-};
-
-}
-
-#endif // __rendertexture_hh
diff --git a/otk/screeninfo.cc b/otk/screeninfo.cc
deleted file mode 100644
index 368ae982..00000000
--- a/otk/screeninfo.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-extern "C" {
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-}
-
-#include "screeninfo.hh"
-#include "display.hh"
-#include "util.hh"
-
-using std::string;
-
-namespace otk {
-
-ScreenInfo::ScreenInfo(int num) {
- assert(num >= 0 && num < ScreenCount(**display));
-
- _screen = num;
-
- _root_window = RootWindow(**display, _screen);
-
- _size = Size(WidthOfScreen(ScreenOfDisplay(**display,
- _screen)),
- HeightOfScreen(ScreenOfDisplay(**display,
- _screen)));
- // get the default display string and strip the screen number
- string default_string = DisplayString(**display);
- const string::size_type pos = default_string.rfind(".");
- if (pos != string::npos)
- default_string.resize(pos);
-
- _display_string = string("DISPLAY=") + default_string + '.' +
- itostring(static_cast<unsigned long>(_screen));
-
-#if 0 //def XINERAMA
- _xinerama_active = False;
-
- if (d->hasXineramaExtensions()) {
- if (d->getXineramaMajorVersion() == 1) {
- // we know the version 1(.1?) protocol
-
- /*
- in this version of Xinerama, we can't query on a per-screen basis, but
- in future versions we should be able, so the 'activeness' is checked
- on a pre-screen basis anyways.
- */
- if (XineramaIsActive(**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
- is why no screen number is used in this function call. There should
- never be more than one screen present with Xinerama active.
- */
- int num;
- XineramaScreenInfo *info = XineramaQueryScreens(**display, &num);
- if (num > 0 && info) {
- _xinerama_areas.reserve(num);
- for (int i = 0; i < num; ++i) {
- _xinerama_areas.push_back(Rect(info[i].x_org, info[i].y_org,
- info[i].width, info[i].height));
- }
- XFree(info);
-
- // if we can't find any xinerama regions, then we act as if it is not
- // active, even though it said it was
- _xinerama_active = true;
- }
- }
- }
- }
-#else
- _xinerama_active = false;
-#endif // XINERAMA
- if (!_xinerama_active)
- _xinerama_areas.push_back(Rect(Point(0, 0), _size));
-}
-
-}
diff --git a/otk/screeninfo.hh b/otk/screeninfo.hh
deleted file mode 100644
index 93e835fa..00000000
--- a/otk/screeninfo.hh
+++ /dev/null
@@ -1,42 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __screeninfo_hh
-#define __screeninfo_hh
-
-#include "size.hh"
-#include "rect.hh"
-
-extern "C" {
-#include <X11/Xlib.h>
-}
-
-#include <string>
-#include <vector>
-
-namespace otk {
-
-class ScreenInfo {
-private:
- int _screen;
- std::string _display_string;
- Size _size;
- std::vector<Rect> _xinerama_areas;
- bool _xinerama_active;
-
-public:
- ScreenInfo(int num);
-
- inline Visual *visual() const { return _visual; }
- inline Window rootWindow() const { return _root_window; }
- inline Colormap colormap() const { return _colormap; }
- inline int depth() const { return _depth; }
- inline int screen() const { return _screen; }
- inline const Size& size() const { return _size; }
- inline const std::string& displayString() const { return _display_string; }
- inline const std::vector<Rect> &xineramaAreas() const
- { return _xinerama_areas; }
- inline bool isXineramaActive() const { return _xinerama_active; }
-};
-
-}
-
-#endif // __screeninfo_hh
diff --git a/otk/size.hh b/otk/size.hh
deleted file mode 100644
index 57447d5d..00000000
--- a/otk/size.hh
+++ /dev/null
@@ -1,25 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __size_hh
-#define __size_hh
-
-#include <cassert>
-
-namespace otk {
-
-class Size {
- int _w, _h;
-public:
- Size() : _w(1), _h(1) {}
- Size(int w, int h) : _w(w), _h(h) { assert(_w >= 0 && _h >= 0); }
- Size(const Size &s) : _w(s._w), _h(s._h) { assert(_w >= 0 && _h >= 0); }
-
- inline int width() const { return _w; }
- inline int height() const { return _h; }
-
- bool operator==(const Size &o) const { return _w == o._w && _h == o._h; }
- bool operator!=(const Size &o) const { return _w != o._w || _h != o._h; }
-};
-
-}
-
-#endif // __size_hh
diff --git a/otk/strut.hh b/otk/strut.hh
deleted file mode 100644
index 71553da2..00000000
--- a/otk/strut.hh
+++ /dev/null
@@ -1,35 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __strut_hh
-#define __strut_hh
-
-/*! @file strut.hh
- @brief The Strut struct defines a margin on 4 sides
-*/
-
-namespace otk {
-
-//! Defines a margin on 4 sides
-struct Strut {
- //! The margin on the top of the Strut
- unsigned int top;
- //! The margin on the bottom of the Strut
- unsigned int bottom;
- //! The margin on the left of the Strut
- unsigned int left;
- //! The margin on the right of the Strut
- unsigned int right;
-
- //! Constructs a new Strut with no margins
- Strut(void): top(0), bottom(0), left(0), right(0) {}
- //! Constructs a new Strut with margins
- Strut(int l, int t, int r, int b): top(t), bottom(b), left(l), right(r) {}
-
- bool operator==(const Strut &o) const {
- return top == o.top && bottom == o.bottom && left == o.left &&
- right == o.right;
- }
-};
-
-}
-
-#endif // __strut_hh
diff --git a/otk/surface.cc b/otk/surface.cc
deleted file mode 100644
index cc225503..00000000
--- a/otk/surface.cc
+++ /dev/null
@@ -1,97 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "surface.hh"
-#include "display.hh"
-#include "screeninfo.hh"
-#include "rendercolor.hh"
-
-extern "C" {
-#include <X11/Xutil.h>
-#include <cstring>
-}
-
-namespace otk {
-
-Surface::Surface(int screen, const Size &size)
- : _screen(screen),
- _size(size),
- _pixel_data(new pixel32[size.width()*size.height()]),
- _pixmap(None),
- _xftdraw(0)
-{
-}
-
-Surface::~Surface()
-{
- destroyObjects();
- freePixelData();
-}
-
-void Surface::freePixelData()
-{
- if (_pixel_data) {
- delete [] _pixel_data;
- _pixel_data = 0;
- }
-}
-
-void Surface::setPixmap(const RenderColor &color)
-{
- assert(_pixel_data);
- if (_pixmap == None)
- createObjects();
-
- XFillRectangle(**display, _pixmap, color.gc(), 0, 0,
- _size.width(), _size.height());
-
- pixel32 val = (color.red() << default_red_shift) |
- (color.green() << default_green_shift) |
- (color.blue() << default_blue_shift);
- for (unsigned int i = 0, s = _size.width() * _size.height(); i < s; ++i)
- _pixel_data[i] = val;
-}
-
-void Surface::setPixmap(XImage *image)
-{
- assert(_pixel_data);
- assert(image->width == _size.width());
- assert(image->height == _size.height());
-
- if (_pixmap == None)
- createObjects();
-
- XPutImage(**display, _pixmap, DefaultGC(**display, _screen),
- image, 0, 0, 0, 0, _size.width(), _size.height());
-}
-
-void Surface::createObjects()
-{
- assert(_pixmap == None); assert(!_xftdraw);
-
- const ScreenInfo *info = display->screenInfo(_screen);
-
- _pixmap = XCreatePixmap(**display, info->rootWindow(),
- _size.width(), _size.height(), info->depth());
- assert(_pixmap != None);
-
- _xftdraw = XftDrawCreate(**display, _pixmap,
- info->visual(), info->colormap());
- assert(_xftdraw);
-}
-
-void Surface::destroyObjects()
-{
- if (_xftdraw) {
- XftDrawDestroy(_xftdraw);
- _xftdraw = 0;
- }
-
- if (_pixmap != None) {
- XFreePixmap(**display, _pixmap);
- _pixmap = None;
- }
-}
-
-}
diff --git a/otk/surface.hh b/otk/surface.hh
deleted file mode 100644
index a44b9049..00000000
--- a/otk/surface.hh
+++ /dev/null
@@ -1,88 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __surface_hh
-#define __surface_hh
-
-#include "size.hh"
-
-extern "C" {
-#include <X11/Xlib.h>
-#define _XFT_NO_COMPAT_ // no Xft 1 API
-#include <X11/Xft/Xft.h>
-
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#else
-# ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-# endif
-#endif
-}
-
-namespace otk {
-
-class ScreenInfo;
-class RenderColor;
-class RenderControl;
-class TrueRenderControl;
-class PseudoRenderControl;
-
-#ifdef HAVE_STDINT_H
-typedef uint32_t pixel32;
-typedef uint16_t pixel16;
-#else
-typedef u_int32_t pixel32;
-typedef u_int16_t pixel16;
-#endif /* HAVE_STDINT_H */
-
-#ifdef WORDS_BIGENDIAN
-const int default_red_shift=0;
-const int default_green_shift=8;
-const int default_blue_shift=16;
-const int endian=MSBFirst;
-#else
-const int default_red_shift=16;
-const int default_green_shift=8;
-const int default_blue_shift=0;
-const int endian=LSBFirst;
-#endif /* WORDS_BIGENDIAN */
-
-class Surface {
- int _screen;
- Size _size;
- pixel32 *_pixel_data;
- Pixmap _pixmap;
- XftDraw *_xftdraw;
-
-protected:
- void createObjects();
- void destroyObjects();
-
- void setPixmap(XImage *image);
- void setPixmap(const RenderColor &color);
-
-public:
- Surface(int screen, const Size &size);
- virtual ~Surface();
-
- inline int screen(void) const { return _screen; }
-
- const Size& size() const { return _size; }
-
- Pixmap pixmap() const { return _pixmap; }
-
- pixel32 *pixelData() { return _pixel_data; }
-
- //! Frees the pixel data when it will no longer be needed. Only do this once
- //! you have completed rendering onto the surface.
- void freePixelData();
-
- // The RenderControl classes use the internal objects in this class to render
- // to it. Noone else needs them tho, so they are private.
- friend class RenderControl;
- friend class TrueRenderControl;
- friend class PseudoRenderControl;
-};
-
-}
-
-#endif // __surface_hh
diff --git a/otk/timer.cc b/otk/timer.cc
deleted file mode 100644
index 0a008314..00000000
--- a/otk/timer.cc
+++ /dev/null
@@ -1,145 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "timer.hh"
-#include "display.hh"
-
-extern "C" {
-#ifdef HAVE_SYS_SELECT_H
-# include <sys/select.h>
-#endif // HAVE_SYS_SELECT_H
-
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-}
-
-namespace otk {
-
-timeval Timer::_nearest_timeout, Timer::_now;
-Timer::TimerQ Timer::_q;
-
-void Timer::timevalAdd(timeval &a, long msec)
-{
- a.tv_sec += msec / 1000;
- a.tv_usec += (msec % 1000) * 1000;
- a.tv_sec += a.tv_usec / 1000000;
- a.tv_usec %= 1000000;
-}
-
-bool Timer::nearestTimeout(struct timeval &tm)
-{
- if (_q.empty())
- return false;
- tm.tv_sec = _nearest_timeout.tv_sec - _now.tv_sec;
- tm.tv_usec = _nearest_timeout.tv_usec - _now.tv_usec;
-
- while (tm.tv_usec < 0) {
- tm.tv_usec += 1000000;
- tm.tv_sec--;
- }
- tm.tv_sec += tm.tv_usec / 1000000;
- tm.tv_usec %= 1000000;
- if (tm.tv_sec < 0)
- tm.tv_sec = 0;
-
- return true;
-}
-
-void Timer::dispatchTimers(bool wait)
-{
- fd_set selset;
- int fd;
- timeval next;
- Timer *curr;
-
- gettimeofday(&_now, NULL);
- _nearest_timeout = _now;
- _nearest_timeout.tv_sec += 10000;
-
- while (!_q.empty()) {
- curr = _q.top();
- /* since we overload the destructor to keep from removing from the middle
- of the priority queue, set _del_me, we have to do our real delete in
- here.
- */
- if (curr->_del_me) {
- _q.pop();
- realDelete(curr);
- continue;
- }
-
- // the queue is sorted, so if this timer shouldn't fire, none are ready
- _nearest_timeout = curr->_timeout;
- if (!timercmp(&_now, &_nearest_timeout, >))
- break;
-
- /* we set the last fired time to delay msec after the previous firing, then
- re-insert. timers maintain their order and may trigger more than once
- if they've waited more than one delay's worth of time.
- */
- _q.pop();
- timevalAdd(curr->_last, curr->_delay);
- curr->_action(curr->_data);
- timevalAdd(curr->_timeout, curr->_delay);
- _q.push(curr);
-
- /* if at least one timer fires, then don't wait on X events, as there may
- already be some in the queue from the timer callbacks.
- */
- wait = false;
- }
-
- if (wait) {
- // wait for the nearest trigger, or for X to do something interesting
- fd = ConnectionNumber(**display);
- FD_ZERO(&selset);
- FD_SET(fd, &selset);
- if (nearestTimeout(next)) {
- select(fd + 1, &selset, NULL, NULL, &next);
- } else
- select(fd + 1, &selset, NULL, NULL, NULL);
- }
-}
-
-Timer::Timer(long delay, Timer::TimeoutHandler action, void *data)
- : _delay(delay),
- _action(action),
- _data(data),
- _del_me(false),
- _last(_now),
- _timeout(_now)
-{
- timevalAdd(_timeout, delay);
- _q.push(this);
-}
-
-void Timer::operator delete(void *self)
-{
- Timer *t;
- t = (Timer *)self;
- t->_del_me = true;
-}
-
-void Timer::realDelete(Timer *me)
-{
- ::delete me;
-}
-
-void Timer::initialize(void)
-{
- gettimeofday(&_now, NULL);
- _nearest_timeout.tv_sec = 100000;
- _nearest_timeout.tv_usec = 0;
-}
-
-void Timer::destroy(void)
-{
- while(!_q.empty()) {
- realDelete(_q.top());
- _q.pop();
- }
-}
-
-}
diff --git a/otk/timer.hh b/otk/timer.hh
deleted file mode 100644
index dc2917f1..00000000
--- a/otk/timer.hh
+++ /dev/null
@@ -1,114 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __timer_hh
-#define __timer_hh
-
-/*! @file timer.hh
- @brief Contains the Timer class, used for timed callbacks.
-*/
-
-extern "C" {
-#include <ctime>
-}
-
-#include <queue>
-#include <vector>
-
-namespace otk {
-
-//! The Timer class implements timed callbacks.
-/*!
- The Timer class can be used to have a callback fire after a given time
- interval. A created Timer will fire repetitively until it is destroyed.
-*/
-class Timer {
-public:
- //! Data type of Timer callback
- typedef void (*TimeoutHandler)(void *data);
-
-private:
- //! Compares two timeval structs
- struct TimerCompare {
- //! Compares two timeval structs
- inline bool operator()(const Timer *a, const Timer *b) const {
- return ((&a->_timeout)->tv_sec == (&b->_timeout)->tv_sec) ?
- ((&a->_timeout)->tv_usec > (&b->_timeout)->tv_usec) :
- ((&a->_timeout)->tv_sec > (&b->_timeout)->tv_sec);
- }
- };
- friend struct TimerCompare; // give access to _timeout for shitty compilers
-
- typedef
- std::priority_queue<Timer*, std::vector<Timer*>, TimerCompare> TimerQ;
-
- //! Milliseconds between timer firings
- long _delay;
- //! Callback for timer expiry
- TimeoutHandler _action;
- //! Data sent to callback
- void *_data;
- //! We overload the delete operator to just set this to true
- bool _del_me;
- //! The time the last fire should've been at
- struct timeval _last;
- //! When this timer will next trigger
- struct timeval _timeout;
-
- //! Queue of pending timers
- static TimerQ _q;
- //! Time next timer will expire
- static timeval _nearest_timeout;
- //! Time at start of current processing loop
- static timeval _now;
-
- //! Really delete something (not just flag for later)
- /*!
- @param self Timer to be deleted.
- */
- static void realDelete(Timer *self);
-
- //! Adds a millisecond delay to a timeval structure
- /*!
- @param a Amount of time to increment.
- @param msec Number of milliseconds to increment by.
- */
- static void timevalAdd(timeval &a, long msec);
-
-public:
- //! Constructs a new running timer and queues it
- /*!
- @param delay Time in milliseconds between firings
- @param cb The function to be called on fire.
- @param data Data to be passed to the callback on fire.
- */
- Timer(long delay, TimeoutHandler cb, void *data);
-
- //! Overloaded delete so we can leave deleted objects in queue for later reap
- /*!
- @param self Pointer to current instance of Timer.
- */
- void operator delete(void *self);
-
- //! Dispatches all elligible timers, then optionally waits for X events
- /*!
- @param wait Whether to wait for X events after processing timers.
- */
- static void dispatchTimers(bool wait = true);
-
- //! Returns a relative timeval (to pass select) of the next timer
- /*!
- @param tm Changed to hold the time until next timer.
- @return true if there are any timers queued, and the timeout is being
- returned in 'tm'. false if there are no timers queued.
- */
- static bool nearestTimeout(struct timeval &tm);
-
- //! Initializes internal data before use
- static void initialize();
-
- //! Deletes all waiting timers
- static void destroy();
-};
-
-}
-
-#endif // __timer.hh
diff --git a/otk/truerendercontrol.cc b/otk/truerendercontrol.cc
deleted file mode 100644
index 42589dd3..00000000
--- a/otk/truerendercontrol.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "truerendercontrol.hh"
-#include "display.hh"
-#include "screeninfo.hh"
-#include "surface.hh"
-#include "rendertexture.hh"
-
-extern "C" {
-#include "../src/gettext.h"
-#define _(str) gettext(str)
-}
-
-#include <cstdlib>
-
-namespace otk {
-
-TrueRenderControl::TrueRenderControl(int screen)
- : RenderControl(screen),
- _red_offset(0),
- _green_offset(0),
- _blue_offset(0)
-{
- printf("Initializing TrueColor RenderControl\n");
-
- const ScreenInfo *info = display->screenInfo(_screen);
- XImage *timage = XCreateImage(**display, info->visual(), info->depth(),
- ZPixmap, 0, NULL, 1, 1, 32, 0);
-
- unsigned long red_mask, green_mask, blue_mask;
-
- // find the offsets for each color in the visual's masks
- red_mask = timage->red_mask;
- green_mask = timage->green_mask;
- blue_mask = timage->blue_mask;
-
- while (! (red_mask & 1)) { _red_offset++; red_mask >>= 1; }
- while (! (green_mask & 1)) { _green_offset++; green_mask >>= 1; }
- while (! (blue_mask & 1)) { _blue_offset++; blue_mask >>= 1; }
-
- _red_shift = _green_shift = _blue_shift = 8;
- while (red_mask) { red_mask >>= 1; _red_shift--; }
- while (green_mask) { green_mask >>= 1; _green_shift--; }
- while (blue_mask) { blue_mask >>= 1; _blue_shift--; }
- XFree(timage);
-}
-
-TrueRenderControl::~TrueRenderControl()
-{
- printf("Destroying TrueColor RenderControl\n");
-}
-
-void TrueRenderControl::reduceDepth(Surface &sf, XImage *im) const
-{
- // since pixel32 is the largest possible pixel size, we can share the array
- int r, g, b;
- int x,y;
- pixel32 *data = sf.pixelData();
- pixel32 *ret = (pixel32*)malloc(im->width * im->height * 4);
- pixel16 *p = (pixel16*) ret;
- switch (im->bits_per_pixel) {
- case 32:
- if ((_red_offset != default_red_shift) ||
- (_blue_offset != default_blue_shift) ||
- (_green_offset != default_green_shift)) {
- printf("cross endian conversion\n");
- for (y = 0; y < im->height; y++) {
- for (x = 0; x < im->width; x++) {
- r = (data[x] >> default_red_shift) & 0xFF;
- g = (data[x] >> default_green_shift) & 0xFF;
- b = (data[x] >> default_blue_shift) & 0xFF;
- ret[x] = (r << _red_offset) + (g << _green_offset) +
- (b << _blue_offset);
- }
- data += im->width;
- }
- } else {
- memcpy(ret, data, im->width * im->height * 4);
- }
- break;
- case 16:
- for (y = 0; y < im->height; y++) {
- for (x = 0; x < im->width; x++) {
- r = (data[x] >> default_red_shift) & 0xFF;
- r = r >> _red_shift;
- g = (data[x] >> default_green_shift) & 0xFF;
- g = g >> _green_shift;
- b = (data[x] >> default_blue_shift) & 0xFF;
- b = b >> _blue_shift;
- p[x] = (r << _red_offset) + (g << _green_offset) + (b << _blue_offset);
- }
- data += im->width;
- p += im->bytes_per_line/2;
- }
- break;
- default:
- printf("your bit depth is currently unhandled\n");
- }
- im->data = (char*)ret;
-}
-
-void TrueRenderControl::allocateColor(XColor *color) const
-{
- const ScreenInfo *info = display->screenInfo(_screen);
- if (!XAllocColor(**display, info->colormap(), color)) {
- fprintf(stderr, "TrueRenderControl: color alloc error: rgb:%x/%x/%x\n",
- color->red & 0xff, color->green & 0xff, color->blue & 0xff);
- color->pixel = 0;
- }
-}
-
-}
diff --git a/otk/truerendercontrol.hh b/otk/truerendercontrol.hh
deleted file mode 100644
index 36dbe244..00000000
--- a/otk/truerendercontrol.hh
+++ /dev/null
@@ -1,35 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __truerendercontrol_hh
-#define __truerendercontrol_hh
-
-#include "rendercontrol.hh"
-
-#include <vector>
-
-namespace otk {
-
-class TrueRenderControl : public RenderControl {
-private:
- // the number of bits to shift a color value (from 0-255) to the right, to
- // fit it into the the color mask (do this before the offset)
- int _red_shift;
- int _green_shift;
- int _blue_shift;
-
- // the offset of each color in a color mask
- int _red_offset;
- int _green_offset;
- int _blue_offset;
-
- virtual void reduceDepth(Surface &sf, XImage *im) const;
-
-public:
- TrueRenderControl(int screen);
- virtual ~TrueRenderControl();
-
- virtual void allocateColor(XColor *color) const;
-};
-
-}
-
-#endif // __truerendercontrol_hh
diff --git a/otk/ustring.cc b/otk/ustring.cc
deleted file mode 100644
index 8ffe07fe..00000000
--- a/otk/ustring.cc
+++ /dev/null
@@ -1,263 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-#include "ustring.hh"
-
-#include <cassert>
-
-namespace otk {
-
-// helper functions
-
-// The number of bytes to skip to find the next character in the string
-static const char utf8_skip[256] = {
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
-};
-
-// takes a pointer into a utf8 string and returns a unicode character for the
-// first character at the pointer
-unichar utf8_get_char (const char *p)
-{
- unichar result = static_cast<unsigned char>(*p);
-
- // if its not a 7-bit ascii character
- if((result & 0x80) != 0) {
- // len is the number of bytes this character takes up in the string
- unsigned char len = utf8_skip[result];
- result &= 0x7F >> len;
-
- while(--len != 0) {
- result <<= 6;
- result |= static_cast<unsigned char>(*++p) & 0x3F;
- }
- }
-
- return result;
-}
-
-// takes a pointer into a string and finds its offset
-static ustring::size_type utf8_ptr_to_offset(const char *str, const char *pos)
-{
- ustring::size_type offset = 0;
-
- while (str < pos) {
- str += utf8_skip[static_cast<unsigned char>(*str)];
- offset++;
- }
-
- return offset;
-}
-
-// takes an offset into a string and returns a pointer to it
-const char *utf8_offset_to_ptr(const char *str, ustring::size_type offset)
-{
- while (offset--)
- str += utf8_skip[static_cast<unsigned char>(*str)];
- return str;
-}
-
-// First overload: stop on '\0' character.
-ustring::size_type utf8_byte_offset(const char* str, ustring::size_type offset)
-{
- if(offset == ustring::npos)
- return ustring::npos;
-
- const char* p = str;
-
- for(; offset != 0; --offset)
- {
- if(*p == '\0')
- return ustring::npos;
-
- p += utf8_skip[static_cast<unsigned char>(*p)];
- }
-
- return (p - str);
-}
-
-// Second overload: stop when reaching maxlen.
-ustring::size_type utf8_byte_offset(const char* str, ustring::size_type offset,
- ustring::size_type maxlen)
-{
- if(offset == ustring::npos)
- return ustring::npos;
-
- const char *const pend = str + maxlen;
- const char* p = str;
-
- for(; offset != 0; --offset)
- {
- if(p >= pend)
- return ustring::npos;
-
- p += utf8_skip[static_cast<unsigned char>(*p)];
- }
-
- return (p - str);
-}
-
-
-// ustring methods
-
-ustring::ustring(bool utf8)
- : _utf8(utf8)
-{
-}
-
-ustring::~ustring()
-{
-}
-
-ustring::ustring(const ustring& other)
- : _string(other._string), _utf8(other._utf8)
-{
-}
-
-ustring& ustring::operator=(const ustring& other)
-{
- _string = other._string;
- _utf8 = other._utf8;
- return *this;
-}
-
-ustring::ustring(const std::string& src, bool utf8)
- : _string(src), _utf8(utf8)
-{
-}
-
-ustring::ustring(const char* src, bool utf8)
- : _string(src), _utf8(utf8)
-{
-}
-
-ustring& ustring::operator+=(const ustring& src)
-{
- assert(_utf8 == src._utf8);
- _string += src._string;
- return *this;
-}
-
-ustring& ustring::operator+=(const char* src)
-{
- _string += src;
- return *this;
-}
-
-ustring& ustring::operator+=(char c)
-{
- _string += c;
- return *this;
-}
-
-ustring::size_type ustring::size() const
-{
- if (_utf8) {
- const char *const pdata = _string.data();
- return utf8_ptr_to_offset(pdata, pdata + _string.size());
- } else
- return _string.size();
-}
-
-ustring::size_type ustring::bytes() const
-{
- return _string.size();
-}
-
-ustring::size_type ustring::capacity() const
-{
- return _string.capacity();
-}
-
-ustring::size_type ustring::max_size() const
-{
- return _string.max_size();
-}
-
-bool ustring::empty() const
-{
- return _string.empty();
-}
-
-void ustring::clear()
-{
- _string.erase();
-}
-
-ustring& ustring::erase(ustring::size_type i, ustring::size_type n)
-{
- if (_utf8) {
- // find a proper offset
- size_type utf_i = utf8_byte_offset(_string.c_str(), i);
- if (utf_i != npos) {
- // if the offset is not npos, find a proper length for 'n'
- size_type utf_n = utf8_byte_offset(_string.data() + utf_i, n,
- _string.size() - utf_i);
- _string.erase(utf_i, utf_n);
- }
- } else
- _string.erase(i, n);
-
- return *this;
-}
-
-void ustring::resize(ustring::size_type n, char c)
-{
- if (_utf8) {
- const size_type size_now = size();
- if(n < size_now)
- erase(n, npos);
- else if(n > size_now)
- _string.append(n - size_now, c);
- } else
- _string.resize(n, c);
-}
-
-ustring::value_type ustring::operator[](ustring::size_type i) const
-{
- return utf8_get_char(utf8_offset_to_ptr(_string.data(), i));
-}
-
-bool ustring::operator==(const ustring &other) const
-{
- return _string == other._string && _utf8 == other._utf8;
-}
-
-bool ustring::operator==(const std::string &other) const
-{
- return _string == other;
-}
-
-bool ustring::operator==(const char *other) const
-{
- return _string == other;
-}
-
-const char* ustring::data() const
-{
- return _string.data();
-}
-
-const char* ustring::c_str() const
-{
- return _string.c_str();
-}
-
-bool ustring::utf8() const
-{
- return _utf8;
-}
-
-void ustring::setUtf8(bool utf8)
-{
- _utf8 = utf8;
-}
-
-}
diff --git a/otk/ustring.hh b/otk/ustring.hh
deleted file mode 100644
index 0031e1c5..00000000
--- a/otk/ustring.hh
+++ /dev/null
@@ -1,177 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __ustring_hh
-#define __ustring_hh
-
-/*! @file ustring.hh
- @brief Provides a simple UTF-8 encoded string
-*/
-
-extern "C" {
-
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#else
-# ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-# endif
-#endif
-
-}
-
-#include <string>
-
-namespace otk {
-
-
-#ifdef HAVE_STDINT_H
-typedef uint32_t unichar;
-#else
-typedef u_int32_t unichar;
-#endif
-
-
-#ifndef DOXYGEN_IGNORE
-
-unichar utf8_get_char(const char *p);
-
-#endif // DOXYGEN_IGNORE
-
-//! The iterator type for ustring
-/*!
- Note this is not a random access iterator but a bidirectional one, since all
- index operations need to iterate over the UTF-8 data. Use std::advance() to
- move to a certain position.
- <p>
- A writeable iterator isn't provided because: The number of bytes of the old
- UTF-8 character and the new one to write could be different. Therefore, any
- write operation would invalidate all other iterators pointing into the same
- string.
-*/
-
-template <class T>
-class ustring_Iterator
-{
-public:
- typedef std::bidirectional_iterator_tag iterator_category;
- typedef unichar value_type;
- typedef std::string::difference_type difference_type;
- //typedef value_type reference;
- typedef void pointer;
-
- inline ustring_Iterator() {}
- inline ustring_Iterator(const ustring_Iterator<std::string::iterator>&
- other) : _pos(other.base()) {}
-
-
- inline value_type operator*() const {
- // get an iterator to the internal string
- std::string::const_iterator pos = _pos;
- return utf8_get_char(&(*pos));
- }
-
-
- inline ustring_Iterator<T> & operator++() {
- pos_ += g_utf8_skip[static_cast<unsigned char>(*pos_)];
- return *this;
- }
- inline ustring_Iterator<T> & operator--() {
- do { --_pos; } while((*_pos & '\xC0') == '\x80');
- return *this;
- }
-
- explicit inline ustring_Iterator(T pos) : _pos(pos) {}
- inline T base() const { return _pos; }
-
-private:
- T _pos;
-};
-
-
-//! This class provides a simple wrapper to a std::string that can be encoded
-//! as UTF-8. The ustring::utf() member specifies if the given string is UTF-8
-//! encoded. ustrings default to specifying UTF-8 encoding.
-/*!
- This class does <b>not</b> handle extended 8-bit ASCII charsets like
- ISO-8859-1.
- <p>
- More info on Unicode and UTF-8 can be found here:
- http://www.cl.cam.ac.uk/~mgk25/unicode.html
- <p>
- This does not subclass std::string, because std::string was intended to be a
- final class. For instance, it does not have a virtual destructor.
-*/
-class ustring {
- std::string _string;
- bool _utf8;
-
-public:
- typedef std::string::size_type size_type;
- typedef std::string::difference_type difference_type;
-
- typedef unichar value_type;
- //typedef unichar & reference;
- //typedef const unichar & const_reference;
-
- //typedef ustring_Iterator<std::string::iterator> iterator;
- //typedef ustring_Iterator<std::string::const_iterator> const_iterator;
-
- static const size_type npos = std::string::npos;
-
- ustring(bool utf8 = true);
- ~ustring();
-
- // make new strings
-
- ustring(const ustring& other);
- ustring& operator=(const ustring& other);
- ustring(const std::string& src, bool utf8 = true);
- ustring(const char* src, bool utf8 = true);
-
- // append to the string
-
- ustring& operator+=(const ustring& src);
- ustring& operator+=(const char* src);
- ustring& operator+=(char c);
-
- // sizes
-
- ustring::size_type size() const;
- ustring::size_type bytes() const;
- ustring::size_type capacity() const;
- ustring::size_type max_size() const;
- bool empty() const;
-
- // erase substrings
-
- void clear();
- ustring& erase(size_type i, size_type n=npos);
-
- // change the string's size
-
- void resize(size_type n, char c='\0');
-
- // extract characters
-
- // No reference return; use replace() to write characters.
- value_type operator[](size_type i) const;
-
- // compare strings
-
- bool operator==(const ustring &other) const;
- bool operator==(const std::string &other) const;
- bool operator==(const char *other) const;
-
- // internal data
-
- const char* data() const;
- const char* c_str() const;
-
- // encoding
-
- bool utf8() const;
- void setUtf8(bool utf8);
-};
-
-}
-
-#endif // __ustring_hh
diff --git a/otk/util.cc b/otk/util.cc
deleted file mode 100644
index 03df393e..00000000
--- a/otk/util.cc
+++ /dev/null
@@ -1,97 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-
-extern "C" {
-#include <X11/Xatom.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif // HAVE_UNISTD_H
-
-// this is not checked in configure anymore!!
-//#if defined(HAVE_PROCESS_H) && defined(__EMX__)
-//# include <process.h>
-//#endif // HAVE_PROCESS_H __EMX__
-
-#include "../src/gettext.h"
-#define _(str) gettext(str)
-
-}
-
-#include <algorithm>
-#include <cassert>
-#include <cstdio>
-#include <cstring>
-#include <cstdlib>
-
-#include "util.hh"
-
-using std::string;
-
-namespace otk {
-
-string expandTilde(const string& s) {
- if (s[0] != '~') return s;
-
- const char* const home = getenv("HOME");
- if (home == NULL) return s;
-
- return string(home + s.substr(s.find('/')));
-}
-
-
-void bexec(const string& command, const string& displaystring) {
-//#ifndef __EMX__
- if (! fork()) {
- setsid();
- putenv(displaystring);
- int ret = execl("/bin/sh", "/bin/sh", "-c", command.c_str(), NULL);
- exit(ret);
- }
-//#else // __EMX__
-// spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", command.c_str(), NULL);
-//#endif // !__EMX__
-}
-
-
-string itostring(unsigned long i) {
- if (i == 0)
- return string("0");
-
- string tmp;
- for (; i > 0; i /= 10)
- tmp.insert(tmp.begin(), "0123456789"[i%10]);
- return tmp;
-}
-
-
-string itostring(long i) {
- std::string tmp = itostring( (unsigned long) std::abs(i));
- if (i < 0)
- tmp.insert(tmp.begin(), '-');
- return tmp;
-}
-
-void putenv(const std::string &data)
-{
- char *c = new char[data.size() + 1];
- std::string::size_type i, max;
- for (i = 0, max = data.size(); i < max; ++i)
- c[i] = data[i];
- c[i] = 0;
- if (::putenv(c)) {
- printf(_("warning: couldn't set environment variable\n"));
- perror("putenv()");
- }
-}
-
-string basename (const string& path) {
- string::size_type slash = path.rfind('/');
- if (slash == string::npos)
- return path;
- return path.substr(slash+1);
-}
-
-}
-
diff --git a/otk/util.hh b/otk/util.hh
deleted file mode 100644
index 22d45fba..00000000
--- a/otk/util.hh
+++ /dev/null
@@ -1,32 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __util_hh
-#define __util_hh
-
-extern "C" {
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-}
-
-#include <string>
-#include <vector>
-
-namespace otk {
-
-std::string expandTilde(const std::string& s);
-
-void bexec(const std::string& command, const std::string& displaystring);
-
-std::string itostring(unsigned long i);
-std::string itostring(long i);
-inline std::string itostring(unsigned int i)
- { return itostring((unsigned long) i); }
-inline std::string itostring(int i)
- { return itostring((long) i); }
-
-void putenv(const std::string &data);
-
-std::string basename(const std::string& path);
-
-}
-
-#endif // __util_hh
diff --git a/otk/widget.cc b/otk/widget.cc
deleted file mode 100644
index 1a0c7d9e..00000000
--- a/otk/widget.cc
+++ /dev/null
@@ -1,547 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-
-#include "config.h"
-#include "widget.hh"
-#include "display.hh"
-#include "surface.hh"
-#include "rendertexture.hh"
-#include "rendercolor.hh"
-#include "eventdispatcher.hh"
-#include "screeninfo.hh"
-
-#include <climits>
-#include <cassert>
-#include <algorithm>
-
-namespace otk {
-
-Widget::Widget(int screen, EventDispatcher *ed, Direction direction, int bevel,
- bool overrideredir)
- : _texture(0),
- _screen(screen),
- _parent(0),
- _window(0),
- _surface(0),
- _event_mask(ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
- ExposureMask | StructureNotifyMask),
- _alignment(RenderStyle::CenterJustify),
- _direction(direction),
- _max_size(INT_MAX, INT_MAX),
- _visible(false),
- _bordercolor(0),
- _borderwidth(0),
- _bevel(bevel),
- _dirty(true),
- _dispatcher(ed),
- _ignore_config(0)
-{
- createWindow(overrideredir);
- _dispatcher->registerHandler(_window, this);
-}
-
-Widget::Widget(Widget *parent, Direction direction, int bevel)
- : _texture(0),
- _screen(parent->_screen),
- _parent(parent),
- _window(0),
- _surface(0),
- _event_mask(ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
- ExposureMask | StructureNotifyMask),
- _alignment(RenderStyle::CenterJustify),
- _direction(direction),
- _max_size(INT_MAX, INT_MAX),
- _visible(false),
- _bordercolor(0),
- _borderwidth(0),
- _bevel(bevel),
- _dirty(true),
- _dispatcher(parent->_dispatcher),
- _ignore_config(0)
-{
- assert(parent);
- createWindow(false);
- parent->addChild(this);
- if (parent->visible()) parent->layout();
- _dispatcher->registerHandler(_window, this);
- styleChanged(*RenderStyle::style(_screen));
-}
-
-Widget::~Widget()
-{
- assert(_children.empty()); // this would be bad. theyd have a hanging _parent
-
- if (_surface) delete _surface;
- if (_parent) _parent->removeChild(this);
-
- _dispatcher->clearHandler(_window);
- XDestroyWindow(**display, _window);
-}
-
-void Widget::show(bool children)
-{
- if (children) {
- std::list<Widget*>::iterator it , end = _children.end();
- for (it = _children.begin(); it != end; ++it) {
- (*it)->show(true);
- }
- }
- if (!_visible) {
- if (_parent) _parent->calcDefaultSizes();
- else resize(_area.size()); // constrain sizes
- _visible = true;
- XMapWindow(**display, _window);
- update();
- }
-}
-
-void Widget::hide()
-{
- if (_visible) {
- _visible = false;
- XUnmapWindow(**display, _window);
- if (_parent) {
- _parent->calcDefaultSizes();
- _parent->layout();
- }
- }
-}
-
-void Widget::setEventMask(long e)
-{
- XSelectInput(**display, _window, e);
- _event_mask = e;
-}
-
-void Widget::update()
-{
- if (!_visible) return;
- _dirty = true;
- if (_parent) {
- _parent->calcDefaultSizes();
- _parent->layout(); // relay-out us and our siblings
- } else {
- render();
- layout();
- }
-}
-
-void Widget::moveresize(const Rect &r)
-{
- int w, h;
- w = std::max(std::min(r.width(), maxSize().width()), minSize().width());
- h = std::max(std::min(r.height(), maxSize().height()), minSize().height());
-
- bool sizechange = !(w == area().width() && h == area().height());
-
- if (r.x() == area().x() && r.y() == area().y() && !sizechange)
- return; // no change, don't cause a big layout chain to occur!
-
- internal_moveresize(r.x(), r.y(), w, h);
-
- if (sizechange)
- update();
-}
-
-void Widget::internal_moveresize(int x, int y, int w, int h)
-{
- assert(w > 0);
- assert(h > 0);
- assert(_borderwidth >= 0);
- _dirty = true;
- if (!(x == _area.x() && y == _area.y())) {
- if (!(w == _area.width() && h == _area.height()))
- XMoveResizeWindow(**display, _window, x, y,
- w - _borderwidth * 2,
- h - _borderwidth * 2);
- else
- XMoveWindow(**display, _window, x, y);
- } else
- XResizeWindow(**display, _window, w - _borderwidth*2, h - _borderwidth*2);
- _ignore_config++;
-
- _area = Rect(x, y, w, h);
-}
-
-void Widget::setAlignment(RenderStyle::Justify a)
-{
- _alignment = a;
- layout();
-}
-
-void Widget::createWindow(bool overrideredir)
-{
- const ScreenInfo *info = display->screenInfo(_screen);
- XSetWindowAttributes attrib;
- unsigned long mask = CWEventMask | CWBorderPixel;
-
- attrib.event_mask = _event_mask;
- attrib.border_pixel = (_bordercolor ?
- _bordercolor->pixel():
- BlackPixel(**display, _screen));
-
- if (overrideredir) {
- mask |= CWOverrideRedirect;
- attrib.override_redirect = true;
- }
-
- _window = XCreateWindow(**display, (_parent ?
- _parent->_window :
- RootWindow(**display, _screen)),
- _area.x(), _area.y(),
- _area.width(), _area.height(),
- _borderwidth,
- info->depth(),
- InputOutput,
- info->visual(),
- mask,
- &attrib);
- assert(_window != None);
- ++_ignore_config;
-}
-
-void Widget::calcDefaultSizes()
-{
- std::list<Widget*>::const_iterator it, end = _children.end();
- int min_biggest = 0, max_biggest = 0;
- int min_sum = _bevel + _borderwidth * 2;
- int max_sum = _bevel + _borderwidth * 2;
- bool fullmax = false;
-
- for (it = _children.begin(); it != end; ++it) {
- const otk::Size &min = (*it)->minSize();
- const otk::Size &max = (*it)->maxSize();
- if (_direction == Horizontal) {
- if (min.height() > min_biggest) min_biggest = min.height();
- if (max.height() > max_biggest) max_biggest = max.height();
- min_sum += _bevel + min.width();
- if (max.width() == INT_MAX)
- fullmax = true;
- else if (!fullmax)
- max_sum += _bevel + max.width();
- } else {
- if (min.width() > min_biggest) min_biggest = min.width();
- if (max.width() > max_biggest) max_biggest = max.width();
- min_sum += _bevel + min.height();
- if (max.height() == INT_MAX)
- fullmax = true;
- else if (!fullmax)
- max_sum += _bevel + max.height();
- }
- }
- if (_direction == Horizontal) {
- _min_size = otk::Size(min_sum + (_bevel + _borderwidth) * 2,
- min_biggest + (_bevel + _borderwidth) * 2);
- _max_size = otk::Size((fullmax ? INT_MAX :
- max_sum + (_bevel + _borderwidth) * 2),
- max_biggest);
- } else {
- _min_size = otk::Size(min_biggest + (_bevel + _borderwidth) * 2,
- min_sum + (_bevel + _borderwidth) * 2);
- _max_size = otk::Size(max_biggest, (fullmax ? INT_MAX : max_sum +
- (_bevel + _borderwidth) * 2));
- }
- update();
-}
-
-void Widget::setBorderWidth(int w)
-{
- assert(w >= 0);
- if (!parent()) return; // top-level windows cannot have borders
- if (w == borderWidth()) return; // no change
-
- _borderwidth = w;
- XSetWindowBorderWidth(**display, _window, _borderwidth);
-
- calcDefaultSizes();
- update();
-}
-
-void Widget::setMinSize(const Size &s)
-{
- _min_size = s;
- update();
-}
-
-void Widget::setMaxSize(const Size &s)
-{
- _max_size = s;
- update();
-}
-
-void Widget::setBorderColor(const RenderColor *c)
-{
- _bordercolor = c;
- XSetWindowBorder(**otk::display, _window,
- c ? c->pixel() : BlackPixel(**otk::display, _screen));
-}
-
-void Widget::setBevel(int b)
-{
- _bevel = b;
- calcDefaultSizes();
- layout();
-}
-
-void Widget::layout()
-{
- if (_children.empty() || !_visible) return;
- if (_direction == Horizontal)
- layoutHorz();
- else
- layoutVert();
-}
-
-void Widget::layoutHorz()
-{
- std::list<Widget*>::iterator it, end;
-
- // work with just the visible children
- std::list<Widget*> visible;
- for (it = _children.begin(), end = _children.end(); it != end; ++it)
- if ((*it)->visible())
- visible.push_back(*it);
-
- if (visible.empty()) return;
-
- int x, y, w, h; // working area
- x = y = _bevel;
- w = _area.width() - _borderwidth * 2 - _bevel * 2;
- h = _area.height() - _borderwidth * 2 - _bevel * 2;
- if (w < 0 || h < 0) return; // not worth laying anything out!
-
- int free = w - (visible.size() - 1) * _bevel;
- if (free < 0) free = 0;
- int each;
-
- std::list<Widget*> adjustable;
-
- // find the 'free' space, and how many children will be using it
- for (it = visible.begin(), end = visible.end(); it != end; ++it) {
- free -= (*it)->minSize().width();
- if (free < 0) free = 0;
- if ((*it)->maxSize().width() - (*it)->minSize().width() > 0)
- adjustable.push_back(*it);
- }
- // some widgets may have max widths that restrict them, find the 'true'
- // amount of free space after these widgets are not included
- if (!adjustable.empty()) {
- do {
- each = free / adjustable.size();
- for (it = adjustable.begin(), end = adjustable.end(); it != end;) {
- std::list<Widget*>::iterator next = it; ++next;
- int m = (*it)->maxSize().width() - (*it)->minSize().width();
- if (m > 0 && m < each) {
- free -= m;
- if (free < 0) free = 0;
- adjustable.erase(it);
- break; // if one is found to be fixed, then the free space needs to
- // change, and the rest need to be reexamined
- }
- it = next;
- }
- } while (it != end && !adjustable.empty());
- }
-
- // place/size the widgets
- if (!adjustable.empty())
- each = free / adjustable.size();
- else
- each = 0;
- for (it = visible.begin(), end = visible.end(); it != end; ++it) {
- int w;
- // is the widget adjustable?
- std::list<Widget*>::const_iterator
- found = std::find(adjustable.begin(), adjustable.end(), *it);
- if (found != adjustable.end()) {
- // adjustable
- w = (*it)->minSize().width() + each;
- } else {
- // fixed
- w = (*it)->minSize().width();
- }
- // align it vertically
- int yy = y;
- int hh = std::max(std::min(h, (*it)->_max_size.height()),
- (*it)->_min_size.height());
- if (hh < h) {
- switch(_alignment) {
- case RenderStyle::RightBottomJustify:
- yy += h - hh;
- break;
- case RenderStyle::CenterJustify:
- yy += (h - hh) / 2;
- break;
- case RenderStyle::LeftTopJustify:
- break;
- }
- }
- (*it)->internal_moveresize(x, yy, w, hh);
- (*it)->render();
- (*it)->layout();
- x += w + _bevel;
- }
-}
-
-void Widget::layoutVert()
-{
- std::list<Widget*>::iterator it, end;
-
- // work with just the visible children
- std::list<Widget*> visible;
- for (it = _children.begin(), end = _children.end(); it != end; ++it)
- if ((*it)->visible())
- visible.push_back(*it);
-
- if (visible.empty()) return;
-
- int x, y, w, h; // working area
- x = y = _bevel;
- w = _area.width() - _borderwidth * 2 - _bevel * 2;
- h = _area.height() - _borderwidth * 2 - _bevel * 2;
- if (w < 0 || h < 0) return; // not worth laying anything out!
-
- int free = h - (visible.size() - 1) * _bevel;
- if (free < 0) free = 0;
- int each;
-
- std::list<Widget*> adjustable;
-
- // find the 'free' space, and how many children will be using it
- for (it = visible.begin(), end = visible.end(); it != end; ++it) {
- free -= (*it)->minSize().height();
- if (free < 0) free = 0;
- if ((*it)->maxSize().height() - (*it)->minSize().height() > 0)
- adjustable.push_back(*it);
- }
- // some widgets may have max heights that restrict them, find the 'true'
- // amount of free space after these widgets are not included
- if (!adjustable.empty()) {
- do {
- each = free / adjustable.size();
- for (it = adjustable.begin(), end = adjustable.end(); it != end;) {
- std::list<Widget*>::iterator next = it; ++next;
- int m = (*it)->maxSize().height() - (*it)->minSize().height();
- if (m > 0 && m < each) {
- free -= m;
- if (free < 0) free = 0;
- adjustable.erase(it);
- break; // if one is found to be fixed, then the free space needs to
- // change, and the rest need to be reexamined
- }
- it = next;
- }
- } while (it != end && !adjustable.empty());
- }
-
- // place/size the widgets
- if (!adjustable.empty())
- each = free / adjustable.size();
- else
- each = 0;
- for (it = visible.begin(), end = visible.end(); it != end; ++it) {
- int h;
- // is the widget adjustable?
- std::list<Widget*>::const_iterator
- found = std::find(adjustable.begin(), adjustable.end(), *it);
- if (found != adjustable.end()) {
- // adjustable
- h = (*it)->minSize().height() + each;
- } else {
- // fixed
- h = (*it)->minSize().height();
- }
- // align it horizontally
- int xx = x;
- int ww = std::max(std::min(w, (*it)->_max_size.width()),
- (*it)->_min_size.width());
- if (ww < w) {
- switch(_alignment) {
- case RenderStyle::RightBottomJustify:
- xx += w - ww;
- break;
- case RenderStyle::CenterJustify:
- xx += (w - ww) / 2;
- break;
- case RenderStyle::LeftTopJustify:
- break;
- }
- }
- (*it)->internal_moveresize(xx, y, ww, h);
- (*it)->render();
- (*it)->layout();
- y += h + _bevel;
- }
-}
-
-void Widget::render()
-{
- if (!_dirty) return;
- if (!_texture) {
- // set a solid color as the default background
- XSetWindowBackground(**display, _window,
- RenderStyle::style(_screen)->
- titlebarUnfocusBackground()->color().pixel());
- return;
- }
- if (_borderwidth * 2 > _area.width() ||
- _borderwidth * 2 > _area.height())
- return; // no surface to draw on
-
- Surface *s = new Surface(_screen, Size(_area.width() - _borderwidth * 2,
- _area.height() - _borderwidth * 2));
- display->renderControl(_screen)->drawBackground(*s, *_texture);
-
- renderForeground(*s); // for inherited types to render onto the _surface
-
- XSetWindowBackgroundPixmap(**display, _window, s->pixmap());
- XClearWindow(**display, _window);
-
- // delete the old surface *after* its pixmap isn't in use anymore
- if (_surface) delete _surface;
-
- s->freePixelData(); // done rendering with this surface
- _surface = s;
-
- _dirty = false;
-}
-
-void Widget::renderChildren()
-{
- std::list<Widget*>::iterator it, end = _children.end();
- for (it = _children.begin(); it != end; ++it)
- (*it)->render();
-}
-
-void Widget::styleChanged(const RenderStyle &)
-{
- refresh();
-}
-
-void Widget::exposeHandler(const XExposeEvent &e)
-{
- EventHandler::exposeHandler(e);
- XClearArea(**display, _window, e.x, e.y, e.width, e.height, false);
-}
-
-void Widget::configureHandler(const XConfigureEvent &e)
-{
- if (_ignore_config) {
- _ignore_config--;
- } else {
- // only interested in these for top level windows
- if (_parent) return;
-
- XEvent ev;
- ev.xconfigure.width = e.width;
- ev.xconfigure.height = e.height;
- while (XCheckTypedWindowEvent(**display, window(), ConfigureNotify, &ev));
-
- if (!(ev.xconfigure.width == area().width() &&
- ev.xconfigure.height == area().height())) {
- _area = Rect(_area.position(), Size(e.width, e.height));
- update();
- }
- }
-}
-
-}
diff --git a/otk/widget.hh b/otk/widget.hh
deleted file mode 100644
index 07b6c084..00000000
--- a/otk/widget.hh
+++ /dev/null
@@ -1,141 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef __widget_hh
-#define __widget_hh
-
-#include "eventhandler.hh"
-#include "rect.hh"
-#include "renderstyle.hh"
-
-#include <list>
-#include <algorithm>
-#include <cassert>
-
-namespace otk {
-
-class Surface;
-class RenderTexture;
-class RenderColor;
-class EventDispatcher;
-
-class Widget : public EventHandler, public StyleNotify {
-public:
- enum Direction { Horizontal, Vertical };
-
- Widget(int screen, EventDispatcher *ed, Direction direction = Horizontal,
- int bevel = 3, bool overrideredir = false);
- Widget(Widget *parent, Direction direction = Horizontal, int bevel = 3);
- virtual ~Widget();
-
- inline int screen() const { return _screen; }
- inline Window window() const { return _window; }
- inline Widget *parent() const { return _parent; }
- inline Direction direction() const { return _direction; }
-
- inline RenderStyle::Justify alignment() const { return _alignment; }
- void setAlignment(RenderStyle::Justify a);
-
- inline long eventMask() const { return _event_mask; }
- virtual void setEventMask(long e);
-
- inline const Rect& area() const { return _area; }
- inline Rect usableArea() const { return Rect(_area.position(),
- Size(_area.width() -
- _borderwidth * 2,
- _area.height() -
- _borderwidth * 2));}
- inline const Size& minSize() const { return _min_size; }
- inline const Size& maxSize() const { return _max_size; }
- virtual void setMaxSize(const Size &s);
-
- virtual void show(bool children = false);
- virtual void hide();
- inline bool visible() const { return _visible; }
-
- virtual void update();
- virtual void refresh() { if (_visible) { _dirty = true; render(); } }
-
- virtual void setBevel(int b);
- inline int bevel() const { return _bevel; }
-
- void move(const Point &p)
- { moveresize(Rect(p, _area.size())); }
- void resize(const Size &s)
- { moveresize(Rect(_area.position(), s)); }
- /*!
- When a widget has a parent, this won't change the widget directly, but will
- just cause the parent to re-layout all its children.
- */
- virtual void moveresize(const Rect &r);
-
- inline const RenderColor *borderColor() const { return _bordercolor; }
- virtual void setBorderColor(const RenderColor *c);
-
- inline int borderWidth() const { return _borderwidth; }
- virtual void setBorderWidth(int w);
-
- const std::list<Widget*>& children() const { return _children; }
-
- virtual void exposeHandler(const XExposeEvent &e);
- virtual void configureHandler(const XConfigureEvent &e);
- virtual void styleChanged(const RenderStyle &style);
-
-protected:
- virtual void addChild(Widget *w) { assert(w); _children.push_back(w); }
- virtual void removeChild(Widget *w) { assert(w); _children.remove(w); }
-
- //! Find the default min/max sizes for the widget. Useful after the in-use
- //! style has changed.
- virtual void calcDefaultSizes();
-
- virtual void setMinSize(const Size &s);
-
- //! Arrange the widget's children
- virtual void layout();
- virtual void layoutHorz();
- virtual void layoutVert();
- virtual void render();
- virtual void renderForeground(Surface&) {};
- virtual void renderChildren();
-
- void createWindow(bool overrideredir);
-
- RenderTexture *_texture;
-
- EventDispatcher *dispatcher() const { return _dispatcher; }
-
-private:
- void internal_moveresize(int x, int y, int w, int h);
-
- int _screen;
- Widget *_parent;
- Window _window;
- Surface *_surface;
- long _event_mask;
-
- RenderStyle::Justify _alignment;
- Direction _direction;
- Rect _area;
- //! This size is the size *inside* the border, so they won't match the
- //! actual size of the widget
- Size _min_size;
- //! This size is the size *inside* the border, so they won't match the
- //! actual size of the widget
- Size _max_size;
-
- bool _visible;
-
- const RenderColor *_bordercolor;
- int _borderwidth;
- int _bevel;
- bool _dirty;
-
- std::list<Widget*> _children;
-
- EventDispatcher *_dispatcher;
-
- int _ignore_config;
-};
-
-}
-
-#endif // __widget_hh