2002-11-17 09:41:58 +00:00
|
|
|
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2002-11-16 02:18:37 +00:00
|
|
|
#include "application.hh"
|
|
|
|
#include "eventhandler.hh"
|
2002-11-16 13:50:59 +00:00
|
|
|
#include "widget.hh"
|
2003-01-14 09:54:05 +00:00
|
|
|
#include "timer.hh"
|
2003-01-16 08:47:21 +00:00
|
|
|
#include "property.hh"
|
2003-01-20 07:07:13 +00:00
|
|
|
#include "rendercolor.hh"
|
2002-11-16 02:18:37 +00:00
|
|
|
|
2002-11-16 12:12:38 +00:00
|
|
|
extern "C" {
|
|
|
|
#ifdef HAVE_STDLIB_H
|
|
|
|
# include <stdlib.h>
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2002-11-16 09:59:37 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2002-11-16 02:18:37 +00:00
|
|
|
namespace otk {
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
Application::Application(int argc, char **argv)
|
|
|
|
: EventDispatcher(),
|
2003-01-13 08:48:03 +00:00
|
|
|
_display(),
|
2002-11-16 14:30:18 +00:00
|
|
|
_dockable(false),
|
|
|
|
_appwidget_count(0)
|
2002-11-16 02:18:37 +00:00
|
|
|
{
|
2003-01-11 19:17:13 +00:00
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
2002-11-16 02:18:37 +00:00
|
|
|
|
2003-01-14 09:54:05 +00:00
|
|
|
Timer::initialize();
|
2003-01-20 07:07:13 +00:00
|
|
|
RenderColor::initialize();
|
2003-01-16 08:47:21 +00:00
|
|
|
Property::initialize();
|
2003-01-22 22:46:16 +00:00
|
|
|
_style = new RenderStyle(DefaultScreen(*_display), ""); // XXX: get a path!
|
2002-11-16 02:18:37 +00:00
|
|
|
|
|
|
|
loadStyle();
|
|
|
|
}
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
Application::~Application()
|
2002-11-16 02:18:37 +00:00
|
|
|
{
|
|
|
|
delete _style;
|
2003-01-20 07:07:13 +00:00
|
|
|
RenderColor::destroy();
|
2003-01-14 09:54:05 +00:00
|
|
|
Timer::destroy();
|
2002-11-16 02:18:37 +00:00
|
|
|
}
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
void Application::loadStyle(void)
|
2002-11-16 02:18:37 +00:00
|
|
|
{
|
2003-01-22 22:46:16 +00:00
|
|
|
// XXX: find the style name as a property
|
2002-11-16 12:12:38 +00:00
|
|
|
std::string style = "/usr/local/share/openbox/styles/artwiz";
|
2003-01-22 22:46:16 +00:00
|
|
|
//_style->load(style);
|
2002-11-16 02:18:37 +00:00
|
|
|
}
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
void Application::run(void)
|
2002-11-16 02:18:37 +00:00
|
|
|
{
|
2002-11-16 14:30:18 +00:00
|
|
|
if (_appwidget_count <= 0) {
|
|
|
|
std::cerr << "ERROR: No main widgets exist. You must create and show() " <<
|
2003-01-11 19:17:13 +00:00
|
|
|
"an AppWidget for the Application before calling " <<
|
|
|
|
"Application::run().\n";
|
2002-11-16 13:50:59 +00:00
|
|
|
::exit(1);
|
|
|
|
}
|
2002-11-16 14:30:18 +00:00
|
|
|
|
|
|
|
while (_appwidget_count > 0) {
|
2002-11-16 09:59:37 +00:00
|
|
|
dispatchEvents();
|
2003-01-22 23:11:30 +00:00
|
|
|
if (_appwidget_count <= 0)
|
|
|
|
break;
|
2003-01-14 09:54:05 +00:00
|
|
|
Timer::dispatchTimers(); // fire pending events
|
2002-11-16 09:59:37 +00:00
|
|
|
}
|
2002-11-16 02:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|