JNR
uiWindow.h
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 
31 
32 
33 #define CUI__WINDOW_DRAGSTEP 1
34 
45 class uiWindow:
46  public laLoadableObj, public uiSkinUser
47 {
48 private:
49  unsigned long _uID;
50 
52 
53  bool m_bMouseInside;
54  BYTE l, r;
55  bool rememver_ldn;
56  bool rememver_rdn;
57 
58  static uiPointer* _pPointer;
59  laPoint3 _ptPointerOldPos;
60  laPoint3 _ptPointerOffest;
62 
63  friend class uiDesktop;
64 
65 protected:
66 
67  friend class uiContainer;
68  friend class uiSlider;
69 
72 
74 
75  laPoint3 _ptPos;
76  laPoint3 _ptSize;
77  laPoint3 _ptDecorationSize;
78 
79 
81  laPoint3 getRelativePointerPos() {
82  return _pPointer->_ptPos - getAbsolutePos();
83  }
84 
86  bool _bVisible;
87 
89  bool _bEnabled;
90 
92  static uiPointer* getMousePointer() {return _pPointer;}
93 
94 public:
95 
97  uiWindow(void);
98  ~uiWindow(void);
99 
101 
102  virtual void create(laPoint3 pos, laPoint3 size);
103  virtual void kill();
104  virtual void load(class laFileParser *fp);
105 
106 
108 
109  virtual void reply();
110  virtual void draw();
111 
112 
114 
115  virtual void show() { _bVisible=true; };
116  virtual void hide() { _bVisible=false; };
117  bool isVisible() { return _bVisible; };
118 
119  void enable() { _bEnabled=true; };
120  void disable() { _bEnabled=false; };
121  bool isEnabled() { return _bEnabled; };
123 
125 
126  unsigned long getID() { return _uID; };
127  void setID(unsigned long id) { _uID=id; };
129 
131 
132  laPoint3 getPos() {return _ptPos; }
133  laPoint3 getAbsolutePos();
134 
135  laPoint3 getSize() {return _ptSize; }
136  laPoint3 getDecorationSize() {return _ptDecorationSize; }
138 
140  M_BOOL isMouseInside() {
141  laPoint3 pt = getRelativePointerPos();
142  if( (pt.x() < 0) || (pt.y() < 0) || (pt.x() > _ptSize.x()) || (pt.y() > _ptSize.y()))
143  return M_FALSE;
144  return M_TRUE;
145  }
146 
148  virtual void move(laPoint3 ptNewPos, unsigned nHReference=M_AL, unsigned nVReference=M_AT);
149 
150 
152 
153  virtual void onMouseIn();
154  virtual void onMouseOut();
155  virtual void onMouseMove(laPoint3 ptRelativePos);
156 
157  virtual void onDown(unsigned nButton);
158  virtual void onUp(unsigned nButton);
159  virtual void onClick(unsigned nButton);
160 
161  /*virtual void OnRDown();
162  virtual void OnRUp();
163  virtual void OnRClick();*/
164 
166  virtual void onCommand(unsigned long uID, unsigned long nCmd);
167 
169 
170 
171 };
172 
M_BOOL isMouseInside()
Helpful function that checks if the mouse pointer is inside the window.
Definition: uiWindow.h:140
laPoint3 _ptPos
Windos position (relative to parent)
Definition: uiWindow.h:75
GUI Container Window.
Definition: uiContainer.h:42
GUI Slider.
Definition: uiSlider.h:71
virtual void load(class laFileParser *fp)
Load a dialog layout form .cui file.
Definition: uiWindow.cpp:113
GUI Skin User.
Definition: uiSkinUser.h:41
virtual void move(laPoint3 ptNewPos, unsigned nHReference=M_AL, unsigned nVReference=M_AT)
Change window position.
Definition: uiWindow.cpp:51
Interface for loadable objects.
Definition: laLoadableObj.h:43
#define M_AL
Text align left.
#define M_AT
Text align top.
laPoint3 _ptSize
Window size.
Definition: uiWindow.h:76
bool _bVisible
Window visibility flag.
Definition: uiWindow.h:86
uiWindow * _pParent
Pointer to parent window, if any.
Definition: uiWindow.h:71
laPoint3 getAbsolutePos()
Get absolute window position.
Definition: uiWindow.cpp:188
static uiPointer * getMousePointer()
Enables children to get a pointer to the mouse pointer, but not to change it.
Definition: uiWindow.h:92
uiWindow(void)
Class constructor.
Definition: uiWindow.cpp:35
Base class for GUI windows.
Definition: uiWindow.h:45
virtual void create(laPoint3 pos, laPoint3 size)
Create new empty window.
Definition: uiWindow.cpp:99
GUI Topmost Window.
Definition: uiDesktop.h:44
laPoint3 _ptDecorationSize
Size of border elements; defaults to 0.
Definition: uiWindow.h:77
laPoint3 getRelativePointerPos()
Get mouse pointer position relative to window position.
Definition: uiWindow.h:81
bool _bEnabled
Window interactivity flag.
Definition: uiWindow.h:89
virtual void reply()
Handle input message.
Definition: uiWindow.cpp:130
virtual void draw()
Display the window.
Definition: uiWindow.cpp:198
laPoint3 getPos()
Get relative window position with regard to parent.
Definition: uiWindow.h:132
virtual void onCommand(unsigned long uID, unsigned long nCmd)
Command event handler.
Definition: uiWindow.cpp:263
File Parser.
Definition: laFileParser.h:41
virtual void kill()
Discard window and all children.
Definition: uiWindow.cpp:125
GUI Mouse Pointer.
Definition: uiPointer.h:41