FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
resizablewindow.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2013 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_GUI_WIDGETS_RESIZABLEWINDOW_H
23 #define FIFE_GUI_WIDGETS_RESIZABLEWINDOW_H
24 
25 // Standard C++ library includes
26 
27 // 3rd party library includes
28 #include <fifechan.hpp>
29 
30 // FIFE includes
31 // These includes are split up in two parts, separated by one empty line
32 // First block: files included from the FIFE root src directory
33 // Second block: files included from the same folder
34 #include "video/cursor.h"
35 
36 
37 namespace fcn {
38  class ResizableWindow : public Window, public KeyListener, public FocusListener {
39  public:
41  // left
43  // right
45  // top
47  // bottom
49  // left and top
51  // right and top
53  // left and bottom
55  // right and bottom
57  };
58 
60  ResizableWindow(bool resizable);
61  ResizableWindow(const std::string& caption, bool resizable=true);
62  virtual ~ResizableWindow();
63 
67  void setResizableBorderDistance(int32_t border);
68 
72  int32_t getResizableBorderDistance() const;
73 
77  void setResizable(bool resizable);
78 
82  bool isResizable() const;
83 
87  void setTopResizable(bool resizable);
88 
92  bool isTopResizable() const;
93 
97  void setRightResizable(bool resizable);
98 
102  bool isRightResizable() const;
103 
107  void setBottomResizable(bool resizable);
108 
112  bool isBottomResizable() const;
113 
117  void setLeftResizable(bool resizable);
118 
122  bool isLeftResizable() const;
123 
127  void setShove(bool shove);
128 
132  bool getShove() const;
133 
137  void set(CursorDirections direction, uint32_t cursor_id=0);
138 
142  void set(CursorDirections direction, FIFE::ImagePtr image);
143 
147  void set(CursorDirections direction, FIFE::AnimationPtr anim);
148 
152 
155  uint32_t getId(CursorDirections direction) const;
156 
160 
164 
165  // Inherited from Window
166 
167  virtual void resizeToContent(bool recursiv=true);
168 
169  // Inherited from FocusListener
170 
171  virtual void focusLost(const Event& event);
172 
173 
174  // Inherited from Window / MouseListener
175 
176  virtual void mouseEntered(MouseEvent& mouseEvent);
177 
178  virtual void mouseExited(MouseEvent& mouseEvent);
179 
180  virtual void mousePressed(MouseEvent& mouseEvent);
181 
182  virtual void mouseReleased(MouseEvent& mouseEvent);
183 
184  virtual void mouseMoved(MouseEvent& mouseEvent);
185 
186  virtual void mouseDragged(MouseEvent& mouseEvent);
187 
188  protected:
189  // initialized the 8 cursors, see CursorDirections
190  void initCursors();
191  // restore cursor
192  void restoreCursor();
193  // save cursor so we can restore it later
194  void saveCursor();
195 
196  // access to fifes cursor class
198  // distance from the widgets edge that is active for resizing events
200  // is resizable
202  // allow resize on top
204  // allow resize on right
206  // allow resize on bottom
208  // allow resize on left
210  // is currently resizing
212 
213  // indicate the changed size per direction
218  // is shove allowed
219  bool m_shove;
220 
221  struct CursorState {
226  };
227  // old saved cursor
229  // contains the 8 CursorStates, one per direction
230  std::vector<CursorState> m_cursors;
231  };
232 }
233 
234 #endif
void setShove(bool shove)
Sets if the widget should be pushed if the size reaches the minimum.
virtual void mousePressed(MouseEvent &mouseEvent)
virtual void mouseExited(MouseEvent &mouseEvent)
virtual void mouseReleased(MouseEvent &mouseEvent)
bool isTopResizable() const
Gets if the widget is resizable at top.
std::vector< CursorState > m_cursors
bool isResizable() const
Gets if the widget is resizable.
uint32_t getId(CursorDirections direction) const
Gets the mouse cursor handle for the specified direction.
void setResizableBorderDistance(int32_t border)
Sets the size of the area that is active for resize events.
virtual void mouseMoved(MouseEvent &mouseEvent)
void setBottomResizable(bool resizable)
Sets if the widget is resizable at bottom.
virtual void resizeToContent(bool recursiv=true)
void setResizable(bool resizable)
Sets if the widget is resizable.
virtual void focusLost(const Event &event)
bool isBottomResizable() const
Gets if the widget is resizable at bottom.
bool isLeftResizable() const
Gets if the widget is resizable at left.
MouseCursorType
Defines the type of shown cursor native -> default cursor image -> cursor from image pool animation -...
Definition: cursor.h:48
bool isRightResizable() const
Gets if the widget is resizable at right.
void setTopResizable(bool resizable)
Sets if the widget is resizable at top.
FIFE::ImagePtr getImage(CursorDirections direction)
Gets the mouse image for the specified direction.
void setLeftResizable(bool resizable)
Sets if the widget is resizable at left.
FIFE::MouseCursorType cursorType
int32_t getResizableBorderDistance() const
Gets the size of the area that is active for resize events.
Cursor class manages mouse cursor handling.
Definition: cursor.h:73
FIFE::AnimationPtr getAnimation(CursorDirections direction)
Gets the mouse animation for the specified direction.
bool getShove() const
Gets if the widget should be pushed if the size reaches the minimum.
virtual void mouseDragged(MouseEvent &mouseEvent)
virtual void mouseEntered(MouseEvent &mouseEvent)
unsigned int uint32_t
Definition: core.h:40
void setRightResizable(bool resizable)
Sets if the widget is resizable at right.
FIFE::Cursor * m_cursor
FIFE::MouseCursorType getType(CursorDirections direction) const
Gets the mouse cursor type for the specified direction.