summaryrefslogtreecommitdiff
path: root/lib/widgets.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/widgets.cc')
-rw-r--r--lib/widgets.cc249
1 files changed, 131 insertions, 118 deletions
diff --git a/lib/widgets.cc b/lib/widgets.cc
index 5d565d6..5fd76e2 100644
--- a/lib/widgets.cc
+++ b/lib/widgets.cc
@@ -17,14 +17,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: widgets.cc,v 1.20 2006-02-02 14:09:49 pixel Exp $ */
+/* $Id: widgets.cc,v 1.21 2006-10-28 16:50:47 pixel Exp $ */
#include <SDL.h>
#include <vector>
#include <Input.h>
-#include "font.h"
+#include "Font.h"
#include "engine.h"
-#include "widgets.h"
+#include "Widgets.h"
#include "sprite.h"
#ifdef HAVE_CONFIG_H
@@ -35,35 +35,35 @@
// Why so much ugly globals... ?
-mogltk::widget * dragged_widget = 0;
+mogltk::Widget * dragged_widget = 0;
-std::vector<mogltk::widget *> out_move, out_click;
-std::vector<mogltk::widget::timed_event> mogltk::widget::timed_events;
-std::vector<mogltk::widget *> mogltk::widget::add_list;
-std::vector<mogltk::widget *> mogltk::widget::del_list;
-bool mogltk::widget::in_delete_loop = false;
+std::vector<mogltk::Widget *> out_move, out_click;
+std::vector<mogltk::Widget::timed_event> mogltk::Widget::timed_events;
+std::vector<mogltk::Widget *> mogltk::Widget::add_list;
+std::vector<mogltk::Widget *> mogltk::Widget::del_list;
+bool mogltk::Widget::in_delete_loop = false;
class widget_mouse_event : public mogltk::engine::mouseevent {
public:
- widget_mouse_event(mogltk::widget *);
+ widget_mouse_event(mogltk::Widget *);
virtual void move(SDL_MouseMotionEvent);
virtual void action(SDL_MouseButtonEvent);
private:
- mogltk::widget * root;
+ mogltk::Widget * root;
int mouse_x_down, mouse_y_down;
bool mouse_down, mouse_drag;
Uint32 old_click;
};
-widget_mouse_event::widget_mouse_event(mogltk::widget * _root) :
+widget_mouse_event::widget_mouse_event(mogltk::Widget * _root) :
root(_root), mouse_down(false), mouse_drag(false) {
}
void widget_mouse_event::move(SDL_MouseMotionEvent m) {
int mx, my;
bool out_threshold;
- std::vector<mogltk::widget *>::iterator i;
- std::vector<mogltk::widget *> out_move_stack;
+ std::vector<mogltk::Widget *>::iterator i;
+ std::vector<mogltk::Widget *> out_move_stack;
mx = mogltk::engine::mouseX();
my = mogltk::engine::mouseY();
@@ -115,8 +115,8 @@ void widget_mouse_event::move(SDL_MouseMotionEvent m) {
void widget_mouse_event::action(SDL_MouseButtonEvent b) {
int mx, my;
- std::vector<mogltk::widget *>::iterator i;
- std::vector<mogltk::widget *> out_click_stack;
+ std::vector<mogltk::Widget *>::iterator i;
+ std::vector<mogltk::Widget *> out_click_stack;
mx = mogltk::engine::mouseX();
my = mogltk::engine::mouseY();
@@ -208,9 +208,9 @@ void widget_mouse_event::action(SDL_MouseButtonEvent b) {
}
}
-mogltk::widget * mogltk::widget::focused = 0;
+mogltk::Widget * mogltk::Widget::focused = 0;
-mogltk::widget::widget(widget * _father, int _x, int _y, int _sx, int _sy, int _type, String _name, mogltk::shape * _sh) :
+mogltk::Widget::Widget(Widget * _father, int _x, int _y, int _sx, int _sy, int _type, String _name, mogltk::Shape * _sh) :
x(_x), y(_y), sx(_sx), sy(_sy), father(_father), prev(0), child(0), last(0), panel(0), type(_type), name(_name), sh(_sh), exclusive(0), visible(true), enabled(true) {
LOCK;
@@ -224,7 +224,7 @@ mogltk::widget::widget(widget * _father, int _x, int _y, int _sx, int _sy, int _
}
}
-void mogltk::widget::linkme() {
+void mogltk::Widget::linkme() {
LOCK;
if (!father) {
root = this;
@@ -244,7 +244,7 @@ void mogltk::widget::linkme() {
computeabs();
}
-mogltk::widget::~widget() throw (GeneralException) {
+mogltk::Widget::~Widget() throw (GeneralException) {
while(child)
delete child;
@@ -262,8 +262,8 @@ mogltk::widget::~widget() throw (GeneralException) {
else
father->last = prev;
- std::vector<mogltk::widget *>::iterator iw;
- std::vector<mogltk::widget::timed_event>::iterator it;
+ std::vector<mogltk::Widget *>::iterator iw;
+ std::vector<mogltk::Widget::timed_event>::iterator it;
for (iw = out_move.begin(); iw != out_move.end(); iw++) {
if (*iw == this) {
@@ -302,7 +302,7 @@ mogltk::widget::~widget() throw (GeneralException) {
UNLOCK;
}
-void mogltk::widget::computeabs() {
+void mogltk::Widget::computeabs() {
if (father != this) {
ax = father->ax + x;
ay = father->ay + y;
@@ -314,7 +314,7 @@ void mogltk::widget::computeabs() {
ay2 = ay + sy;
}
-void mogltk::widget::move(int nx, int ny) {
+void mogltk::Widget::move(int nx, int ny) {
x = nx;
y = ny;
@@ -324,7 +324,7 @@ void mogltk::widget::move(int nx, int ny) {
child->icomputeabs();
}
-void mogltk::widget::resize(int nsx, int nsy) {
+void mogltk::Widget::resize(int nsx, int nsy) {
sx = nsx;
sy = nsy;
@@ -335,39 +335,39 @@ void mogltk::widget::resize(int nsx, int nsy) {
child->iresize_notify();
}
-int mogltk::widget::GetX() {
+int mogltk::Widget::GetX() {
return x;
}
-int mogltk::widget::GetY() {
+int mogltk::Widget::GetY() {
return y;
}
-int mogltk::widget::GetH() {
+int mogltk::Widget::GetH() {
return sy;
}
-int mogltk::widget::GetW() {
+int mogltk::Widget::GetW() {
return sx;
}
-int mogltk::widget::GetAX() {
+int mogltk::Widget::GetAX() {
return ax;
}
-int mogltk::widget::GetAY() {
+int mogltk::Widget::GetAY() {
return ay;
}
-int mogltk::widget::GetAX2() {
+int mogltk::Widget::GetAX2() {
return ax2;
}
-int mogltk::widget::GetAY2() {
+int mogltk::Widget::GetAY2() {
return ay2;
}
-mogltk::rect mogltk::widget::GetDrawRect() {
+mogltk::rect mogltk::Widget::GetDrawRect() {
rect r;
r.x = 0;
r.y = 0;
@@ -377,30 +377,30 @@ mogltk::rect mogltk::widget::GetDrawRect() {
return r;
}
-mogltk::widget * mogltk::widget::Father() {
+mogltk::Widget * mogltk::Widget::Father() {
return father;
}
-mogltk::widget * mogltk::widget::Child() {
+mogltk::Widget * mogltk::Widget::Child() {
return child;
}
-mogltk::widget * mogltk::widget::Next() {
+mogltk::Widget * mogltk::Widget::Next() {
return next;
}
-mogltk::widget * mogltk::widget::Prev() {
+mogltk::Widget * mogltk::Widget::Prev() {
return prev;
}
-mogltk::widget * mogltk::widget::InnerPanel() {
+mogltk::Widget * mogltk::Widget::InnerPanel() {
if (!panel)
panel = create_panel();
return panel;
}
-mogltk::widget * mogltk::widget::find_widget(int _x, int _y) {
- widget * r = 0;
+mogltk::Widget * mogltk::Widget::find_widget(int _x, int _y) {
+ Widget * r = 0;
if (visible && enabled && (_x >= ax) && (_y >= ay) && (_x <= ax2) && (_y <= ay2)) {
if (child)
@@ -416,18 +416,18 @@ mogltk::widget * mogltk::widget::find_widget(int _x, int _y) {
return r;
}
-mogltk::shape * mogltk::widget::Shaper() {
+mogltk::Shape * mogltk::Widget::Shaper() {
return sh;
}
-void mogltk::widget::fulldraw() {
+void mogltk::Widget::fulldraw() {
bool was2D = true;
if (mogltk::engine::glbase_o)
if (!(was2D = mogltk::engine::glbase_o->is2D()))
mogltk::engine::glbase_o->Enter2DMode();
- texture::Unbind();
+ Texture::Unbind();
mogltk::ColorP::Max = WHITE;
mogltk::ColorP::Min = BLACK;
mogltk::ColorP::Min.A = 0;
@@ -439,7 +439,7 @@ void mogltk::widget::fulldraw() {
mogltk::engine::glbase_o->Leave2DMode();
}
-void mogltk::widget::idraw() {
+void mogltk::Widget::idraw() {
if (next)
next->idraw();
@@ -453,7 +453,7 @@ void mogltk::widget::idraw() {
child->idraw();
}
-void mogltk::widget::set_viewport() {
+void mogltk::Widget::set_viewport() {
int x1, y1, x2, y2;
x1 = MAX(GetAX(), father->GetAX());
y1 = MAX(GetAY(), father->GetAY());
@@ -464,13 +464,13 @@ void mogltk::widget::set_viewport() {
engine::base_o->changeviewport(x1, y1, x2 - x1, y2 - y1);
}
-bool mogltk::widget::inside(int xe, int ye) {
+bool mogltk::Widget::inside(int xe, int ye) {
if (!visible)
return false;
return !((xe < ax) || (xe > ax2) || (ye < ay) || (ye > ay2));
}
-void mogltk::widget::m_event(int x, int y, mogltk::event_t event) {
+void mogltk::Widget::m_event(int x, int y, mogltk::event_t event) {
switch (event) {
case E_MOUSE_DRAG_OVER:
case E_MOUSE_END_DRAG_OVER:
@@ -483,7 +483,7 @@ void mogltk::widget::m_event(int x, int y, mogltk::event_t event) {
}
}
-bool mogltk::widget::ievent(int xe, int ye, mogltk::event_t event) {
+bool mogltk::Widget::ievent(int xe, int ye, mogltk::event_t event) {
if (prev)
if (prev->ievent(xe, ye, event))
return true;
@@ -504,22 +504,22 @@ bool mogltk::widget::ievent(int xe, int ye, mogltk::event_t event) {
return process_event(xe, ye, event);
}
-void mogltk::widget::draw() {
+void mogltk::Widget::draw() {
}
-bool mogltk::widget::process_event(int, int, mogltk::event_t) {
+bool mogltk::Widget::process_event(int, int, mogltk::event_t) {
return false;
}
-void mogltk::widget::resize_notify() {
+void mogltk::Widget::resize_notify() {
}
-mogltk::widget * mogltk::widget::create_panel() {
+mogltk::Widget * mogltk::Widget::create_panel() {
mogltk::rect r = GetDrawRect();
- return new widgets::Panel(Shaper(), this, r.x, r.y, r.w, r.h);
+ return new Widgets::Panel(Shaper(), this, r.x, r.y, r.w, r.h);
}
-void mogltk::widget::icomputeabs() {
+void mogltk::Widget::icomputeabs() {
computeabs();
if (next)
@@ -529,7 +529,7 @@ void mogltk::widget::icomputeabs() {
child->icomputeabs();
}
-void mogltk::widget::iresize_notify() {
+void mogltk::Widget::iresize_notify() {
if (next)
next->iresize_notify();
if (child)
@@ -537,31 +537,31 @@ void mogltk::widget::iresize_notify() {
resize_notify();
}
-void mogltk::widget::set_exclusive(mogltk::widget * w) {
+void mogltk::Widget::set_exclusive(mogltk::Widget * w) {
w->exclusive = this;
}
-void mogltk::widget::unset_exclusive(mogltk::widget * w) {
+void mogltk::Widget::unset_exclusive(mogltk::Widget * w) {
w->exclusive = 0;
}
-bool mogltk::widget::GetVisible() {
+bool mogltk::Widget::GetVisible() {
return visible;
}
-void mogltk::widget::SetVisible(bool _visible) {
+void mogltk::Widget::SetVisible(bool _visible) {
visible = _visible;
}
-bool mogltk::widget::GetEnabled() {
+bool mogltk::Widget::GetEnabled() {
return enabled;
}
-void mogltk::widget::SetEnabled(bool _enabled) {
+void mogltk::Widget::SetEnabled(bool _enabled) {
enabled = _enabled;
}
-void mogltk::widget::MoveOnTop() {
+void mogltk::Widget::MoveOnTop() {
if (!prev)
return;
@@ -578,10 +578,10 @@ void mogltk::widget::MoveOnTop() {
father->child = this;
}
-void mogltk::widget::check_timed_events() {
+void mogltk::Widget::check_timed_events() {
std::vector<timed_event>::iterator i;
Uint32 t = SDL_GetTicks();
- widget * w;
+ Widget * w;
for (i = timed_events.begin(); i != timed_events.end(); i++) {
if (i->t <= t) {
@@ -595,8 +595,8 @@ void mogltk::widget::check_timed_events() {
}
}
-void mogltk::widget::add_out_move() {
- std::vector<widget *>::iterator i;
+void mogltk::Widget::add_out_move() {
+ std::vector<Widget *>::iterator i;
for (i = out_move.begin(); i != out_move.end(); i++) {
if (*i == this)
@@ -606,8 +606,8 @@ void mogltk::widget::add_out_move() {
out_move.push_back(this);
}
-void mogltk::widget::remove_out_move() {
- std::vector<widget *>::iterator i;
+void mogltk::Widget::remove_out_move() {
+ std::vector<Widget *>::iterator i;
for (i = out_move.begin(); i != out_move.end(); i++) {
if (*i == this) {
@@ -617,8 +617,8 @@ void mogltk::widget::remove_out_move() {
}
}
-void mogltk::widget::add_out_click() {
- std::vector<widget *>::iterator i;
+void mogltk::Widget::add_out_click() {
+ std::vector<Widget *>::iterator i;
for (i = out_click.begin(); i != out_click.end(); i++) {
if (*i == this)
@@ -628,8 +628,8 @@ void mogltk::widget::add_out_click() {
out_click.push_back(this);
}
-void mogltk::widget::remove_out_click() {
- std::vector<widget *>::iterator i;
+void mogltk::Widget::remove_out_click() {
+ std::vector<Widget *>::iterator i;
for (i = out_click.begin(); i != out_click.end(); i++) {
if (*i == this) {
@@ -639,15 +639,15 @@ void mogltk::widget::remove_out_click() {
}
}
-void mogltk::widget::set_timed_event(Uint32 t) {
+void mogltk::Widget::set_timed_event(Uint32 t) {
timed_events.push_back(timed_event(this, SDL_GetTicks() + t));
}
-void mogltk::widget::set_absolute_timed_event(Uint32 t) {
+void mogltk::Widget::set_absolute_timed_event(Uint32 t) {
timed_events.push_back(timed_event(this, t));
}
-void mogltk::widget::center(bool cx, bool cy) {
+void mogltk::Widget::center(bool cx, bool cy) {
rect tr, fr;
tr.x = GetX();
tr.y = GetY();
@@ -665,7 +665,7 @@ void mogltk::widget::center(bool cx, bool cy) {
move(tr.x, tr.y);
}
-void mogltk::widget::delete_me() {
+void mogltk::Widget::delete_me() {
LOCK;
del_list.push_back(this);
UNLOCK;
@@ -673,36 +673,45 @@ void mogltk::widget::delete_me() {
/*
- * Predefined widgets.
+ * Predefined Widgets.
*/
/***************
* Here is Root *
***************/
-mogltk::widgets::Root::Root(mogltk::shape * sh, mogltk::widgets::drawer * _dr) : widget(0, 0, 0, 0, 0, 0, "Root", sh), dr(_dr) {
+mogltk::Widgets::Root::Root(mogltk::Shape * sh, mogltk::Widgets::drawer * _dr, mogltk::Widgets::drawer * _bg) : Widget(0, 0, 0, 0, 0, 0, "Root", sh), dr(_dr), bg(_bg) {
if (engine::root)
engine::root->delete_me();
engine::root = this;
}
-void mogltk::widgets::Root::draw() {
+void mogltk::Widgets::Root::draw() {
if (dr)
dr->draw(this);
else
Shaper()->box(GetAX(), GetAY(), GetAX2(), GetAY2());
}
-void mogltk::widgets::Root::setdrawer(drawer * _dr) {
+void mogltk::Widgets::Root::drawbg() {
+ if (bg)
+ bg->draw(this);
+}
+
+void mogltk::Widgets::Root::setdrawer(drawer * _dr) {
dr = _dr;
}
+void mogltk::Widgets::Root::setbgdrawer(drawer * _bg) {
+ bg = _bg;
+}
+
/**************************
* A simple clipping Panel *
**************************/
-mogltk::widgets::Panel::Panel(shape * sh, widget * father, int x, int y, int w, int h) : widget(father, x, y, w, h, 0, "Panel", sh) {
+mogltk::Widgets::Panel::Panel(Shape * sh, Widget * father, int x, int y, int w, int h) : Widget(father, x, y, w, h, 0, "Panel", sh) {
}
@@ -710,42 +719,42 @@ mogltk::widgets::Panel::Panel(shape * sh, widget * father, int x, int y, int w,
* The classical Button *
***********************/
-class ButtonCascadeAction : public mogltk::widgets::action {
+class ButtonCascadeAction : public mogltk::Widgets::action {
public:
- ButtonCascadeAction(mogltk::widgets::Button * _parent) : parent(_parent) { }
- virtual void do_action(mogltk::widget *) {
+ ButtonCascadeAction(mogltk::Widgets::Button * _parent) : parent(_parent) { }
+ virtual void do_action(mogltk::Widget *) {
parent->simulate_press();
}
private:
- mogltk::widgets::Button * parent;
+ mogltk::Widgets::Button * parent;
};
-mogltk::widgets::Button::Button(action * _a, shape * sh, widget * father, int x, int y, int w, int h, const String & _caption) : widget(father, x, y, w, h, 0, "Button", sh), bevel(false), dragging(false), a(_a), cascade(0) {
+mogltk::Widgets::Button::Button(action * _a, Shape * sh, Widget * father, int x, int y, int w, int h, const String & _caption) : Widget(father, x, y, w, h, 0, "Button", sh), bevel(false), dragging(false), a(_a), cascade(0) {
caption = _caption;
}
-mogltk::widgets::Button::~Button() throw (GeneralException) {
+mogltk::Widgets::Button::~Button() throw (GeneralException) {
if (cascade)
delete cascade;
}
-void mogltk::widgets::Button::draw() {
+void mogltk::Widgets::Button::draw() {
Shaper()->button(GetAX() + 1, GetAY() + 1, GetAX2() - 1, GetAY2() - 1, caption, bevel);
}
-void mogltk::widgets::Button::simulate_press() {
+void mogltk::Widgets::Button::simulate_press() {
if (a)
a->do_action(this);
}
-mogltk::widgets::action * mogltk::widgets::Button::cascade_action() {
+mogltk::Widgets::action * mogltk::Widgets::Button::cascade_action() {
if (!cascade)
cascade = new ButtonCascadeAction(this);
return cascade;
}
-bool mogltk::widgets::Button::process_event(int xe, int ye, mogltk::event_t event) {
+bool mogltk::Widgets::Button::process_event(int xe, int ye, mogltk::event_t event) {
switch (event) {
case E_MOUSE_DOWN:
bevel = true;
@@ -780,15 +789,15 @@ bool mogltk::widgets::Button::process_event(int xe, int ye, mogltk::event_t even
* The SmartBox window *
**********************/
-mogltk::widgets::SmartBox::SmartBox(shape * sh, mogltk::widget * father, int x, int y, int w, int h, const String & _caption) : widget(father, x, y, w, h, 0, "SmartBox", sh) {
+mogltk::Widgets::SmartBox::SmartBox(Shape * sh, mogltk::Widget * father, int x, int y, int w, int h, const String & _caption) : Widget(father, x, y, w, h, 0, "SmartBox", sh) {
caption = _caption;
}
-void mogltk::widgets::SmartBox::draw() {
+void mogltk::Widgets::SmartBox::draw() {
Shaper()->window(GetAX(), GetAY(), GetAX2(), GetAY2(), caption);
}
-bool mogltk::widgets::SmartBox::process_event(int x, int y, mogltk::event_t event) {
+bool mogltk::Widgets::SmartBox::process_event(int x, int y, mogltk::event_t event) {
switch (event) {
case E_MOUSE_START_DRAG:
if ((GetAY() + 20) > y) {
@@ -808,7 +817,7 @@ bool mogltk::widgets::SmartBox::process_event(int x, int y, mogltk::event_t even
return false;
}
-mogltk::rect mogltk::widgets::SmartBox::GetDrawRect() {
+mogltk::rect mogltk::Widgets::SmartBox::GetDrawRect() {
rect r;
r.x = 2;
@@ -823,19 +832,19 @@ mogltk::rect mogltk::widgets::SmartBox::GetDrawRect() {
* The SmartBox window with a close button *
******************************************/
-class SmartBoxCloseAction : public mogltk::widgets::action {
+class SmartBoxCloseAction : public mogltk::Widgets::action {
public:
- SmartBoxCloseAction(mogltk::widget * _parent) : parent(_parent) { }
- virtual void do_action(mogltk::widget *) {
+ SmartBoxCloseAction(mogltk::Widget * _parent) : parent(_parent) { }
+ virtual void do_action(mogltk::Widget *) {
parent->delete_me();
delete this;
}
private:
- mogltk::widget * parent;
+ mogltk::Widget * parent;
};
-mogltk::widgets::SmartBoxClose::SmartBoxClose(mogltk::shape * sh, mogltk::widget * father, int x, int y, int w, int h, const String & _caption) : SmartBox(sh, father, x, y, w, h, _caption) {
- new mogltk::widgets::Button(new SmartBoxCloseAction(this), sh, this, 1, 1, 16, 16, "X");
+mogltk::Widgets::SmartBoxClose::SmartBoxClose(mogltk::Shape * sh, mogltk::Widget * father, int x, int y, int w, int h, const String & _caption) : SmartBox(sh, father, x, y, w, h, _caption) {
+ new mogltk::Widgets::Button(new SmartBoxCloseAction(this), sh, this, 1, 1, 16, 16, "X");
}
@@ -843,7 +852,7 @@ mogltk::widgets::SmartBoxClose::SmartBoxClose(mogltk::shape * sh, mogltk::widget
* The MessageBox child *
***********************/
-mogltk::widgets::MsgBox::MsgBox(action * a, shape * sh, mogltk::widget * father, const String & caption, const String & text, mogltk::font * _font) : SmartBox(sh, father, 0, 0, 0, 0, caption), msgbox_font(_font) {
+mogltk::Widgets::MsgBox::MsgBox(action * a, Shape * sh, mogltk::Widget * father, const String & caption, const String & text, mogltk::Font * _font) : SmartBox(sh, father, 0, 0, 0, 0, caption), msgbox_font(_font) {
rect size = msgbox_font->size(text);
rect lsize = size;
@@ -859,7 +868,7 @@ mogltk::widgets::MsgBox::MsgBox(action * a, shape * sh, mogltk::widget * father,
set_exclusive(father);
}
-mogltk::widgets::MsgBox::~MsgBox() throw (GeneralException) {
+mogltk::Widgets::MsgBox::~MsgBox() throw (GeneralException) {
unset_exclusive(Father());
}
@@ -868,11 +877,11 @@ mogltk::widgets::MsgBox::~MsgBox() throw (GeneralException) {
* A simple Label *
*****************/
-mogltk::widgets::Label::Label(shape * sh, mogltk::widget * father, int x, int y, int w, int h, const String & _caption, const ColorP & _color, mogltk::font * _font) : widget(father, x, y, w, h, 0, "Label", sh), color(_color), label_font(_font) {
+mogltk::Widgets::Label::Label(Shape * sh, mogltk::Widget * father, int x, int y, int w, int h, const String & _caption, const ColorP & _color, mogltk::Font * _font) : Widget(father, x, y, w, h, 0, "Label", sh), color(_color), label_font(_font) {
caption = _caption;
}
-void mogltk::widgets::Label::draw() {
+void mogltk::Widgets::Label::draw() {
Shaper()->text(GetAX(), GetAY(), caption, color, LEFT, label_font);
}
@@ -881,14 +890,14 @@ void mogltk::widgets::Label::draw() {
* The classical 3D Frame *
*************************/
-mogltk::widgets::Frame::Frame(shape * sh, widget * father, int x, int y, int w, int h) : widget(father, x, y, w, h, 0, "Frame", sh) {
+mogltk::Widgets::Frame::Frame(Shape * sh, Widget * father, int x, int y, int w, int h) : Widget(father, x, y, w, h, 0, "Frame", sh) {
}
-void mogltk::widgets::Frame::draw() {
+void mogltk::Widgets::Frame::draw() {
Shaper()->obox3d(GetAX(), GetAY(), GetAX2(), GetAY2());
}
-mogltk::rect mogltk::widgets::Frame::GetDrawRect() {
+mogltk::rect mogltk::Widgets::Frame::GetDrawRect() {
rect r;
r.x = 4;
@@ -901,17 +910,21 @@ mogltk::rect mogltk::widgets::Frame::GetDrawRect() {
/*
- * The mainloop widget thing.
+ * The mainloop Widget thing.
*/
-void mogltk::widget::mainloop() {
+void mogltk::Widget::mainloop() throw (GeneralException) {
bool end_event_loop = false;
widget_mouse_event * mouse = new widget_mouse_event(this);
int mx, my;
+ if (root) {
+ throw GeneralException("Main loop can only be run on the root widget.");
+ }
+
while (!end_event_loop && !engine::quitrequested()) {
- if (root)
- root->fulldraw();
+ ((Widgets::Root *) this)->drawbg();
+ fulldraw();
mx = mogltk::engine::mouseX();
my = mogltk::engine::mouseY();
@@ -923,25 +936,25 @@ void mogltk::widget::mainloop() {
// }
engine::base_o->Flip();
- widget::check_timed_events();
+ Widget::check_timed_events();
LOCK;
- std::vector<widget *> del_list_copy = del_list;
+ std::vector<Widget *> del_list_copy = del_list;
del_list.clear();
UNLOCK;
in_delete_loop = true;
- for (std::vector<widget *>::iterator i = del_list_copy.begin(); i != del_list_copy.end(); i++) {
+ for (std::vector<Widget *>::iterator i = del_list_copy.begin(); i != del_list_copy.end(); i++) {
delete *i;
}
in_delete_loop = false;
LOCK;
- std::vector<widget *> add_list_copy = add_list;
+ std::vector<Widget *> add_list_copy = add_list;
add_list.clear();
UNLOCK;
- for (std::vector<widget *>::iterator i = add_list_copy.begin(); i != add_list_copy.end(); i++) {
+ for (std::vector<Widget *>::iterator i = add_list_copy.begin(); i != add_list_copy.end(); i++) {
(*i)->linkme();
}
}