]> icculus.org git repositories - dana/openbox.git/blob - otk/application.cc
signed ints instead of unsigned ints again. less pain. pain bad.
[dana/openbox.git] / 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 "timer.hh"
10 #include "property.hh"
11 #include "rendercolor.hh"
12 #include "renderstyle.hh"
13
14 extern "C" {
15 #ifdef HAVE_STDLIB_H
16 # include <stdlib.h>
17 #endif
18 }
19
20 #include <iostream>
21
22 namespace otk {
23
24 Application::Application(int argc, char **argv)
25   : EventDispatcher(),
26     _display(),
27     _dockable(false),
28     _appwidget_count(0)
29 {
30   (void)argc;
31   (void)argv;
32
33   _screen = DefaultScreen(*_display);
34   
35   Timer::initialize();
36   RenderColor::initialize();
37   RenderStyle::initialize();
38   Property::initialize();
39
40   loadStyle();
41 }
42
43 Application::~Application()
44 {
45   RenderStyle::destroy();
46   RenderColor::destroy();
47   Timer::destroy();
48 }
49
50 void Application::loadStyle(void)
51 {
52   // XXX: find the style name as a property
53   std::string style = "/usr/local/share/openbox/styles/artwiz";
54   //_style->load(style);
55 }
56
57 void Application::run(void)
58 {
59   if (_appwidget_count <= 0) {
60     std::cerr << "ERROR: No main widgets exist. You must create and show() " <<
61       "an AppWidget for the Application before calling " <<
62       "Application::run().\n";
63     ::exit(1);
64   }
65
66   while (_appwidget_count > 0) {
67     dispatchEvents();
68     if (_appwidget_count <= 0)
69       break;
70     Timer::dispatchTimers(); // fire pending events
71   }
72 }
73
74 }