From: Mikko Rasa Date: Tue, 27 Nov 2007 08:41:36 +0000 (+0000) Subject: Reorder class members X-Git-Tag: 0.9~25 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c2635c5a3dca6a6cea5562fd387beb0662b18cf0;p=libs%2Fgltk.git Reorder class members Add Id tags to all files Add basic documentation to all classes --- diff --git a/Build b/Build index b7bffe4..c0dcafc 100644 --- a/Build +++ b/Build @@ -1,3 +1,5 @@ +/* $Id$ */ + package "mspgltk" { require "mspgl"; diff --git a/source/alignment.cpp b/source/alignment.cpp index bb5d392..110aa09 100644 --- a/source/alignment.cpp +++ b/source/alignment.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include #include "alignment.h" #include "geometry.h" diff --git a/source/alignment.h b/source/alignment.h index c89148d..56d6766 100644 --- a/source/alignment.h +++ b/source/alignment.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_ALIGNMENT_H_ #define MSP_GLTK_ALIGNMENT_H_ diff --git a/source/button.cpp b/source/button.cpp index 543782e..f078ca6 100644 --- a/source/button.cpp +++ b/source/button.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include "button.h" #include "part.h" diff --git a/source/button.h b/source/button.h index 841786c..bd81841 100644 --- a/source/button.h +++ b/source/button.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_BUTTON_H_ #define MSP_GLTK_BUTTON_H_ @@ -7,6 +14,10 @@ namespace Msp { namespace GLtk { +/** +A clickable button widget. Buttons can have a text label, which is displayed +in a spacial part "text". +*/ class Button: public Widget { public: @@ -17,6 +28,11 @@ public: Button &get_object() const; }; +private + std::string text; + bool pressed; + +public: sigc::signal signal_clicked; Button(const Resources &, const std::string & =std::string()); @@ -26,9 +42,6 @@ public: void pointer_enter(); void pointer_leave(); private: - std::string text; - bool pressed; - const char *get_class() const { return "button"; } void render_part(const Part &) const; }; diff --git a/source/entry.cpp b/source/entry.cpp index 65bae72..2c9b9d6 100644 --- a/source/entry.cpp +++ b/source/entry.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include #include #include diff --git a/source/entry.h b/source/entry.h index 2c9c314..bd986c2 100644 --- a/source/entry.h +++ b/source/entry.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_ENTRY_H_ #define MSP_GLTK_ENTRY_H_ @@ -6,19 +13,30 @@ namespace Msp { namespace GLtk { +/** +Text entry field. + +Special parts: + + text The current text of the widget. Graphics are ignored. + cursor Indicates the current input position. Fill_x is ignored. +*/ class Entry: public Widget { +private: + std::string text; + unsigned edit_pos; + public: Entry(const Resources &, const std::string & =std::string()); + void set_text(const std::string &); const std::string &get_text() const { return text; } + void key_press(unsigned, unsigned, wchar_t); void focus_in(); void focus_out(); private: - std::string text; - unsigned edit_pos; - const char *get_class() const { return "entry"; } void render_part(const Part &) const; }; diff --git a/source/geometry.cpp b/source/geometry.cpp index d7a0756..6183928 100644 --- a/source/geometry.cpp +++ b/source/geometry.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include "geometry.h" namespace Msp { diff --git a/source/geometry.h b/source/geometry.h index fdef8ac..6dc9827 100644 --- a/source/geometry.h +++ b/source/geometry.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_GEOMETRY_H_ #define MSP_GLTK_GEOMETRY_H_ diff --git a/source/graphic.cpp b/source/graphic.cpp index 01bfcdb..0c874c8 100644 --- a/source/graphic.cpp +++ b/source/graphic.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include #include "graphic.h" #include "resources.h" diff --git a/source/graphic.h b/source/graphic.h index b931113..1647d2f 100644 --- a/source/graphic.h +++ b/source/graphic.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_GRAPHIC_H_ #define MSP_GLTK_GRAPHIC_H_ @@ -10,6 +17,9 @@ namespace GLtk { class Resources; +/** +Stores a single graphical element. Graphics are used as parts of widgets. +*/ class Graphic { public: @@ -31,6 +41,14 @@ public: void shadow(); }; +private: + Sides border; + Sides shadow; + const GL::Texture2D *texture; + Geometry slice; + bool repeat; + +public: Graphic(); const Sides &get_border() const { return border; } const Sides &get_shadow() const { return shadow; } @@ -39,12 +57,6 @@ public: unsigned get_height() const { return slice.h; } void render(unsigned, unsigned) const; private: - Sides border; - Sides shadow; - const GL::Texture2D *texture; - Geometry slice; - bool repeat; - void create_coords(float, float, float, float, float, std::vector &) const; void create_texcoords(float, float, float, float, float, std::vector &) const; }; diff --git a/source/hslider.cpp b/source/hslider.cpp index 8a9cbb8..f19eafe 100644 --- a/source/hslider.cpp +++ b/source/hslider.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include #include #include "graphic.h" diff --git a/source/hslider.h b/source/hslider.h index 25ad0b1..0ce6377 100644 --- a/source/hslider.h +++ b/source/hslider.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_HSLIDER_H_ #define MSP_GLTK_HSLIDER_H_ @@ -6,18 +13,23 @@ namespace Msp { namespace GLtk { +/** +Horizontal slider widget. A special part named "slider" will be positioned at +the current value of the widget. The fill_x attribute is ignored. +*/ class HSlider: public Slider { +private: + bool dragging; + int drag_start_x; + double drag_start_value; + public: HSlider(const Resources &); void button_press(int, int, unsigned); void button_release(int, int, unsigned); void pointer_motion(int, int); private: - bool dragging; - int drag_start_x; - double drag_start_value; - const char *get_class() const { return "hslider"; } void render_part(const Part &) const; unsigned get_slider_width() const; diff --git a/source/indicator.cpp b/source/indicator.cpp index 682837a..86c2524 100644 --- a/source/indicator.cpp +++ b/source/indicator.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include "indicator.h" namespace Msp { diff --git a/source/indicator.h b/source/indicator.h index c8ecbc5..dd8a26e 100644 --- a/source/indicator.h +++ b/source/indicator.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_INDICATOR_H_ #define MSP_GLTK_INDICATOR_H_ @@ -6,6 +13,9 @@ namespace Msp { namespace GLtk { +/** +An Indicator visualizes a boolean state. It can be either active or inactive. +*/ class Indicator: public Widget { public: diff --git a/source/label.cpp b/source/label.cpp index 9676fa3..36637d0 100644 --- a/source/label.cpp +++ b/source/label.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include "label.h" #include "part.h" diff --git a/source/label.h b/source/label.h index 8380ef0..373e4e4 100644 --- a/source/label.h +++ b/source/label.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_LABEL_H_ #define MSP_GLTK_LABEL_H_ @@ -6,6 +13,9 @@ namespace Msp { namespace GLtk { +/** +Labels display static text. There is one special part: "text". +*/ class Label: public Widget { public: @@ -16,11 +26,14 @@ public: Label &get_object(); }; - Label(const Resources &, const std::string & =std::string()); - void set_text(const std::string &); private: std::string text; +public: + Label(const Resources &, const std::string & =std::string()); + void set_text(const std::string &); + +private: const char *get_class() const { return "label"; } void render_part(const Part &) const; }; diff --git a/source/panel.cpp b/source/panel.cpp index c763e6e..529ec19 100644 --- a/source/panel.cpp +++ b/source/panel.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include #include "button.h" #include "label.h" @@ -24,6 +31,11 @@ Panel::~Panel() delete *i; } +void Panel::add(Widget &wdg) +{ + children.push_back(&wdg); +} + void Panel::button_press(int x, int y, unsigned btn) { if(pointer_grab>0) @@ -89,11 +101,6 @@ void Panel::focus_out() set_input_focus(0); } -void Panel::add(Widget &wdg) -{ - children.push_back(&wdg); -} - void Panel::render_part(const Part &part) const { if(part.get_name()=="children") diff --git a/source/panel.h b/source/panel.h index d922a99..b4fc023 100644 --- a/source/panel.h +++ b/source/panel.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_PANEL_H_ #define MSP_GLTK_PANEL_H_ @@ -6,6 +13,11 @@ namespace Msp { namespace GLtk { +/** +Panels are containers for other widgets. Panel styles should have a special +part "children" to render the child widgets. All properties of this part are +ignored. +*/ class Panel: public Widget { public: @@ -23,10 +35,22 @@ public: void panel(const std::string &); }; +private: + typedef std::list ChildSeq; + + ChildSeq children; + Widget *pointer_focus; + unsigned pointer_grab; + Widget *input_focus; + + Panel(const Panel &); + Panel &operator=(const Panel &); +public: Panel(const Resources &); ~Panel(); void add(Widget &); + void button_press(int, int, unsigned); void button_release(int, int, unsigned); void pointer_motion(int, int); @@ -34,15 +58,6 @@ public: void key_release(unsigned, unsigned); void focus_out(); private: - typedef std::list ChildSeq; - - ChildSeq children; - Widget *pointer_focus; - unsigned pointer_grab; - Widget *input_focus; - - Panel(const Panel &); - Panel &operator=(const Panel &); const char *get_class() const { return "panel"; } void render_part(const Part &) const; void set_pointer_focus(Widget *); diff --git a/source/part.cpp b/source/part.cpp index d65fc2e..f5e4b79 100644 --- a/source/part.cpp +++ b/source/part.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include "geometry.h" #include "part.h" #include "resources.h" diff --git a/source/part.h b/source/part.h index 58386ca..5736f7a 100644 --- a/source/part.h +++ b/source/part.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_PART_H_ #define MSP_GLTK_PART_H_ @@ -13,6 +20,9 @@ namespace GLtk { class Graphic; class Resources; +/** +Defines a single graphical element of a widget style. +*/ class Part { public: @@ -31,6 +41,16 @@ public: void fill(bool, bool); }; +private: + std::string name; + const Graphic *graphic[N_STATES_]; + unsigned width; + unsigned height; + Alignment align; + bool fill_x; + bool fill_y; + +public: Part(const std::string &); const std::string &get_name() const { return name; } const Graphic *get_graphic(State) const; @@ -40,14 +60,6 @@ public: bool get_fill_x() const { return fill_x; } bool get_fill_y() const { return fill_y; } void render(const Geometry &, State) const; -private: - std::string name; - const Graphic *graphic[N_STATES_]; - unsigned width; - unsigned height; - Alignment align; - bool fill_x; - bool fill_y; }; typedef std::list PartSeq; diff --git a/source/resources.cpp b/source/resources.cpp index 3b0f4f9..35af009 100644 --- a/source/resources.cpp +++ b/source/resources.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include #include "resources.h" diff --git a/source/resources.h b/source/resources.h index 3d39393..8fb2185 100644 --- a/source/resources.h +++ b/source/resources.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_RESOURCES_H_ #define MSP_GLTK_RESOURCES_H_ @@ -11,6 +18,10 @@ namespace Msp { namespace GLtk { +/** +Stores resources such as styles and graphics. All widgets require a Resources +instance in constructor. +*/ class Resources: public DataFile::Collection { private: diff --git a/source/root.cpp b/source/root.cpp index 32cd879..a59c939 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include "root.h" namespace Msp { diff --git a/source/root.h b/source/root.h index 809780c..863f1f7 100644 --- a/source/root.h +++ b/source/root.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_ROOT_H_ #define MSP_GLTK_ROOT_H_ @@ -7,13 +14,20 @@ namespace Msp { namespace GLtk { +/** +A Root is a special type of Panel that covers and entire Window and accepts +input from it. When created, a Root widget will take its size from the window +it is created for. The size can be changed, but a Root should always be +rendered to fill the window in order to get coordinates mapped correctly. +*/ class Root: public Panel { -public: - Root(Resources &, Window &); private: Window &window; +public: + Root(Resources &, Window &); +private: const char *get_class() const { return "root"; } void button_press_event(int, int, unsigned, unsigned); void button_release_event(int, int, unsigned, unsigned); diff --git a/source/slider.cpp b/source/slider.cpp index 11e4c24..52a4b4d 100644 --- a/source/slider.cpp +++ b/source/slider.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include "slider.h" namespace Msp { @@ -11,19 +18,6 @@ Slider::Slider(const Resources &r): step(0.1) { } -void Slider::set_range(double a, double b) -{ - min=a; - max=b; - set_value(value); -} - -void Slider::set_step(double s) -{ - step=s; - set_value(value); -} - void Slider::set_value(double v) { double old_value=value; @@ -42,5 +36,18 @@ void Slider::set_value(double v) signal_value_changed.emit(value); } +void Slider::set_range(double a, double b) +{ + min=a; + max=b; + set_value(value); +} + +void Slider::set_step(double s) +{ + step=s; + set_value(value); +} + } // namespace GLtk } // namespace Msp diff --git a/source/slider.h b/source/slider.h index d4ae46b..8eb3736 100644 --- a/source/slider.h +++ b/source/slider.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_SLIDER_H_ #define MSP_GLTK_SLIDER_H_ @@ -7,21 +14,28 @@ namespace Msp { namespace GLtk { +/** +Sliders are used to adjust numeric values visually. This class provides the +common interface for sliders - see classes HSlider and VSlider (NYI) for +concrete variations. +*/ class Slider: public Widget { +protected: + double min, max; + double value; + double step; + public: sigc::signal signal_value_changed; +protected: + Slider(const Resources &); +public: void set_value(double); void set_range(double, double); void set_step(double); double get_value() const { return value; } -protected: - double min, max; - double value; - double step; - - Slider(const Resources &); }; } // namespace GLtk diff --git a/source/state.cpp b/source/state.cpp index 9e44e14..368e693 100644 --- a/source/state.cpp +++ b/source/state.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include "state.h" using namespace std; diff --git a/source/state.h b/source/state.h index 4e57990..8e29ab0 100644 --- a/source/state.h +++ b/source/state.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_STATE_H_ #define MSP_GLTK_STATE_H_ diff --git a/source/style.cpp b/source/style.cpp index b4ee82d..6c11657 100644 --- a/source/style.cpp +++ b/source/style.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include "resources.h" #include "style.h" diff --git a/source/style.h b/source/style.h index bc210a2..0bbdc21 100644 --- a/source/style.h +++ b/source/style.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_STYLE_H_ #define MSP_GLTK_STYLE_H_ @@ -11,6 +18,10 @@ namespace GLtk { class Resources; +/** +Styles define what wigets look like. They are made up of Parts and some +generic properties. +*/ class Style { public: @@ -32,14 +43,16 @@ public: void part(const std::string &); }; - Style(); - const GL::Font *get_font() const { return font; } - const GL::Color &get_font_color() const { return font_color; } - const PartSeq &get_parts() const { return parts; } private: const GL::Font *font; GL::Color font_color; PartSeq parts; + +public: + Style(); + const GL::Font *get_font() const { return font; } + const GL::Color &get_font_color() const { return font_color; } + const PartSeq &get_parts() const { return parts; } }; } // namespace GLtk diff --git a/source/widget.cpp b/source/widget.cpp index e1538de..e20ea82 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -1,14 +1,27 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include #include #include "resources.h" #include "widget.h" -#include using namespace std; namespace Msp { namespace GLtk { +Widget::Widget(const Resources &r): + res(r), + style(0), + state(NORMAL), + visible(true) +{ } + void Widget::set_position(int x, int y) { geom.x=x; @@ -44,24 +57,6 @@ void Widget::render() const GL::pop_matrix(); } -Widget::Widget(const Resources &r): - res(r), - style(0), - state(NORMAL), - visible(true) -{ } - -void Widget::update_style() -{ - string sname=get_class(); - if(!style_name.empty()) - { - sname+='-'; - sname+=style_name; - } - style=res.get