diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2006-01-02 20:18:23 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2006-01-02 20:18:23 +0000 |
| commit | f5a571fc83921005c21eff1383cd30ac4afadd2c (patch) | |
| tree | 442a96fc4bd3fefa9a21d760fba91574209b279c /test/pixmap_browser.cxx | |
| parent | 0321627691afc62288cd25495b19fb510becf2d9 (diff) | |
Fixed "Pixmap" demo to not pop up a dialog if an image (or other file or even directory) is not readable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4735 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test/pixmap_browser.cxx')
| -rw-r--r-- | test/pixmap_browser.cxx | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/test/pixmap_browser.cxx b/test/pixmap_browser.cxx index 16e064259..a2cb1ff25 100644 --- a/test/pixmap_browser.cxx +++ b/test/pixmap_browser.cxx @@ -43,11 +43,25 @@ Fl_Shared_Image *img; static char name[1024]; void load_file(const char *n) { - if (img) img->release(); - + if (img) { + img->release(); + img = 0L; + } + if (fl_filename_isdir(n)) { + b->label("@fileopen"); // show a generic folder + b->labelsize(64); + b->labelcolor(FL_LIGHT2); + b->image(0); + b->redraw(); + return; + } img = Fl_Shared_Image::get(n); if (!img) { - fl_alert("Image file format not recognized!"); + b->label("@filenew"); // show an empty document + b->labelsize(64); + b->labelcolor(FL_LIGHT2); + b->image(0); + b->redraw(); return; } if (img->w() > b->w() || img->h() > b->h()) { @@ -58,8 +72,9 @@ void load_file(const char *n) { img->release(); img = (Fl_Shared_Image *)temp; } - b->label(name); + b->labelsize(14); + b->labelcolor(FL_FOREGROUND_COLOR); b->image(img); b->redraw(); } @@ -90,10 +105,11 @@ int main(int argc, char **argv) { Fl::args(argc,argv,i,arg); - Fl_Window window(400,400); ::w = &window; - Fl_Box b(0,0,window.w(),window.h()); ::b = &b; - b.box(FL_FLAT_BOX); - Fl_Button button(5,5,100,35,"load"); + Fl_Window window(400,435); ::w = &window; + Fl_Box b(10,45,380,380); ::b = &b; + b.box(FL_THIN_DOWN_BOX); + b.align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER); + Fl_Button button(150,5,100,30,"load"); button.callback(button_cb); if (!dvisual) Fl::visual(FL_RGB); if (argv[1]) load_file(argv[1]); |
