fltk_hello world

int main(int argc, char *argv[])
{
#define WINDOW_BG FL_BLACK
#define WINDOW_WIDTH 640
#define WINDOW_HEIGHT 480
#define BOX_WIDTH 100
#define BOX_HEIGHT 40
#define TEXT_COLOR FL_GREEN
#define TEXT_FONT FL_BOLD
#define TEXT_SIZE 40
// replace by xml ?

    const char* pszText = "Hello FLTK";
    int iW = 0;
    int iH = 0;

        
    Fl_Double_Window win(640, 480);
    win.color(FL_BLACK);

    fl_font(TEXT_FONT, TEXT_SIZE);
    fl_measure(pszText, iW, iH);

    Fl_Box* box = new Fl_Box(WINDOW_WIDTH/2 - iW/2, WINDOW_HEIGHT/2 - iH/2, iW, iH);
    box->box(FL_FLAT_BOX);
    box->color(TEXT_COLOR);
    box->labelfont(TEXT_FONT);
    box->labelsize(TEXT_SIZE);
    box->label(pszText);

    
    win.show();
    win.end();

    return Fl::run();
}

 

posted @ 2014-11-25 11:59  stanley19861028  阅读(189)  评论(0编辑  收藏  举报