File: windowing.h

package info (click to toggle)
asc 2.6.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 81,592 kB
  • sloc: cpp: 158,704; sh: 11,544; ansic: 6,736; makefile: 606; perl: 138
file content (143 lines) | stat: -rw-r--r-- 5,490 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/***************************************************************************
                          paradialog.h  -  description
                             -------------------
    begin                : Thu Feb 21 2002
    copyright            : (C) 2002 by Martin Bickel
    email                : bickel@asc-hq.org
 ***************************************************************************/

/*! \file paradialog.h
    \brief Dialog classes based on the Paragui library
*/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef windowingH
#define windowingH

#include "global.h"

#include <sigc++/sigc++.h>

#include "loki/SmartPtr.h"

#include "paradialog.h"
#include "widgets/bargraphwidget.h"

class ASCGUI_Window : public  PG_Window {
      ASCString panelName;
      void destruct();
   protected:
      bool setup();

      class WidgetParameters
      {
         public:
            WidgetParameters();
            ASCString backgroundImage;
            PG_Draw::BkMode backgroundMode;
            
            PG_Label::TextAlign textAlign;
            bool textAlign_defined;
            
            int fontColor;
            bool fontColor_defined;
            
            ASCString fontName;
            ASCString style;
            int fontAlpha;
            bool fontAlpha_defined;
            
            int fontSize;
            bool fontSize_defined;
            
            int backgroundColor;
            bool backgroundColor_defined;
            
            int transparency;
            bool transparency_defined;

            int bordersize;
            bool bordersize_defined;
            bool hidden;

            void assign( PG_Widget* widget );
            void assign( BarGraphWidget* widget );
            void assign( PG_ThemeWidget* widget );
            void assign( PG_Label* widget );
            void runTextIO ( PropertyReadingContainer& pc );
      };

      virtual WidgetParameters getDefaultWidgetParams() = 0;

      typedef deallocating_map<ASCString, TextPropertyGroup*> GuiCache;
      static GuiCache guiCache;
      
      TextPropertyGroup* textPropertyGroup;
   public:
      void setLabelText ( const ASCString& widgetName, const ASCString& text, PG_Widget* parent = NULL );
      void setLabelText ( const ASCString& widgetName, int i, PG_Widget* parent = NULL );
      void setLabelColor ( const ASCString& widgetName, PG_Color color, PG_Widget* parent = NULL );
      void setImage ( const ASCString& widgetName, Surface& image, PG_Widget* parent = NULL );
      void setImage ( const ASCString& widgetName, SDL_Surface* image = NULL, PG_Widget* parent = NULL );
      void setImage ( const ASCString& widgetName, const ASCString& filename, PG_Widget* parent = NULL );
      void hide( const ASCString& widgetName, PG_Widget* parent = NULL );
      void show( const ASCString& widgetName, PG_Widget* parent = NULL );
      void setBargraphValue( const ASCString& widgetName, float fraction, PG_Widget* parent = NULL );
      void setBarGraphColor( const ASCString& widgetName, PG_Color color, PG_Widget* parent = NULL );
      void rename( const ASCString& widgetName, const ASCString& newname, PG_Widget* parent = NULL );
      void setWidgetTransparency ( const ASCString& widgetName, int transparency, PG_Widget* parent = NULL );
      
      int RunModal();
   protected:

      virtual void userHandler( const ASCString& label, PropertyReadingContainer& pc, PG_Widget* parent, WidgetParameters widgetParams ) {}; 

      static PG_Rect parseRect ( PropertyReadingContainer& pc, PG_Widget* parent );
      void parsePanelASCTXT ( PropertyReadingContainer& pc, PG_Widget* parent, WidgetParameters widgetParams );

      ASCGUI_Window ( PG_Widget *parent, const PG_Rect &r, const ASCString& panelName_, const ASCString& baseStyle = "Panel", bool loadTheme = true );
      // FIXME Close button does not delete Panel
      ~ASCGUI_Window();
};


class Panel : public ASCGUI_Window {
   protected:
      WidgetParameters getDefaultWidgetParams();
   public:
      Panel ( PG_Widget *parent, const PG_Rect &r, const ASCString& panelName_, bool loadTheme = true );
};


//! this Panel saves its position in the gameoptions and loads it on construction
class LayoutablePanel: public Panel {
   private:
      ASCString name;
      static PG_Rect PositionCalculator( const PG_Rect& r, const ASCString& panelName );
      static const int DashBoardWidth = 170;
   protected:
      void eventMoveWidget (int x, int y);
      void eventHide();
      void eventShow();
   public:
      LayoutablePanel ( PG_Widget *parent, const PG_Rect &r, const ASCString& panelName_, bool loadTheme = true );
   
};

class ConfigurableWindow : public ASCGUI_Window {
   protected:
      WidgetParameters getDefaultWidgetParams();
   public:
      ConfigurableWindow ( PG_Widget *parent, const PG_Rect &r, const ASCString& panelName_, bool loadTheme = true );
};


#endif