Planeshift
pawswidget.h
Go to the documentation of this file.
1 /*
2  * pawswidget.h - Author: Andrew Craig
3  *
4  * Copyright (C) 2003 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  * pawswidget.h: interface for the pawsWidget class.
20  ---------------------------------------------------------------------------*/
21 
22 #ifndef PAWS_WIDGET_HEADER
23 #define PAWS_WIDGET_HEADER
24 
25 #include <ivideo/graph2d.h>
26 
27 #include <csutil/array.h>
28 #include <csutil/csstring.h>
29 
30 #include <csgeom/csrectrg.h>
31 #include <csgeom/vector2.h>
32 
33 #include <iutil/document.h>
34 
35 //#include "net/cmdbase.h"
36 #include "pawsmanager.h"
37 #include "util/scriptvar.h"
38 
43 #define ATTACH_LEFT 2
44 #define ATTACH_RIGHT 4
45 #define ATTACH_BOTTOM 8
46 #define ATTACH_TOP 16
47 #define PROPORTIONAL_LEFT 32
48 #define PROPORTIONAL_RIGHT 64
49 #define PROPORTIONAL_TOP 128
50 #define PROPORTIONAL_BOTTOM 256
51 
52 #define SCROLL_UP -1000
53 #define SCROLL_DOWN -2000
54 #define SCROLL_THUMB -3000
55 #define SCROLL_AUTO -4000
56 #define SCROLL_SET -5000
57 
58 #define DEFAULT_MIN_HEIGHT 5
59 #define DEFAULT_MIN_WIDTH 5
60 
61 
62 #define RESIZE_LEFT 2
63 #define RESIZE_RIGHT 4
64 #define RESIZE_TOP 8
65 #define RESIZE_BOTTOM 16
66 
67 enum
68 {
72 };
73 
74 #define BORDER_INNER_BEVEL 0x1
75 #define BORDER_OUTER_BEVEL 0x2
76 #define BORDER_REVERSED 0x4
77 #define BORDER_BUMP (BORDER_OUTER_BEVEL)
78 #define BORDER_RAISED (BORDER_INNER_BEVEL|BORDER_OUTER_BEVEL)
79 #define BORDER_SUNKEN (BORDER_REVERSED|BORDER_OUTER_BEVEL)
80 #define BORDER_ETCHED (BORDER_REVERSED|BORDER_RAISED)
81 
82 
83 #define DEFAULT_FONT_SIZE 12
84 
85 #define DEFAULT_FONT_STYLE 0
86 #define FONT_STYLE_DROPSHADOW 1
87 #define FONT_STYLE_BOLD 2
88 
89 
91 {
97 
99 };
100 
101 struct iPawsImage;
102 class PawsManager;
103 class pawsBorder;
104 class pawsScrollBar;
105 class pawsListBox;
106 class pawsButton;
107 class pawsMenu;
108 class pawsMenuAction;
109 class WidgetConfigWindow;
110 class pawsScript;
111 class pawsTitle;
112 
117 {
118 public:
120  class iWidgetData {};
121 
122 protected:
124  csString factory;
125 
127  int id;
128 
131 
133  csRef<iGraphics2D> graphics2D;
134 
136  csRect defaultFrame;
137 
139  csRect screenFrame;
140 
142  csRect clipRect;
143 
146 
148  csString filename;
149 
152 
160  csArray<pawsWidget*> children;
161 
163  csArray<pawsWidget*> taborder;
164 
167 
169  bool visible;
170 
176 
182 
184  bool movable;
185 
188 
191 
197 
200 
203 
206 
209 
212 
215 
217  csString name;
218 
220  csString closeName;
221 
223  csString subscribedVar;
224 
230  int bgColour;
231 
233  csRef<iPawsImage> bgImage;
234 
237 
240 
243 
245  bool hasFocus;
246 
249 
251  float fadeVal;
252 
254  int alpha;
255 
257  int alphaMin;
258 
260  bool fade;
261 
263  float fadeSpeed;
264 
271  csString contextMenuFile;
272 
279 
282 
285 
287  csRef<iFont> myFont;
288 
291 
294 
297 
299  float fontSize;
300 
302  bool scaleFont;
303 
305  csString fontName;
306 
309 
314  csString xmlbinding;
315 
317  csString toolTip;
318 
320  csString defaultToolTip;
321 
323  csRef<iPawsImage> maskImage;
324 
330  bool ignore;
331 
333  int margin;
334 
337 
340 
346 
355 
357 
359 
360  csHash<csString,csString> defaultWidgetStyles;
361 
362  bool ReadDefaultWidgetStyles(iDocumentNode* node);
363 
366 
369 
370 public:
371 
372  pawsWidget();
373  pawsWidget(const pawsWidget &origin);
374 
375 
376  virtual ~pawsWidget();
377 
390  virtual pawsWidget* WidgetAt(int x, int y);
391 
392  virtual void Ignore(bool ig)
393  {
394  ignore = ig;
395  }
396 
402  virtual void PerformAction(const char* action);
403 
409  virtual csRect GetScreenFrame();
410 
416  virtual csRect GetDefaultFrame()
417  {
418  return defaultFrame;
419  }
420 
426  bool IsVisible()
427  {
428  return visible && (!parent || parent->IsVisible());
429  }
430 
436  void SetVisibility(bool visible)
437  {
438  if(visible) Show();
439  else Hide();
440  }
441 
448  virtual void Show();
449 
457  virtual void ShowBehind();
458 
465  virtual void Hide();
466 
470  virtual void Close()
471  {
472  Hide();
473  }
474 
483  virtual bool CheckButtonPressed(int button, int modifiers, pawsWidget* pressedWidget);
484 
493  virtual bool CheckButtonReleased(int button, int modifiers, pawsWidget* pressedWidget);
494 
499  virtual bool CheckKeyHandled(int /*keyCode*/)
500  {
501  return false;
502  }
503 
511  void AddChild(pawsWidget* widget);
512 
520  void AddChild(size_t Index, pawsWidget* widget);
521 
526  virtual void DeleteChild(pawsWidget* widget);
527 
532  {
533  parent->DeleteChild(this);
534  }
535 
542  void RemoveChild(pawsWidget* widget);
543 
549  pawsWidget* GetChild(size_t i)
550  {
551  return children.Get(i);
552  }
553 
560  {
561  return children.GetSize();
562  }
563 
570  bool IsIndirectChild(pawsWidget* widget);
571 
577  bool IsChildOf(pawsWidget* someParent);
578 
584  bool Includes(pawsWidget* widget);
585 
591  void SetParent(pawsWidget* widget);
592 
602  pawsWidget* FindWidget(const char* name, bool complain = true);
603 
613  pawsWidget* FindWidget(int id, bool complain = true);
614 
623  pawsWidget* FindWidgetXMLBinding(const char* xmlbinding);
624 
630  virtual const csString &GetXMLBinding()
631  {
632  return xmlbinding;
633  }
634 
640  virtual void SetXMLBinding(csString &xmlbinding)
641  {
642  this->xmlbinding = xmlbinding;
643  }
644 
651  {
652  return parent;
653  }
654 
661  virtual bool Load(iDocumentNode* node);
662 
668  virtual bool LoadAttributes(iDocumentNode* node);
669 
675  virtual bool LoadEventScripts(iDocumentNode* node);
676 
682  virtual bool LoadChildren(iDocumentNode* node);
683 
692  bool LoadFromFile(const csString &fileName);
693 
697  virtual bool Setup(iDocumentNode* /*node*/)
698  {
699  return true;
700  }
701 
709  virtual bool PostSetup()
710  {
711  return true;
712  }
713 
722  virtual bool SelfPopulateXML(const char* xmlstr);
723 
736  virtual bool SelfPopulate(iDocumentNode* node);
737 
743  bool DrawWindow();
744 
748  void DrawForeground();
749 
756  virtual void Draw();
757 
758  virtual void Draw3D(iGraphics3D*) {}
759 
765  virtual void DrawBackground();
766 
770  virtual void DrawChildren();
771 
777  virtual void DrawMask();
778 
782  virtual bool ParentDraw() const
783  {
784  return parentDraw || !PawsManager::GetSingleton().UsingR2T();
785  }
786 
794  bool IsResizable()
795  {
796  return isResizable;
797  }
798 
804  void SetResizeShow(bool v)
805  {
806  showResize = v;
807  }
808 
814  void SetModalState(bool isModal);
815 
823  virtual bool OnGainFocus(bool /*notifyParent*/ = true)
824  {
825  hasFocus = true;
826  if(hasFocus) return true;
827  if(parent) parent->OnGainFocus();
828  return true;
829  }
830 
834  virtual void OnLostFocus()
835  {
836  if(!hasFocus) return;
837  hasFocus = false;
838  if(parent) parent->OnLostFocus();
839  }
840 
844  virtual void OnResize();
845 
849  virtual void StopResize();
850 
859  virtual int GetBorderColour(int which);
860 
869  virtual void SetRelativeFrame(int x, int y, int width, int height);
870 
874  virtual void ResetToDefaultFrame()
875  {
876  screenFrame = defaultFrame;
877  }
878 
886  virtual void SetRelativeFramePos(int x, int y);
887 
895  virtual void SetRelativeFrameSize(int width, int height);
896 
903  virtual void SetAttachFlags(int flags)
904  {
905  attachFlags = flags;
906  }
907 
919  virtual bool OnMouseDown(int button, int modifiers, int x, int y);
920 
927  virtual bool OnMouseUp(int button, int modifiers, int x, int y);
928 
935  virtual bool OnDoubleClick(int button, int modifiers, int x, int y);
936 
937 
944  virtual bool OnMouseEnter();
945 
951  virtual bool OnMouseExit();
952 
960  virtual bool OnChildMouseEnter(pawsWidget* child);
961 
969  virtual bool OnChildMouseExit(pawsWidget* child);
970 
981  virtual bool OnKeyDown(utf32_char keyCode, utf32_char keyChar, int modifiers);
982 
990  virtual bool OnJoypadDown(int key, int modifiers);
991 
998  virtual bool OnClipboard(const csString &content);
999 
1005  virtual bool HasFocus()
1006  {
1007  return hasFocus;
1008  }
1009 
1015  virtual bool GetFocusOverridesControls() const
1016  {
1017  return false;
1018  }
1019 
1029  virtual void BringToTop(pawsWidget* widget);
1030 
1036  virtual void SendToBottom(pawsWidget* widget);
1037 
1041  const char* GetName()
1042  {
1043  return name;
1044  }
1045 
1049  void SetName(const char* newName)
1050  {
1051  name.Replace(newName);
1052  closeName = name;
1053  closeName.Append("_close");
1054  }
1055 
1059  const char* GetCloseName()
1060  {
1061  return closeName;
1062  }
1063 
1071  virtual void MoveDelta(int dx, int dy);
1072 
1079  virtual void MoveTo(int x, int y);
1080 
1087  virtual void CenterTo(int x, int y);
1088 
1092  virtual void CenterToMouse();
1093 
1100  virtual void Resize(int flags);
1101 
1110  virtual void Resize(int dx, int dy, int flags);
1111 
1120  virtual void SetSize(int newWidth, int newHeight);
1121 
1125  virtual void SetForceSize(int newWidth, int newHeight);
1126 
1132  virtual void UseBorder(const char* style = 0);
1133 
1138  {
1139  return border;
1140  }
1141 
1148  virtual int GetBorderStyle()
1149  {
1150  return BORDER_BUMP;
1151  }
1152 
1159  virtual void SetBackground(const char* imageName);
1160 
1166  csString GetBackground();
1167 
1175  virtual void SetBackgroundAlpha(int alphaValue);
1176 
1180  virtual void Resize();
1181 
1190  virtual bool OnButtonPressed(int button, int keyModifier, pawsWidget* widget)
1191  {
1192  if(parent)
1193  return parent->OnButtonPressed(button, keyModifier, widget);
1194 
1195  return true;
1196  }
1197 
1205  virtual bool OnButtonReleased(int button, int keyModifier, pawsWidget* widget)
1206  {
1207  if(parent)
1208  return parent->OnButtonReleased(button, keyModifier, widget);
1209  return false;
1210  }
1211 
1219  virtual bool OnScroll(int scrollDirection, pawsScrollBar* widget)
1220  {
1221  if(parent) return parent->OnScroll(scrollDirection, widget);
1222  return false;
1223  }
1224 
1231  virtual bool OnSelected(pawsWidget* widget);
1232 
1240  virtual bool OnMenuAction(pawsWidget* widget, const pawsMenuAction &action);
1241 
1248  virtual bool OnChange(pawsWidget* widget);
1249 
1255  void SetID(int newID)
1256  {
1257  id = newID;
1258  }
1259 
1265  int GetID()
1266  {
1267  return id;
1268  }
1269 
1276  {
1277  return alwaysOnTop;
1278  }
1279 
1286  void SetAlwaysOnTop(bool value)
1287  {
1288  alwaysOnTop = value;
1289  if(parent)
1290  parent->BringToTop(this);
1291  }
1292 
1298  void SetMovable(bool value)
1299  {
1300  movable = value;
1301  }
1302 
1308  void SetToolTip(const char* text)
1309  {
1310  toolTip.Replace(text);
1311  }
1312 
1318  csString &GetToolTip()
1319  {
1320  return toolTip;
1321  }
1322 
1329  void FormatToolTip(const char* fmt, ...);
1330 
1335  {
1336  toolTip.Replace(defaultToolTip);
1337  }
1338 
1345  virtual void OnListAction(pawsListBox* selected, int status)
1346  {
1347  if(parent) parent->OnListAction(selected,status);
1348  }
1349 
1356  virtual void SavePosition();
1357 
1364  virtual csRect LoadPositions();
1365 
1371  void SetFactory(const char* myfactory)
1372  {
1373  factory = myfactory;
1374  }
1375 
1381  const char* GetType()
1382  {
1383  return factory;
1384  }
1385 
1390  int GetActualWidth(int myValue=-1)
1391  {
1392  if(myValue == -1)
1393  return screenFrame.Width();
1394 
1395  if(!resizeToScreen)
1396  return myValue;
1397 
1398  int desktop = graphics2D->GetWidth();
1399  if(myValue > 800)
1400  return desktop;
1401 
1402  float value = (float)myValue;
1403 
1404  float ret = (value * desktop) / 800.0f + 0.5f;
1405  return ((int)ret);
1406  }
1407 
1412  int GetActualHeight(int myValue=-1)
1413  {
1414  if(myValue == -1)
1415  return screenFrame.Height();
1416 
1417  if(!resizeToScreen)
1418  return myValue;
1419 
1420  int desktop = graphics2D->GetHeight();
1421  if(myValue > 600)
1422  return desktop;
1423 
1424  float value = (float)myValue;
1425 
1426  float ret = (value * desktop) / 600.0f + 0.5f;
1427  return ((int)ret);
1428  }
1429 
1430  int GetLogicalWidth(int myValue)
1431  {
1432  if(!resizeToScreen)
1433  return myValue;
1434 
1435  int desktop = graphics2D->GetWidth();
1436  myValue *= 800;
1437  myValue /= desktop;
1438  return myValue;
1439  }
1440 
1441  int GetLogicalHeight(int myValue)
1442  {
1443  if(!resizeToScreen)
1444  return myValue;
1445 
1446  int desktop = graphics2D->GetHeight();
1447  myValue *= 600;
1448  myValue /= desktop;
1449  return myValue;
1450  }
1451 
1459  virtual void MouseOver(bool value);
1460 
1466  void SetFade(bool value);
1467 
1473  void SetFontScaling(bool value);
1474 
1485  void DrawWidgetText(const char* text, int x, int y, int style=-1);
1486 
1497  csRect GetWidgetTextRect(const char* text, int x, int y, int style=-1);
1498 
1502  void SetMinSize(int width, int height)
1503  {
1504  min_width = width;
1505  min_height = height;
1506  }
1507 
1508  void GetMinSize(int &width, int &height)
1509  {
1510  width = min_width;
1511  height = min_height;
1512  }
1513 
1519  void SetMaxSize(int width, int height)
1520  {
1521  max_width = width;
1522  max_height = height;
1523  }
1524 
1525 
1529  void SetContextMenu(const csString &fileName)
1530  {
1531  contextMenuFile = fileName;
1532  }
1533 
1538  void MakeFullyVisible();
1539 
1544  void RecalcScreenPositions();
1545 
1553  void ClipToParent(bool allowForBackgroundBorder);
1554 
1560  csRect ClipRect()
1561  {
1562  return clipRect;
1563  }
1564 
1574  void SetColour(int newColour = -2);
1575 
1579  void SetFont(const char* fontName, int Size=0);
1580 
1586  void ChangeFontSize(float newSize);
1587 
1594  float GetFontSize();
1595 
1602  iFont* GetFont(bool scaled = true);
1603 
1611  virtual int GetFontColour();
1612 
1619  int GetFontShadowColour();
1620 
1627  int GetFontStyle();
1628 
1632  void SetFontStyle(int style);
1633 
1641  virtual bool Contains(int x, int y);
1642 
1647  virtual void CreateWidgetConfigWindow();
1648 
1653  virtual void DestroyWidgetConfigWindow();
1654 
1659  {
1660  return alphaMin;
1661  };
1662 
1667  {
1668  return alpha;
1669  };
1670 
1675  {
1676  return (int)fadeVal;
1677  };
1678 
1682  void SetMinAlpha(int value)
1683  {
1684  alphaMin=value;
1685  };
1686 
1690  void SetMaxAlpha(int value)
1691  {
1692  alpha=value;
1693  };
1694 
1699  {
1700  return fade;
1701  };
1702 
1707  {
1708  return fadeSpeed;
1709  };
1710 
1714  void SetFadeSpeed(float speed)
1715  {
1716  fadeSpeed=speed;
1717  };
1718 
1723  {
1724  return scaleFont;
1725  }
1726 
1730  void SetTitle(const char* title);
1731 
1735  virtual void SaveSettings();
1736 
1740  virtual void LoadSettings();
1741 
1749  virtual void DrawToolTip(int x, int y);
1750 
1756  virtual void Dump(csString tab = "");
1757 
1762  csString GetPathInWidgetTree();
1763 
1769  void SetMaskingImage(const char* image);
1770 
1774  void ClearMaskingImage();
1775 
1783  void SetBackgroundColor(int r,int g, int b);
1784 
1786  {
1787  bgColour = -1;
1788  }
1789 
1793  void SetFilename(const char* name);
1794 
1798  const char* GetFilename();
1799 
1803  void ReloadWidget();
1804 
1812  {
1813  delete extraData;
1814  extraData = data;
1815  }
1816 
1823  {
1824  return extraData;
1825  }
1826 
1833  {
1834  return configurable;
1835  }
1836 
1837  virtual void OnUpdateData(const char* /*dataname*/, PAWSData & /*data*/) {}
1838  virtual void NewSubscription(const char* dataname)
1839  {
1840  subscribedVar = dataname;
1841  }
1842 
1854  bool SetTitle(const char* text, const char* image, const char* align, const char* close_button, const bool shadowTitle = true);
1855 
1856  void RemoveTitle();
1857 
1858  const char* FindDefaultWidgetStyle(const char* factoryName);
1859 
1864  void SetNeedsRender(bool needs)
1865  {
1866  if(parent)
1867  parent->SetNeedsRender(needs);
1868  else
1869  needsRender = needs;
1870  }
1871 
1875  bool NeedsRender() const
1876  {
1877  return needsRender;
1878  }
1879 
1880 protected:
1884  int ResizeFlags(int mouseX, int mouseY);
1885 
1889  bool CreateContextMenu();
1890 
1895  int CalcChildPosition(pawsWidget* child);
1896 
1900  void LoadBorderColours(iDocumentNode* node);
1901 
1905  void SetCloseButtonPos();
1906 
1910  int GetAttachFlag(const char* flag);
1911 
1912 public:
1917 
1918  const char* ToString()
1919  {
1920  return name.GetDataSafe();
1921  }
1922  virtual double GetProperty(MathEnvironment* env, const char* ptr);
1923  virtual double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
1924  virtual void SetProperty(const char* ptr, double value);
1925 
1926  csArray<csString> publishList;
1927 };
1928 
1929 //----------------------------------------------------------------------------
1930 
1931 
1932 
1934 {
1935 public:
1936  virtual ~pawsWidgetFactory() {};
1937 
1938  virtual pawsWidget* Create();
1939 
1940  virtual pawsWidget* Create(const pawsWidget* origin);
1941 
1942  virtual const char* GetName()
1943  {
1944  return factoryName;
1945  }
1946 
1947 protected:
1948  virtual void Register(const char* name);
1949 
1950 
1951  csString factoryName;
1952 };
1953 
1954 //---------------------------------------------------------------------------
1955 
1956 
1958 {
1959 public:
1961  {
1962  Register("pawsWidget");
1963  }
1964 
1966  {
1967  return new pawsWidget();
1968  }
1969 };
1970 
1971 
1972 #define CREATE_PAWS_FACTORY( factoryName ) \
1973 class factoryName##Factory : public pawsWidgetFactory \
1974 { \
1975 public: \
1976  factoryName##Factory( ) \
1977  { \
1978  Register( #factoryName ); \
1979  } \
1980  \
1981  pawsWidget* Create() \
1982  { \
1983  return new factoryName( ); \
1984  } \
1985  pawsWidget* Create(const pawsWidget* origin)\
1986  {\
1987  const factoryName * widget = dynamic_cast<const factoryName *>(origin);\
1988  if(widget)\
1989  {\
1990  return new factoryName(*widget);\
1991  }\
1992  return NULL;\
1993  }\
1994 }
1995 
1996 
1997 
1998 
2001 #endif
2002 
2003 
int CalcChildPosition(pawsWidget *child)
Calculates the right position in array of children for a given child (depends on always-on-top state)...
virtual void SetRelativeFramePos(int x, int y)
Set the position of this widget relative to the parent.
pawsWidget * GetParent()
Get this widget&#39;s parent.
Definition: pawswidget.h:650
virtual void ShowBehind()
Makes widget visible and brings it to the front but behind widget with current focus.
virtual void ResetToDefaultFrame()
Resets the position, width and height to the default position.
Definition: pawswidget.h:874
void SetMaxSize(int width, int height)
Set the max size for height and width.
Definition: pawswidget.h:1519
csRect GetWidgetTextRect(const char *text, int x, int y, int style=-1)
Get the rectangle containing the text DrawWidgetText will produce.
csHash< csString, csString > defaultWidgetStyles
Definition: pawswidget.h:360
bool keepaspect
Enforce keeping the default aspect ratio when resizing.
Definition: pawswidget.h:199
void SetExtraData(iWidgetData *data)
Stores extra data into this widget.
Definition: pawswidget.h:1811
bool parentDraw
Whether to draw this widget (different from visible, used to decide if Draw() is called via parent-ch...
Definition: pawswidget.h:345
csString toolTip
Tooltip to be displayed.
Definition: pawswidget.h:317
const char * FindDefaultWidgetStyle(const char *factoryName)
bool visible
Flag to determine visiblity.
Definition: pawswidget.h:169
int id
The id of the widget.
Definition: pawswidget.h:127
bool showResize
If the resize widget should be drawn.
Definition: pawswidget.h:190
virtual bool Contains(int x, int y)
Determines if the coordinates are within this widget.
bool isResizable
Determines if this widget can be resized by user.
Definition: pawswidget.h:187
bool alwaysOnTop
Is this windows painted on top of other windows.
Definition: pawswidget.h:202
int ResizeFlags(int mouseX, int mouseY)
This will check to see if the mouse is over the resize hot spot.
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
void SetFontScaling(bool value)
Used to control the font scaling of the widget.
virtual int GetFontColour()
Gets the current font color.
virtual bool OnKeyDown(utf32_char keyCode, utf32_char keyChar, int modifiers)
Process keydown messages.
void DrawWidgetText(const char *text, int x, int y, int style=-1)
Draw text in the widget at specified location.
virtual void SetBackground(const char *imageName)
Sets the background image, logs error if NULL.
bool IsIndirectChild(pawsWidget *widget)
Returns true, if &#39;widget&#39; is child of our widget, even if it is indirect.
virtual bool OnButtonReleased(int button, int keyModifier, pawsWidget *widget)
Called whenever a button is released.
Definition: pawswidget.h:1205
bool ignore
Flag determines if WidgetAT() ignores this widget.
Definition: pawswidget.h:330
iFont * GetFont(bool scaled=true)
Gets the current font as an iFont.
void SetTitle(const char *title)
Sets the border title of this widget.
csArray< csString > publishList
Definition: pawswidget.h:1926
pawsWidget * onEnter
Widget to call if enter is pressed.
Definition: pawswidget.h:166
csString showOnMouseOver_image
Stores the bgimage name if showOnMouseOver is true.
Definition: pawswidget.h:368
csString fontName
Name of currently selected font.
Definition: pawswidget.h:305
Shown when you right click on a window.
float GetFadeSpeed()
Gets the fading speed.
Definition: pawswidget.h:1706
virtual double CalcFunction(MathEnvironment *env, const char *functionName, const double *params)
A specific MathEnvironment to be used in a MathScript.
Definition: mathscript.h:188
void SetMinAlpha(int value)
Sets the minimim alpha of this widget.
Definition: pawswidget.h:1682
pawsWidget * GetChild(size_t i)
Used if you need to loop through the children of a widget.
Definition: pawswidget.h:549
bool fade
Set to false to disable fading.
Definition: pawswidget.h:260
virtual void CenterToMouse()
Move this widget so that its center is at mouse pointer, but it is fully on screen.
virtual void Resize()
Resize a widget based on it&#39;s parent&#39;s size.
virtual pawsWidget * WidgetAt(int x, int y)
Locate a widget that is at these screen coordindates.
When pawsMenu is created, target of notification messages (OnMenuAction) must be set by SetNotify() m...
Definition: pawsmenu.h:96
void ReloadWidget()
Reloads widget from XML file.
int GetLogicalHeight(int myValue)
Definition: pawswidget.h:1441
csString subscribedVar
The variable that this widget is subscribed to.
Definition: pawswidget.h:223
pawsWidget * FindWidget(const char *name, bool complain=true)
Find a child widget of this widget.
virtual void StopResize()
Called once the mouse up is done after resizing a widget.
bool isScalingFont()
Returns whether or not font is being auto-scaled.
Definition: pawswidget.h:1722
void SetFadeSpeed(float speed)
Sets the fading speed.
Definition: pawswidget.h:1714
float defaultFontSize
Default font size.
Definition: pawswidget.h:296
void SetID(int newID)
Change the id of a widget.
Definition: pawswidget.h:1255
pawsWidget * Create()
Definition: pawswidget.h:1965
bool overwrite_subscription
Flag of whether OnUpdateData should overwrite the previous value or add to it.
Definition: pawswidget.h:354
Main PlaneShift Window manager.
Definition: pawsmanager.h:82
csString defaultToolTip
Default tool tip string for the widget.
Definition: pawswidget.h:320
bool UsingR2T() const
Definition: pawsmanager.h:141
csString name
The name of this widget.
Definition: pawswidget.h:217
virtual void SetForceSize(int newWidth, int newHeight)
Same as above, but does not resize children.
bool scaleFont
Determines whether or not to scale font when a widget it resized.
Definition: pawswidget.h:302
bool saveWidgetPositions
Determines if this widget should write/load it&#39;s position from a config file.
Definition: pawswidget.h:175
virtual bool PostSetup()
This is called after the widget and all of it&#39;s children have been created.
Definition: pawswidget.h:709
bool CreateContextMenu()
Creates context menu from file (&#39;contextMenuFile&#39; attribute)
int GetFontStyle()
Gets the current font style.
virtual bool LoadEventScripts(iDocumentNode *node)
Load event scripts for this widget.
virtual void CenterTo(int x, int y)
Move this widget so that its center is at given location.
bool Includes(pawsWidget *widget)
Returns true if widget equals this, or widget is a child of this.
bool hasMouseFocus
Flag for mouse over behavior.
Definition: pawswidget.h:248
virtual void SetBackgroundAlpha(int alphaValue)
Sets the alpha level of the background.
int alphaMin
The minimum background alpha.
Definition: pawswidget.h:257
int min_height
Defines the minimum height that the widget can be.
Definition: pawswidget.h:208
csString GetBackground()
Retrieve the background image name.
static PawsManager & GetSingleton(void)
Definition: singleton.h:49
virtual pawsBorder * GetBorder()
This returns the border created by UseBorder().
Definition: pawswidget.h:1137
virtual bool OnSelected(pawsWidget *widget)
Called whenever a widget is selected.
void SetResizeShow(bool v)
Sets the showResize flag, controlling if the resize widget should be drawn.
Definition: pawswidget.h:804
bool needsRender
Whether we need to do a r2t update.
Definition: pawswidget.h:339
virtual void CreateWidgetConfigWindow()
Creates a popup window that the user can use to adjust the settings of this window.
virtual bool CheckKeyHandled(int)
Allow pawsButton to simulate button pushes based on keypresses.
Definition: pawswidget.h:499
bool movable
Determines if this widget is movable.
Definition: pawswidget.h:184
virtual bool SelfPopulate(iDocumentNode *node)
This function allows a widget to fill in its own contents from an xml node supplied and calls the sam...
csString xmlbinding
Used in the SelfPopulate functions to map to xml nodes for each widget.
Definition: pawswidget.h:314
float fadeSpeed
The speed of the fading process.
Definition: pawswidget.h:263
csString contextMenuFile
Path to the file that describes context menu of our widget (invoked by mouse right-click).
Definition: pawswidget.h:271
bool IsAlwaysOnTop()
Tests value of this widgets alwaysOnTop flag.
Definition: pawswidget.h:1275
float fadeVal
The direction and percentage of current fade in progress.
Definition: pawswidget.h:251
void SetFactory(const char *myfactory)
Sets the type of factory.
Definition: pawswidget.h:1371
void SetFontStyle(int style)
Sets the current font style.
float fontSize
Current font size.
Definition: pawswidget.h:299
virtual bool OnMenuAction(pawsWidget *widget, const pawsMenuAction &action)
Called whenever a menu action occurs.
void ChangeFontSize(float newSize)
Change font to new size and reload font to make it take effect.
virtual void DeleteChild(pawsWidget *widget)
Removes the widget from list of children and destructs it.
void DrawForeground()
Does the second part of the drawing drawing the background of the window.
virtual bool OnScroll(int scrollDirection, pawsScrollBar *widget)
Called whenever a window is scrolled.
Definition: pawswidget.h:1219
virtual void MoveDelta(int dx, int dy)
Move a widget by a delta amount.
virtual bool HasFocus()
Test focus of the widget.
Definition: pawswidget.h:1005
int max_width
Defines the maximum width that the widget can be.
Definition: pawswidget.h:211
pawsWidget * parent
This widget&#39;s parent.
Definition: pawswidget.h:130
bool DrawWindow()
Does the first part of the drawing.
csRef< iFont > myFont
Optional font to use when drawing this widget.
Definition: pawswidget.h:287
void ClearBackgroundColor()
Definition: pawswidget.h:1785
virtual void BringToTop(pawsWidget *widget)
Move this widget up the z order to the top.
csString factory
factory name
Definition: pawswidget.h:124
csRect clipRect
Current clipping rectangle.
Definition: pawswidget.h:142
pawsTitle * titleBar
reference to titleBar object, if any
Definition: pawswidget.h:145
bool LoadFromFile(const csString &fileName)
Parses XML file &#39;fileName&#39;, finds first widget tag and Load()s itself from this tag.
void SetCloseButtonPos()
Gets button from widget and sets it&#39;s location.
virtual void DrawToolTip(int x, int y)
This draws the tool tip if a widget is visible and a tool tip is available.
int GetActualHeight(int myValue=-1)
Returns the actual Height assuming the passed value was in 800x600 resolution.
Definition: pawswidget.h:1412
virtual bool LoadAttributes(iDocumentNode *node)
Load standard widget attributes based on its <widget></widget> tag.
pawsMenu * contextMenu
Existing context menu of the widget.
Definition: pawswidget.h:278
int defaultFontColour
Optional color to use when drawing text with this widget.
Definition: pawswidget.h:290
virtual csRect GetScreenFrame()
Returns the csRect that defines widget area.
virtual bool OnMouseUp(int button, int modifiers, int x, int y)
Manage mouse up event.
pawsMenu is standard PAWS menu widget.
Definition: pawsmenu.h:192
Definition: wn.h:164
void MakeFullyVisible()
If some part of the widget is not within the rectangle of its parent, then the widget is moved inside...
void SetToolTip(const char *text)
Changes the text for a tool tip.
Definition: pawswidget.h:1308
bool resizeToScreen
Determines if this widget should be auto resized with screen resolution.
Definition: pawswidget.h:196
virtual void DrawChildren()
Draws all children marked visible.
virtual void DestroyWidgetConfigWindow()
Called by ApplyAlphaOnChildren to remove the config window to prevent weird stuff.
csString GetPathInWidgetTree()
Returns textual description of path to our widget through the widget tree.
void SetMaskingImage(const char *image)
Sets a masking image which will be drawn after the normal stuff.
int max_height
Defines the maximum height that the widget can be.
Definition: pawswidget.h:214
int attachFlags
The attachpoints for when a resize takes place.
Definition: pawswidget.h:242
csString factoryName
Definition: pawswidget.h:1951
bool NeedsRender() const
Whether we need to r2t.
Definition: pawswidget.h:1875
const char * GetName()
Get the name of this widget.
Definition: pawswidget.h:1041
virtual csRect LoadPositions()
Get the position of this widget that was stored in a cfg file.
int alpha
The original background alpha.
Definition: pawswidget.h:254
void DeleteYourself()
Removes and destructs itself.
Definition: pawswidget.h:531
virtual bool OnChange(pawsWidget *widget)
Called whenever a widget is selected.
virtual void DrawBackground()
Draws the background with a color or an image.
virtual void SetRelativeFrame(int x, int y, int width, int height)
Set the size of this widget and it&#39;s position relative to the parent.
csRect ClipRect()
This returns the current clipping rectangle.
Definition: pawswidget.h:1560
int borderColours[5]
Custom border colors for this window.
Definition: pawswidget.h:281
virtual void MouseOver(bool value)
Sets hasMouseFocus.
virtual void Dump(csString tab="")
Prints the widget names for the widget and all it&#39;s children.
virtual bool ParentDraw() const
Whether to draw via the parent-child draw tree.
Definition: pawswidget.h:782
void RunScriptEvent(PAWS_WIDGET_SCRIPT_EVENTS event)
Executes any pawsScript associated with the given event.
csString closeName
Old name of the widget with "_close" appended by SetName().
Definition: pawswidget.h:220
csRect defaultFrame
The default frame for the widget.
Definition: pawswidget.h:136
void FormatToolTip(const char *fmt,...)
Changes the format of a tool tip.
A simple list box widget.
Definition: pawslistbox.h:202
int GetFontShadowColour()
Gets the current shadow color.
int GetActualWidth(int myValue=-1)
Returns the actual width assuming the passed value was in 800x600 resolution.
Definition: pawswidget.h:1390
csString & GetToolTip()
Gets the text from a tool tip.
Definition: pawswidget.h:1318
int GetMaxAlpha()
Gets the maximum alpha value of this widget.
Definition: pawswidget.h:1666
void SetContextMenu(const csString &fileName)
Sets name of the PAWS xml-file that describes context menu of our widget.
Definition: pawswidget.h:1529
virtual void Close()
Simply calls Hide() unless overidden.
Definition: pawswidget.h:470
int bgColour
Stores the bgColour for this widget.
Definition: pawswidget.h:230
virtual void OnResize()
Sets the new position of the close button.
virtual bool OnChildMouseEnter(pawsWidget *child)
Called when mouse enters a child widget.
pawsBorder * border
border created by GetBorder().
Definition: pawswidget.h:236
virtual void SetProperty(const char *ptr, double value)
pawsScript * scriptEvents[PW_SCRIPT_EVENT_COUNT]
Definition: pawswidget.h:358
bool IsChildOf(pawsWidget *someParent)
Returns true, if this widget is the child of &#39;someParent&#39;.
int GetFadeVal()
Gets the fade value of this widget.
Definition: pawswidget.h:1674
virtual void Draw()
Draws the widget and all of it&#39;s children.
bool hasBorderColours
Flag to indicate using custom border colors.
Definition: pawswidget.h:284
A simple scroll bar widget.
Definition: pawscrollbar.h:64
void ClearMaskingImage()
Clears the masking image.
void GetMinSize(int &width, int &height)
Definition: pawswidget.h:1508
const char * GetFilename()
Returns the filename.
void ClipToParent(bool allowForBackgroundBorder)
Determines clipping area to use.
int GetMinAlpha()
Gets the minimim alpha value of this widget.
Definition: pawswidget.h:1658
pawsButton * close_widget
Used in SetTitle() for the new close button.
Definition: pawswidget.h:151
virtual bool OnJoypadDown(int key, int modifiers)
Process joypadDown messages.
virtual void MoveTo(int x, int y)
Moves this widget and all of its children to a new screen location.
virtual void Ignore(bool ig)
Definition: pawswidget.h:392
int defaultFontShadowColour
Optional color to use when doing text dropshadows.
Definition: pawswidget.h:293
virtual bool CheckButtonReleased(int button, int modifiers, pawsWidget *pressedWidget)
Test button for activity.
csArray< pawsWidget * > taborder
Contains the children for tabbing.
Definition: pawswidget.h:163
void SetBackgroundColor(int r, int g, int b)
Sets the background color.
int margin
Stores margin value. Used in LoadAttributes().
Definition: pawswidget.h:333
This is a class that draws the border around a widget.
Definition: pawsborder.h:78
const char * GetCloseName()
Returns the closeName of this widget.
Definition: pawswidget.h:1059
virtual bool OnMouseDown(int button, int modifiers, int x, int y)
Manage mouse down event to test for and apply window changes.
virtual bool CheckButtonPressed(int button, int modifiers, pawsWidget *pressedWidget)
Test button for activity.
void SetMinSize(int width, int height)
Set the minimum height and width to protect the widget from negatives.
Definition: pawswidget.h:1502
virtual bool OnClipboard(const csString &content)
Process Clipboard content, as a response to RequestClipboardContent.
virtual bool OnDoubleClick(int button, int modifiers, int x, int y)
Manage mouse double click event.
csString filename
filename to load from or save to.
Definition: pawswidget.h:148
virtual bool OnMouseEnter()
Called whenever the mouse enters this widget.
virtual void OnListAction(pawsListBox *selected, int status)
Called whenever an item in a child list box is selected.
Definition: pawswidget.h:1345
size_t GetChildrenCount()
Used if you need to loop through the children of a widget.
Definition: pawswidget.h:559
void SetVisibility(bool visible)
Make the widget visible or hides it.
Definition: pawswidget.h:436
bool borderTitleShadow
whether the title in the border should be shadow font
Definition: pawswidget.h:239
A simple button widget.
Definition: pawsbutton.h:43
virtual bool LoadChildren(iDocumentNode *node)
Load widget children based on subtags of its <widget></widget> tag.
virtual csRect GetDefaultFrame()
Returns the default csRect.
Definition: pawswidget.h:416
virtual void SavePosition()
Saves the position of this widget to the config file.
virtual bool OnChildMouseExit(pawsWidget *child)
Called when a mouse exits a child widget.
virtual int GetBorderStyle()
This returns the BORDER_BUMP style.
Definition: pawswidget.h:1148
void SetMaxAlpha(int value)
Sets the maximum alpha of this widget.
Definition: pawswidget.h:1690
void SetParent(pawsWidget *widget)
Set the owner of this widget.
virtual bool Load(iDocumentNode *node)
Load a widget based on its <widget></widget> tag.
virtual void UseBorder(const char *style=0)
Creates a new border and links it to the widget.
int GetAttachFlag(const char *flag)
Convert from string flag to int flag.
void SetNeedsRender(bool needs)
Marks that we need to r2t.
Definition: pawswidget.h:1864
void SetFont(const char *fontName, int Size=0)
Set font to use programmatically.
virtual void SaveSettings()
Saves current widget settings to an XML file.
int GetID()
Gets the id of a widget.
Definition: pawswidget.h:1265
virtual void SendToBottom(pawsWidget *widget)
Move this widget down the z order to the bottom.
virtual double GetProperty(MathEnvironment *env, const char *ptr)
virtual ~pawsWidgetFactory()
Definition: pawswidget.h:1936
A class that can be inherited to store extra data in a widget.
Definition: pawswidget.h:120
void SetModalState(bool isModal)
Registers mode with the windowManager.
void RemoveTitle()
virtual void Show()
Makes widget visible and brings it to the front.
void SetName(const char *newName)
Set the name of this widget.
Definition: pawswidget.h:1049
virtual int GetBorderColour(int which)
Get the color for this widgets border.
virtual const char * GetName()
Definition: pawswidget.h:1942
bool hasFocus
Flag for widget focus.
Definition: pawswidget.h:245
virtual bool SelfPopulateXML(const char *xmlstr)
This function parses the xml string and calls SelfPopulate with the resulting DOM structure if valid...
float GetFontSize()
Gets the current font size.
bool IsConfigurable()
Tests if widget settings (alpha, fade, etc) are configurable.
Definition: pawswidget.h:1832
virtual void SetXMLBinding(csString &xmlbinding)
Sets the xml nodes of this widget.
Definition: pawswidget.h:640
void RecalcScreenPositions()
This re-calculates a widget&#39;s on screen position to draw based on it&#39;s relative position and parent s...
void SetAlwaysOnTop(bool value)
Sets value of this widgets alwaysOnTop flag.
Definition: pawswidget.h:1286
pawsWidget * FindWidgetXMLBinding(const char *xmlbinding)
Find a child widget of this widget with the given XML binding.
iWidgetData * GetExtraData()
Grabs extra data stored in the widget.
Definition: pawswidget.h:1822
virtual bool OnGainFocus(bool=true)
Changes hasFocus to TRUE and reports status to parent.
Definition: pawswidget.h:823
virtual void PerformAction(const char *action)
Does an action based on this string.
virtual const csString & GetXMLBinding()
Get the xml nodes of this widget.
Definition: pawswidget.h:630
const char * GetType()
Gets the current factory type.
Definition: pawswidget.h:1381
bool ReadDefaultWidgetStyles(iDocumentNode *node)
bool IsVisible()
Is the widget currently set visible?
Definition: pawswidget.h:426
virtual ~pawsWidget()
csRef< iPawsImage > bgImage
Background image.
Definition: pawswidget.h:233
virtual void SetAttachFlags(int flags)
Modify attachFlags to control widget construction.
Definition: pawswidget.h:903
int fontStyle
Current font style.
Definition: pawswidget.h:308
virtual bool OnMouseExit()
Called whenever the mouse leaves this widget.
void AddChild(pawsWidget *widget)
Add a child widget to this widget.
#define BORDER_BUMP
Definition: pawswidget.h:77
csRect screenFrame
The screen area of the widget.
Definition: pawswidget.h:139
virtual bool GetFocusOverridesControls() const
Test if the widget should intercept all key presses.
Definition: pawswidget.h:1015
virtual void NewSubscription(const char *dataname)
Definition: pawswidget.h:1838
void LoadBorderColours(iDocumentNode *node)
Loads custom border color preferences.
virtual void SetRelativeFrameSize(int width, int height)
Sets defaultFrame and screenFrame size attributes.
iWidgetData * extraData
Holds any extra data the widget may need.
Definition: pawswidget.h:336
bool showOnMouseOver
Stores status of showOnMouseOver.
Definition: pawswidget.h:365
void SetMovable(bool value)
Makes a widget movable.
Definition: pawswidget.h:1298
virtual void LoadSettings()
Loads current widget settings from an XML file.
virtual bool OnButtonPressed(int button, int keyModifier, pawsWidget *widget)
Called whenever a button is pressed.
Definition: pawswidget.h:1190
virtual void DrawMask()
Draws the mask picture.
virtual void Draw3D(iGraphics3D *)
Definition: pawswidget.h:758
virtual void Hide()
Makes widget invisible and removes focus if widget has current focus.
csRef< iGraphics2D > graphics2D
The 2D graphics interface.
Definition: pawswidget.h:133
int GetLogicalWidth(int myValue)
Definition: pawswidget.h:1430
virtual void OnLostFocus()
Sets hasFocus false and notifys parent.
Definition: pawswidget.h:834
void RemoveChild(pawsWidget *widget)
Removes the widget from list of children but does NOT destruct it.
virtual void OnUpdateData(const char *, PAWSData &)
Definition: pawswidget.h:1837
csString subscription_format
Definition: pawswidget.h:356
const char * ToString()
Definition: pawswidget.h:1918
csRef< iPawsImage > maskImage
Masking image, used for nice-looking stuff.
Definition: pawswidget.h:323
void SetFade(bool value)
Used to control the fading feature of the widget.
PAWS_WIDGET_SCRIPT_EVENTS
Definition: pawswidget.h:90
virtual void SetSize(int newWidth, int newHeight)
Set the size of a particlar widget.
bool isFadeEnabled()
Gets the fade status of this widget.
Definition: pawswidget.h:1698
csArray< pawsWidget * > children
The child widgets.
Definition: pawswidget.h:160
void SetFilename(const char *name)
Changes filename to the name provided.
virtual bool Setup(iDocumentNode *)
Setup this widget.
Definition: pawswidget.h:697
void SetColour(int newColour=-2)
Set text color.
bool configurable
Determines if the settings (alpha, fade, etc) of this widget are configurable.
Definition: pawswidget.h:181
bool IsResizable()
Test widget to see if it is resizable.
Definition: pawswidget.h:794
void SetDefaultToolTip()
Sets the tool tip to the one defined in the XML.
Definition: pawswidget.h:1334
int min_width
Defines the minimum width that the widget can be.
Definition: pawswidget.h:205