2 * psychlops_widgets_prototype.h
3 * Psychlops Standard Library (Universal)
5 * Last Modified 2009/02/15 by Kenchi HOSOKAWA
6 * (C) 2009 Kenchi HOSOKAWA, Kazushi MARUYA, Takao SATO
9 #ifndef HEADER_PSYCHLOPS_WIDGET
10 #define HEADER_PSYCHLOPS_WIDGET
13 #include "../../../core/graphic/psychlops_g_module.h"
14 #include "../../../psychlops_core.h"
15 #include "../psychophysics/psychlops_exp_psychophysics.h"
16 #include "psychlops_widgets_event.h"
21 class Widget : public Figure {
23 namespace ExperimentalMethods
30 class WidgetBase : public Events::Emittable, public Group
33 Events::Container *parent_;
34 Events::Dispatcher slots_;
40 virtual Rectangle getArea();
41 virtual Events::Container& getParent();
42 virtual Events::Container& setParent(Events::Container &par);
43 virtual Events::Dispatcher& getSlots();
44 virtual void distribute(Event &ev);
45 virtual void distribute(Events::PointerDeviceEvent &event);
46 void tabStop(bool on_off = true);
56 static bool initialized__;
57 static Image default_button, default_horiz_grad;
58 enum TYPE_TAG { NORMAL, ALERT };
60 Color normal_foreground[2], active_foreground[2];
61 Color normal_background[2], active_background[2], over_background[2];
62 Stroke normal_stroke[2], active_stroke[2];
63 Image *button_back, *horiz_grad;
66 static void initialize();
69 Point drawableMouse(Drawable &d);
74 class WidgetDatum : public Widget {
79 virtual const Point getDatum() const;
80 virtual WidgetDatum& setDatum(const Point&);
81 virtual WidgetDatum& centering(const Point&);
82 using Figure::centering;
85 class WidgetRect : public Widget {
87 HumanInterfaceDevice::ButtonStateHolder mleft;
89 bool tabStopRegistered;
94 static int __LAST_TOTAL_REFRESH;
95 static double __autoAlign_;
96 static void __autoAlign(WidgetRect &target);
99 Theme::TYPE_TAG theme_type;
104 virtual const Point getDatum() const;
105 virtual WidgetRect& setDatum(const Point&);
106 virtual WidgetRect& centering(const Point&);
107 using Figure::centering;
108 double getWidth() const;
109 double getHeight() const;
110 double getLeft() const;
111 double getTop() const;
112 double getRight() const;
113 double getBottom() const;
114 WidgetRect& alignLeft(const double lef);
115 WidgetRect& alignTop(const double to_);
116 WidgetRect& alignRight(const double rig);
117 WidgetRect& alignBottom(const double bot);
119 virtual WidgetRect& set(double wid, double hei);
120 virtual WidgetRect& set(std::wstring name);
121 virtual WidgetRect& set(std::wstring name, double hei);
122 virtual WidgetRect& setLabel(std::wstring s);
123 virtual WidgetRect& draw(Drawable &target = *Drawable::prime);
125 WidgetRect& pushThis();
128 class StackPanel : public WidgetRect {
130 std::deque< WidgetRect* > content;
132 enum Orientation { VERTICAL, HORIZONTAL };
133 Orientation orientation;
134 bool forceBase, forceAnother;
138 StackPanel& setWidth(double wid);
139 StackPanel& setHeight(double hei);
140 StackPanel& append(WidgetRect *target1, WidgetRect *target2=0, WidgetRect *target3=0, WidgetRect *target4=0, WidgetRect *target5=0);
141 StackPanel& remove(WidgetRect *target);
142 void align(Orientation ori = VERTICAL);
143 virtual StackPanel& draw(Drawable &target = *Drawable::prime);
145 static StackPanel default_stack;
150 } /* <- namespace Widgets */
151 } /* <- namespace Psycholops */