openbox/otk/otk_test.cc

109 lines
2.8 KiB
C++
Raw Normal View History

#include "focuswidget.hh"
2002-11-14 11:44:14 +00:00
#include "button.hh"
2002-11-11 03:49:09 +00:00
#include "display.hh"
#include "configuration.hh"
#include "timerqueuemanager.hh"
#include "image.hh"
#include "style.hh"
2002-11-15 03:10:34 +00:00
#include <iostream>
2002-11-11 03:49:09 +00:00
int main(void) {
otk::OBDisplay::initialize(NULL);
otk::Configuration style_conf(False);
otk::OBTimerQueueManager *tm = new otk::OBTimerQueueManager();
2002-11-11 08:42:19 +00:00
const otk::ScreenInfo *s_info =
otk::OBDisplay::screenInfo(DefaultScreen(otk::OBDisplay::display));
2002-11-11 03:49:09 +00:00
otk::BImageControl *ctrl = new otk::BImageControl(tm, s_info, True, 4, 5, 200);
otk::Style *my_style = new otk::Style(ctrl);
2002-11-11 03:49:09 +00:00
2002-11-13 10:39:04 +00:00
style_conf.setFile("/usr/local/share/openbox/styles/artwiz");
2002-11-11 03:49:09 +00:00
style_conf.load();
my_style->load(style_conf);
otk::OtkFocusWidget foo(my_style);
2002-11-11 03:49:09 +00:00
2002-11-15 05:02:07 +00:00
foo.resize(600, 500);
foo.setTexture(my_style->getTitleFocus());
foo.setUnfocusTexture(my_style->getTitleUnfocus());
2002-11-11 03:49:09 +00:00
2002-11-15 05:02:07 +00:00
foo.setBevelWidth(2);
foo.setDirection(otk::OtkWidget::Horizontal);
otk::OtkFocusWidget left(&foo);
otk::OtkFocusWidget right(&foo);
left.setDirection(otk::OtkWidget::Horizontal);
left.setStretchableVert(true);
left.setStretchableHorz(true);
left.setTexture(my_style->getTitleFocus());
left.setUnfocusTexture(my_style->getTitleUnfocus());
right.setDirection(otk::OtkWidget::Vertical);
right.setBevelWidth(10);
right.setStretchableVert(true);
right.setWidth(300);
right.setTexture(my_style->getTitleFocus());
right.setUnfocusTexture(my_style->getTitleUnfocus());
otk::OtkButton iconb(&left);
otk::OtkFocusWidget label(&left);
otk::OtkButton maxb(&left);
otk::OtkButton closeb(&left);
// fixed size
2002-11-14 11:44:14 +00:00
iconb.setText("foo");
iconb.press();
2002-11-11 03:49:09 +00:00
2002-11-13 10:39:04 +00:00
// fix width to 60 and let the height be calculated by its parent
2002-11-15 05:02:07 +00:00
//label.setHeight(20);
2002-11-13 10:39:04 +00:00
label.setStretchableVert(true);
2002-11-15 05:02:07 +00:00
label.setStretchableHorz(true);
label.setTexture(my_style->getLabelFocus());
label.setUnfocusTexture(my_style->getLabelUnfocus());
2002-11-11 03:49:09 +00:00
// fixed size
2002-11-14 11:44:14 +00:00
maxb.setText("bar");
// fixed size
2002-11-14 11:44:14 +00:00
closeb.setText("fuubar");
2002-11-15 05:02:07 +00:00
otk::OtkFocusWidget rblef(&right);
otk::OtkButton rbutt1(&right);
otk::OtkButton rbutt2(&right);
rblef.setStretchableHorz(true);
rblef.setHeight(50);
rblef.setTexture(my_style->getHandleFocus());
rblef.setUnfocusTexture(my_style->getHandleUnfocus());
rbutt1.setText("this is fucking tight");
rbutt2.setText("heh, WOOP");
// will recursively unfocus its children
2002-11-13 10:39:04 +00:00
//foo.unfocus();
2002-11-14 11:44:14 +00:00
foo.update();
2002-11-11 03:49:09 +00:00
foo.show();
while (1) {
if (XPending(otk::OBDisplay::display)) {
XEvent e;
XNextEvent(otk::OBDisplay::display, &e);
2002-11-15 03:10:34 +00:00
if (e.type == Expose) {
2002-11-15 02:30:14 +00:00
foo.expose(e.xexpose);
2002-11-15 03:10:34 +00:00
} else if (e.type == ConfigureNotify) {
foo.configure(e.xconfigure);
}
2002-11-11 03:49:09 +00:00
}
}
delete my_style;
delete tm;
delete ctrl;
2002-11-11 08:42:19 +00:00
otk::OBDisplay::destroy();
2002-11-11 03:49:09 +00:00
return 0;
}