mirror of
https://github.com/fltk/fltk.git
synced 2026-02-06 00:01:57 +08:00
Adding size range settings to Fl_Tile, initial commit.
- some documentation missing - Fl_Tile::resize() not satisfying yet - minimums work, maximums currently ignored - 0 size children may make program hang
This commit is contained in:
11
FL/Fl_Rect.H
11
FL/Fl_Rect.H
@@ -88,6 +88,9 @@ public:
|
||||
void w(int W) { w_ = W; } ///< sets the width
|
||||
void h(int H) { h_ = H; } ///< sets the height
|
||||
|
||||
void r(int R) { w_ = R - x_; } ///< sets the width based on R and x
|
||||
void b(int B) { h_ = B - y_; } ///< sets the height based on B and y
|
||||
|
||||
/** Move all edges in by \p d.
|
||||
|
||||
Shrinks the rectangle by \p d at all sides keeping the center of the
|
||||
@@ -143,6 +146,14 @@ public:
|
||||
h_ -= (top + bottom);
|
||||
}
|
||||
|
||||
friend bool operator==(const Fl_Rect& lhs, const Fl_Rect& rhs) {
|
||||
return (lhs.x_==rhs.x_) && (lhs.y_==rhs.y_) && (lhs.w_==rhs.w_) && (lhs.h_==rhs.h_);
|
||||
}
|
||||
|
||||
friend bool operator!=(const Fl_Rect& lhs, const Fl_Rect& rhs) {
|
||||
return !(lhs==rhs);
|
||||
}
|
||||
|
||||
}; // class Fl_Rect
|
||||
|
||||
#endif // Fl_Rect_H
|
||||
|
||||
23
FL/Fl_Tile.H
23
FL/Fl_Tile.H
@@ -28,11 +28,16 @@ class FL_EXPORT Fl_Tile : public Fl_Group {
|
||||
public:
|
||||
int handle(int event) FL_OVERRIDE;
|
||||
Fl_Tile(int X, int Y, int W, int H, const char *L=0);
|
||||
~Fl_Tile() FL_OVERRIDE;
|
||||
void resize(int X, int Y, int W, int H) FL_OVERRIDE;
|
||||
virtual void move_intersection(int oldx, int oldy, int newx, int newy);
|
||||
virtual void drag_intersection(int oldx, int oldy, int newx, int newy);
|
||||
FL_DEPRECATED("in 1.4.0 - use move_intersection(p) instead",
|
||||
void position(int oldx, int oldy, int newx, int newy)) { move_intersection(oldx, oldy, newx, newy); }
|
||||
void position(int x, int y) { Fl_Group::position(x, y); }
|
||||
void size_range(int index, int minw, int minh, int maxw=0x7FFFFFFF, int maxh=0x7FFFFFFF);
|
||||
void size_range(Fl_Widget *w , int minw, int minh, int maxw=0x7FFFFFFF, int maxh=0x7FFFFFFF);
|
||||
void init_size_range(int default_min_w = -1, int default_min_h = -1);
|
||||
|
||||
protected:
|
||||
int cursor_; ///< current cursor index (0..3)
|
||||
@@ -47,6 +52,24 @@ protected:
|
||||
}
|
||||
|
||||
void set_cursor(int n); // set one of n (0..3) cursors
|
||||
|
||||
typedef struct { int minw, minh, maxw, maxh; } Size_Range;
|
||||
|
||||
Size_Range *size_range_;
|
||||
int size_range_size_, size_range_capacity_;
|
||||
int default_min_w_, default_min_h_;
|
||||
void request_shrink_l(int old_l, int &new_l, Fl_Rect *final_size);
|
||||
void request_shrink_r(int old_r, int &new_r, Fl_Rect *final_size);
|
||||
void request_shrink_t(int old_t, int &new_t, Fl_Rect *final_size);
|
||||
void request_shrink_b(int old_b, int &new_b, Fl_Rect *final_size);
|
||||
void request_grow_l(int old_l, int &new_l, Fl_Rect *final_size);
|
||||
void request_grow_r(int old_r, int &new_r, Fl_Rect *final_size);
|
||||
void request_grow_t(int old_t, int &new_t, Fl_Rect *final_size);
|
||||
void request_grow_b(int old_b, int &new_b, Fl_Rect *final_size);
|
||||
|
||||
int on_insert(Fl_Widget*, int) FL_OVERRIDE;
|
||||
int on_move(int, int) FL_OVERRIDE;
|
||||
void on_remove(int) FL_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
547
src/Fl_Tile.cxx
547
src/Fl_Tile.cxx
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@
|
||||
#include <FL/Fl_Box.H>
|
||||
|
||||
// #define TEST_INACTIVE
|
||||
// #define CLASSIC_MODE
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
Fl_Double_Window window(300, 300);
|
||||
@@ -27,19 +28,27 @@ int main(int argc, char** argv) {
|
||||
window.resizable(window);
|
||||
|
||||
Fl_Tile tile(0, 0, 300, 300);
|
||||
#ifndef CLASSIC_MODE
|
||||
tile.init_size_range(30, 30); // all children's size shall be at least 30x30
|
||||
#endif
|
||||
|
||||
// create the symmetrical resize box with dx and dy pixels distance, resp.
|
||||
// from the borders of the Fl_Tile widget before all other children
|
||||
|
||||
#ifdef CLASSIC_MODE
|
||||
int dx = 20, dy = dx; // border width of resizable()
|
||||
Fl_Box r(tile.x()+dx,tile.y()+dy,tile.w()-2*dx,tile.h()-2*dy);
|
||||
tile.resizable(r);
|
||||
#endif
|
||||
|
||||
Fl_Box box0(0,0,150,150,"0");
|
||||
box0.box(FL_DOWN_BOX);
|
||||
box0.color(9);
|
||||
box0.labelsize(36);
|
||||
box0.align(FL_ALIGN_CLIP);
|
||||
#ifndef CLASSIC_MODE
|
||||
tile.resizable(&box0);
|
||||
#endif
|
||||
|
||||
Fl_Double_Window w1(150,0,150,150,"1");
|
||||
w1.box(FL_NO_BOX);
|
||||
|
||||
Reference in New Issue
Block a user