DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2378
Version: 1.3.0





Link: http://www.fltk.org/str.php?L2378
Version: 1.3.0
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Table.H>
#include <FL/fl_draw.H>
#include <FL/Fl_PostScript.H>
#include <ctype.h>

class MyTable : public Fl_Table {
public:
  MyTable(int x, int y, int w, int h, const char *l) : Fl_Table(x,y,w,h,l) {};
  virtual void draw_cell(TableContext tc, int r, int c, int x, int y, int w, 
int h);
};


void MyTable::draw_cell(TableContext context, int R, int C, int X, int Y, int 
W, int H)
{
  switch ( context )
  {
    case CONTEXT_STARTPAGE:             // Fl_Table telling us its starting to 
draw page
      fl_font(FL_HELVETICA, 14);
      return;
            
    case CONTEXT_CELL:                  // Fl_Table telling us to draw cells
      fl_push_clip(X, Y, W, H);
    {
      // BG COLOR
      fl_color(FL_WHITE);
      fl_rectf(X, Y, W, H);
      
      // TEXT
      char s[10];
      int offset;
      if(strcmp(label(), "LatExtA") == 0) offset = 0x100;
      else if(strcmp(label(), "Latin") == 0) offset = 0x80;
      else if(strcmp(label(), "ASCII") == 0) offset = 0x0;
      unsigned utf = offset + R + C * 0x10;
      int l = fl_utf8encode(utf, s);
      s[l] = 0;
      fl_color(FL_BLACK);
      fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER);
      
      // BORDER
      fl_color(FL_LIGHT2);
      fl_rect(X, Y, W, H);
    }
      fl_pop_clip();
      return;
      
    default:
      return;
  }
}

Fl_Window *window;

void postscript(Fl_Widget *w, void *data)
{
  Fl_PostScript_File_Device printer ;
  if( printer.start_job(1, Fl_PostScript_Graphics_Driver::LETTER, 
Fl_PostScript_Graphics_Driver::LANDSCAPE) == 0 ) {
    printer.start_page();
    printer.print_widget(window);
    printer.end_page();
    printer.end_job();
    }
}

int main(void)
{
  window = new Fl_Window(31*8*3+30,25*16+30);
  Fl_Button *b = new Fl_Button(0,0,80, 20, "PostScript");
  b->callback(postscript, NULL);
  
  window->begin();
  MyTable *table = new MyTable(0, 25, 31 * 8, window->h(), "ASCII");
  table->col_resize_min(4);
  table->row_resize_min(4);
  table->rows(16);
  table->row_resize(1);
  table->cols(8);
  table->col_resize(1);
  table->row_height_all(25);
  table->col_width_all(30);
  table->set_visible();
  window->end();
 
  window->begin();
  MyTable *table2 = new MyTable(31 * 8 + 10, 25, 31 * 8, window->h(), "Latin");
  table2->col_resize_min(4);
  table2->row_resize_min(4);
  table2->rows(16);
  table2->row_resize(1);
  table2->cols(8);
  table2->col_resize(1);
  table2->row_height_all(25);
  table2->col_width_all(30);
  table2->set_visible();
  window->end();

  window->begin();
  MyTable *table3 = new MyTable(2*(31 * 8 + 10), 25, 31 * 8, window->h(), 
"LatExtA");
  table3->col_resize_min(4);
  table3->row_resize_min(4);
  table3->rows(16);
  table3->row_resize(1);
  table3->cols(8);
  table3->col_resize(1);
  table3->row_height_all(25);
  table3->col_width_all(30);
  table3->set_visible();
  window->end();

  window->show();
  Fl::run();
  return 0;
}
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to