Advanced Strategic Command
paradialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  paradialog.h - description
3  -------------------
4  begin : Thu Feb 21 2002
5  copyright : (C) 2002 by Martin Bickel
6  email : bickel@asc-hq.org
7  ***************************************************************************/
8 
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  ***************************************************************************/
21 
22 #ifndef paradialogH
23  #define paradialogH
24 
25 #include <vector>
26 #include "global.h"
27 
28 #include <sigc++/sigc++.h>
29 
30 #include <paragui.h>
31 #include <pgapplication.h>
32 #include <pgmessagebox.h>
33 #include <pgdropdown.h>
34 #include <pgcolor.h>
35 
36 #include "pgbutton.h"
37 #include "pgwidgetlist.h"
38 #include "pglabel.h"
39 #include "pgwindow.h"
40 #include "pgscrollbar.h"
41 #include "pgradiobutton.h"
42 #include "pgthemewidget.h"
43 #include "pgcheckbutton.h"
44 #include "pgslider.h"
45 #include "pglistbox.h"
46 
47 #include "pgpropertyeditor.h"
48 
49 #include "sdl/graphics.h"
50 #include "ascstring.h"
51 #include "textfile_evaluation.h"
52 #include "graphics/drawing.h"
53 #include "util/messaginghub.h"
54 
55 class AutoProgressBar;
56 
57 class StartupScreen: public sigc::trackable {
58  vector<PG_Label*> infoLabels;
59  PG_Label* versionLabel;
60  PG_ThemeWidget* background;
61  AutoProgressBar* progressBar;
62  Surface fullscreenImage;
63  void disp( const ASCString& s );
64  void dispLine( const ASCString& s, int line );
65  public:
66  StartupScreen( const ASCString& filename, sigc::signal<void>& ticker );
68 };
69 
70  class ASC_PG_App : public PG_Application {
71  ASCString themeName;
72  bool fullScreen;
73  int bitsperpixel;
74 
75  void messageDialog( const ASCString& message, MessagingHubBase::MessageType mt );
76 
77  typedef list<PG_MessageObject*> DeletionQueue;
78  DeletionQueue deletionQueue;
79 
80  bool removeFromDeletionQueue( const PG_MessageObject* obj );
81 
82  protected:
83  bool eventQuit(int id, PG_MessageObject* widget, unsigned long data);
84  void eventIdle();
85 
86  public:
87  static const int mapDisplayID = 2;
88  static const int mainScreenID = 1;
89 
90  ASC_PG_App ( const ASCString& themeName );
91  bool InitScreen ( int w, int h, int depth = 0, Uint32 flags = SDL_SWSURFACE|SDL_HWPALETTE );
92 
93  void reloadTheme();
94  int Run ();
95  void Quit ();
96 
97  bool isFullscreen() { return fullScreen; };
98  bool toggleFullscreen();
99 
100  void setIcon( const ASCString& filename );
101 
102  void processEvent();
103  bool enableLegacyEventHandling( bool use );
104 
105  bool queueWidgetForDeletion( PG_Widget* widget );
106 
107  ~ASC_PG_App();
108 
109  void SetNewScreenSurface( SDL_Surface* surface );
110 
111  // sigc::signal<void> sigQuit;
112  // PG_Theme* LoadTheme(const char* xmltheme, bool asDefault = true, const char* searchpath = NULL );
113  };
114 
115  extern ASC_PG_App& getPGApplication();
116 
118  static int windowNum;
119  public:
120  WindowCounter() { ++windowNum; };
121  static int num() { return windowNum; };
122  ~WindowCounter() { --windowNum; };
123  };
124 
125 
127 class ASC_PG_Dialog : public PG_Window {
128  private:
129  int stdButtonNum;
130  protected:
131  PG_MessageObject* caller;
132  virtual bool closeWindow();
133  bool quitModalLoopW(PG_Button* button, int value );
134  bool quitModalLoop(int value );
135  virtual bool eventKeyDown(const SDL_KeyboardEvent *key);
136  public:
137  ASC_PG_Dialog ( PG_Widget *parent, const PG_Rect &r, const ASCString& windowtext, WindowFlags flags=DEFAULT, const ASCString& style="Window", int heightTitlebar=25);
138  PG_Button* AddStandardButton( const ASCString& name );
141  int RunModal();
142 
143  static PG_Rect centerRectangle( const PG_Rect& rect );
144 
145  private:
146  StandardButtonDirectonType standardButtonDir;
147 };
148 
149 class ASC_PropertyEditor : public PG_PropertyEditor {
150  public:
151  ASC_PropertyEditor( PG_Widget *parent, const PG_Rect &r, const std::string &style="PropertyEditor", int labelWidthPercentage = 50 ) : PG_PropertyEditor( parent, r, style, labelWidthPercentage ) {};
152  std::string GetStyleName( const std::string& widgetName ) {
153  if ( widgetName == "DropDownSelectorProperty" )
154  return "DropDown";
155  else
156  if ( widgetName == "BoolProperty" )
157  return "CheckButton";
158  else
159  return PG_PropertyEditor::GetStyleName( widgetName );
160  };
161 };
162 
163 
164 
165 class ColoredBar : public PG_ThemeWidget {
166  public:
167  ColoredBar( PG_Color col, PG_Widget *parent, const PG_Rect &r ) : PG_ThemeWidget( parent, r )
168  {
169  SetGradient ( PG_Gradient( col,col,col,col ));
170  SetBorderSize(0);
171  SetBackgroundBlend ( 255 );
172  };
173 };
174 
175 
176 
177 class SpecialDisplayWidget : public PG_Widget {
178  public:
179 
180  typedef sigc::signal<void,const PG_Rect&, const ASCString&, const PG_Rect&> DisplayHook;
181 
183 
184  SpecialDisplayWidget (PG_Widget *parent, const PG_Rect &rect ) : PG_Widget( parent, rect, false )
185  {
186  }
187 
188 
189  void eventBlit (SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst) {
190  display( src, GetName(), dst );
191  };
192  /*
193  void eventDraw (SDL_Surface *surface, const PG_Rect &rect) {
194  Surface s = Surface::Wrap( surface );
195  display( s, rect, GetID(), *this );
196  };
197  */
198 
199 };
200 
201 
202 class SpecialInputWidget : public PG_Widget {
203  public:
204 
205  SpecialInputWidget (PG_Widget *parent, const PG_Rect &rect ) : PG_Widget( parent, rect, false ) { SetTransparency(255); };
206  void eventBlit (SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst) { };
207 };
208 
209 class Emboss : public PG_Widget {
210  bool inv;
211  public:
212 
213  Emboss (PG_Widget *parent, const PG_Rect &rect, bool inverted = false ) : PG_Widget( parent, rect, false ), inv(inverted)
214  {
215  }
216 
217  void eventBlit (SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst);
218 };
219 
220 
221 
222 
223 
224 class MessageDialog;
225 
227  MessageDialog* md;
228  public:
229  PG_StatusWindowData( const ASCString& msg );
230  void SetText( const ASCString& text );
232 };
233 
236 extern pair<int,int> new_chooseString ( const ASCString& title, const vector<ASCString>& entries, const vector<ASCString>& buttons, int defaultEntry = -1 );
237 
238 extern bool MultiLineEditor( const ASCString& title, ASCString& textToEdit );
239 
241 extern ASCString editString2( const ASCString& title, const ASCString& defaultValue = "" );
242 
243 extern int choiceDialog(const ASCString& text, const ASCString& button1, const ASCString& button2, const ASCString& shortLabel );
244 
245 
247  PG_Widget* parent;
248  bool bulk;
249  bool active;
250  public:
251  BulkGraphicUpdates( PG_Widget* parent = NULL );
252  void release();
254 };
255 
256 
257 #endif
StartupScreen(const ASCString &filename, sigc::signal< void > &ticker)
Definition: paradialog.cpp:302
void eventBlit(SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
Definition: paradialog.cpp:772
DisplayHook display
Definition: paradialog.h:182
void setIcon(const ASCString &filename)
Definition: paradialog.cpp:211
bool quitModalLoopW(PG_Button *button, int value)
Definition: paradialog.cpp:540
PG_StatusWindowData(const ASCString &msg)
Definition: paradialog.cpp:638
static int num()
Definition: paradialog.h:121
bool MultiLineEditor(const ASCString &title, ASCString &textToEdit)
Definition: paradialog.cpp:736
Functions to evaluate the parsed *.asctxt files.
void StandardButtonDirection(StandardButtonDirectonType dir)
Definition: paradialog.cpp:511
virtual bool eventKeyDown(const SDL_KeyboardEvent *key)
Definition: paradialog.cpp:531
StandardButtonDirectonType
Definition: paradialog.h:139
void SetNewScreenSurface(SDL_Surface *surface)
Definition: paradialog.cpp:252
void processEvent()
Definition: paradialog.cpp:436
std::string GetStyleName(const std::string &widgetName)
Definition: paradialog.h:152
PG_MessageObject * caller
Definition: paradialog.h:131
Emboss(PG_Widget *parent, const PG_Rect &rect, bool inverted=false)
Definition: paradialog.h:213
bool InitScreen(int w, int h, int depth=0, Uint32 flags=SDL_SWSURFACE|SDL_HWPALETTE)
Definition: paradialog.cpp:403
Global platform dependant definitions. This file just branches to the platform specific files in thei...
ASC_PropertyEditor(PG_Widget *parent, const PG_Rect &r, const std::string &style="PropertyEditor", int labelWidthPercentage=50)
Definition: paradialog.h:151
ASC_PG_Dialog(PG_Widget *parent, const PG_Rect &r, const ASCString &windowtext, WindowFlags flags=DEFAULT, const ASCString &style="Window", int heightTitlebar=25)
Definition: paradialog.cpp:462
void eventBlit(SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
Definition: paradialog.h:206
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
ASC_PG_App(const ASCString &themeName)
Definition: paradialog.cpp:151
bool enableLegacyEventHandling(bool use)
Definition: paradialog.cpp:430
SpecialDisplayWidget(PG_Widget *parent, const PG_Rect &rect)
Definition: paradialog.h:184
bool quitModalLoop(int value)
Definition: paradialog.cpp:545
void Quit()
Definition: paradialog.cpp:223
Adapter class for using Paragui Dialogs in ASC. This class transfers the event control from ASC to Pa...
Definition: paradialog.h:127
ColoredBar(PG_Color col, PG_Widget *parent, const PG_Rect &r)
Definition: paradialog.h:167
void eventIdle()
Definition: paradialog.cpp:236
sigc::signal< void, const PG_Rect &, const ASCString &, const PG_Rect & > DisplayHook
Definition: paradialog.h:180
virtual bool closeWindow()
Definition: paradialog.cpp:580
void eventBlit(SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
Definition: paradialog.h:189
pair< int, int > new_chooseString(const ASCString &title, const vector< ASCString > &entries, const vector< ASCString > &buttons, int defaultEntry=-1)
Definition: paradialog.cpp:712
SpecialInputWidget(PG_Widget *parent, const PG_Rect &rect)
Definition: paradialog.h:205
bool toggleFullscreen()
Definition: paradialog.cpp:258
bool eventQuit(int id, PG_MessageObject *widget, unsigned long data)
Definition: paradialog.cpp:230
static PG_Rect centerRectangle(const PG_Rect &rect)
Definition: paradialog.cpp:484
static const int mapDisplayID
Definition: paradialog.h:87
ASCString editString2(const ASCString &title, const ASCString &defaultValue="")
uses the new dialog engine
Definition: paradialog.cpp:798
int choiceDialog(const ASCString &text, const ASCString &button1, const ASCString &button2, const ASCString &shortLabel)
Definition: paradialog.cpp:806
bool queueWidgetForDeletion(PG_Widget *widget)
Definition: paradialog.cpp:194
PG_Button * AddStandardButton(const ASCString &name)
Definition: paradialog.cpp:516
void reloadTheme()
Definition: paradialog.cpp:423
void SetText(const ASCString &text)
Definition: paradialog.cpp:644
ASC_PG_App & getPGApplication()
Definition: paradialog.cpp:294
static const int mainScreenID
Definition: paradialog.h:88
bool isFullscreen()
Definition: paradialog.h:97
BulkGraphicUpdates(PG_Widget *parent=NULL)
Definition: paradialog.cpp:748
void line(int x1, int y1, int x2, int y2, Uint8 actcol)
draws a simple line on the screen. Not very fast...
Definition: basegfx.cpp:181
volatile int ticker
Definition: events.cpp:234