FLTK logo

Re: [fltk.general] Getting text into the top-left "cell" in Fl_Table_Row

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Getting text into the top-left "cell" in Fl_Table_Row Greg Ercolano Nov 30, 2020  
 
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 the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/4f9dfacc-9d3a-004a-e12f-c105cb79d339%40seriss.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.