mirror of https://github.com/fltk/fltk
Add more public accessor methods to Fl_Grid (#937)
Some of these accessor methods should be private so they can't be used by user code but - due to compiler issues - they must be public for HP-UX 11.11 (for details see GitHub Issue #937).
This commit is contained in:
parent
dddfec57a1
commit
5af2d77b84
36
FL/Fl_Grid.H
36
FL/Fl_Grid.H
|
@ -151,7 +151,7 @@ public:
|
||||||
class Cell {
|
class Cell {
|
||||||
friend class Fl_Grid;
|
friend class Fl_Grid;
|
||||||
private:
|
private:
|
||||||
Cell *next_; // next cell in row
|
Cell *next_; // next cell in the same row
|
||||||
short row_; // row number
|
short row_; // row number
|
||||||
short col_; // column number
|
short col_; // column number
|
||||||
short rowspan_; // row span (1 - n)
|
short rowspan_; // row span (1 - n)
|
||||||
|
@ -163,7 +163,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void Cell_() {
|
void Cell_() { // common initialization
|
||||||
next_ = NULL;
|
next_ = NULL;
|
||||||
row_ = 0;
|
row_ = 0;
|
||||||
col_ = 0;
|
col_ = 0;
|
||||||
|
@ -175,21 +175,49 @@ public:
|
||||||
align_ = 0;
|
align_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cell(int row, int col) {
|
Cell(int row, int col) { // constructor
|
||||||
Cell_();
|
Cell_();
|
||||||
row_ = row;
|
row_ = row;
|
||||||
col_ = col;
|
col_ = col;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cell(Fl_Widget *w, int row, int col) {
|
Cell(Fl_Widget *w, int row, int col) { // widget assignment
|
||||||
Cell_();
|
Cell_();
|
||||||
widget_ = w;
|
widget_ = w;
|
||||||
row_ = row;
|
row_ = row;
|
||||||
col_ = col;
|
col_ = col;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
The destructor deletes the cell.
|
||||||
|
|
||||||
|
\todo Fl_Grid's cell destructor should remove the cell from the grid.
|
||||||
|
Currently it does nothing!
|
||||||
|
*/
|
||||||
~Cell() {}
|
~Cell() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the next widget cell of the same row of this cell.
|
||||||
|
*/
|
||||||
|
Cell *next() {
|
||||||
|
return next_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the \c next pointer of a grid's cell.
|
||||||
|
|
||||||
|
\b Internal use only!
|
||||||
|
|
||||||
|
Do not use this method, it may corrupt the allocated memory.
|
||||||
|
|
||||||
|
\internal
|
||||||
|
This method is public due to issue #937 but should be private or
|
||||||
|
at least protected. For more info see GitHub issue #937.
|
||||||
|
*/
|
||||||
|
void next(Cell *c) {
|
||||||
|
next_ = c;
|
||||||
|
}
|
||||||
|
|
||||||
Fl_Widget *widget() const { return widget_; }
|
Fl_Widget *widget() const { return widget_; }
|
||||||
|
|
||||||
short row() const { return row_; }
|
short row() const { return row_; }
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Fl_Grid widget for the Fast Light Tool Kit (FLTK).
|
// Fl_Grid widget for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
// Copyright 2021-2022 by Albrecht Schlosser.
|
// Copyright 2021-2022 by Albrecht Schlosser.
|
||||||
// Copyright 2022-2023 by Bill Spitzak and others.
|
// Copyright 2022-2024 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
|
@ -70,23 +70,23 @@ class Fl_Grid::Row {
|
||||||
void free_cells() {
|
void free_cells() {
|
||||||
Cell *cel = cells_;
|
Cell *cel = cells_;
|
||||||
while (cel) {
|
while (cel) {
|
||||||
Cell *next = cel->next_;
|
Cell *next = cel->next();
|
||||||
delete cel;
|
delete cel;
|
||||||
cel = next;
|
cel = next;
|
||||||
} // free_cells()
|
} // free_cells()
|
||||||
cells_ = 0;
|
cells_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fl_Grid::Row::remove_cell() - remove all cells of column col from list of cells
|
// Fl_Grid::Row::remove_cell() - remove all cells of column col from the list of cells
|
||||||
|
|
||||||
void remove_cell(int col) { //
|
void remove_cell(int col) { //
|
||||||
Cell *cel = cells_;
|
Cell *cel = cells_;
|
||||||
Cell *prev = 0;
|
Cell *prev = 0;
|
||||||
while (cel) {
|
while (cel) {
|
||||||
Cell *next = cel->next_;
|
Cell *next = cel->next();
|
||||||
if (cel->col_ == col) {
|
if (cel->col() == col) {
|
||||||
if (prev) {
|
if (prev) {
|
||||||
prev->next_ = next;
|
prev->next(next);
|
||||||
} else {
|
} else {
|
||||||
cells_ = next;
|
cells_ = next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue