/* $Id$
This file is part of libmspgltk
-Copyright © 2007, 2009 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
icon = i;
}
+void Button::render_special(const Part &part) const
+{
+ if(part.get_name()=="text")
+ text.render(part, geom);
+ if(part.get_name()=="icon" && icon)
+ {
+ Geometry rgeom;
+ rgeom.w = icon->get_width();
+ rgeom.h = icon->get_height();
+ part.get_alignment().apply(rgeom, geom, part.get_margin());
+
+ icon->bind();
+ GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
+ imm.color(1.0f, 1.0f, 1.0f);
+ imm.begin(GL::QUADS);
+ imm.texcoord(0, 0);
+ imm.vertex(rgeom.x, rgeom.y);
+ imm.texcoord(1, 0);
+ imm.vertex(rgeom.x+rgeom.w, rgeom.y);
+ imm.texcoord(1, 1);
+ imm.vertex(rgeom.x+rgeom.w, rgeom.y+rgeom.h);
+ imm.texcoord(0, 1);
+ imm.vertex(rgeom.x, rgeom.y+rgeom.h);
+ imm.end();
+ GL::Texture::unbind();
+ }
+}
+
void Button::button_press(int, int, unsigned btn)
{
if(btn==1)
}
}
-void Button::render_special(const Part &part) const
-{
- if(part.get_name()=="text")
- text.render(part, geom);
- if(part.get_name()=="icon" && icon)
- {
- Geometry rgeom;
- rgeom.w = icon->get_width();
- rgeom.h = icon->get_height();
- part.get_alignment().apply(rgeom, geom, part.get_margin());
-
- icon->bind();
- GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
- imm.color(1.0f, 1.0f, 1.0f);
- imm.begin(GL::QUADS);
- imm.texcoord(0, 0);
- imm.vertex(rgeom.x, rgeom.y);
- imm.texcoord(1, 0);
- imm.vertex(rgeom.x+rgeom.w, rgeom.y);
- imm.texcoord(1, 1);
- imm.vertex(rgeom.x+rgeom.w, rgeom.y+rgeom.h);
- imm.texcoord(0, 1);
- imm.vertex(rgeom.x, rgeom.y+rgeom.h);
- imm.end();
- GL::Texture::unbind();
- }
-}
-
void Button::on_style_change()
{
text.set_style(style);
/* $Id$
This file is part of libmspgltk
-Copyright © 2007, 2009 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
void text(const std::string &);
};
+ sigc::signal<void> signal_clicked;
+
private:
Text text;
const GL::Texture2D *icon;
bool pressed;
public:
- sigc::signal<void> signal_clicked;
-
Button(const std::string & = std::string());
+ virtual const char *get_class() const { return "button"; }
+
void set_text(const std::string &);
void set_icon(const GL::Texture2D *);
+
+private:
+ virtual void render_special(const Part &) const;
+
+public:
virtual void button_press(int, int, unsigned);
virtual void button_release(int, int, unsigned);
virtual void pointer_motion(int, int);
private:
- virtual const char *get_class() const { return "button"; }
- virtual void render_special(const Part &) const;
-
virtual void on_style_change();
};
/* $Id$
This file is part of libmspgltk
-Copyright © 2009 Mikko Rasa, Mikkosoft Productions
+Copyright © 2009-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
void Container::add(Widget &wdg)
{
- set_parent(wdg, this);
+ wdg.set_parent(this);
children.push_back(create_child(&wdg));
}
for(list<Child *>::iterator i=children.begin(); i!=children.end(); ++i)
if((*i)->widget==&wdg)
{
- set_parent(wdg, 0);
+ wdg.set_parent(0);
delete *i;
children.erase(i);
return;
throw InvalidState("That Widget is not in this Container");
}
+Container::Child *Container::create_child(Widget *wdg)
+{
+ return new Child(*this, wdg);
+}
+
list<Widget *> Container::get_children() const
{
list<Widget *> result;
click_focus = 0;
}
-Container::Child *Container::create_child(Widget *wdg)
-{
- return new Child(*this, wdg);
-}
-
void Container::on_reparent()
{
for(list<Child *>::iterator i=children.begin(); i!=children.end(); ++i)
{
if(Container *c = dynamic_cast<Container *>((*i)->widget))
c->on_reparent();
- update_style(*(*i)->widget);
+ (*i)->widget->update_style();
}
}
/* $Id$
This file is part of libmspgltk
-Copyright © 2009 Mikko Rasa, Mikkosoft Productions
+Copyright © 2009-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
void add(Widget &);
void remove(Widget &);
+protected:
+ virtual Child *create_child(Widget *);
+public:
std::list<Widget *> get_children() const;
Widget *get_child_at(int, int);
Widget *get_descendant_at(int, int);
virtual void pointer_motion(int, int);
virtual void pointer_leave();
protected:
- virtual Child *create_child(Widget *);
virtual void on_reparent();
};
/* $Id$
This file is part of libmspgltk
-Copyright © 2010 Mikko Rasa, Mikkosoft Productions
+Copyright © 2010-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
*/
class Dialog: public Panel
{
+public:
+ sigc::signal<void, int> signal_response;
+
private:
bool stale;
public:
- sigc::signal<void, int> signal_response;
-
Dialog();
/** Adds an action button to the dialog. Pressing the button will invoke
/* $Id$
This file is part of libmspgltk
-Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
return list.get_selected_index();
}
+void Dropdown::render_special(const Part &part) const
+{
+ if(part.get_name()=="text")
+ {
+ if(list.get_selected_index()>=0)
+ Text(*style, list.get_selected()).render(part, geom);
+ }
+ else if(part.get_name()=="list" && dropped)
+ list.render();
+}
+
void Dropdown::button_press(int x, int y, unsigned btn)
{
if(dropped)
}
}
-void Dropdown::render_special(const Part &part) const
-{
- if(part.get_name()=="text")
- {
- if(list.get_selected_index()>=0)
- Text(*style, list.get_selected()).render(part, geom);
- }
- else if(part.get_name()=="list" && dropped)
- list.render();
-}
-
void Dropdown::on_geometry_change()
{
resize_list();
/* $Id$
This file is part of libmspgltk
-Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
void item(const std::string &);
};
+ sigc::signal<void, int, const std::string &> signal_item_selected;
+
private:
List list;
bool dropped;
public:
- sigc::signal<void, int, const std::string &> signal_item_selected;
-
Dropdown();
+ virtual const char *get_class() const { return "dropdown"; }
+
void append(const std::string &);
void insert(unsigned, const std::string &);
void remove(unsigned);
const std::string &get_selected() const;
int get_selected_index() const;
- virtual void button_press(int, int, unsigned);
-
private:
- virtual const char *get_class() const { return "dropdown"; }
virtual void render_special(const Part &) const;
+public:
+ virtual void button_press(int, int, unsigned);
+private:
virtual void on_geometry_change();
virtual void on_style_change();
- void resize_list();
+ void resize_list();
void list_item_selected(unsigned, const std::string &);
};
/* $Id$
This file is part of libmspgltk
-Copyright © 2007-2010 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
}
}
+void Entry::render_special(const Part &part) const
+{
+ if(part.get_name()=="text")
+ text.render(part, geom, first_row);
+ else if(part.get_name()=="cursor")
+ {
+ if(!text_part || !part.get_graphic(state))
+ return;
+
+ unsigned row, col;
+ text.offset_to_coords(edit_pos, row, col);
+
+ if(row<first_row || row>=first_row+visible_rows)
+ return;
+
+ Geometry rgeom = text.coords_to_geometry(*text_part, geom, first_row, row, col);
+
+ GL::push_matrix();
+ GL::translate(rgeom.x, rgeom.y, 0);
+ part.get_graphic(state)->render(part.get_geometry().w, part.get_geometry().h);
+ GL::pop_matrix();
+ }
+ else if(part.get_name()=="slider")
+ slider->render();
+}
+
void Entry::key_press(unsigned key, unsigned, wchar_t ch)
{
if(key==Input::KEY_LEFT)
}
}
-void Entry::render_special(const Part &part) const
-{
- if(part.get_name()=="text")
- text.render(part, geom, first_row);
- else if(part.get_name()=="cursor")
- {
- if(!text_part || !part.get_graphic(state))
- return;
-
- unsigned row, col;
- text.offset_to_coords(edit_pos, row, col);
-
- if(row<first_row || row>=first_row+visible_rows)
- return;
-
- Geometry rgeom = text.coords_to_geometry(*text_part, geom, first_row, row, col);
-
- GL::push_matrix();
- GL::translate(rgeom.x, rgeom.y, 0);
- part.get_graphic(state)->render(part.get_geometry().w, part.get_geometry().h);
- GL::pop_matrix();
- }
- else if(part.get_name()=="slider")
- slider->render();
-}
-
void Entry::on_geometry_change()
{
reposition_slider();
}
}
-void Entry::slider_value_changed(double value)
-{
- if(text.get_n_lines()>visible_rows)
- first_row = text.get_n_lines()-visible_rows-static_cast<unsigned>(value);
-}
-
void Entry::check_view_range()
{
if(!multiline || !text_part)
}
}
+void Entry::slider_value_changed(double value)
+{
+ if(text.get_n_lines()>visible_rows)
+ first_row = text.get_n_lines()-visible_rows-static_cast<unsigned>(value);
+}
+
Entry::Loader::Loader(Entry &ent):
Widget::Loader(ent)
/* $Id$
This file is part of libmspgltk
-Copyright © 2007-2010 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
Loader(Entry &);
};
+ sigc::signal<void> signal_enter;
+
private:
Text text;
bool multiline;
VSlider *slider;
public:
- sigc::signal<void> signal_enter;
-
Entry(const std::string & = std::string());
+ virtual const char *get_class() const { return "entry"; }
+
void set_text(const std::string &);
const std::string &get_text() const { return text.get(); }
void set_multiline(bool);
bool is_multiline() const { return multiline; }
- virtual void key_press(unsigned, unsigned, wchar_t);
private:
- virtual const char *get_class() const { return "entry"; }
virtual void render_special(const Part &) const;
+public:
+ virtual void key_press(unsigned, unsigned, wchar_t);
+private:
virtual void on_geometry_change();
virtual void on_style_change();
+
void reposition_slider();
- void slider_value_changed(double);
void check_view_range();
+ void slider_value_changed(double);
};
} // namespace GLtk
/* $Id$
This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2008, 2010-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
slider_size(1)
{ }
+void HSlider::render_special(const Part &part) const
+{
+ if(part.get_name()=="slider")
+ {
+ Alignment align = part.get_alignment();
+ if(max>min)
+ align.x = (value-min)/(max-min);
+
+ Geometry pgeom = part.get_geometry();
+ align.apply(pgeom, geom, part.get_margin());
+
+ GL::push_matrix();
+ GL::translate(pgeom.x, pgeom.y, 0);
+ part.get_graphic(state)->render(pgeom.w, pgeom.h);
+ GL::pop_matrix();
+ }
+}
+
void HSlider::button_press(int x, int y, unsigned btn)
{
if(btn==1 && geom.is_inside_relative(x, y) && max>min)
drag(x);
}
-void HSlider::render_special(const Part &part) const
-{
- if(part.get_name()=="slider")
- {
- Alignment align = part.get_alignment();
- if(max>min)
- align.x = (value-min)/(max-min);
-
- Geometry pgeom = part.get_geometry();
- align.apply(pgeom, geom, part.get_margin());
-
- GL::push_matrix();
- GL::translate(pgeom.x, pgeom.y, 0);
- part.get_graphic(state)->render(pgeom.w, pgeom.h);
- GL::pop_matrix();
- }
-}
-
void HSlider::on_geometry_change()
{
drag_area_size = geom.w-slider_size;
/* $Id$
This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007, 2010-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
public:
HSlider();
+
+ virtual const char *get_class() const { return "hslider"; }
+
+private:
+ virtual void render_special(const Part &) const;
+
+public:
virtual void button_press(int, int, unsigned);
virtual void button_release(int, int, unsigned);
virtual void pointer_motion(int, int);
private:
- virtual const char *get_class() const { return "hslider"; }
- virtual void render_special(const Part &) const;
-
virtual void on_geometry_change();
virtual void on_style_change();
};
/* $Id$
This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2010-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
public:
Image(const GL::Texture2D * = 0);
+ virtual const char *get_class() const { return "image"; }
+
void set_image(const GL::Texture2D *);
void set_keep_aspect(bool);
+
private:
- virtual const char *get_class() const { return "image"; }
virtual void render_special(const Part &) const;
};
/* $Id$
This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007, 2010-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
{
public:
Indicator();
- void set_active(bool);
-private:
+
virtual const char *get_class() const { return "indicator"; }
+
+ void set_active(bool);
};
} // namespace GLtk
/* $Id$
This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007, 2009-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
public:
Label(const std::string & = std::string());
+ virtual const char *get_class() const { return "label"; }
+
virtual void autosize();
void set_text(const std::string &);
private:
- virtual const char *get_class() const { return "label"; }
virtual void render_special(const Part &) const;
virtual void on_style_change();
/* $Id$
This file is part of libmspgltk
-Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
return items[sel_index];
}
-void List::button_press(int x, int y, unsigned btn)
-{
- Container::button_press(x, y, btn);
- if(!click_focus && btn==1)
- {
- if(items_part)
- y += items_part->get_margin().top;
-
- unsigned i = (geom.h-1-y)/row_height;
- if(i<n_visible && first+i<items.size())
- {
- sel_index = first+i;
-
- signal_item_selected.emit(sel_index, items[sel_index]);
- }
- }
-}
-
void List::render_special(const Part &part) const
{
if(part.get_name()=="items")
slider.render();
}
+void List::button_press(int x, int y, unsigned btn)
+{
+ Container::button_press(x, y, btn);
+ if(!click_focus && btn==1)
+ {
+ if(items_part)
+ y += items_part->get_margin().top;
+
+ unsigned i = (geom.h-1-y)/row_height;
+ if(i<n_visible && first+i<items.size())
+ {
+ sel_index = first+i;
+
+ signal_item_selected.emit(sel_index, items[sel_index]);
+ }
+ }
+}
+
void List::on_geometry_change()
{
reposition_slider();
/* $Id$
This file is part of libmspgltk
-Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
void item(const std::string &);
};
+ sigc::signal<void, unsigned, const std::string &> signal_item_selected;
+
private:
std::vector<std::string> items;
int sel_index;
VSlider slider;
public:
- sigc::signal<void, unsigned, const std::string &> signal_item_selected;
-
List();
+ virtual const char *get_class() const { return "list"; }
+
virtual void autosize();
void append(const std::string &);
const std::string &get_selected() const;
int get_selected_index() const { return sel_index; }
- virtual void button_press(int, int, unsigned);
-
private:
- virtual const char *get_class() const { return "list"; }
virtual void render_special(const Part &) const;
+public:
+ virtual void button_press(int, int, unsigned);
+private:
virtual void on_geometry_change();
virtual void on_style_change();
+
void reposition_slider();
void check_view_range();
void slider_value_changed(double);
/* $Id$
This file is part of libmspgltk
-Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
input_focus(0)
{ }
+Panel::Child *Panel::create_child(Widget *wdg)
+{
+ return new Child(*this, wdg);
+}
+
void Panel::raise(Widget &wdg)
{
for(list<Container::Child *>::iterator i=children.begin(); i!=children.end(); ++i)
return input_focus;
}
+void Panel::render_special(const Part &part) const
+{
+ if(part.get_name()=="children")
+ {
+ for(list<Container::Child *>::const_iterator i=children.begin(); i!=children.end(); ++i)
+ if((*i)->widget->is_visible())
+ (*i)->widget->render();
+ }
+}
+
void Panel::button_press(int x, int y, unsigned btn)
{
if(pointer_grabbed)
set_input_focus(0);
}
-void Panel::render_special(const Part &part) const
-{
- if(part.get_name()=="children")
- {
- for(list<Container::Child *>::const_iterator i=children.begin(); i!=children.end(); ++i)
- if((*i)->widget->is_visible())
- (*i)->widget->render();
- }
-}
-
-Panel::Child *Panel::create_child(Widget *wdg)
-{
- return new Child(*this, wdg);
-}
-
void Panel::set_pointer_focus(Widget *wdg)
{
if(wdg!=pointer_focus)
/* $Id$
This file is part of libmspgltk
-Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
public:
Panel();
+ virtual const char *get_class() const { return "panel"; }
+
+protected:
+ virtual Child *create_child(Widget *);
+
+public:
void raise(Widget &);
Widget *get_input_focus() const { return input_focus; }
Widget *get_final_input_focus() const;
+protected:
+ virtual void render_special(const Part &) const;
+
+public:
virtual void button_press(int, int, unsigned);
virtual void button_release(int, int, unsigned);
virtual void pointer_motion(int, int);
virtual void key_press(unsigned, unsigned, wchar_t);
virtual void key_release(unsigned, unsigned);
virtual void focus_out();
-protected:
- virtual const char *get_class() const { return "panel"; }
- virtual void render_special(const Part &) const;
- virtual Child *create_child(Widget *);
+protected:
void set_pointer_focus(Widget *);
void set_input_focus(Widget *);
};
/* $Id$
This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007, 2010-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
Slider &get_object() const;
};
+ sigc::signal<void, double> signal_value_changed;
+
protected:
double min, max;
double value;
double drag_start_value;
unsigned drag_area_size;
-public:
- sigc::signal<void, double> signal_value_changed;
-
-protected:
Slider();
+
public:
void set_value(double);
void set_range(double, double);
void set_step(double);
double get_value() const { return value; }
+
protected:
void start_drag(int);
void drag(int);
/* $Id$
This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
exclude_siblings();
}
+void Toggle::exclude_siblings()
+{
+ const list<Widget *> &siblings = parent->get_children();
+ for(list<Widget *>::const_iterator i=siblings.begin(); i!=siblings.end(); ++i)
+ if(Toggle *tgl = dynamic_cast<Toggle *>(*i))
+ if(tgl!=this && tgl->get_exclusive() && tgl->get_value())
+ tgl->set_value(false);
+}
+
void Toggle::set_value(bool v)
{
value = v;
state &= ~ACTIVE;
}
+void Toggle::render_special(const Part &part) const
+{
+ if(part.get_name()=="text")
+ text.render(part, geom);
+}
+
void Toggle::button_press(int, int, unsigned btn)
{
if(btn==1)
}
}
-void Toggle::render_special(const Part &part) const
-{
- if(part.get_name()=="text")
- text.render(part, geom);
-}
-
-void Toggle::exclude_siblings()
-{
- const list<Widget *> &siblings = parent->get_children();
- for(list<Widget *>::const_iterator i=siblings.begin(); i!=siblings.end(); ++i)
- if(Toggle *tgl = dynamic_cast<Toggle *>(*i))
- if(tgl!=this && tgl->get_exclusive() && tgl->get_value())
- tgl->set_value(false);
-}
-
void Toggle::on_style_change()
{
text.set_style(style);
/* $Id$
This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
void text(const std::string &);
};
+ sigc::signal<void, bool> signal_toggled;
+
private:
Text text;
bool pressed;
bool exclusive;
public:
- sigc::signal<void, bool> signal_toggled;
-
Toggle(const std::string & = std::string());
+ virtual const char *get_class() const { return "toggle"; }
+
void set_text(const std::string &);
void set_exclusive(bool);
bool get_exclusive() const { return exclusive; }
+private:
+ void exclude_siblings();
+public:
void set_value(bool);
bool get_value() const { return value; }
- virtual void button_press(int, int, unsigned);
- virtual void button_release(int, int, unsigned);
private:
- virtual const char *get_class() const { return "toggle"; }
virtual void render_special(const Part &) const;
- void exclude_siblings();
-
+public:
+ virtual void button_press(int, int, unsigned);
+ virtual void button_release(int, int, unsigned);
+private:
virtual void on_style_change();
};
/* $Id$
This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2008, 2010-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
VSlider::VSlider():
slider_size(1)
+{ }
+
+void VSlider::render_special(const Part &part) const
{
+ if(part.get_name()=="slider")
+ {
+ Alignment align = part.get_alignment();
+ if(max>min)
+ align.y = (value-min)/(max-min);
+
+ Geometry pgeom = part.get_geometry();
+ align.apply(pgeom, geom, part.get_margin());
+
+ GL::push_matrix();
+ GL::translate(pgeom.x, pgeom.y, 0);
+ part.get_graphic(state)->render(pgeom.w, pgeom.h);
+ GL::pop_matrix();
+ }
}
void VSlider::button_press(int x, int y, unsigned btn)
drag(y);
}
-void VSlider::render_special(const Part &part) const
-{
- if(part.get_name()=="slider")
- {
- Alignment align = part.get_alignment();
- if(max>min)
- align.y = (value-min)/(max-min);
-
- Geometry pgeom = part.get_geometry();
- align.apply(pgeom, geom, part.get_margin());
-
- GL::push_matrix();
- GL::translate(pgeom.x, pgeom.y, 0);
- part.get_graphic(state)->render(pgeom.w, pgeom.h);
- GL::pop_matrix();
- }
-}
-
void VSlider::on_geometry_change()
{
drag_area_size = geom.h-slider_size;
/* $Id$
This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007, 2010-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
public:
VSlider();
+
+ virtual const char *get_class() const { return "vslider"; }
+
+private:
+ virtual void render_special(const Part &) const;
+
+public:
virtual void button_press(int, int, unsigned);
virtual void button_release(int, int, unsigned);
virtual void pointer_motion(int, int);
private:
- virtual const char *get_class() const { return "vslider"; }
- virtual void render_special(const Part &) const;
-
virtual void on_geometry_change();
virtual void on_style_change();
};
/* $Id$
This file is part of libmspgltk
-Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
on_geometry_change();
}
+void Widget::set_parent(Container *p)
+{
+ if(parent && p)
+ throw InvalidState("Widget is already in a Container");
+ parent = p;
+
+ on_reparent();
+ update_style();
+}
+
void Widget::set_style(const string &s)
{
style_name = s;
update_style();
}
+void Widget::update_style()
+{
+ Widget *top;
+ for(top=this; top->parent; top=top->parent) ;
+ Root *root = dynamic_cast<Root *>(top);
+ if(!root)
+ style = 0;
+ else
+ {
+ string sname = get_class();
+ if(!style_name.empty())
+ {
+ sname += '-';
+ sname += style_name;
+ }
+
+ style = root->get_resources().get<Style>(sname);
+ }
+
+ on_style_change();
+}
+
void Widget::set_tooltip(const string &t)
{
tooltip = t;
state &= ~FOCUS;
}
-void Widget::update_style()
-{
- Widget *top;
- for(top=this; top->parent; top=top->parent) ;
- Root *root = dynamic_cast<Root *>(top);
- if(!root)
- style = 0;
- else
- {
- string sname = get_class();
- if(!style_name.empty())
- {
- sname += '-';
- sname += style_name;
- }
-
- style = root->get_resources().get<Style>(sname);
- }
-
- on_style_change();
-}
-
-void Widget::update_style(Widget &w)
-{
- w.update_style();
-}
-
-void Widget::set_parent(Container *p)
-{
- if(parent && p)
- throw InvalidState("Widget is already in a Container");
- parent = p;
-
- on_reparent();
- update_style();
-}
-
-void Widget::set_parent(Widget &w, Container *p)
-{
- w.set_parent(p);
-}
-
Widget::Loader::Loader(Widget &w):
wdg(w)
/* $Id$
This file is part of libmspgltk
-Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
*/
class Widget
{
+ friend class Container;
+
public:
class Loader: public Msp::DataFile::Loader
{
public:
virtual ~Widget();
+ /**
+ Returns the name of the widget class. Used for style lookup.
+ */
+ virtual const char *get_class() const { return "widget"; }
+
void set_position(int, int);
void set_size(unsigned, unsigned);
virtual void autosize() { }
void set_geometry(const Geometry &);
const Geometry &get_geometry() const { return geom; }
+protected:
+ /**
+ Sets the widget's parent Container. The widget must be unparented when
+ calling this function with a non-null parameter.
+ */
+ void set_parent(Container *);
+
+public:
/**
Sets the widget style. The final style name is constructed by concatenating
the widget class and the style name with a dash.
void set_style(const std::string &);
const Style &get_style() const { return *style; }
+protected:
+ /**
+ Gets a style object from the resource collection based on the class and
+ style names of the widget.
+ */
+ void update_style();
+
+public:
void set_tooltip(const std::string &);
const std::string &get_tooltip() const { return tooltip; }
virtual void key_release(unsigned, unsigned) { }
virtual void focus_in();
virtual void focus_out();
-
protected:
- /**
- Returns the name of the widget class. Used for style lookup.
- */
- virtual const char *get_class() const { return "widget"; }
-
- /**
- Gets a style object from the resource collection based on the class and
- style names of the widget.
- */
- void update_style();
-
- static void update_style(Widget &);
-
- /**
- Sets the widget's parent Panel. The widget must be unparented when calling
- this function with a nonzero parameter.
- */
- void set_parent(Container *);
-
- /**
- A helper function to set the parent of another widget.
- */
- static void set_parent(Widget &, Container *);
-
- // More events
virtual void on_geometry_change() { }
virtual void on_style_change() { }
virtual void on_reparent() { }