From 45e08ccde95c84932557701235558e72cdc95f1b Mon Sep 17 00:00:00 2001 From: pixel Date: Sat, 28 Oct 2006 16:50:46 +0000 Subject: Fixing caps in class names. --- lib/LuaGL.cc | 4 +- lib/base.cc | 10 +-- lib/contextmenu.cc | 98 ++++++++++----------- lib/engine.cc | 8 +- lib/font.cc | 100 ++++++++++----------- lib/glbase.cc | 6 +- lib/glfont.cc | 4 +- lib/glshape.cc | 52 +++++------ lib/glwidgets.cc | 4 +- lib/inputtext.cc | 34 ++++---- lib/mcolor.cc | 37 +++++++- lib/shape.cc | 154 ++++++++++++++++----------------- lib/sprite.cc | 12 +-- lib/texture.cc | 66 +++++++------- lib/widgets.cc | 249 ++++++++++++++++++++++++++++------------------------- 15 files changed, 443 insertions(+), 395 deletions(-) (limited to 'lib') diff --git a/lib/LuaGL.cc b/lib/LuaGL.cc index facd6ec..9631abc 100644 --- a/lib/LuaGL.cc +++ b/lib/LuaGL.cc @@ -1017,7 +1017,7 @@ static int gl_begin(lua_State *L) return 0; } -/*BindTexture (target, texture) -> none*/ +/*BindTexture (target, Texture) -> none*/ static int gl_bind_texture(lua_State *L) { GLenum e; @@ -2998,7 +2998,7 @@ static int gl_is_list(lua_State *L) return 1; } -/*IsTexture (texture) -> true/false*/ +/*IsTexture (Texture) -> true/false*/ static int gl_is_texture(lua_State *L) { /* test argument type */ diff --git a/lib/base.cc b/lib/base.cc index db0e77f..a9d31a5 100644 --- a/lib/base.cc +++ b/lib/base.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: base.cc,v 1.16 2006-02-02 17:29:05 pixel Exp $ */ +/* $Id: base.cc,v 1.17 2006-10-28 16:50:46 pixel Exp $ */ #include #include @@ -125,7 +125,7 @@ void mogltk::base::ToggleFullscreen() { else newflags |= SDL_FULLSCREEN; - texture::Taintall(); + Texture::Taintall(); surface = SDL_SetVideoMode(surface->w, surface->h, surface->format->BitsPerPixel, SDL_HWSURFACE | newflags); @@ -147,11 +147,11 @@ inline static unsigned int nextpower(unsigned int n) { } } -mogltk::texture * mogltk::base::GrabTexture() { +mogltk::Texture * mogltk::base::GrabTexture() { int w = nextpower(GetWidth()); int h = nextpower(GetHeight()); - texture * r = new texture(w, h); - r->name = "texture grabbed"; + Texture * r = new Texture(w, h); + r->name = "Texture grabbed"; SDL_BlitSurface(getsurface(), NULL, r->GetSurface(), NULL); diff --git a/lib/contextmenu.cc b/lib/contextmenu.cc index 1c513cf..97cec1e 100644 --- a/lib/contextmenu.cc +++ b/lib/contextmenu.cc @@ -17,71 +17,71 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: contextmenu.cc,v 1.2 2006-02-02 11:01:13 pixel Exp $ */ +/* $Id: contextmenu.cc,v 1.3 2006-10-28 16:50:46 pixel Exp $ */ #include #include #include -#include "font.h" +#include "Font.h" #include "engine.h" -#include "widgets.h" +#include "Widgets.h" #include "sprite.h" /*********************************** * The huge and bloated ContextMenu * ***********************************/ -mogltk::widgets::ContextMenu::node::node(const String & _caption, int _x, int _y, int _w, int _h, mogltk::widgets::action * _a, mogltk::widgets::ContextMenu * _sub, mogltk::widgets::ContextMenu * _father, bool _line) : caption(_caption), x(_x), y(_y), w(_w), h(_h), a(_a), sub(_sub), father(_father), line(_line), enabled(true) { +mogltk::Widgets::ContextMenu::node::node(const String & _caption, int _x, int _y, int _w, int _h, mogltk::Widgets::action * _a, mogltk::Widgets::ContextMenu * _sub, mogltk::Widgets::ContextMenu * _father, bool _line) : caption(_caption), x(_x), y(_y), w(_w), h(_h), a(_a), sub(_sub), father(_father), line(_line), enabled(true) { } -String mogltk::widgets::ContextMenu::node::GetCaption() { +String mogltk::Widgets::ContextMenu::node::GetCaption() { return caption; } -mogltk::widgets::action * mogltk::widgets::ContextMenu::node::GetAction() { +mogltk::Widgets::action * mogltk::Widgets::ContextMenu::node::GetAction() { return a; } -mogltk::widgets::ContextMenu * mogltk::widgets::ContextMenu::node::GetFather() { +mogltk::Widgets::ContextMenu * mogltk::Widgets::ContextMenu::node::GetFather() { return father; } -mogltk::widgets::ContextMenu * mogltk::widgets::ContextMenu::node::GetSub() { +mogltk::Widgets::ContextMenu * mogltk::Widgets::ContextMenu::node::GetSub() { return sub; } -bool mogltk::widgets::ContextMenu::node::GetLine() { +bool mogltk::Widgets::ContextMenu::node::GetLine() { return line; } -bool mogltk::widgets::ContextMenu::node::GetEnabled() { +bool mogltk::Widgets::ContextMenu::node::GetEnabled() { return enabled; } -void mogltk::widgets::ContextMenu::node::SetEnabled(bool _enabled) { +void mogltk::Widgets::ContextMenu::node::SetEnabled(bool _enabled) { enabled = _enabled; } -int mogltk::widgets::ContextMenu::node::GetX() { +int mogltk::Widgets::ContextMenu::node::GetX() { return x; } -int mogltk::widgets::ContextMenu::node::GetY() { +int mogltk::Widgets::ContextMenu::node::GetY() { return y; } -int mogltk::widgets::ContextMenu::node::GetW() { +int mogltk::Widgets::ContextMenu::node::GetW() { return w; } -int mogltk::widgets::ContextMenu::node::GetH() { +int mogltk::Widgets::ContextMenu::node::GetH() { return h; } -mogltk::widgets::ContextMenu::ContextMenu(shape * sh, mogltk::widget * father, int x, int y) : widget(father, x, y, 8, 4, 1, "ContextMenu", sh), selected(-1), subselected(0), in_click(false), sticky(false) { +mogltk::Widgets::ContextMenu::ContextMenu(Shape * sh, mogltk::Widget * father, int x, int y) : Widget(father, x, y, 8, 4, 1, "ContextMenu", sh), selected(-1), subselected(0), in_click(false), sticky(false) { } -mogltk::widgets::ContextMenu::~ContextMenu() throw (GeneralException) { +mogltk::Widgets::ContextMenu::~ContextMenu() throw (GeneralException) { std::vector::iterator i; ContextMenu * sub; @@ -91,7 +91,7 @@ mogltk::widgets::ContextMenu::~ContextMenu() throw (GeneralException) { } } -void mogltk::widgets::ContextMenu::addnode(const String & caption, mogltk::widgets::action * a) { +void mogltk::Widgets::ContextMenu::addnode(const String & caption, mogltk::Widgets::action * a) { rect size; size = SystemFont->size(caption); @@ -102,7 +102,7 @@ void mogltk::widgets::ContextMenu::addnode(const String & caption, mogltk::widge resize(size.w, GetH() + size.h); } -void mogltk::widgets::ContextMenu::addsub(const String & caption, mogltk::widgets::ContextMenu * sub) { +void mogltk::Widgets::ContextMenu::addsub(const String & caption, mogltk::Widgets::ContextMenu * sub) { rect size; size = SystemFont->size(caption + " >"); @@ -113,12 +113,12 @@ void mogltk::widgets::ContextMenu::addsub(const String & caption, mogltk::widget resize(size.w, GetH() + size.h); } -void mogltk::widgets::ContextMenu::addline() { +void mogltk::Widgets::ContextMenu::addline() { nodes.push_back(node("", 2, GetH() - 1, 0, 0, 0, 0, this, true)); resize(GetW(), GetH() + 4); } -mogltk::widgets::ContextMenu * mogltk::widgets::ContextMenu::createsub(const String & caption) { +mogltk::Widgets::ContextMenu * mogltk::Widgets::ContextMenu::createsub(const String & caption) { ContextMenu * r; r = new ContextMenu(Shaper(), Father(), GetX() + GetW(), GetY() + GetH()); @@ -129,14 +129,14 @@ mogltk::widgets::ContextMenu * mogltk::widgets::ContextMenu::createsub(const Str return r; } -void mogltk::widgets::ContextMenu::move(int x, int y) { +void mogltk::Widgets::ContextMenu::move(int x, int y) { int dx, dy; std::vector::iterator i; ContextMenu * sub; dx = x - GetX(); dy = y - GetY(); - widget::move(x, y); + Widget::move(x, y); for (i = nodes.begin(); i != nodes.end(); i++) { if ((sub = i->GetSub())) @@ -144,13 +144,13 @@ void mogltk::widgets::ContextMenu::move(int x, int y) { } } -void mogltk::widgets::ContextMenu::resize(int w, int h) { +void mogltk::Widgets::ContextMenu::resize(int w, int h) { int dw; std::vector::iterator i; ContextMenu * sub; dw = w - GetW(); - widget::resize(w, h); + Widget::resize(w, h); for (i = nodes.begin(); i != nodes.end(); i++) { if ((sub = i->GetSub())) @@ -158,10 +158,10 @@ void mogltk::widgets::ContextMenu::resize(int w, int h) { } } -void mogltk::widgets::ContextMenu::SetVisible(bool visible) { +void mogltk::Widgets::ContextMenu::SetVisible(bool visible) { if (!visible && sticky) return; - widget::SetVisible(visible); + Widget::SetVisible(visible); if (!visible && subselected) { subselected->SetVisible(false); } @@ -172,16 +172,16 @@ void mogltk::widgets::ContextMenu::SetVisible(bool visible) { } } -void mogltk::widgets::ContextMenu::SetEnabled(int i, bool e) { +void mogltk::Widgets::ContextMenu::SetEnabled(int i, bool e) { nodes[i].SetEnabled(e); } -void mogltk::widgets::ContextMenu::StickyDisplay() { +void mogltk::Widgets::ContextMenu::StickyDisplay() { sticky = true; SetVisible(true); } -void mogltk::widgets::ContextMenu::draw() { +void mogltk::Widgets::ContextMenu::draw() { std::vector::iterator i; int n; rect size; @@ -201,7 +201,7 @@ void mogltk::widgets::ContextMenu::draw() { } } -bool mogltk::widgets::ContextMenu::process_event(int xe, int ye, mogltk::event_t event) { +bool mogltk::Widgets::ContextMenu::process_event(int xe, int ye, mogltk::event_t event) { std::vector::iterator i; action * a; int n; @@ -268,7 +268,7 @@ bool mogltk::widgets::ContextMenu::process_event(int xe, int ye, mogltk::event_t return false; } -bool mogltk::widgets::ContextMenu::iin_click() { +bool mogltk::Widgets::ContextMenu::iin_click() { if (in_click) return true; @@ -283,74 +283,74 @@ bool mogltk::widgets::ContextMenu::iin_click() { * The Menu topframe * ********************/ -mogltk::widgets::Menu::node::node(const String & _caption, mogltk::widgets::ContextMenu * _sub, mogltk::widgets::action * _a, int _x) : caption(_caption), sub(_sub), a(_a), x(_x) { +mogltk::Widgets::Menu::node::node(const String & _caption, mogltk::Widgets::ContextMenu * _sub, mogltk::Widgets::action * _a, int _x) : caption(_caption), sub(_sub), a(_a), x(_x) { } -String mogltk::widgets::Menu::node::GetCaption() { +String mogltk::Widgets::Menu::node::GetCaption() { return caption; } -void mogltk::widgets::Menu::node::SetCaption(const String & s) { +void mogltk::Widgets::Menu::node::SetCaption(const String & s) { caption = s; } -mogltk::widgets::ContextMenu * mogltk::widgets::Menu::node::GetSub() { +mogltk::Widgets::ContextMenu * mogltk::Widgets::Menu::node::GetSub() { return sub; } -mogltk::widgets::action * mogltk::widgets::Menu::node::GetAction() { +mogltk::Widgets::action * mogltk::Widgets::Menu::node::GetAction() { return a; } -int mogltk::widgets::Menu::node::GetX() { +int mogltk::Widgets::Menu::node::GetX() { return x; } -bool mogltk::widgets::Menu::node::GetEnabled() { +bool mogltk::Widgets::Menu::node::GetEnabled() { return enabled; } -void mogltk::widgets::Menu::node::SetEnabled(bool _enabled) { +void mogltk::Widgets::Menu::node::SetEnabled(bool _enabled) { enabled = _enabled; } -mogltk::widgets::Menu::Menu(shape * sh, mogltk::widget * father) : widget(father, 0, 0, 0, 0, 0, "Menu", sh), cur_x(0), selected(-1), subselected(0) { +mogltk::Widgets::Menu::Menu(Shape * sh, mogltk::Widget * father) : Widget(father, 0, 0, 0, 0, 0, "Menu", sh), cur_x(0), selected(-1), subselected(0) { rect r = father->GetDrawRect(); move(r.x, r.y); resize(r.w, 16); } -void mogltk::widgets::Menu::resize_notify() { +void mogltk::Widgets::Menu::resize_notify() { rect r = Father()->GetDrawRect(); resize(r.w, 16); } -void mogltk::widgets::Menu::addnode(const String & caption, mogltk::widgets::action * a) { +void mogltk::Widgets::Menu::addnode(const String & caption, mogltk::Widgets::action * a) { nodes.push_back(node(caption, 0, a, cur_x)); cur_x += SystemFont->singletextsize(caption) + 6; } -void mogltk::widgets::Menu::addsub(const String & caption, mogltk::widgets::ContextMenu * sub) { +void mogltk::Widgets::Menu::addsub(const String & caption, mogltk::Widgets::ContextMenu * sub) { nodes.push_back(node(caption, sub, 0, cur_x)); cur_x += SystemFont->singletextsize(caption) + 6; } -mogltk::widgets::ContextMenu * mogltk::widgets::Menu::createsub(const String & caption) { +mogltk::Widgets::ContextMenu * mogltk::Widgets::Menu::createsub(const String & caption) { ContextMenu * r = new ContextMenu(Shaper(), Father(), GetX() + cur_x, GetY() + 16); addsub(caption, r); r->SetVisible(false); return r; } -void mogltk::widgets::Menu::SetEnabled(int i, bool e) { +void mogltk::Widgets::Menu::SetEnabled(int i, bool e) { nodes[i].SetEnabled(e); } -void mogltk::widgets::Menu::SetCaption(int i, const String & s) { +void mogltk::Widgets::Menu::SetCaption(int i, const String & s) { nodes[i].SetCaption(s); } -void mogltk::widgets::Menu::draw(void) { +void mogltk::Widgets::Menu::draw(void) { std::vector::iterator i; int n; @@ -368,7 +368,7 @@ void mogltk::widgets::Menu::draw(void) { } } -bool mogltk::widgets::Menu::process_event(int mx, int my, mogltk::event_t event) { +bool mogltk::Widgets::Menu::process_event(int mx, int my, mogltk::event_t event) { std::vector::iterator i; action * a; ContextMenu * sub; diff --git a/lib/engine.cc b/lib/engine.cc index c372f0b..d49574c 100644 --- a/lib/engine.cc +++ b/lib/engine.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: engine.cc,v 1.30 2006-02-09 17:04:58 pixel Exp $ */ +/* $Id: engine.cc,v 1.31 2006-10-28 16:50:46 pixel Exp $ */ #include #include @@ -36,7 +36,7 @@ int mogltk::engine::mx, mogltk::engine::my, mogltk::engine::mz = 0, mogltk::engi int mogltk::engine::frames, mogltk::engine::locked = 0; double mogltk::engine::curfps = -1; Uint32 mogltk::engine::curticks; -mogltk::widget * mogltk::engine::root = 0; +mogltk::Widget * mogltk::engine::root = 0; mogltk::glbase * mogltk::engine::glbase_o = 0; mogltk::base * mogltk::engine::base_o = 0; @@ -142,8 +142,8 @@ int mogltk::engine::postsetup() throw(GeneralException) { mogltk::FixedFont = new mogltk::glfont(&Input("fixed-font.bin")); Sprite::Cursor = new mogltk::glSprite(&Input("cursor.rgba"), 25, 25); } else { - mogltk::SystemFont = new mogltk::font(&Input("font.bin")); - mogltk::FixedFont = new mogltk::font(&Input("fixed-font.bin")); + mogltk::SystemFont = new mogltk::Font(&Input("font.bin")); + mogltk::FixedFont = new mogltk::Font(&Input("fixed-font.bin")); Sprite::Cursor = new mogltk::Sprite(&Input("cursor.rgba"), 25, 25); } diff --git a/lib/font.cc b/lib/font.cc index fab51e4..fbd871d 100644 --- a/lib/font.cc +++ b/lib/font.cc @@ -17,13 +17,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: font.cc,v 1.18 2006-02-02 17:29:05 pixel Exp $ */ +/* $Id: font.cc,v 1.19 2006-10-28 16:50:46 pixel Exp $ */ #include #include #include #include "base.h" -#include "font.h" +#include "Font.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -35,7 +35,7 @@ Uint8 prescale2[4] = { 0, 85, 170, 255 }, prescale3[8] = { 0, 36, 72, 109, 145, /* -font file format +Font file format ================ off|siz|description @@ -93,9 +93,9 @@ match only one byte in the string. Otherwise, it should match two bytes. Variables comments ================== -nbcU = number of chars on X by texture -nbcV = number of chars on Y by texture -nbcT = number of char by texture +nbcU = number of chars on X by Texture +nbcV = number of chars on Y by Texture +nbcT = number of char by Texture nbT = number of textures */ @@ -119,7 +119,7 @@ mogltk::ColorP colorcached[16] = { DOS_HIGH_WHITE }; -mogltk::font::font(Handle * ffont) : textcolor(255, 255, 255, 255), shadow(0), wspace(0) { +mogltk::Font::Font(Handle * ffont) : textcolor(255, 255, 255, 255), shadow(0), wspace(0) { int i, j; nbentries = ffont->readU16(); @@ -140,17 +140,17 @@ mogltk::font::font(Handle * ffont) : textcolor(255, 255, 255, 255), shadow(0), w nbT++; } - printm(M_INFO, "Creating font texture: %i entries, flags = 0x%02x, maxX = %i, maxY = %i\n", nbentries, flags, maxX, maxY); - printm(M_INFO, "Which makes %i texture(s), with %i char by texture, %i on X, and %i on Y\n", nbT, nbcT, nbcU, nbcV); + printm(M_INFO, "Creating Font Texture: %i entries, flags = 0x%02x, maxX = %i, maxY = %i\n", nbentries, flags, maxX, maxY); + printm(M_INFO, "Which makes %i Texture(s), with %i char by Texture, %i on X, and %i on Y\n", nbT, nbcT, nbcU, nbcV); - fonttex = (texture **) malloc(nbT * sizeof(texture *)); + fonttex = (Texture **) malloc(nbT * sizeof(Texture *)); for (i = 0; i < 16; i++) { - fontcache[i] = (texture **) malloc(nbT * sizeof(texture *)); + fontcache[i] = (Texture **) malloc(nbT * sizeof(Texture *)); } for (i = 0; i < nbT; i++) { fonttex[i] = alloctexture(); - fonttex[i]->name = "Main font texture number " + String(i); + fonttex[i]->name = "Main Font Texture number " + String(i); for (j = 0; j < 15; j++) { fontcache[j][i] = 0; } @@ -202,7 +202,7 @@ mogltk::font::font(Handle * ffont) : textcolor(255, 255, 255, 255), shadow(0), w } } -mogltk::font::~font() { +mogltk::Font::~Font() { int i, j; for (i = 0; i < nbT; i++) for (j = 0; j < 16; j++) @@ -216,7 +216,7 @@ mogltk::font::~font() { free(sizes); } -void mogltk::font::drawentry(Uint16 entry, int x, int y, ColorP c) { +void mogltk::Font::drawentry(Uint16 entry, int x, int y, ColorP c) { bool locked = false; int trueentry, cx, cy, px, py; SDL_Rect src, dst; @@ -254,7 +254,7 @@ void mogltk::font::drawentry(Uint16 entry, int x, int y, ColorP c) { SDL_UnlockSurface(mogltk::engine::base_o->getsurface()); } -void mogltk::font::drawtotex(texture * t, Uint16 entry, int x, int y, ColorP c) { +void mogltk::Font::drawtotex(Texture * t, Uint16 entry, int x, int y, ColorP c) { bool locked = false; int trueentry, cx, cy, px, py; SDL_Rect src, dst; @@ -292,22 +292,22 @@ void mogltk::font::drawtotex(texture * t, Uint16 entry, int x, int y, ColorP c) SDL_UnlockSurface(t->GetSurface()); } -void mogltk::font::putcursor(int x, int y) { +void mogltk::Font::putcursor(int x, int y) { cx = ox = x; cy = y; } -void mogltk::font::putentry(Uint16 entry, ColorP c) { +void mogltk::Font::putentry(Uint16 entry, ColorP c) { drawentry(entry, cx, cy, c); cx += sizes[entry] + wspace; } -void mogltk::font::putentryontex(texture * t, Uint16 entry, ColorP c) { +void mogltk::Font::putentryontex(Texture * t, Uint16 entry, ColorP c) { drawtotex(t, entry, cx, cy, c); cx += sizes[entry] + wspace; } -void mogltk::font::drawchar(unsigned char ch, ColorP c) { +void mogltk::Font::drawchar(unsigned char ch, ColorP c) { Uint16 * p; int i; @@ -319,7 +319,7 @@ void mogltk::font::drawchar(unsigned char ch, ColorP c) { } } -void mogltk::font::drawcharontex(texture * t, unsigned char ch, ColorP c) { +void mogltk::Font::drawcharontex(Texture * t, unsigned char ch, ColorP c) { Uint16 * p; int i; @@ -331,7 +331,7 @@ void mogltk::font::drawcharontex(texture * t, unsigned char ch, ColorP c) { } } -int mogltk::font::findchar(unsigned char ch) const { +int mogltk::Font::findchar(unsigned char ch) const { Uint16 * p; int i; @@ -344,12 +344,12 @@ int mogltk::font::findchar(unsigned char ch) const { return -1; } -void mogltk::font::newline(void) { +void mogltk::Font::newline(void) { cx = ox; cy += inter; } -int mogltk::font::printf(const ugly_string & m, va_list ap) { +int mogltk::Font::printf(const ugly_string & m, va_list ap) { char * p; static char buffer[STRBUFSIZ + 1]; int r; @@ -371,7 +371,7 @@ int mogltk::font::printf(const ugly_string & m, va_list ap) { return r; } -int mogltk::font::printf(const ugly_string & m, ...) { +int mogltk::Font::printf(const ugly_string & m, ...) { va_list ap; int r; @@ -382,7 +382,7 @@ int mogltk::font::printf(const ugly_string & m, ...) { return r; } -int mogltk::font::printf(const char * p, ...) { +int mogltk::Font::printf(const char * p, ...) { ugly_string m; va_list ap; int r; @@ -396,7 +396,7 @@ int mogltk::font::printf(const char * p, ...) { return r; } -mogltk::rect mogltk::font::size(const ugly_string & m, va_list ap) { +mogltk::rect mogltk::Font::size(const ugly_string & m, va_list ap) { char * p; static char buffer[STRBUFSIZ + 1]; rect r; @@ -438,7 +438,7 @@ mogltk::rect mogltk::font::size(const ugly_string & m, va_list ap) { return r; } -mogltk::rect mogltk::font::size(const ugly_string & m, ...) { +mogltk::rect mogltk::Font::size(const ugly_string & m, ...) { va_list ap; rect r; @@ -449,7 +449,7 @@ mogltk::rect mogltk::font::size(const ugly_string & m, ...) { return r; } -mogltk::rect mogltk::font::size(const char * p, ...) { +mogltk::rect mogltk::Font::size(const char * p, ...) { ugly_string m; va_list ap; rect r; @@ -463,7 +463,7 @@ mogltk::rect mogltk::font::size(const char * p, ...) { return r; } -mogltk::rect mogltk::font::printtotex(texture * t, const ugly_string & m, va_list ap) { +mogltk::rect mogltk::Font::printtotex(Texture * t, const ugly_string & m, va_list ap) { char * p; static char buffer[STRBUFSIZ + 1]; rect r; @@ -513,7 +513,7 @@ mogltk::rect mogltk::font::printtotex(texture * t, const ugly_string & m, va_lis return r; } -mogltk::rect mogltk::font::printtotex(texture * t, const ugly_string & m, ...) { +mogltk::rect mogltk::Font::printtotex(Texture * t, const ugly_string & m, ...) { va_list ap; rect r; @@ -524,7 +524,7 @@ mogltk::rect mogltk::font::printtotex(texture * t, const ugly_string & m, ...) { return r; } -mogltk::rect mogltk::font::printtotex(texture * t, const char * p, ...) { +mogltk::rect mogltk::Font::printtotex(Texture * t, const char * p, ...) { ugly_string m; va_list ap; rect r; @@ -554,12 +554,12 @@ inline static unsigned int nextpower(unsigned int n) { } } -mogltk::texture * mogltk::font::printtex(rect * _r, const ugly_string & m, va_list ap) { +mogltk::Texture * mogltk::Font::printtex(rect * _r, const ugly_string & m, va_list ap) { rect r; char * p; static char buffer[STRBUFSIZ + 1]; int mw, w, pw, ph; - texture * t; + Texture * t; int ocx, ocy, oox; ocx = cx; @@ -605,8 +605,8 @@ mogltk::texture * mogltk::font::printtex(rect * _r, const ugly_string & m, va_li pw = nextpower(r.w); ph = nextpower(r.h); - t = new texture(pw, ph); - t->name = String("Text-on-texture: '") + m.p + "'"; + t = new Texture(pw, ph); + t->name = String("Text-on-Texture: '") + m.p + "'"; for (p = buffer; *p; p++) { if (*p == '\n') { @@ -622,9 +622,9 @@ mogltk::texture * mogltk::font::printtex(rect * _r, const ugly_string & m, va_li return t; } -mogltk::texture * mogltk::font::printtex(rect * r, const ugly_string & m, ...) { +mogltk::Texture * mogltk::Font::printtex(rect * r, const ugly_string & m, ...) { va_list ap; - texture * t; + Texture * t; va_start(ap, m); t = printtex(r, m, ap); @@ -633,10 +633,10 @@ mogltk::texture * mogltk::font::printtex(rect * r, const ugly_string & m, ...) { return t; } -mogltk::texture * mogltk::font::printtex(rect * r, const char * p, ...) { +mogltk::Texture * mogltk::Font::printtex(rect * r, const char * p, ...) { ugly_string m; va_list ap; - texture * t; + Texture * t; m.p = p; @@ -647,19 +647,19 @@ mogltk::texture * mogltk::font::printtex(rect * r, const char * p, ...) { return t; } -void mogltk::font::setcolor(ColorP c) { +void mogltk::Font::setcolor(ColorP c) { textcolor = c; } -void mogltk::font::setshadow(int s) { +void mogltk::Font::setshadow(int s) { shadow = s; } -void mogltk::font::setwspace(int w) { +void mogltk::Font::setwspace(int w) { wspace = w; } -int mogltk::font::singletextsize(const String & s) const { +int mogltk::Font::singletextsize(const String & s) const { unsigned int i; int r = 0; @@ -670,18 +670,18 @@ int mogltk::font::singletextsize(const String & s) const { return r; } -mogltk::font * mogltk::SystemFont; -mogltk::font * mogltk::FixedFont; +mogltk::Font * mogltk::SystemFont; +mogltk::Font * mogltk::FixedFont; -mogltk::texture * mogltk::font::alloctexture() { - return new texture(256, 256); +mogltk::Texture * mogltk::Font::alloctexture() { + return new Texture(256, 256); } -void mogltk::font::Bind(int f) { +void mogltk::Font::Bind(int f) { fonttex[f]->Bind(); } -void mogltk::font::checknbind(int index, ColorP c) { +void mogltk::Font::checknbind(int index, ColorP c) { int i, x, y; ColorP oldmax = ColorP::Max, t; ColorP::Max = c.c; @@ -693,7 +693,7 @@ void mogltk::font::checknbind(int index, ColorP c) { if (!fontcache[i][index]) { fontcache[i][index] = alloctexture(); - fontcache[i][index]->name = "Color font texture number " + String(index); + fontcache[i][index]->name = "Color Font Texture number " + String(index); for (y = 0; y < 256; y++) { for (x = 0; x < 256; x++) { t.fromSDL(fontcache[15][index]->GetPixels()[(y << 8) + x], f); diff --git a/lib/glbase.cc b/lib/glbase.cc index 89b849a..922a263 100644 --- a/lib/glbase.cc +++ b/lib/glbase.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: glbase.cc,v 1.23 2006-02-02 17:29:05 pixel Exp $ */ +/* $Id: glbase.cc,v 1.24 2006-10-28 16:50:46 pixel Exp $ */ #include #include @@ -220,10 +220,10 @@ inline static unsigned int nextpower(unsigned int n) { } } -mogltk::texture * mogltk::glbase::GrabTexture() { +mogltk::Texture * mogltk::glbase::GrabTexture() { int w = nextpower(GetWidth()); int h = nextpower(GetHeight()); - texture * r = new texture(w, h); + Texture * r = new Texture(w, h); r->name = "Texture grabbed."; SDL_Surface * t; diff --git a/lib/glfont.cc b/lib/glfont.cc index 5b28591..4bc9a0e 100644 --- a/lib/glfont.cc +++ b/lib/glfont.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: glfont.cc,v 1.25 2004-11-27 21:48:03 pixel Exp $ */ +/* $Id: glfont.cc,v 1.26 2006-10-28 16:50:46 pixel Exp $ */ #include "engine.h" #include "glbase.h" @@ -26,7 +26,7 @@ #include "config.h" #endif -mogltk::glfont::glfont(Handle * ffont) : font(ffont) { +mogltk::glfont::glfont(Handle * ffont) : Font(ffont) { } mogltk::glfont::~glfont() { diff --git a/lib/glshape.cc b/lib/glshape.cc index 8fa718e..6c0b2d9 100644 --- a/lib/glshape.cc +++ b/lib/glshape.cc @@ -17,12 +17,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: glshape.cc,v 1.16 2004-11-27 21:48:03 pixel Exp $ */ +/* $Id: glshape.cc,v 1.17 2006-10-28 16:50:46 pixel Exp $ */ #include #include "glbase.h" -#include "glshape.h" -#include "texture.h" +#include "glShape.h" +#include "Texture.h" #include "glfont.h" #include "engine.h" @@ -30,7 +30,7 @@ #define ENTERT bool was2d = Enter(false) #define LEAVE Leave(was2d) -void mogltk::glshape::box(int x1, int y1, int x2, int y2, ColorP c) { +void mogltk::glShape::box(int x1, int y1, int x2, int y2, ColorP c) { ENTER; c.Bind(); @@ -44,7 +44,7 @@ void mogltk::glshape::box(int x1, int y1, int x2, int y2, ColorP c) { LEAVE; } -void mogltk::glshape::box(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) { +void mogltk::glShape::box(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) { ENTER; glBegin(GL_TRIANGLE_STRIP); @@ -57,33 +57,33 @@ void mogltk::glshape::box(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, LEAVE; } -void mogltk::glshape::hline(int x1, int x2, int y, ColorP c1, ColorP c2) { +void mogltk::glShape::hline(int x1, int x2, int y, ColorP c1, ColorP c2) { box(x1, y, x2, y, c1, c2, c1, c2); } -void mogltk::glshape::hline(int x1, int x2, int y, ColorP c) { +void mogltk::glShape::hline(int x1, int x2, int y, ColorP c) { box(x1, y, x2, y, c, c, c, c); } -void mogltk::glshape::vline(int x, int y1, int y2, ColorP c1, ColorP c2) { +void mogltk::glShape::vline(int x, int y1, int y2, ColorP c1, ColorP c2) { box(x, y1, x, y2, c1, c1, c2, c2); } -void mogltk::glshape::vline(int x, int y1, int y2, ColorP c) { +void mogltk::glShape::vline(int x, int y1, int y2, ColorP c) { box(x, y1, x, y2, c, c, c, c); } -void mogltk::glshape::pixel(int x, int y, ColorP c) { +void mogltk::glShape::pixel(int x, int y, ColorP c) { box(x, y, x, y, c); } -void mogltk::glshape::obox(int x1, int y1, int x2, int y2, ColorP c) { +void mogltk::glShape::obox(int x1, int y1, int x2, int y2, ColorP c) { ENTER; - shape::obox(x1, y1, x2, y2, c); + Shape::obox(x1, y1, x2, y2, c); LEAVE; } -void mogltk::glshape::obox(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) { +void mogltk::glShape::obox(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) { ENTER; hline(x1, x2, y1, c1, c2); @@ -94,10 +94,10 @@ void mogltk::glshape::obox(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, LEAVE; } -void mogltk::glshape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, int tx, int ty, double f, ColorP c) { +void mogltk::glShape::tbox(mogltk::Texture * t, int x1, int y1, int x2, int y2, int tx, int ty, double f, ColorP c) { tbox(t, x1, y1, x2, y2, tx, ty, tx + (int) ((x2 - x1) * f), ty + (int) ((y2 - y1) * f), c); } -void mogltk::glshape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, int tx1, int ty1, int tx2, int ty2, ColorP c) { +void mogltk::glShape::tbox(mogltk::Texture * t, int x1, int y1, int x2, int y2, int tx1, int ty1, int tx2, int ty2, ColorP c) { ENTERT; c.Bind(); @@ -112,11 +112,11 @@ void mogltk::glshape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, LEAVE; } -void mogltk::glshape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4, int tx, int ty, double f) { +void mogltk::glShape::tbox(mogltk::Texture * t, int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4, int tx, int ty, double f) { tbox(t, x1, y1, x2, y2, c1, c2, c3, c4, tx, ty, tx + (int) ((x2 - x1) * f), ty + (int) ((y2 - y1) * f)); } -void mogltk::glshape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4, int tx1, int ty1, int tx2, int ty2) { +void mogltk::glShape::tbox(mogltk::Texture * t, int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4, int tx1, int ty1, int tx2, int ty2) { ENTERT; t->Bind(); @@ -130,7 +130,7 @@ void mogltk::glshape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, LEAVE; } -void mogltk::glshape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP shade1, ColorP shade2, int depth, bool bevel) { +void mogltk::glShape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP shade1, ColorP shade2, int depth, bool bevel) { ENTER; if (!bevel) { @@ -170,33 +170,33 @@ void mogltk::glshape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP LEAVE; } -bool mogltk::glshape::Enter(bool unbind) { +bool mogltk::glShape::Enter(bool unbind) { bool was2D = mogltk::engine::glbase_o->is2D(); if (!was2D) mogltk::engine::glbase_o->Enter2DMode(); - if (unbind) mogltk::texture::Unbind(); + if (unbind) mogltk::Texture::Unbind(); return was2D; } -bool mogltk::glshape::Enter() { +bool mogltk::glShape::Enter() { return Enter(true); } -void mogltk::glshape::Leave(bool was2D) { +void mogltk::glShape::Leave(bool was2D) { if (!was2D) mogltk::engine::glbase_o->Leave2DMode(); } -void mogltk::glshape::fdraw(fill * f, ColorP c, int sx, int sy) { +void mogltk::glShape::fdraw(Fill * f, ColorP c, int sx, int sy) { ENTERT; if (!f) return; - texture * t = f->GetTexture(); + Texture * t = f->GetTexture(); if (!t) { filldrawer * w = new filldrawer(f, t = f->Talloc(), WHITE); @@ -221,13 +221,13 @@ void mogltk::glshape::fdraw(fill * f, ColorP c, int sx, int sy) { LEAVE; } -void mogltk::glshape::sdraw(fill * f, ColorP c, int sx, int sy) { +void mogltk::glShape::sdraw(Fill * f, ColorP c, int sx, int sy) { ENTERT; if (!f) return; - texture * t = f->GetSTexture(); + Texture * t = f->GetSTexture(); if (!t) { segdrawer * w = new segdrawer(f, t = f->STalloc(), WHITE); diff --git a/lib/glwidgets.cc b/lib/glwidgets.cc index 5ff8c23..c306b73 100644 --- a/lib/glwidgets.cc +++ b/lib/glwidgets.cc @@ -17,13 +17,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: glwidgets.cc,v 1.9 2004-11-27 21:48:03 pixel Exp $ */ +/* $Id: glwidgets.cc,v 1.10 2006-10-28 16:50:46 pixel Exp $ */ #include #include #include "mcolor.h" #include "glwidgets.h" -void mogltk::widgets::glRoot::draw() { +void mogltk::Widgets::glRoot::draw() { Shaper()->box(GetAX(), GetAY(), GetAX2(), GetAY2()); } diff --git a/lib/inputtext.cc b/lib/inputtext.cc index 094f04b..9a63c07 100644 --- a/lib/inputtext.cc +++ b/lib/inputtext.cc @@ -17,41 +17,41 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: inputtext.cc,v 1.3 2006-02-02 11:01:13 pixel Exp $ */ +/* $Id: inputtext.cc,v 1.4 2006-10-28 16:50:46 pixel Exp $ */ #include #include #include -#include "font.h" +#include "Font.h" #include "engine.h" -#include "widgets.h" +#include "Widgets.h" #include "sprite.h" /********************** * The InputText entry * **********************/ -mogltk::widgets::InputText::InputText(mogltk::widgets::action * _a, shape * sh, mogltk::widget * father, int _x, int _y) : widget(father, _x, _y, 80, 20, 0, "InputText", sh), it_keyevent(0), a(_a), cursor_visible(false), cursor_pos(0) { - it_keyevent = new mogltk::widgets::InputText::inputtext_keyevent(this); +mogltk::Widgets::InputText::InputText(mogltk::Widgets::action * _a, Shape * sh, mogltk::Widget * father, int _x, int _y) : Widget(father, _x, _y, 80, 20, 0, "InputText", sh), it_keyevent(0), a(_a), cursor_visible(false), cursor_pos(0) { + it_keyevent = new mogltk::Widgets::InputText::inputtext_keyevent(this); set_timed_event(500); } -mogltk::widgets::InputText::~InputText() throw (GeneralException) { +mogltk::Widgets::InputText::~InputText() throw (GeneralException) { delete it_keyevent; } -void mogltk::widgets::InputText::activate() { +void mogltk::Widgets::InputText::activate() { if (a) a->do_action(this); } -mogltk::widgets::InputText::inputtext_keyevent::inputtext_keyevent(mogltk::widgets::InputText * _father) : father(_father) { +mogltk::Widgets::InputText::inputtext_keyevent::inputtext_keyevent(mogltk::Widgets::InputText * _father) : father(_father) { } -void mogltk::widgets::InputText::inputtext_keyevent::up(SDL_keysym k) { +void mogltk::Widgets::InputText::inputtext_keyevent::up(SDL_keysym k) { } -void mogltk::widgets::InputText::inputtext_keyevent::down(SDL_keysym k) { +void mogltk::Widgets::InputText::inputtext_keyevent::down(SDL_keysym k) { if (father->GetVisible()) { switch (k.sym) { case SDLK_BACKSPACE: @@ -78,15 +78,15 @@ void mogltk::widgets::InputText::inputtext_keyevent::down(SDL_keysym k) { } } -const String & mogltk::widgets::InputText::GetText() const{ +const String & mogltk::Widgets::InputText::GetText() const{ return text; } -void mogltk::widgets::InputText::SetText(const String & _text) { +void mogltk::Widgets::InputText::SetText(const String & _text) { text = _text; } -bool mogltk::widgets::InputText::process_event(int x, int y, mogltk::event_t event) { +bool mogltk::Widgets::InputText::process_event(int x, int y, mogltk::event_t event) { switch (event) { case E_TIMER: set_timed_event(500); @@ -96,7 +96,7 @@ bool mogltk::widgets::InputText::process_event(int x, int y, mogltk::event_t eve return false; } -void mogltk::widgets::InputText::draw() { +void mogltk::Widgets::InputText::draw() { int x = MIN(SystemFont->singletextsize(text) + GetAX() + 2, GetAX2() - 2); Shaper()->box3d(GetAX(), GetAY(), GetAX2(), GetAY2(), DOS_WHITE, DOS_HIGH_WHITE, DOS_GRAY, 2, true); @@ -111,7 +111,7 @@ void mogltk::widgets::InputText::draw() { * The InputDialog child * ************************/ -mogltk::widgets::InputDialog::InputDialog(mogltk::widgets::action * a, shape * sh, mogltk::widget * father, const String & caption, const String & text, mogltk::font * _font) : SmartBox(sh, father, 0, 0, 0, 0, caption), InputDialog_font(_font) { +mogltk::Widgets::InputDialog::InputDialog(mogltk::Widgets::action * a, Shape * sh, mogltk::Widget * father, const String & caption, const String & text, mogltk::Font * _font) : SmartBox(sh, father, 0, 0, 0, 0, caption), InputDialog_font(_font) { rect size = InputDialog_font->size(text); rect lsize = size; @@ -130,10 +130,10 @@ mogltk::widgets::InputDialog::InputDialog(mogltk::widgets::action * a, shape * s set_exclusive(father); } -mogltk::widgets::InputDialog::~InputDialog() throw (GeneralException) { +mogltk::Widgets::InputDialog::~InputDialog() throw (GeneralException) { unset_exclusive(Father()); } -String mogltk::widgets::InputDialog::GetText() { +String mogltk::Widgets::InputDialog::GetText() { return it->GetText(); } diff --git a/lib/mcolor.cc b/lib/mcolor.cc index 618ae4f..a8c6d16 100644 --- a/lib/mcolor.cc +++ b/lib/mcolor.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: mcolor.cc,v 1.9 2006-01-31 17:02:39 pixel Exp $ */ +/* $Id: mcolor.cc,v 1.10 2006-10-28 16:50:46 pixel Exp $ */ #include #include @@ -71,6 +71,41 @@ void mogltk::ColorP::fromHSV(double H, double S, double V) { c.R = R * 255; c.G = G * 255; c.B = B * 255; } +void mogltk::ColorP::toHSV(double * H, double * S, double * V) { + double R, G, B, cMAX, cMIN; + + R = ((double) c.R) / 255; + G = ((double) c.G) / 255; + B = ((double) c.B) / 255; + + cMAX = MAX(MAX(R, G), B); + cMIN = MIN(MIN(R, G), B); + + if (cMAX == cMIN) { + *H = 0; + *S = 0; + *V = cMAX; + return; + } + + if ((cMAX == R) && (G >= B)) { + *H = 60 * ((G - B) / (cMAX - cMIN)); + } else if ((cMAX == R) && (G < B)) { + *H = 60 * ((G - B) / (cMAX - cMIN)) + 360; + } else if (cMAX == G) { + *H = 60 * ((B - R) / (cMAX - cMIN)) + 120; + } else { + *H = 60 * ((R - G) / (cMAX - cMIN)) + 240; + } + + if (cMAX == 0) { + *S = 0; + } else { + *S = (cMAX - cMIN) / cMAX; + } + *V = cMAX; +} + void mogltk::ColorP::Norm() { c.R = MIN(MAX(c.R, Min.R), Max.R); c.G = MIN(MAX(c.R, Min.G), Max.G); diff --git a/lib/shape.cc b/lib/shape.cc index 63b0920..d817895 100644 --- a/lib/shape.cc +++ b/lib/shape.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: shape.cc,v 1.21 2006-02-02 17:29:05 pixel Exp $ */ +/* $Id: shape.cc,v 1.22 2006-10-28 16:50:46 pixel Exp $ */ #include #include @@ -26,9 +26,9 @@ #include #include "engine.h" #include "base.h" -#include "shape.h" -#include "texture.h" -#include "font.h" +#include "Shape.h" +#include "Texture.h" +#include "Font.h" #define ENTER bool flag = Enter() #define LEAVE Leave(flag) @@ -51,10 +51,10 @@ mogltk::segwalker::~segwalker() { void mogltk::segwalker::step(int x1, int y1, int x2, int y2) { } -mogltk::fill::fill() : minX(INT_MAX), minY(INT_MAX), maxX(INT_MIN), maxY(INT_MIN), cached(0), scached(0), header(0) { +mogltk::Fill::Fill() : minX(INT_MAX), minY(INT_MAX), maxX(INT_MIN), maxY(INT_MIN), cached(0), scached(0), header(0) { } -mogltk::fill::~fill() { +mogltk::Fill::~Fill() { if (header) delete header; @@ -65,12 +65,12 @@ mogltk::fill::~fill() { delete scached; } -void mogltk::fill::walk(fillwalker * w) { +void mogltk::Fill::walk(fillwalker * w) { if (header) header->walk(w); } -void mogltk::fill::swalk(segwalker * s) { +void mogltk::Fill::swalk(segwalker * s) { std::vector::iterator i; for (i = segments.begin(); i != segments.end(); i++) { @@ -78,7 +78,7 @@ void mogltk::fill::swalk(segwalker * s) { } } -void mogltk::fill::insert(int x, int y) { +void mogltk::Fill::insert(int x, int y) { if (cached) { delete cached; cached = 0; @@ -107,7 +107,7 @@ void mogltk::fill::insert(int x, int y) { minY = y; } -void mogltk::fill::insert(int x1, int y1, int x2, int y2) { +void mogltk::Fill::insert(int x1, int y1, int x2, int y2) { int dx, dy, y; double x, i, i2; @@ -136,38 +136,38 @@ void mogltk::fill::insert(int x1, int y1, int x2, int y2) { insert(x + i2, y); } -void mogltk::fill::insertfix(int x, int y) { +void mogltk::Fill::insertfix(int x, int y) { if (!header) return; header->insertfix(x, y); } -int mogltk::fill::GetMaxX() const { +int mogltk::Fill::GetMaxX() const { return maxX; } -int mogltk::fill::GetMaxY() const { +int mogltk::Fill::GetMaxY() const { return maxY; } -int mogltk::fill::GetMinX() const { +int mogltk::Fill::GetMinX() const { return minX; } -int mogltk::fill::GetMinY() const { +int mogltk::Fill::GetMinY() const { return minY; } -mogltk::texture * mogltk::fill::GetTexture() { +mogltk::Texture * mogltk::Fill::GetTexture() { return cached; } -mogltk::texture * mogltk::fill::GetSTexture() { +mogltk::Texture * mogltk::Fill::GetSTexture() { return scached; } -mogltk::texture * mogltk::fill::Talloc() { +mogltk::Texture * mogltk::Fill::Talloc() { if (cached) return cached; @@ -176,12 +176,12 @@ mogltk::texture * mogltk::fill::Talloc() { for (x = 1; x <= (maxX - minX); x <<= 1); for (y = 1; y <= (maxY - minY); y <<= 1); - cached = new texture(x, y, true); - cached->name = "Fill-texture - cached"; + cached = new Texture(x, y, true); + cached->name = "Fill-Texture - cached"; return cached; } -mogltk::texture * mogltk::fill::STalloc() { +mogltk::Texture * mogltk::Fill::STalloc() { if (scached) return scached; @@ -190,12 +190,12 @@ mogltk::texture * mogltk::fill::STalloc() { for (x = 1; x <= (maxX - minX); x <<= 1); for (y = 1; y <= (maxY - minY); y <<= 1); - scached = new texture(x, y, true); - cached->name = "Fill-texture - scached"; + scached = new Texture(x, y, true); + cached->name = "Fill-Texture - scached"; return scached; } -mogltk::fill::sline::sline(int _y, fill * _header) : y(_y), header(_header), pheader(0) { +mogltk::Fill::sline::sline(int _y, Fill * _header) : y(_y), header(_header), pheader(0) { if (!header->header) { header->header = this; } else { @@ -217,18 +217,18 @@ mogltk::fill::sline::sline(int _y, fill * _header) : y(_y), header(_header), phe } } -mogltk::fill::sline::~sline() { +mogltk::Fill::sline::~sline() { if (pheader) delete pheader; if (next) delete next; } -int mogltk::fill::sline::GetY() const { +int mogltk::Fill::sline::GetY() const { return y; } -void mogltk::fill::sline::insert(int ax, int ay) { +void mogltk::Fill::sline::insert(int ax, int ay) { sline * f; if (ay == y) { @@ -247,7 +247,7 @@ void mogltk::fill::sline::insert(int ax, int ay) { } } -void mogltk::fill::sline::insertfix(int ax, int ay) { +void mogltk::Fill::sline::insertfix(int ax, int ay) { sline * f; if (ay == y) { @@ -263,7 +263,7 @@ void mogltk::fill::sline::insertfix(int ax, int ay) { } } -int mogltk::fill::sline::count() const { +int mogltk::Fill::sline::count() const { int r = 0; if (next) @@ -272,14 +272,14 @@ int mogltk::fill::sline::count() const { return r + 1; } -void mogltk::fill::sline::walk(fillwalker * w) { +void mogltk::Fill::sline::walk(fillwalker * w) { if (pheader) pheader->walk(w); if (next) next->walk(w); } -mogltk::fill::sline::point::point(int _x, sline * _header) : x(_x), header(_header) { +mogltk::Fill::sline::point::point(int _x, sline * _header) : x(_x), header(_header) { if (!header->pheader) { header->pheader = this; } else { @@ -301,26 +301,26 @@ mogltk::fill::sline::point::point(int _x, sline * _header) : x(_x), header(_head } } -mogltk::fill::sline::point::~point() { +mogltk::Fill::sline::point::~point() { if (next) delete next; } -int mogltk::fill::sline::point::GetX() const { +int mogltk::Fill::sline::point::GetX() const { return x; } -int mogltk::fill::sline::point::GetY() const { +int mogltk::Fill::sline::point::GetY() const { return header->GetY(); } -void mogltk::fill::sline::point::walk(fillwalker * w) { +void mogltk::Fill::sline::point::walk(fillwalker * w) { w->step(GetX(), GetY()); if (next) next->walk(w); } -mogltk::fill::sline::point * mogltk::fill::sline::point::look(int _x) { +mogltk::Fill::sline::point * mogltk::Fill::sline::point::look(int _x) { if (x > _x) return 0; @@ -333,7 +333,7 @@ mogltk::fill::sline::point * mogltk::fill::sline::point::look(int _x) { return next->look(_x); } -mogltk::fill::sline * mogltk::fill::sline::look(int _y) { +mogltk::Fill::sline * mogltk::Fill::sline::look(int _y) { if (y > _y) return 0; @@ -346,16 +346,16 @@ mogltk::fill::sline * mogltk::fill::sline::look(int _y) { return next->look(_y); } -mogltk::shape::shape(SDL_Surface * _surf) : surf(_surf) { +mogltk::Shape::Shape(SDL_Surface * _surf) : surf(_surf) { if (!surf) surf = mogltk::engine::base_o->getsurface(); } -SDL_Surface * mogltk::shape::GetSurf() { +SDL_Surface * mogltk::Shape::GetSurf() { return surf; } -void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c) { +void mogltk::Shape::box(int x1, int y1, int x2, int y2, ColorP c) { ENTER; SDL_Rect rect; @@ -366,13 +366,13 @@ void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c) { LEAVE; } -void mogltk::shape::hline(int x1, int x2, int y, ColorP c) { +void mogltk::Shape::hline(int x1, int x2, int y, ColorP c) { for (; x1 <= x2; x1++) { pixel(x1, y, c); } } -void mogltk::shape::hline3d(int x1, int x2, int y, ColorP shade1, ColorP shade2, bool bevel) { +void mogltk::Shape::hline3d(int x1, int x2, int y, ColorP shade1, ColorP shade2, bool bevel) { ENTER; if (!bevel) { @@ -386,13 +386,13 @@ void mogltk::shape::hline3d(int x1, int x2, int y, ColorP shade1, ColorP shade2, LEAVE; } -void mogltk::shape::vline(int x, int y1, int y2, ColorP c) { +void mogltk::Shape::vline(int x, int y1, int y2, ColorP c) { for (; y1 <= y2; y1++) { pixel(x, y1, c); } } -void mogltk::shape::vline3d(int x, int y1, int y2, ColorP shade1, ColorP shade2, bool bevel) { +void mogltk::Shape::vline3d(int x, int y1, int y2, ColorP shade1, ColorP shade2, bool bevel) { ENTER; if (!bevel) { @@ -406,7 +406,7 @@ void mogltk::shape::vline3d(int x, int y1, int y2, ColorP shade1, ColorP shade2, LEAVE; } -void mogltk::shape::bsubline_1(int x1, int y1, int x2, int y2, ColorP c) { +void mogltk::Shape::bsubline_1(int x1, int y1, int x2, int y2, ColorP c) { int x, y, ddx, ddy, e; ddx = abs(x2 - x1); ddy = abs(y2 - y1) << 1; @@ -433,7 +433,7 @@ void mogltk::shape::bsubline_1(int x1, int y1, int x2, int y2, ColorP c) { LEAVE; } -void mogltk::shape::bsubline_2(int x1, int y1, int x2, int y2, ColorP c) { +void mogltk::Shape::bsubline_2(int x1, int y1, int x2, int y2, ColorP c) { int x, y, ddx, ddy, e; ddx = abs(x2 - x1) << 1; ddy = abs(y2 - y1); @@ -460,7 +460,7 @@ void mogltk::shape::bsubline_2(int x1, int y1, int x2, int y2, ColorP c) { LEAVE; } -void mogltk::shape::bsubline_3(int x1, int y1, int x2, int y2, ColorP c) { +void mogltk::Shape::bsubline_3(int x1, int y1, int x2, int y2, ColorP c) { int x, y, ddx, ddy, e; ddx = abs(x1 - x2) << 1; ddy = abs(y2 - y1); @@ -487,7 +487,7 @@ void mogltk::shape::bsubline_3(int x1, int y1, int x2, int y2, ColorP c) { LEAVE; } -void mogltk::shape::bsubline_4(int x1, int y1, int x2, int y2, ColorP c) { +void mogltk::Shape::bsubline_4(int x1, int y1, int x2, int y2, ColorP c) { int x, y, ddx, ddy, e; ddy = abs(y2 - y1) << 1; ddx = abs(x1 - x2); @@ -510,7 +510,7 @@ void mogltk::shape::bsubline_4(int x1, int y1, int x2, int y2, ColorP c) { } } -void mogltk::shape::line(int x1, int y1, int x2, int y2, ColorP c) { +void mogltk::Shape::line(int x1, int y1, int x2, int y2, ColorP c) { if ((x1 == x2) && (y1 == y2)) { printm(M_INFO, "Line is a pixel...\n"); pixel(x1, y1, c); @@ -540,7 +540,7 @@ void mogltk::shape::line(int x1, int y1, int x2, int y2, ColorP c) { } } -void mogltk::shape::pixel(int x, int y, ColorP c) { +void mogltk::Shape::pixel(int x, int y, ColorP c) { ENTER; int bpp = surf->format->BytesPerPixel; @@ -581,7 +581,7 @@ void mogltk::shape::pixel(int x, int y, ColorP c) { LEAVE; } -void mogltk::shape::circle(int x0, int y0, int r, ColorP c) { +void mogltk::Shape::circle(int x0, int y0, int r, ColorP c) { ENTER; int x = 0; @@ -614,13 +614,13 @@ void mogltk::shape::circle(int x0, int y0, int r, ColorP c) { LEAVE; } -mogltk::fill * mogltk::shape::fcircle(int x0, int y0, int r) { +mogltk::Fill * mogltk::Shape::fcircle(int x0, int y0, int r) { int x = 0; int y = r - 1; int d = 3 - 2 * r; int dI = 10 - 4 * r; int rI = 6; - mogltk::fill * f = new fill(); + mogltk::Fill * f = new Fill(); bool t = false; int ox = 0, oy = 0; @@ -664,13 +664,13 @@ mogltk::fill * mogltk::shape::fcircle(int x0, int y0, int r) { return f; } -void mogltk::shape::pcircle(int x, int y, int r, ColorP c) { - fill * f = fcircle(x, y, r); +void mogltk::Shape::pcircle(int x, int y, int r, ColorP c) { + Fill * f = fcircle(x, y, r); fdraw(f, c); delete f; } -mogltk::filldrawer::filldrawer(fill * _f, texture * _t, ColorP _c) : f(_f), t(_t), c(_c), oldx(-1), oldy(-1) { +mogltk::filldrawer::filldrawer(Fill * _f, Texture * _t, ColorP _c) : f(_f), t(_t), c(_c), oldx(-1), oldy(-1) { } mogltk::filldrawer::~filldrawer() { @@ -706,7 +706,7 @@ void mogltk::filldrawer::step(int x, int y) { oldy = y; } -void mogltk::shape::fdraw(fill * f, ColorP c, int sx, int sy) { +void mogltk::Shape::fdraw(Fill * f, ColorP c, int sx, int sy) { ENTER; if (!f) return; @@ -734,7 +734,7 @@ void mogltk::shape::fdraw(fill * f, ColorP c, int sx, int sy) { LEAVE; } -mogltk::segdrawer::segdrawer(fill * _f, texture * _t, ColorP _c) : f(_f), t(_t), c(_c), sh(new shape(_t->GetSurface())) { +mogltk::segdrawer::segdrawer(Fill * _f, Texture * _t, ColorP _c) : f(_f), t(_t), c(_c), sh(new Shape(_t->GetSurface())) { } mogltk::segdrawer::~segdrawer() { @@ -745,7 +745,7 @@ void mogltk::segdrawer::step(int x1, int y1, int x2, int y2) { sh->line(x1 - f->GetMinX(), y1 - f->GetMinY(), x2 - f->GetMinX(), y2 - f->GetMinY(), c); } -void mogltk::shape::sdraw(fill * f, ColorP c, int sx, int sy) { +void mogltk::Shape::sdraw(Fill * f, ColorP c, int sx, int sy) { ENTER; if (!f) @@ -775,7 +775,7 @@ void mogltk::shape::sdraw(fill * f, ColorP c, int sx, int sy) { LEAVE; } -void mogltk::shape::obox(int x1, int y1, int x2, int y2, ColorP c) { +void mogltk::Shape::obox(int x1, int y1, int x2, int y2, ColorP c) { ENTER; hline(x1, x2, y1, c); @@ -786,7 +786,7 @@ void mogltk::shape::obox(int x1, int y1, int x2, int y2, ColorP c) { LEAVE; } -void mogltk::shape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP shade1, ColorP shade2, int depth, bool bevel) { +void mogltk::Shape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP shade1, ColorP shade2, int depth, bool bevel) { ENTER; int i; @@ -806,7 +806,7 @@ void mogltk::shape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP sh LEAVE; } -void mogltk::shape::obox3d(int x1, int y1, int x2, int y2, ColorP shade1, ColorP shade2, bool bevel) { +void mogltk::Shape::obox3d(int x1, int y1, int x2, int y2, ColorP shade1, ColorP shade2, bool bevel) { ENTER; if (!bevel) { @@ -820,7 +820,7 @@ void mogltk::shape::obox3d(int x1, int y1, int x2, int y2, ColorP shade1, ColorP LEAVE; } -void mogltk::shape::window(int x1, int y1, int x2, int y2, const String & title, +void mogltk::Shape::window(int x1, int y1, int x2, int y2, const String & title, ColorP titlecolor, ColorP titlebackcolor, ColorP front, ColorP shade1, ColorP shade2) { ENTER; @@ -833,7 +833,7 @@ void mogltk::shape::window(int x1, int y1, int x2, int y2, const String & title, LEAVE; } -void mogltk::shape::text(int x, int y, const String & text, ColorP textcolor, align_t align, mogltk::font * _font) { +void mogltk::Shape::text(int x, int y, const String & text, ColorP textcolor, align_t align, mogltk::Font * _font) { int tsize = _font->singletextsize(text); switch (align) { case LEFT: @@ -851,9 +851,9 @@ void mogltk::shape::text(int x, int y, const String & text, ColorP textcolor, al _font->printf("%s", text.to_charp()); } -void mogltk::shape::text3d(int x, int y, const String & atext, ColorP textcolor, +void mogltk::Shape::text3d(int x, int y, const String & atext, ColorP textcolor, ColorP shade1, ColorP shade2, - align_t align, bool bevel, mogltk::font * _font) { + align_t align, bool bevel, mogltk::Font * _font) { ENTER; _font->setwspace(1); @@ -870,7 +870,7 @@ void mogltk::shape::text3d(int x, int y, const String & atext, ColorP textcolor, LEAVE; } -void mogltk::shape::button(int x1, int y1, int x2, int y2, +void mogltk::Shape::button(int x1, int y1, int x2, int y2, const String & atext, bool bevel, ColorP front, ColorP shade1, ColorP shade2, ColorP round, ColorP textcolor, @@ -891,7 +891,7 @@ void mogltk::shape::button(int x1, int y1, int x2, int y2, LEAVE; } -bool mogltk::shape::Enter() { +bool mogltk::Shape::Enter() { if (SDL_MUSTLOCK(surf)) { SDL_LockSurface(surf); return true; @@ -900,31 +900,31 @@ bool mogltk::shape::Enter() { } } -void mogltk::shape::Leave(bool locked) { +void mogltk::Shape::Leave(bool locked) { if (locked) SDL_UnlockSurface(surf); } -void mogltk::shape::tbox(texture *, int x1, int y1, int x2, int y2, int tx, int ty, double f, ColorP c) { +void mogltk::Shape::tbox(Texture *, int x1, int y1, int x2, int y2, int tx, int ty, double f, ColorP c) { } -void mogltk::shape::tbox(texture *, int x1, int y1, int x2, int y2, int tx1, int ty1, int tx2, int ty2, ColorP c) { +void mogltk::Shape::tbox(Texture *, int x1, int y1, int x2, int y2, int tx1, int ty1, int tx2, int ty2, ColorP c) { } -void mogltk::shape::tbox(texture *, int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP, int tx, int ty, double f) { +void mogltk::Shape::tbox(Texture *, int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP, int tx, int ty, double f) { } -void mogltk::shape::tbox(texture *, int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP, int tx1, int ty1, int tx2, int ty2) { +void mogltk::Shape::tbox(Texture *, int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP, int tx1, int ty1, int tx2, int ty2) { } -void mogltk::shape::vline(int x, int y1, int y2, ColorP c1, ColorP c2) { +void mogltk::Shape::vline(int x, int y1, int y2, ColorP c1, ColorP c2) { } -void mogltk::shape::hline(int x1, int x2, int y, ColorP c1, ColorP c2) { +void mogltk::Shape::hline(int x1, int x2, int y, ColorP c1, ColorP c2) { } -void mogltk::shape::box(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) { +void mogltk::Shape::box(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) { } -void mogltk::shape::obox(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) { +void mogltk::Shape::obox(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4) { } diff --git a/lib/sprite.cc b/lib/sprite.cc index bce6bf2..8b93a0f 100644 --- a/lib/sprite.cc +++ b/lib/sprite.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: sprite.cc,v 1.16 2006-02-02 17:29:05 pixel Exp $ */ +/* $Id: sprite.cc,v 1.17 2006-10-28 16:50:47 pixel Exp $ */ #include #include "engine.h" @@ -75,7 +75,7 @@ void mogltk::Sprite::alloc() { } if (!found) { - printm(M_INFO, "Allocating a new texture for sprites\n"); + printm(M_INFO, "Allocating a new Texture for sprites\n"); posx = posy = 0; p = new TexList(TEXSIZE); } @@ -84,8 +84,8 @@ void mogltk::Sprite::alloc() { } mogltk::Sprite::TexList::TexList(int size) { - tex = new texture(size, size, true); - tex->name = "Sprite texture."; + tex = new Texture(size, size, true); + tex->name = "Sprite Texture."; if (header) header->prev = this; @@ -106,11 +106,11 @@ mogltk::Sprite::TexList::~TexList() { next->prev = prev; } -const mogltk::texture * mogltk::Sprite::TexList::GetTex() const { +const mogltk::Texture * mogltk::Sprite::TexList::GetTex() const { return tex; } -mogltk::texture * mogltk::Sprite::TexList::GetTex() { +mogltk::Texture * mogltk::Sprite::TexList::GetTex() { return tex; } diff --git a/lib/texture.cc b/lib/texture.cc index aa927c8..4ba5572 100644 --- a/lib/texture.cc +++ b/lib/texture.cc @@ -17,28 +17,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: texture.cc,v 1.14 2006-02-02 17:29:05 pixel Exp $ */ +/* $Id: texture.cc,v 1.15 2006-10-28 16:50:47 pixel Exp $ */ #include #include #include #include -#include "texture.h" +#include "Texture.h" #include "engine.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "gettext.h" -mogltk::texture * mogltk::texture::header = 0; -mogltk::texture * mogltk::texture::footer = 0; +mogltk::Texture * mogltk::Texture::header = 0; +mogltk::Texture * mogltk::Texture::footer = 0; -mogltk::texture * mogltk::texture::active = 0; +mogltk::Texture * mogltk::Texture::active = 0; -mogltk::texture::texture(int w, int h, bool plane) throw (GeneralException) : width(w), height(h), +mogltk::Texture::Texture(int w, int h, bool plane) throw (GeneralException) : width(w), height(h), texture_allocated(false), planar(plane), tainted(true), taintable(true) { if ((!ISPOT(w)) || (!ISPOT(h))) - throw GeneralException(_("Size of the texture not a power of 2!")); + throw GeneralException(_("Size of the Texture not a power of 2!")); if (!(surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, #if SDL_BYTEORDER == SDL_BIG_ENDIAN @@ -69,7 +69,7 @@ mogltk::texture::texture(int w, int h, bool plane) throw (GeneralException) : wi } } -mogltk::texture::texture(Handle * h, bool plane) throw (GeneralException) : +mogltk::Texture::Texture(Handle * h, bool plane) throw (GeneralException) : texture_allocated(false), planar(plane), tainted(true), taintable(true) { SDL_Surface * temp; @@ -78,11 +78,11 @@ mogltk::texture::texture(Handle * h, bool plane) throw (GeneralException) : width = temp->w; height = temp->h; - printm(M_INFO, "Creating texture from file: size %ix%i\n", height, width); + printm(M_INFO, "Creating Texture from file: size %ix%i\n", height, width); if ((!ISPOT(width)) || (!ISPOT(height))) { SDL_FreeSurface(temp); - throw GeneralException(_("Size of the texture not a power of 2!")); + throw GeneralException(_("Size of the Texture not a power of 2!")); } SDL_PixelFormat f; @@ -115,7 +115,7 @@ mogltk::texture::texture(Handle * h, bool plane) throw (GeneralException) : f.Aloss = 0; if (!(surface = SDL_ConvertSurface(temp, &f, 0))) { - throw GeneralException("Could not convert texture to OpenGL format"); + throw GeneralException("Could not convert Texture to OpenGL format"); } SDL_FreeSurface(temp); @@ -131,16 +131,16 @@ mogltk::texture::texture(Handle * h, bool plane) throw (GeneralException) : } } -mogltk::texture::texture(SDL_Surface * temp, bool plane) throw (GeneralException) : +mogltk::Texture::Texture(SDL_Surface * temp, bool plane) throw (GeneralException) : texture_allocated(false), planar(plane), tainted(true), taintable(true) { width = temp->w; height = temp->h; - printm(M_INFO, "Creating texture from file: size %ix%i\n", height, width); + printm(M_INFO, "Creating Texture from file: size %ix%i\n", height, width); if ((!ISPOT(width)) || (!ISPOT(height))) { - throw GeneralException(_("Size of the texture not a power of 2!")); + throw GeneralException(_("Size of the Texture not a power of 2!")); } SDL_PixelFormat f; @@ -173,7 +173,7 @@ mogltk::texture::texture(SDL_Surface * temp, bool plane) throw (GeneralException f.Aloss = 0; if (!(surface = SDL_ConvertSurface(temp, &f, 0))) { - throw GeneralException("Could not convert texture to OpenGL format"); + throw GeneralException("Could not convert Texture to OpenGL format"); } next = 0; @@ -203,7 +203,7 @@ inline static unsigned int nextpower(unsigned int n) { } } -mogltk::texture::texture(int x, int y, int w, int h) : width(nextpower(w)), height(nextpower(h)), +mogltk::Texture::Texture(int x, int y, int w, int h) : width(nextpower(w)), height(nextpower(h)), texture_allocated(true), planar(false), tainted(false), taintable(false) { glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); @@ -215,7 +215,7 @@ mogltk::texture::texture(int x, int y, int w, int h) : width(nextpower(w)), heig glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, x, y, w, h); } -mogltk::texture::~texture() { +mogltk::Texture::~Texture() { if (surface) { SDL_FreeSurface(surface); } @@ -241,39 +241,39 @@ mogltk::texture::~texture() { } } -Uint32 * mogltk::texture::GetPixels() { +Uint32 * mogltk::Texture::GetPixels() { if (surface) return (Uint32 *) surface->pixels; else return 0; } -SDL_Surface * mogltk::texture::GetSurface() { +SDL_Surface * mogltk::Texture::GetSurface() { return surface; } -SDL_PixelFormat * mogltk::texture::GetFormat() { +SDL_PixelFormat * mogltk::Texture::GetFormat() { if (surface) return surface->format; else return 0; } -void mogltk::texture::Generate() { +void mogltk::Texture::Generate() { if (texture_allocated) { glDeleteTextures(1, &tex); } glGenTextures(1, &tex); - printm(M_INFO, "Generated texture " + name + " with index " + tex + "\n"); + printm(M_INFO, "Generated Texture " + name + " with index " + tex + "\n"); glBindTexture(GL_TEXTURE_2D, tex); #if 0 if (planar) { #ifdef DEBUG - printm(M_INFO, _("Generating planar texture: %i\n"), tex); + printm(M_INFO, _("Generating planar Texture: %i\n"), tex); #endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -294,7 +294,7 @@ void mogltk::texture::Generate() { tainted = false; } -void mogltk::texture::Bind(bool expand) { +void mogltk::Texture::Bind(bool expand) { if ((!texture_allocated) || tainted) Generate(); glEnable(GL_TEXTURE_2D); @@ -331,15 +331,15 @@ void mogltk::texture::Bind(bool expand) { header = this; } -GLuint mogltk::texture::GetWidth() { +GLuint mogltk::Texture::GetWidth() { return width; } -GLuint mogltk::texture::GetHeight() { +GLuint mogltk::Texture::GetHeight() { return height; } -void mogltk::texture::Unbind(void) { +void mogltk::Texture::Unbind(void) { if (active) { glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); @@ -347,9 +347,9 @@ void mogltk::texture::Unbind(void) { } } -void mogltk::texture::Taint(void) { +void mogltk::Texture::Taint(void) { if (taintable) { - printm(M_INFO, "Tainting texture " + name + "\n"); + printm(M_INFO, "Tainting Texture " + name + "\n"); tainted = true; if (active == this) Unbind(); @@ -360,13 +360,13 @@ void mogltk::texture::Taint(void) { } } -void mogltk::texture::Taintall(void) { +void mogltk::Texture::Taintall(void) { Unbind(); if (header) header->recTaint(); } -void mogltk::texture::recTaint(void) { +void mogltk::Texture::recTaint(void) { Taint(); if (next) next->recTaint(); @@ -378,7 +378,7 @@ void mogltk::texture::recTaint(void) { #define NTEX_SIGNATURE 0x5845544e #endif -SDL_Surface * mogltk::texture::LoadNTEX(Handle * h) throw (GeneralException) { +SDL_Surface * mogltk::Texture::LoadNTEX(Handle * h) throw (GeneralException) { SDL_Surface * r; char buffer[5]; Uint16 height, width; @@ -412,7 +412,7 @@ SDL_Surface * mogltk::texture::LoadNTEX(Handle * h) throw (GeneralException) { return r; } -void mogltk::texture::DumpBMP(const String & n) { +void mogltk::Texture::DumpBMP(const String & n) { if (surface) SDL_SaveBMP(surface, n.to_charp()); } 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 #include #include -#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 out_move, out_click; -std::vector mogltk::widget::timed_events; -std::vector mogltk::widget::add_list; -std::vector mogltk::widget::del_list; -bool mogltk::widget::in_delete_loop = false; +std::vector out_move, out_click; +std::vector mogltk::Widget::timed_events; +std::vector mogltk::Widget::add_list; +std::vector 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::iterator i; - std::vector out_move_stack; + std::vector::iterator i; + std::vector 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::iterator i; - std::vector out_click_stack; + std::vector::iterator i; + std::vector 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::iterator iw; - std::vector::iterator it; + std::vector::iterator iw; + std::vector::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::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::iterator i; +void mogltk::Widget::add_out_move() { + std::vector::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::iterator i; +void mogltk::Widget::remove_out_move() { + std::vector::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::iterator i; +void mogltk::Widget::add_out_click() { + std::vector::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::iterator i; +void mogltk::Widget::remove_out_click() { + std::vector::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 del_list_copy = del_list; + std::vector del_list_copy = del_list; del_list.clear(); UNLOCK; in_delete_loop = true; - for (std::vector::iterator i = del_list_copy.begin(); i != del_list_copy.end(); i++) { + for (std::vector::iterator i = del_list_copy.begin(); i != del_list_copy.end(); i++) { delete *i; } in_delete_loop = false; LOCK; - std::vector add_list_copy = add_list; + std::vector add_list_copy = add_list; add_list.clear(); UNLOCK; - for (std::vector::iterator i = add_list_copy.begin(); i != add_list_copy.end(); i++) { + for (std::vector::iterator i = add_list_copy.begin(); i != add_list_copy.end(); i++) { (*i)->linkme(); } } -- cgit v1.2.3