Author: dejan
Date: 2007-11-13 15:05:48 -0800 (Tue, 13 Nov 2007)
New Revision: 5970
Log:
A handy fix from STR#1666 by Davy Durham. It adds a margin property to
PackedGroup. It creates a constant spacing AROUND all the child Widgets in
distinction to the spacing BETWEEN the child widgets. It gives a methods either
to control left,right,top,button margins separately, or all at once.
Modified:
trunk/fltk/PackedGroup.h
trunk/src/PackedGroup.cxx
Modified: trunk/fltk/PackedGroup.h
===================================================================
--- trunk/fltk/PackedGroup.h 2007-11-13 22:59:07 UTC (rev 5969)
+++ trunk/fltk/PackedGroup.h 2007-11-13 23:05:48 UTC (rev 5970)
@@ -35,6 +35,10 @@
class FL_API PackedGroup : public Group {
int spacing_;
+ int margin_left_;
+ int margin_right_;
+ int margin_top_;
+ int margin_bottom_;;
public:
enum { // values for type(int), for back-compatability
NORMAL = GROUP_TYPE,
@@ -44,6 +48,17 @@
PackedGroup(int x, int y, int w, int h, const char *l = 0, bool begin=false);
int spacing() const {return spacing_;}
void spacing(int i) {spacing_ = i;}
+
+ int margin_left() const {return margin_left_;}
+ void margin_left(int m) {margin_left_ = m;}
+ int margin_right() const {return margin_right_;}
+ void margin_right(int m) {margin_right_ = m;}
+ int margin_top() const {return margin_top_;}
+ void margin_top(int m) {margin_top_ = m;}
+ int margin_bottom() const {return margin_bottom_;}
+ void margin_bottom(int m) {margin_bottom_ = m;}
+
+ void margin(int m) {margin_left_ = margin_right_ = margin_top_ =
margin_bottom_ = m;}
};
}
Modified: trunk/src/PackedGroup.cxx
===================================================================
--- trunk/src/PackedGroup.cxx 2007-11-13 22:59:07 UTC (rev 5969)
+++ trunk/src/PackedGroup.cxx 2007-11-13 23:05:48 UTC (rev 5970)
@@ -67,6 +67,7 @@
: Group(x, y, w, h, l, begin) {
resizable(0);
spacing_ = 0;
+ margin(0);
}
void PackedGroup::layout() {
@@ -87,6 +88,12 @@
Rectangle r(w(),h());
box()->inset(r);
+ // Apply margins
+ r.set_x(r.x()+margin_left_);
+ r.set_r(r.r()-margin_right_);
+ r.set_y(r.y()+margin_top_);
+ r.set_b(r.b()-margin_bottom_);
+
bool saw_horizontal = false;
bool saw_vertical = false;
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit