Planeshift
pawsscrollmenu.h
Go to the documentation of this file.
1 /*
2  * pawsscrollmenu.h - Author: Joe Lyon
3  *
4  * Copyright (C) 2013 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 // pawsscrollmenu.h: interface for the pawsScrollMenu class.
20 //
22 
23 #ifndef PAWS_SCROLLMENU_HEADER
24 #define PAWS_SCROLLMENU_HEADER
25 
26 
27 
28 #include "globals.h"
29 
30 //=============================================================================
31 // Application Includes
32 //=============================================================================
33 #include "pawsscrollmenu.h"
34 
35 
36 //=============================================================================
37 // Defines
38 //=============================================================================
39 #define BUTTON_PADDING 4
40 #define SHORTCUT_BUTTON_OFFSET 2000
41 
42 #define ScrollMenuOptionDISABLED 0
43 #define ScrollMenuOptionENABLED 1
44 #define ScrollMenuOptionDYNAMIC 2
45 #define ScrollMenuOptionHORIZONTAL 3
46 #define ScrollMenuOptionVERTICAL 4
47 
48 #include "paws/pawswidget.h"
49 #include "gui/pawsdndbutton.h"
50 
51 
52 
53 
54 
57 class pawsScrollMenu : public pawsWidget
58 {
59 
60 public:
61 
62 
64  virtual ~pawsScrollMenu();
65 
66  bool PostSetup();
67  void OnResize();
68  void OnResizeStop();
69  int CalcButtonSize(pawsDnDButton* target);
70  void LayoutButtons();
71 
72  virtual bool OnButtonReleased(int mouseButton, int keyModifier, pawsWidget* reporter);
73  virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* reporter);
74 
75  bool LoadArrays(csArray<csString> &name, csArray<csString> &icon, csArray<csString> &toolTip, csArray<csString> &actions, int baseIndex, pawsWidget* widget);
76  pawsDnDButton* LoadSingle(csString name, csString icon, csString toolTip, csString action, int Index, pawsWidget* widget, bool IsEnabled);
77 
78  bool RemoveByName(csString name);
79  bool Clear();
80  int GetSize();
81  int GetButtonWidth();
82 
83 
91  int GetWidestWidth();
92 
93  int GetButtonHeight();
96  int GetTotalButtonWidth();
97  int GetTotalButtonWidth(unsigned int targetButton);
98  int GetOrientation();
100  {
101  return EditMode;
102  }
104  {
105  return EditLockMode;
106  }
107 
108  virtual bool Setup(iDocumentNode* node);
109  bool SelfPopulate(iDocumentNode* node);
110 
111  bool ScrollUp();
112  bool ScrollDown();
113  bool ScrollToPosition( float pos );
114  virtual bool OnMouseDown(int button, int modifiers, int x, int y);
115  virtual bool OnKeyDown(utf32_char keyCode, utf32_char key, int modifiers);
116 
117  void SetEditLock(int mode);
118  bool IsEditable()
119  {
120  return EditLockButton->GetState();
121  }
122  void SetLeftScroll(int mode);
123  int GetLeftScroll();
124  void SetRightScroll(int mode);
125  int GetRightScroll();
126  void SetButtonWidth(int width);
127  void SetButtonHeight(int height);
128 // void SetScrollIncrement(int incr);
129 // void SetScrollProportion(float prop);
130  bool SetScrollWidget( pawsScrollBar* sb);
131  void SetOrientation(int Orientation);
132  int AutoResize();
136  void SetEditMode(int val)
137  {
138  EditMode = val;
139  }
140 
141  void SetButtonPaddingWidth( int width )
142  {
143  paddingWidth = width;
144  }
146  {
147  return paddingWidth;
148  }
149  void SetButtonBackground( const char* image );
150  csString GetButtonBackground();
151  void SetButtonFont( const char* Font, int size );
152  char const * GetButtonFontName();
153  float GetButtonFontSize();
154 
158  char const * GetFontName()
159  {
160  return fontName;
161  }
162 
163  void SetTextSpacing( int v );
164 
165  void EnableButtonBackground( bool mode );
167 
168  void ShowScrollButtons();
169 
170  void SetWarnLevel(float, bool);
171  void SetDangerLevel(float, bool);
172  void SetFlashLevel(float, bool);
173 
174  float GetWarnLevel();
175  float GetDangerLevel();
176  float GetFlashLevel();
177 
178  void SetWarnMode(int);
179  void SetDangerMode(int);
180  void SetFlashMode(int);
181 
182 protected:
183 
185  buttonHeight,
188  paddingWidth;
189 
192 
194  csArray<pawsWidget*> Buttons;
196 
200 
204 
206  int EditLockMode; //enabled, disabled, (dynamic==>enabled)
207  bool EditLock; //true = editing prevented, false = editing allowed
208 
210 
212 
214  int EditMode;
215 
216  float warnLevel;
217  int warnMode;
218  float dangerLevel;
219  bool dangerLow;
221  float flashLevel;
222  bool flashLow;
224 
225 };
226 
227 //----------------------------------------------------------------------
229 
232 #endif
CREATE_PAWS_FACTORY(pawsScrollMenu)
csString toolTip
Tooltip to be displayed.
Definition: pawswidget.h:317
void SetWarnLevel(float, bool)
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
virtual bool GetState()
Definition: pawsbutton.h:76
pawsWidget * callbackWidget
float GetDangerLevel()
void SetEditMode(int val)
set edit lock to allow rt-click edit and prevent DND, or to disallow all editing
csString fontName
Name of currently selected font.
Definition: pawswidget.h:305
void LayoutButtons()
void SetRightScroll(int mode)
csArray< pawsWidget * > Buttons
csString name
The name of this widget.
Definition: pawswidget.h:217
virtual bool Setup(iDocumentNode *node)
Setup this widget.
void SetTextSpacing(int v)
pawsWidget * ButtonHolder
void SetButtonHeight(int height)
bool RemoveByName(csString name)
virtual ~pawsScrollMenu()
bool SetScrollWidget(pawsScrollBar *sb)
int GetWidestWidth()
Find the width of the widest button.
int GetButtonHeight()
A Drag-and-Drop capable button widget with timer.
Definition: pawsdndbutton.h:45
void SetEditLock(int mode)
bool IsButtonBackgroundEnabled()
pawsScrollBar * scrollBarWidget
bool PostSetup()
This is called after the widget and all of it&#39;s children have been created.
void SetDangerMode(int)
int CalcButtonSize(pawsDnDButton *target)
void SetButtonPaddingWidth(int width)
void OnResize()
Sets the new position of the close button.
Definition: wn.h:164
A scrolling list of buttons, each with an icon and which accepts drag-n-drop.
int GetRightScroll()
int GetOrientation()
void SetFlashMode(int)
csString GetButtonBackground()
void EnableButtonBackground(bool mode)
bool LoadArrays(csArray< csString > &name, csArray< csString > &icon, csArray< csString > &toolTip, csArray< csString > &actions, int baseIndex, pawsWidget *widget)
float GetFlashLevel()
virtual bool OnMouseDown(int button, int modifiers, int x, int y)
Manage mouse down event to test for and apply window changes.
pawsDnDButton * LoadSingle(csString name, csString icon, csString toolTip, csString action, int Index, pawsWidget *widget, bool IsEnabled)
pawsButton * LeftScrollButton
A simple scroll bar widget.
Definition: pawscrollbar.h:64
void SetButtonBackground(const char *image)
void SetWarnMode(int)
virtual bool OnButtonReleased(int mouseButton, int keyModifier, pawsWidget *reporter)
Called whenever a button is released.
void SetButtonFont(const char *Font, int size)
void SetFlashLevel(float, bool)
A simple button widget.
Definition: pawsbutton.h:43
pawsButton * EditLockButton
void ShowScrollButtons()
int GetButtonWidth()
char const * GetButtonFontName()
float GetButtonFontSize()
bool SelfPopulate(iDocumentNode *node)
This function allows a widget to fill in its own contents from an xml node supplied and calls the sam...
void SetButtonWidth(int width)
void SetOrientation(int Orientation)
int GetButtonPaddingWidth()
float GetWarnLevel()
int GetButtonHolderWidth()
void OnResizeStop()
int GetTotalButtonWidth()
pawsButton * RightScrollButton
void SetDangerLevel(float, bool)
virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget *reporter)
Called whenever a button is pressed.
char const * GetFontName()
return the name of the font
virtual bool OnKeyDown(utf32_char keyCode, utf32_char key, int modifiers)
Process keydown messages.
int GetButtonHolderHeight()
bool ScrollToPosition(float pos)
void SetLeftScroll(int mode)