summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2015-12-18 18:56:58 +0000
committerManolo Gouy <Manolo>2015-12-18 18:56:58 +0000
commit43bfe74b25d0b7709757037a13c8ee2118bb8588 (patch)
tree3b73cd48622f7b642618c296e79a182549db6bc9 /src
parent5c7ef303413c03a0c5f645276e9c2b7ae8289680 (diff)
Running FLTK in static initializers (cont'd):
1) Changed the way fluid attaches images to widgets and menu items so it is compatible with running fluid-generated code containing such images in a static initializer. Images are now attached calling a function: widget->image( image_function_name() ); and this function is defined before in fluid-generated code as: static Fl_Image *image_function_name() { static Fl_Image *image = new image_type(......); return image; } 2) Changed src/Fl_File_Chooser.fl so the source code generate by fluid from it is compatible with running in a static initializer. 3) Changed src/Fl_File_Chooser.cxx and FL/Fl_File_Chooser.H to the result of running fluid on src/Fl_File_Chooser.fl git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10972 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_File_Chooser.cxx12
-rw-r--r--src/Fl_File_Chooser.fl9
2 files changed, 13 insertions, 8 deletions
diff --git a/src/Fl_File_Chooser.cxx b/src/Fl_File_Chooser.cxx
index c5288e92a..e5274cb51 100644
--- a/src/Fl_File_Chooser.cxx
+++ b/src/Fl_File_Chooser.cxx
@@ -27,7 +27,6 @@
#include "../FL/Fl_File_Chooser.H"
#include <FL/fl_draw.H>
-#include <FL/Fl_Bitmap.H>
void Fl_File_Chooser::cb_window_i(Fl_Double_Window*, void*) {
fileName->value("");
@@ -60,9 +59,14 @@ void Fl_File_Chooser::cb_newButton(Fl_Button* o, void* v) {
((Fl_File_Chooser*)(o->parent()->parent()->user_data()))->cb_newButton_i(o,v);
}
+#include <FL/Fl_Bitmap.H>
static const unsigned char idata_new[] =
{0,0,120,0,132,0,2,1,1,254,1,128,49,128,49,128,253,128,253,128,49,128,49,
128,1,128,1,128,255,255,0,0};
+static Fl_Image *image_new() {
+ static Fl_Image *image = new Fl_Bitmap(idata_new, 16, 16);
+ return image;
+}
void Fl_File_Chooser::cb__i(Fl_Tile*, void*) {
update_preview();
@@ -163,10 +167,8 @@ void Fl_File_Chooser::cb_favOkButton(Fl_Return_Button* o, void* v) {
}
Fl_File_Chooser::Fl_File_Chooser(const char *d, const char *p, int t, const char *title) {
- static Fl_Bitmap *image_new = NULL;
- if (!image_new) {
+ if (!prefs_) {
prefs_ = new Fl_Preferences(Fl_Preferences::USER, "fltk.org", "filechooser");
- image_new = new Fl_Bitmap(idata_new, 16, 16);
}
Fl_Group *prev_current = Fl_Group::current();
{ window = new Fl_Double_Window(490, 380, "Choose File");
@@ -186,7 +188,7 @@ Fl_File_Chooser::Fl_File_Chooser(const char *d, const char *p, int t, const char
favoritesButton->label(favorites_label);
} // Fl_Menu_Button* favoritesButton
{ Fl_Button* o = newButton = new Fl_Button(455, 10, 25, 25);
- newButton->image(image_new);
+ newButton->image( image_new() );
newButton->labelsize(8);
newButton->callback((Fl_Callback*)cb_newButton);
o->tooltip(new_directory_tooltip);
diff --git a/src/Fl_File_Chooser.fl b/src/Fl_File_Chooser.fl
index c7332a776..c0940be94 100644
--- a/src/Fl_File_Chooser.fl
+++ b/src/Fl_File_Chooser.fl
@@ -36,7 +36,7 @@ class FL_EXPORT Fl_File_Chooser {open
} {
decl {enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };} {public local
}
- decl {static Fl_Preferences prefs_;} {private local
+ decl {static Fl_Preferences *prefs_;} {private local
}
decl {void (*callback_)(Fl_File_Chooser*, void *);} {private local
}
@@ -69,6 +69,9 @@ class FL_EXPORT Fl_File_Chooser {open
decl {void update_preview();} {private local
}
Function {Fl_File_Chooser(const char *d, const char *p, int t, const char *title)} {} {
+ code {if (!prefs_) {
+ prefs_ = new Fl_Preferences(Fl_Preferences::USER, "fltk.org", "filechooser");
+}} {}
code {Fl_Group *prev_current = Fl_Group::current();} {}
Fl_Window window {
label {Choose File}
@@ -238,7 +241,7 @@ update_favorites();
value(d);
type(t);
int e;
-prefs_.get("preview", e, 1);
+prefs_->get("preview", e, 1);
preview(e);
Fl_Group::current(prev_current);} {}
code {ext_group=(Fl_Widget*)0;} {}
@@ -307,7 +310,7 @@ showChoiceCB();} {}
}
Function {ok_label(const char *l)} {return_type void
} {
- code {okButton->label(l);
+ code {if (l) okButton->label(l);
int w=0, h=0;
okButton->measure_label(w, h);
okButton->resize(cancelButton->x() - 50 - w, cancelButton->y(),