00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00033 #ifndef PG_WINDOW_H
00034 #define PG_WINDOW_H
00035
00036 #include "pgthemewidget.h"
00037 #include "pglabel.h"
00038 #include <string>
00039
00040 class PG_Button;
00041
00051 class DECLSPEC PG_Window : public PG_ThemeWidget {
00052 public:
00053
00054
00055 typedef enum {
00056 MODAL = 0x01,
00057 SHOW_CLOSE = 0x02,
00058 SHOW_MINIMIZE = 0x04,
00059 DEFAULT = SHOW_CLOSE
00060 } WindowFlags;
00061
00062 enum {
00063 IDWINDOW_CLOSE = PG_WIDGETID_INTERNAL + 14,
00064 IDWINDOW_MINIMIZE = PG_WIDGETID_INTERNAL + 15,
00065 IDWINDOW_RESTORE = PG_WIDGETID_INTERNAL + 15
00066 };
00067
00071 typedef PG_Signal1<PG_Window*> SignalWindowClose;
00072 typedef PG_Signal1<PG_Window*> SignalWindowMinimize;
00073 typedef PG_Signal1<PG_Window*> SignalWindowRestore;
00074
00084 PG_Window(PG_Widget* parent, const PG_Rect& r = PG_Rect::null, const std::string& windowtext = PG_NULLSTR, WindowFlags flags = DEFAULT, const std::string& style="Window", int heightTitlebar = 25);
00085
00087 ~PG_Window();
00088
00089 void LoadThemeStyle(const std::string& widgettype);
00090
00095 void SetTitlebarColor(const PG_Color& c);
00096
00101 PG_Color GetTitlebarColor();
00102
00107 void SetTitlebarHeight(Uint8 height);
00108
00113 Uint8 GetTitlebarHeight();
00114
00120 void SetTitle(const std::string& title, PG_Label::TextAlign alignment = PG_Label::CENTER);
00121
00122 void SetText(const std::string& text);
00123
00128 const PG_String& GetTitle();
00129
00130 const PG_String& GetText();
00131
00136 SDL_Surface* GetIcon();
00137
00142 void SetIcon(const std::string& filename);
00143
00148 void SetIcon(SDL_Surface* icon);
00149
00153 void SetMoveable(bool moveable = true);
00154
00155 SignalWindowClose sigClose;
00156 SignalWindowMinimize sigMinimize;
00157 SignalWindowRestore sigRestore;
00158
00159 protected:
00160
00161 void RecalcPositions();
00162
00164 void eventBlit(SDL_Surface* surface, const PG_Rect& src, const PG_Rect& dst);
00165
00167 void eventSizeWidget(Uint16 w, Uint16 h);
00168
00170 virtual bool handleButtonClick(PG_Button* button);
00171
00173 bool eventMouseButtonDown(const SDL_MouseButtonEvent* button);
00174
00176 bool eventMouseButtonUp(const SDL_MouseButtonEvent* button);
00177
00179 bool eventMouseMotion(const SDL_MouseMotionEvent* motion);
00180
00181 private:
00182
00183 Uint8 my_heightTitlebar;
00184
00185 PG_Button* my_buttonClose;
00186
00187 PG_Button* my_buttonMinimize;
00188
00189 PG_Button* my_buttonIcon;
00190
00191 PG_ThemeWidget* my_titlebar;
00192
00193 PG_Label* my_labelTitle;
00194
00195 bool my_moveMode;
00196
00197 Uint8 my_moveTransparency;
00198
00199 PG_Point my_moveDelta;
00200
00201 bool my_showCloseButton;
00202
00203 bool my_showMinimizeButton;
00204
00205 bool my_moveable;
00206
00207 private:
00208
00209 PG_Window(const PG_Window&);
00210 PG_Window& operator=(const PG_Window&);
00211
00212 };
00213
00214 #endif // PG_WINDOW_H