#include <Fl/Fl_Double_Window.H>
#include <FL/Fl.H>
#include <FL/Fl_Table.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Tile.H>
#include <FL/fl_draw.H>
class Testtable : public Fl_Table {
void DrawHeader(const char *s, int X, int Y, int W, int H) {
fl_push_clip(X, Y, W, H);
fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, row_header_color());
fl_color(FL_BLACK);
fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER);
fl_pop_clip();
}
void draw_cell(TableContext context, int ROW = 0, int COL = 0, int
X = 0, int Y = 0, int W = 0, int H = 0) {
static char s[40];
switch (context) {
case CONTEXT_STARTPAGE:
fl_font(FL_HELVETICA, 16);
return;
case CONTEXT_COL_HEADER:
sprintf(s, "%c", 'A' + COL);
DrawHeader(s, X, Y, W, H);
return;
case CONTEXT_ROW_HEADER:
sprintf(s, "%03d:", ROW);
DrawHeader(s, X, Y, W, H);
return;
case CONTEXT_CELL: {
fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, FL_WHITE);
fl_color(FL_BLACK);
fl_draw("test", X, Y, W, H, FL_ALIGN_CENTER);
return;
}
default:
return;
}
}
Fl_Group* grpWrapper;
public:
Testtable(int X, int Y, int W, int H, const char* L = 0) :
Fl_Table(X, Y+20, W, H-20, L) {
rows(20);
cols(5);
col_header(1);
col_resize(1);
end();
grpWrapper = new Fl_Group(X, Y, W, H);
grpWrapper->box(FL_FLAT_BOX);
grpWrapper->color(FL_MAGENTA);
grpWrapper->add(this);
Fl_Group* menuResizeLock = new Fl_Group(X, Y, W / 2, 20);
Fl_Menu_Bar* menubar = new Fl_Menu_Bar(X, Y, W/2, 20);
menubar->add("test menu 1/choice 1");
menubar->add("test menu 1/choice 2");
menubar->add("test menu 2/choice 1");
menubar->add("test menu 2/choice 2");
menuResizeLock->end();
menuResizeLock->resizable(NULL);
grpWrapper->end();
}
int y() { return grpWrapper->y(); }
int h() { return grpWrapper->h(); }
};
int main()
{
Fl_Double_Window* win = new Fl_Double_Window(640, 480);
Fl_Tile* tile = new Fl_Tile(0, 0, win->w(), win->h());
Fl_Group* grpTop = new Fl_Group(tile->x(), tile->y(), tile->w(),
win->h() / 3);
grpTop->box(FL_FLAT_BOX);
grpTop->color(FL_RED);
grpTop->end();
Testtable* tbl = new Testtable(grpTop->x(), grpTop->y() +
grpTop->h(), grpTop->w(), grpTop->h());
Fl_Group* grpBottom = new Fl_Group(tbl->x(), tbl->y() + tbl->h(),
tbl->w(), tbl->h());
grpBottom->box(FL_FLAT_BOX);
grpBottom->color(FL_GREEN);
grpBottom->end();
win->resizable(win);
tile->end();
win->end();
win->show();
return Fl::run();
}