tbx  0.7.5
lockextentposition.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2015 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 #ifndef TBX_LOCKEXTENTPOSITION_H
26 #define TBX_LOCKEXTENTPOSITION_H
27 
28 #include "window.h"
29 #include "gadget.h"
30 #include <utility>
31 
32 namespace tbx
33 {
34 
44 {
45  tbx::Window _window;
46  tbx::BBox _last_extent;
47  int _num_gadgets;
48  typedef std::pair<tbx::Gadget, unsigned int> Item;
49  Item *_items;
50 
51 public:
52  LockExtentPosition() : _num_gadgets(0), _items(0) {}
54  virtual ~LockExtentPosition();
55 
59  tbx::Window &window() {return _window;}
60  void window(tbx::Window &window);
61 
65  enum LockFlags
66  {
67  left_to_left = 1,
68  left_to_right = 2,
69  right_to_left = 4,
70  right_to_right = 8,
71  bottom_to_top = 16,
72  bottom_to_bottom = 32,
73  top_to_top = 64,
74  top_to_bottom = 128
75  };
76 
77  void add_gadget(tbx::Gadget gadget, unsigned int lock_flags);
78  void add_gadget(tbx::ComponentId id, unsigned int lock_flags);
79  void add_gadgets(tbx::ComponentId from, tbx::ComponentId to, unsigned int lock_flags);
80  void remove_gadget(tbx::Gadget gadget);
83  void clear();
84 
85  void extent_changed();
86 };
87 
88 } /* namespace tbx */
89 
90 #endif
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
This is the base class for all Gadgets.
Definition: gadget.h:48
Class to represent a two dimensional bounding box.
Definition: bbox.h:37
int ComponentId
Type for underlying toolbox component id.
Definition: handles.h:33
void extent_changed()
Method to check if window extent has changed and move the gadgets if necessary.
Definition: lockextentposition.cc:202
virtual ~LockExtentPosition()
Destructor free resources and remove window listener used.
Definition: lockextentposition.cc:47
void add_gadgets(tbx::ComponentId from, tbx::ComponentId to, unsigned int lock_flags)
Add range of gadgets with the same lock flags.
Definition: lockextentposition.cc:114
The Window object represents a toolbox window.
Definition: window.h:69
LockFlags
Lock states, shifted for each edge.
Definition: lockextentposition.h:65
void add_gadget(tbx::Gadget gadget, unsigned int lock_flags)
Add a gadget to the list to be locked.
Definition: lockextentposition.cc:78
void clear()
Clear list of gadget locked in place.
Definition: lockextentposition.cc:191
void remove_gadgets(tbx::ComponentId from, tbx::ComponentId to)
Remove a range of gadgets.
Definition: lockextentposition.cc:181
tbx::Window & window()
Return window gadgets are locked to.
Definition: lockextentposition.h:59
Class to lock the position of gadgets relative to the work area of the window they are in...
Definition: lockextentposition.h:43
void remove_gadget(tbx::Gadget gadget)
Remove gadget from list.
Definition: lockextentposition.cc:140