]> Dogcows Code - chaz/openbox/blob - otk/application.cc
make shape work with the titlebar and handle
[chaz/openbox] / otk / application.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #ifdef HAVE_CONFIG_H
4 # include "../config.h"
5 #endif
6
7 #include "application.hh"
8 #include "eventhandler.hh"
9 #include "widget.hh"
10
11 extern "C" {
12 #ifdef HAVE_STDLIB_H
13 # include <stdlib.h>
14 #endif
15 }
16
17 #include <iostream>
18
19 namespace otk {
20
21 OtkApplication::OtkApplication(int argc, char **argv)
22 : OtkEventDispatcher(),
23 _dockable(false),
24 _appwidget_count(0)
25 {
26 argc = argc;
27 argv = argv;
28
29 OBDisplay::initialize(0);
30 const ScreenInfo *s_info =
31 OBDisplay::screenInfo(DefaultScreen(OBDisplay::display));
32
33 _timer_manager = new OBTimerQueueManager();
34 _img_ctrl = new BImageControl(_timer_manager, s_info, True, 4, 5, 200);
35 _style_conf = new Configuration(False);
36 _style = new Style(_img_ctrl);
37
38 loadStyle();
39 }
40
41 OtkApplication::~OtkApplication()
42 {
43 delete _style_conf;
44 delete _img_ctrl;
45 delete _timer_manager;
46 delete _style;
47
48 OBDisplay::destroy();
49 }
50
51 void OtkApplication::loadStyle(void)
52 {
53 // find the style name as a property
54 std::string style = "/usr/local/share/openbox/styles/artwiz";
55 _style_conf->setFile(style);
56 if (!_style_conf->load()) {
57 std::cerr << "ERROR: Unable to load style \"" << style << "\".\n";
58 ::exit(1);
59 }
60 _style->load(*_style_conf);
61 }
62
63 void OtkApplication::exec(void)
64 {
65 if (_appwidget_count <= 0) {
66 std::cerr << "ERROR: No main widgets exist. You must create and show() " <<
67 "an OtkAppWidget for the OtkApplication before calling " <<
68 "OtkApplication::exec().\n";
69 ::exit(1);
70 }
71
72 while (_appwidget_count > 0) {
73 dispatchEvents();
74 _timer_manager->fire(); // fire pending events
75 }
76 }
77
78 }
This page took 0.03597 seconds and 4 git commands to generate.