Hi,
I am extending Fl_Table_Row to display records in a database. I would like to add the column header of the [rows]. Is this possible?
I tried to draw the text in draw_cell in the CONTEXT_STARTPAGE and CONTEXT_ENDPAGE, but neither did what I wanted. All I wanted to add was "Record No." or similar.
The "CONTEXT_XXXPAGE" sections are just for drawing something
over the entire table like a background, floating text, or some
such.
This is because the XYWH values at that time will be for the entire
table, not any particular row/column or cell, which
you'd need to know
to draw each column's header.
I suggest looking at the examples/table-simple.cxx
example program, and look at how the A/B/C/D.. column headers are
drawn, e.g.
void draw_cell(TableContext context, int ROW=0, int COL=0,
int X=0, int Y=0, int W=0, int H=0) {
[..]
switch ( context ) {
[..]
case
CONTEXT_COL_HEADER: // Draw column headers
sprintf(s,"%c",'A'+COL); // "A", "B",
"C", etc.
DrawHeader(s,X,Y,W,H);
return;
[..]
From: Greg Ercolano
Sent: 30 November 2020 18:26
To: fltkg...@googlegroups.com
Subject: Re: [fltk.general] Getting text into the top-left "cell" in Fl_Table_Row
On 2020-11-30 08:17, 'pvr...@btinternet.com' via fltk.general wrote:
Hi,
I am extending Fl_Table_Row to display records in a database. I would like to add the column header of the [rows]. Is this possible?
Sure, be sure to turn on col_header(1) and then in your draw_cell(), add your code to the CONTEXT_COL_HEADER section
to draw the text inside the cell area for that column# (the XYWH and COL values passed to you for those values respectively).
I tried to draw the text in draw_cell in the CONTEXT_STARTPAGE and CONTEXT_ENDPAGE, but neither did what I wanted. All I wanted to add was "Record No." or similar.
The "CONTEXT_XXXPAGE" sections are just for drawing something over the entire table like a background, floating text, or some such.
This is because the XYWH values at that time will be for the entire table, not any particular row/column or cell, which you'd need to know
to draw each column's header.
I suggest looking at the examples/table-simple.cxx example program, and look at how the A/B/C/D.. column headers are drawn, e.g.
void draw_cell(TableContext context, int ROW=0, int COL=0, int X=0, int Y=0, int W=0, int H=0) {
[..]
switch ( context ) {
[..]
case CONTEXT_COL_HEADER: // Draw column headers
sprintf(s,"%c",'A'+COL); // "A", "B", "C", etc.
DrawHeader(s,X,Y,W,H);
return;
[..]
--
You received this message because you are subscribed to a topic in the Google Groups "fltk.general" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fltkgeneral/KDDLWooAfAU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/65d32c9f-72fc-6153-3ae9-5f44e80297a9%40seriss.com.
Thanks Greg,
What is the column number for the row headers?
The row headers have their own context just like the column
headers: CONTEXT_ROW_HEADER
When you receive CONTEXT_ROW_HEADER, the ROW value will have
the row number so you can draw
the different headings for each row.
If you have a 2x2 table, you'll get:
> Two callbacks for the two column headings, each will
have CONTEXT_COL_HEADER set, and COL will have the column#.
> Two callbacks for the two row headings, each will
have CONTEXT_ROW_HEADER set, and ROW will have the row#.
> You'll also get four CONTEXT_CELL calls for each of
the 4 cells, where ROW and COL will have the appropriate values
for each cell
Please look at the draw_cell() function in table-simple.cxx,
it shows how to draw both row and column headers
in addition to the cells; note the comments:
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: // before
page is drawn..
fl_font(FL_HELVETICA, 16); // set
the font for our drawing operations
return;
case CONTEXT_COL_HEADER: // Draw
column headers
sprintf(s,"%c",'A'+COL); // "A",
"B", "C", etc.
DrawHeader(s,X,Y,W,H);
return;
case CONTEXT_ROW_HEADER: // Draw
row headers
sprintf(s,"%03d:",ROW); //
"001:", "002:", etc
DrawHeader(s,X,Y,W,H);
return;
case CONTEXT_CELL: // Draw
data in cells
sprintf(s,"%d",data[ROW][COL]);
DrawData(s,X,Y,W,H);
return;
default:
return;
I want to write text into the bit of the table that is above the row headers and to the left of the column headers to provide a header to the row headers.
In the example you gave the two columns have a header each, the two rows have a header each. That’s 8 cells occupied. I want to write something into the ninth cell in the top-left.
Phil
Sent from Mail for Windows 10
From: Greg Ercolano
Sent: 30 November 2020 21:59
To: fltkg...@googlegroups.com
Subject: Re: [fltk.general] Getting text into the top-left "cell" in Fl_Table_Row
On 2020-11-30 13:47, 'Philip Rose' via fltk.general wrote:
Thanks Greg,
What is the column number for the row headers?
The row headers have their own context just like the column headers: CONTEXT_ROW_HEADER
When you receive CONTEXT_ROW_HEADER, the ROW value will have the row number so you can draw
the different headings for each row.
If you have a 2x2 table, you'll get:
> Two callbacks for the two column headings, each will have CONTEXT_COL_HEADER set, and COL will have the column#.
> Two callbacks for the two row headings, each will have CONTEXT_ROW_HEADER set, and ROW will have the row#.
> You'll also get four CONTEXT_CELL calls for each of the 4 cells, where ROW and COL will have the appropriate values for each cell
Please look at the draw_cell() function in table-simple.cxx, it shows how to draw both row and column headers
in addition to the cells; note the comments:
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: // before page is drawn..
fl_font(FL_HELVETICA, 16); // set the font for our drawing operations
return;
case CONTEXT_COL_HEADER: // Draw column headers
sprintf(s,"%c",'A'+COL); // "A", "B", "C", etc.
DrawHeader(s,X,Y,W,H);
return;
case CONTEXT_ROW_HEADER: // Draw row headers
sprintf(s,"%03d:",ROW); // "001:", "002:", etc
DrawHeader(s,X,Y,W,H);
return;
case CONTEXT_CELL: // Draw data in cells
sprintf(s,"%d",data[ROW][COL]);
DrawData(s,X,Y,W,H);
return;
default:
return;
--
You received this message because you are subscribed to a topic in the Google Groups "fltk.general" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fltkgeneral/KDDLWooAfAU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/4f9dfacc-9d3a-004a-e12f-c105cb79d339%40seriss.com.
In the shown example, it’s the place to the left of where it says “Date” and above the place where it has “2925”. I would like to write into there.
Phil.
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/5fc57085.1c69fb81.3f986.6ef8SMTPIN_ADDED_BROKEN%40gmr-mx.google.com.
In the shown example, it’s the place to the left of where it says “Date” and above the place where it has “2925”. I would like to write into there.
Oh, that little area is neither cell nor header.. that's a
perfect use for CONTEXT_ENDPAGE.
Here's how to write to that area, shown by drawing an "X":
case CONTEXT_ENDPAGE: { // after page
headers/cells are drawn..
// Draw black 'x' in the dead area
int X1=x(), Y1=y(), X2=x()+row_header_width(),
Y2=y()+col_header_height();
fl_color(FL_BLACK);
fl_line(X1,Y1,X2,Y2);
fl_line(X1,Y2,X2,Y1);
return;
}
From: Greg Ercolano
Sent: 30 November 2020 23:43
To: fltkg...@googlegroups.com
Subject: Re: [fltk.general] Getting text into the top-left "cell" in Fl_Table_Row
On 2020-11-30 14:44, 'Philip Rose' via fltk.general wrote:
In the shown example, it’s the place to the left of where it says “Date” and above the place where it has “2925”. I would like to write into there.
Oh, that little area is neither cell nor header.. that's a perfect use for CONTEXT_ENDPAGE.
Here's how to write to that area, shown by drawing an "X":
case CONTEXT_ENDPAGE: { // after page headers/cells are drawn..
// Draw black 'x' in the dead area
int X1=x(), Y1=y(), X2=x()+row_header_width(), Y2=y()+col_header_height();
fl_color(FL_BLACK);
fl_line(X1,Y1,X2,Y2);
fl_line(X1,Y2,X2,Y1);
return;
}
Thanks Greg,
Looks like I had originally tried to display the text in the top-left of the window.
I had to tweak the code slightly to get the box to line up with the column headers:
case CONTEXT_ENDPAGE:
{
// Code trying to write text into the top-left corner
// Set the font for the header header
fl_font(fl_font() | FL_ITALIC, fontsize_);
// Set the col header row header crossing point
fl_color(col_header_color());
int X1 = x() + Fl::box_dx(box());
int Y1 = y() + Fl::box_dy(box());
int W1 = row_header_width();
int H1 = col_header_height();
fl_draw_box(FL_BORDER_BOX, X1, Y1, W1, H1, col_header_color());
// Text color
fl_color(FL_BLACK);
fl_draw("QSO No.", X1, Y1, W1, H1, FL_ALIGN_CENTER);
return;
}
Regards Phil.
I’ve since found out I could use Fl_Table_Row::wix and Fl_Table_Row::wiy, I had a vague remembrance they were there, but couldn’t find the article about them. I came across I had used tih in my code so searched that in the manual and found the others.
I know I’ve top-posted, but I cant be bothered the rigmarole to bottom post.
--
You received this message because you are subscribed to a topic in the Google Groups "fltk.general" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fltkgeneral/KDDLWooAfAU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/5fc6613f.1c69fb81.139f8.3b14SMTPIN_ADDED_BROKEN%40gmr-mx.google.com.
I’ve since found out I could use Fl_Table_Row::wix and Fl_Table_Row::wiy, I had a vague remembrance they were there, but couldn’t find the article about them.
I was gonna mention them, but really using Fl::box_dx() et al
as you did should work fine too.
I came across I had used tih in my code so searched that in the manual and found the others.
Right.
I know I’ve top-posted, but I cant be bothered the rigmarole to bottom post.
Yes, I assume you're using the google group web interface,
which doesn't seem to make that configurable,
so until they do (probably never), we're stuck with their top
post default.
I prefer enabling the mail gateway to google groups, so I can
use my mail client to handle everything
in a way I'm used to, using a mail folder. (I hardly ever use
the web interface to the group)
Hmm - it looks from here as if Phil *might* be using the mail client that’s “built into” Win10 - is that right?
Sent from Mail for Windows 10