Commit dfcd459e authored by Davis King's avatar Davis King

Made widget_group objects apply fit_to_contents() recursively when

widget_group objects are nested.  Also fixed some spelling errors in the
spec file.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402824
parent f739b89a
......@@ -1304,6 +1304,7 @@ namespace dlib
{
auto_mutex M(m);
widgets.clear();
wg_widgets.clear();
}
// ----------------------------------------------------------------------------------------
......@@ -1343,6 +1344,23 @@ namespace dlib
widget.set_pos(x+rect.left(),y+rect.top());
}
// ----------------------------------------------------------------------------------------
void widget_group::
add (
widget_group& widget,
unsigned long x,
unsigned long y
)
{
auto_mutex M(m);
drawable& w = widget;
add(w, x, y);
widget_group* wg = &widget;
wg_widgets.add(wg);
}
// ----------------------------------------------------------------------------------------
bool widget_group::
......@@ -1366,9 +1384,15 @@ namespace dlib
drawable* w = const_cast<drawable*>(&widget);
if (widgets.is_in_domain(w))
{
relpos junk;
drawable* junk2;
widgets.remove(w,junk2,junk);
widgets.destroy(w);
// check if we also have an entry in the wg_widgets set and if
// so then remove that too
widget_group* wg = reinterpret_cast<widget_group*>(w);
if (wg_widgets.is_member(wg))
{
wg_widgets.destroy(wg);
}
}
}
......@@ -1473,6 +1497,13 @@ namespace dlib
)
{
auto_mutex M(m);
// call fit_to_contents on all the widget_groups we contain
wg_widgets.reset();
while (wg_widgets.move_next())
wg_widgets.element()->fit_to_contents();
// now accumulate a rectangle that contains everything in this widget_group
rectangle r;
widgets.reset();
while (widgets.move_next())
......
......@@ -11,6 +11,7 @@
#include "../member_function_pointer.h"
#include "../timer.h"
#include "../map.h"
#include "../set.h"
#include "../array2d.h"
#include "../pixel.h"
#include "../image_transforms.h"
......@@ -283,8 +284,10 @@ namespace dlib
widgets.size() == 0
CONVENTION
Widgets contains all the drawable objects and their relative positions
- widgets contains all the drawable objects and their relative positions
that are in *this.
- wg_widgets contains pointers to just the widgets that happen
to be widget_group objects.
!*/
struct relpos
......@@ -310,6 +313,12 @@ namespace dlib
unsigned long y
);
void add (
widget_group& widget,
unsigned long x,
unsigned long y
);
bool is_member (
const drawable& widget
) const;
......@@ -355,6 +364,8 @@ namespace dlib
private:
map<drawable*,relpos>::kernel_1a_c widgets;
set<widget_group*>::kernel_1a_c wg_widgets;
// restricted functions
widget_group(widget_group&); // copy constructor
......
......@@ -158,7 +158,7 @@ namespace dlib
is_mouse_over() == false
WHAT THIS OBJECT REPRESENTS
This object represents a drawable object with the additoin of two events
This object represents a drawable object with the addition of two events
that will alert you when the mouse enters or leaves your drawable object.
You use it by inheriting from it and defining the draw() method and any
......@@ -848,6 +848,8 @@ namespace dlib
- if (size() == 0) then
- #get_rect().is_empty() == true
- else
- recursively calls fit_to_contents() on any widget_groups inside
this object.
- #get_rect() will be the smallest rectangle that contains all the
widgets in this group and the upper left corner of get_rect().
!*/
......@@ -1258,7 +1260,7 @@ namespace dlib
- #get_hot_key() == hotkey
!*/
// overloads for wide charactor strings
// overloads for wide character strings
template <
typename T
>
......@@ -1302,7 +1304,7 @@ namespace dlib
- #get_hot_key() == hotkey
!*/
//overloads for wide charactor strings
//overloads for wide character strings
menu_item_submenu (
const std::wstring& str,
unichar hotkey = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment