summaryrefslogtreecommitdiff
path: root/src/Fl_Flex.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2022-12-15 16:46:40 +0100
committerGitHub <noreply@github.com>2022-12-15 16:46:40 +0100
commit44a2547394a3b4f8b0177c2f33aa8ed47a2c1051 (patch)
treed0611bedf1be051c9e5b2183314bc7e17648c5ad /src/Fl_Flex.cxx
parent2fd1866f492daa4caa7fdad6c05cd34bc79ba913 (diff)
Rename some Fl_Flex methods for FLTK compliance (#594)
Change some method names to comply with FLTK style as discussed in fltk.coredev, thread "Fl_Flex method name question". * Rename Fl_Flex::margins(...) to Fl_Flex::margin(...) (use singular form for all margin related methods) * Remove Fl_Flex::setSize() and isSetSize() "backwards compatibility" methods * Rename Fl_Flex::set_size(...) to fixed(...) Note: the latter affects existing (pre-release) fluid (.fl) files: you may want to edit and replace "set_size_tuples" with "fixed_size_tuples"
Diffstat (limited to 'src/Fl_Flex.cxx')
-rw-r--r--src/Fl_Flex.cxx70
1 files changed, 35 insertions, 35 deletions
diff --git a/src/Fl_Flex.cxx b/src/Fl_Flex.cxx
index 446d00aea..5167bc4d1 100644
--- a/src/Fl_Flex.cxx
+++ b/src/Fl_Flex.cxx
@@ -39,8 +39,8 @@
*/
Fl_Flex::Fl_Flex(int X, int Y, int W, int H, const char *L)
: Fl_Group(X, Y, W, H, L) {
- init();
- }
+ init();
+}
// special Fl_Flex constructors w/o label (backwards compatible with original Fl_Flex widget)
@@ -54,7 +54,7 @@ Fl_Flex::Fl_Flex(int X, int Y, int W, int H, const char *L)
for nested Fl_Flex widgets. Use one of the other constructors to set the
desired position and size as well.
- \param[in] direction horizontal (row) or vertical (column) layout
+ \param[in] direction horizontal (row) or vertical (column) layout
\see Fl_Flex::Fl_Flex(int w, int h, int direction)
\see Fl_Flex::Fl_Flex(int x, int y, int w, int h, int direction)
@@ -75,9 +75,8 @@ Fl_Flex::Fl_Flex(int direction)
for nested Fl_Flex widgets. Use one of the other constructors to set the
desired position as well.
-
- \param[in] w,h widget size
- \param[in] direction horizontal (row) or vertical (column) layout
+ \param[in] w,h widget size
+ \param[in] direction horizontal (row) or vertical (column) layout
\see Fl_Flex::Fl_Flex(int direction)
\see Fl_Flex::Fl_Flex(int x, int y, int w, int h, int direction)
@@ -115,22 +114,22 @@ Fl_Flex::Fl_Flex(int x, int y, int w, int h, int direction)
}
void Fl_Flex::init(int t) {
- gap_ = 0; // default gap size
- margin_left_ = 0; // default margin size
- margin_top_ = 0; // default margin size
- margin_right_ = 0; // default margin size
- margin_bottom_ = 0; // default margin size
- set_size_ = NULL; // array of fixed size widgets
- set_size_size_ = 0; // number of fixed size widgets
- set_size_alloc_ = 0; // allocated size of array of fixed size widgets
+ gap_ = 0; // default gap size
+ margin_left_ = 0; // default margin size
+ margin_top_ = 0; // default margin size
+ margin_right_ = 0; // default margin size
+ margin_bottom_ = 0; // default margin size
+ fixed_size_ = NULL; // array of fixed size widgets
+ fixed_size_size_ = 0; // number of fixed size widgets
+ fixed_size_alloc_ = 0; // allocated size of array of fixed size widgets
type(HORIZONTAL);
if (t == VERTICAL)
type(VERTICAL);
}
Fl_Flex::~Fl_Flex() {
- if (set_size_)
- free(set_size_);
+ if (fixed_size_)
+ free(fixed_size_);
}
/*
@@ -138,7 +137,7 @@ Fl_Flex::~Fl_Flex() {
Make sure that the widget is also removed from our fixed list.
*/
void Fl_Flex::on_remove(int index) {
- set_size(child(index), 0);
+ fixed(child(index), 0);
}
void Fl_Flex::resize(int x, int y, int w, int h) {
@@ -171,7 +170,7 @@ void Fl_Flex::resize(int x, int y, int w, int h) {
for (int i = 0; i < cc; i++) {
Fl_Widget *c = child(i);
if (c->visible()) {
- if (set_size(c)) {
+ if (fixed(c)) {
space -= (hori ? c->w() : c->h());
fw--;
}
@@ -201,7 +200,7 @@ void Fl_Flex::resize(int x, int y, int w, int h) {
continue;
if (hori) {
- if (set_size(c)) {
+ if (fixed(c)) {
c->resize(xp, yp, c->w(), hh);
} else {
c->resize(xp, yp, sp, hh);
@@ -209,7 +208,7 @@ void Fl_Flex::resize(int x, int y, int w, int h) {
}
xp += c->w() + gap_;
} else {
- if (set_size(c)) {
+ if (fixed(c)) {
c->resize(xp, yp, vw, c->h());
} else {
c->resize(xp, yp, vw, sp);
@@ -237,7 +236,8 @@ void Fl_Flex::end() {
This sets either the width or height of a child widget, depending on the
type() of the Fl_Flex container (Fl_Flex::HORIZONTAL or Fl_Flex::VERTICAL).
- The other dimension is set to the full width or height of the Fl_Flex widget.
+ The other dimension is set to the full width or height of the Fl_Flex widget
+ minus margin sizes.
This can be used to set a fixed widget width or height of children
of Fl_Flex so they are not resized dynamically.
@@ -247,14 +247,14 @@ void Fl_Flex::end() {
\param[in] child widget to be affected
\param[in] size width (Fl_Flex::HORIZONTAL) or height (Fl_Flex::VERTICAL)
*/
-void Fl_Flex::set_size(Fl_Widget *child, int size) {
+void Fl_Flex::fixed(Fl_Widget *child, int size) {
if (size <= 0)
size = 0;
// find w in our fixed size list
int idx = -1;
- for (int i = 0; i < set_size_size_; i++) {
- if (set_size_[i] == child) {
+ for (int i = 0; i < fixed_size_size_; i++) {
+ if (fixed_size_[i] == child) {
idx = i;
break;
}
@@ -262,10 +262,10 @@ void Fl_Flex::set_size(Fl_Widget *child, int size) {
// remove from array, if we want the widget to be flexible, but an entry was found
if (size == 0 && idx >= 0) {
- for (int i = idx; i < set_size_size_ - 1; i++) {
- set_size_[i] = set_size_[i+1];
+ for (int i = idx; i < fixed_size_size_ - 1; i++) {
+ fixed_size_[i] = fixed_size_[i+1];
}
- set_size_size_--;
+ fixed_size_size_--;
return;
}
@@ -275,12 +275,12 @@ void Fl_Flex::set_size(Fl_Widget *child, int size) {
// if we have no entry yet, add to array of fixed size widgets
if (idx == -1) {
- if (set_size_size_ == set_size_alloc_) {
- set_size_alloc_ = alloc_size(set_size_alloc_);
- set_size_ = (Fl_Widget **)realloc(set_size_, set_size_alloc_ * sizeof(Fl_Widget *));
+ if (fixed_size_size_ == fixed_size_alloc_) {
+ fixed_size_alloc_ = alloc_size(fixed_size_alloc_);
+ fixed_size_ = (Fl_Widget **)realloc(fixed_size_, fixed_size_alloc_ * sizeof(Fl_Widget *));
}
- set_size_[set_size_size_] = child;
- set_size_size_++;
+ fixed_size_[fixed_size_size_] = child;
+ fixed_size_size_++;
}
// if the child size is meant to be fixed, set its new size
@@ -298,9 +298,9 @@ void Fl_Flex::set_size(Fl_Widget *child, int size) {
\retval 1 the widget has a fixed size
\retval 0 the widget resizes dynamically
*/
-int Fl_Flex::set_size(Fl_Widget *w) const {
- for (int i = 0; i < set_size_size_; i++) {
- if (w == set_size_[i]) {
+int Fl_Flex::fixed(Fl_Widget *w) const {
+ for (int i = 0; i < fixed_size_size_; i++) {
+ if (w == fixed_size_[i]) {
return 1;
}
}