Skip to content

Commit 32e0de3

Browse files
author
fabien
committed
Library:
+ New FileChooser from 1.1.x ! still FileIcon must be updated and used, for now all functionalities are implemented(completion, fileinupt buttons,favorites,preview...) but the icon are not yet displayed close to the filename. + ide/visualc + general code cleanup as detailed in the merged branch fcupd1 + fltk_dll + fltk_images compile fixes (FL_API FL_IMAGES_API modifications) Fluid + Fixed a bug when displaying widget with no label a label was still used and displayed + more code cleanup git-svn-id: http://seriss.com/public/fltk/fltk/trunk@4878 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
1 parent 550dfde commit 32e0de3

26 files changed

+3653
-2295
lines changed

fltk/FileBrowser.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ class FL_API FileBrowser : public Browser
5050
uchar icon_size_;
5151
const char *pattern_;
5252

53-
int full_height() const;
54-
int item_height(void *) const;
55-
int item_width(void *) const;
56-
void item_draw(void *, int, int, int, int) const;
57-
int incr_height() const { return (item_height(0)); }
53+
// following is obsolete: has to be replaced by adequate fltk drawing :
54+
// void item_draw(void *, int, int, int, int) const;
55+
//DEL int incr_height() const { return (item_height(0)); }
5856

5957
public:
6058
enum { FILES, DIRECTORIES };

fltk/FileChooser.h

Lines changed: 114 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,156 @@
1-
// generated by Fast Light User Interface Designer (fluid) version 2.0000
1+
// generated by Fast Light User Interface Designer (fluid) version 2.0100
22

3-
#ifndef fltk_FileChooser_h
4-
#define fltk_FileChooser_h
5-
6-
#include <fltk/Window.h>
3+
#ifndef FileChooser_h
4+
#define FileChooser_h
5+
// Header for //\n// "$Id: FileChooser.fl 4007 2005-02-04 08:42...
6+
#include <fltk/DoubleBufferWindow.h>
77
#include <stdio.h>
88
#include <stdlib.h>
99
#include <string.h>
10+
#include <fltk/Group.h>
1011
#include <fltk/Choice.h>
12+
#include <fltk/PopupMenu.h>
1113
#include <fltk/Button.h>
12-
#include "filename.h"
14+
#include <fltk/Preferences.h>
15+
#include <fltk/TiledGroup.h>
1316
#include <fltk/FileBrowser.h>
17+
#include <fltk/InvisibleBox.h>
18+
#include <fltk/CheckButton.h>
1419
#include <fltk/FileInput.h>
1520
#include <fltk/ReturnButton.h>
21+
#include <fltk/ask.h>
1622

17-
namespace fltk {
23+
namespace fltk {
1824

19-
class FL_API FileChooser {
25+
class FL_API FileChooser {
2026
public:
21-
enum { SINGLE, MULTI, CREATE };
22-
FileChooser(const char *d, const char *p, int t, const char *title);
23-
Window *window;
27+
enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };
2428
private:
25-
inline void cb_window_i(Window*, void*);
26-
static void cb_window(Window*, void*);
27-
Choice *dirMenu;
28-
inline void cb_dirMenu_i(Choice*, void*);
29-
static void cb_dirMenu(Choice*, void*);
30-
Button *upButton;
31-
inline void cb_upButton_i(Button*, void*);
32-
static void cb_upButton(Button*, void*);
33-
Button *newButton;
34-
inline void cb_newButton_i(Button*, void*);
35-
static void cb_newButton(Button*, void*);
36-
inline void cb__i(Button*, void*);
37-
static void cb_(Button*, void*);
38-
FileBrowser *fileList;
39-
inline void cb_fileList_i(FileBrowser*, void*);
40-
static void cb_fileList(FileBrowser*, void*);
41-
FileInput *fileName;
42-
inline void cb_fileName_i(FileInput*, void*);
43-
static void cb_fileName(FileInput*, void*);
44-
ReturnButton *okButton;
45-
inline void cb_okButton_i(ReturnButton*, void*);
46-
static void cb_okButton(ReturnButton*, void*);
47-
inline void cb_Cancel_i(Button*, void*);
48-
static void cb_Cancel(Button*, void*);
29+
static fltk::Preferences prefs_;
30+
void (*callback_)(FileChooser*, void *);
31+
void *data_;
4932
char directory_[1024];
33+
char pattern_[1024];
34+
char preview_text_[2048];
5035
int type_;
36+
void favoritesButtonCB();
37+
void favoritesCB(fltk::Widget *w);
5138
void fileListCB();
5239
void fileNameCB();
5340
void newdir();
54-
void up();
41+
static void previewCB(FileChooser *fc);
42+
void showChoiceCB();
43+
void update_favorites();
44+
void update_preview();
45+
public:
46+
FileChooser(const char *d, const char *p, int t, const char *title);
47+
private:
48+
fltk::DoubleBufferWindow *window;
49+
inline void cb_window_i(fltk::DoubleBufferWindow*, void*);
50+
static void cb_window(fltk::DoubleBufferWindow*, void*);
51+
fltk::Choice *showChoice;
52+
inline void cb_showChoice_i(fltk::Choice*, void*);
53+
static void cb_showChoice(fltk::Choice*, void*);
54+
fltk::PopupMenu *favoritesButton;
55+
inline void cb_favoritesButton_i(fltk::PopupMenu*, void*);
56+
static void cb_favoritesButton(fltk::PopupMenu*, void*);
5557
public:
58+
fltk::Button *newButton;
59+
private:
60+
inline void cb_newButton_i(fltk::Button*, void*);
61+
static void cb_newButton(fltk::Button*, void*);
62+
inline void cb__i(fltk::TiledGroup*, void*);
63+
static void cb_(fltk::TiledGroup*, void*);
64+
fltk::FileBrowser *fileList;
65+
inline void cb_fileList_i(fltk::FileBrowser*, void*);
66+
static void cb_fileList(fltk::FileBrowser*, void*);
67+
fltk::InvisibleBox *previewBox;
68+
public:
69+
fltk::CheckButton *previewButton;
70+
private:
71+
inline void cb_previewButton_i(fltk::CheckButton*, void*);
72+
static void cb_previewButton(fltk::CheckButton*, void*);
73+
fltk::FileInput *fileName;
74+
inline void cb_fileName_i(fltk::FileInput*, void*);
75+
static void cb_fileName(fltk::FileInput*, void*);
76+
fltk::ReturnButton *okButton;
77+
inline void cb_okButton_i(fltk::ReturnButton*, void*);
78+
static void cb_okButton(fltk::ReturnButton*, void*);
79+
fltk::Button *cancelButton;
80+
inline void cb_cancelButton_i(fltk::Button*, void*);
81+
static void cb_cancelButton(fltk::Button*, void*);
82+
fltk::DoubleBufferWindow *favWindow;
83+
fltk::FileBrowser *favList;
84+
inline void cb_favList_i(fltk::FileBrowser*, void*);
85+
static void cb_favList(fltk::FileBrowser*, void*);
86+
fltk::Button *favUpButton;
87+
inline void cb_favUpButton_i(fltk::Button*, void*);
88+
static void cb_favUpButton(fltk::Button*, void*);
89+
fltk::Button *favDeleteButton;
90+
inline void cb_favDeleteButton_i(fltk::Button*, void*);
91+
static void cb_favDeleteButton(fltk::Button*, void*);
92+
fltk::Button *favDownButton;
93+
inline void cb_favDownButton_i(fltk::Button*, void*);
94+
static void cb_favDownButton(fltk::Button*, void*);
95+
fltk::Button *favCancelButton;
96+
inline void cb_favCancelButton_i(fltk::Button*, void*);
97+
static void cb_favCancelButton(fltk::Button*, void*);
98+
fltk::ReturnButton *favOkButton;
99+
inline void cb_favOkButton_i(fltk::ReturnButton*, void*);
100+
static void cb_favOkButton(fltk::ReturnButton*, void*);
101+
public:
102+
~FileChooser();
103+
void callback(void (*cb)(FileChooser *, void *), void *d = 0);
56104
void color(Color c);
57105
Color color();
58106
int count();
59107
void directory(const char *d);
60108
char * directory();
61-
void exec();
62109
void filter(const char *p);
63110
const char * filter();
111+
int filter_value();
112+
void filter_value(int f);
64113
void hide();
65114
void icon_size(uchar s);
66115
uchar icon_size();
67116
void label(const char *l);
68117
const char * label();
118+
void ok_label(const char *l);
119+
const char * ok_label();
120+
void preview(int e);
121+
int preview() const { return previewButton->value(); };
69122
void rescan();
123+
void show();
124+
int shown();
70125
void textcolor(Color c);
71126
Color textcolor();
72127
void textfont(Font* f);
73128
Font* textfont();
74-
void textsize(uchar s);
75-
uchar textsize();
129+
void textsize(float s);
130+
float textsize();
76131
void type(int t);
77132
int type();
78-
const char *text(int f = 1);
79-
void text(const char *filename);
133+
void * user_data() const;
134+
void user_data(void *d);
135+
const char *value(int f = 1);
136+
void value(const char *filename);
80137
int visible();
138+
static const char *add_favorites_label;
139+
static const char *all_files_label;
140+
static const char *custom_filter_label;
141+
static const char *existing_file_label;
142+
static const char *favorites_label;
143+
static const char *filename_label;
144+
static const char *filesystems_label;
145+
static const char *manage_favorites_label;
146+
static const char *new_directory_label;
147+
static const char *new_directory_tooltip;
148+
static const char *preview_label;
149+
static const char *save_label;
150+
static const char *show_label;
151+
static File_Sort_F *sort;
81152
};
82-
153+
extern FL_API void file_chooser_ok_label(const char*l);
83154
}
155+
// Header for //\n// End of "$Id: FileChooser.fl 4007 2005-02-0...
84156
#endif

fltk/FileInput.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class FL_API FileInput : public Input {
4747

4848
FileInput(int,int,int,int,const char *t=0);
4949

50-
void draw_boxes(Box* b,const Rectangle& r);
50+
void draw_boxes(bool pressed, const Rectangle& r);
5151
virtual int handle(int);
5252
virtual void draw();
5353

fltk/HelpDialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace fltk {
1313

14-
class FL_API HelpDialog {
14+
class FL_IMAGES_API HelpDialog {
1515
int index_;
1616
int max_;
1717
int line_[100];

fltk/HelpView.h

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct HelpTarget {
8989
// HelpView class...
9090
//
9191

92-
class FL_IMAGES_API HelpView : public Group //// Help viewer widget
92+
class FL_API HelpView : public Group //// Help viewer widget
9393
{
9494
enum { RIGHT = -1, CENTER, LEFT }; // Alignments
9595

@@ -147,24 +147,9 @@ class FL_IMAGES_API HelpView : public Group //// Help viewer widget
147147
int get_length (const char *l);
148148
int handle (int);
149149

150-
void initfont (Font *&f, int &s) {
151-
nfonts_ = 0;
152-
f = fonts_[0] = textfont_;
153-
s = fontsizes_[0] = textsize_;
154-
setfont (f, (float)s-1);
155-
}
156-
void pushfont (Font *f, int s) {
157-
if (nfonts_ < 99) nfonts_++;
158-
fonts_[nfonts_] = f;
159-
fontsizes_[nfonts_] = s;
160-
setfont (f, (float)s-1);
161-
}
162-
void popfont (Font *&f, int &s) {
163-
if (nfonts_ > 0) nfonts_--;
164-
f = fonts_[nfonts_];
165-
s = fontsizes_[nfonts_];
166-
setfont(f, (float)s-1);
167-
}
150+
void initfont (Font *&f, int &s);
151+
void pushfont (Font *f, int s);
152+
void popfont (Font *&f, int &s);
168153

169154
public:
170155

@@ -189,21 +174,13 @@ class FL_IMAGES_API HelpView : public Group //// Help viewer widget
189174
void resize (int, int, int, int);
190175
void layout();
191176
int size () const { return (size_); }
192-
void textcolor (Color c) {
193-
if (textcolor_ == defcolor_)
194-
textcolor_ = c;
195-
defcolor_ = c;
196-
}
177+
178+
void textcolor (Color c);
179+
void textfont (Font *f);
180+
void textsize (int s);
181+
197182
Color textcolor () const { return (defcolor_); }
198-
void textfont (Font *f) {
199-
textfont_ = f;
200-
format();
201-
}
202183
Font *textfont () const { return (textfont_); }
203-
void textsize (int s) {
204-
textsize_ = s;
205-
format ();
206-
}
207184
int textsize () const { return (textsize_); }
208185
const char *title () { return (title_); }
209186
void topline (const char *n);

fltk/SharedImage.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ class FL_IMAGES_API pngImage : public SharedImage {
223223
}
224224
};
225225

226-
extern FL_API void register_images(); // return always true only for automatic lib init purpose see images_core.cxx trick
227-
extern FL_API void unregister_images();
226+
extern FL_IMAGES_API void register_images(); // return always true only for automatic lib init purpose see images_core.cxx trick
227+
extern FL_IMAGES_API void unregister_images();
228228
}
229229

230230
#endif

fltk/file_chooser.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ namespace fltk {
3131

3232
FL_API void use_system_file_chooser(bool = true);
3333

34-
FL_API const char *file_chooser(const char *message,
35-
const char *pattern,
36-
const char *filename,
37-
bool save = true);
34+
FL_API const char *dir_chooser(const char *message,const char *fname,int relative=0);
35+
FL_API const char *file_chooser(const char *message,const char *pattern,
36+
const char *filename, int relative = 0);
3837
FL_API void file_chooser_callback(void (*cb)(const char *));
3938

4039
/* \} */

fluid/Fl_Widget_Type.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,7 @@ void WidgetType::write_widget_code() {
17101710

17111711
if (is_button()) {
17121712
fltk::Button* b = (fltk::Button*)o;
1713-
if (b->value()) write_c("%so->set_flag(VALUE);\n", indent());
1713+
if (b->value()) write_c("%so->set_flag(fltk::VALUE);\n", indent());
17141714
if (b->shortcut())
17151715
write_c("%so->shortcut(0x%x);\n", indent(), b->shortcut());
17161716
}

fluid/factory.cxx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ int TextDisplayType::textstuff(int w, fltk::Font* f, int& s, fltk::Color c) {
397397
fltk::TextDisplay *myo = (fltk::TextDisplay*)(w==4 ? ((WidgetType*)factory)->o : o);
398398
switch (w) {
399399
case 4:
400-
case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
400+
case 0: f = myo->textfont(); s = (int) myo->textsize(); c = myo->textcolor(); break;
401401
case 1: myo->textfont(f); break;
402402
case 2: myo->textsize((float)s); break;
403403
case 3: myo->textcolor(c); break;
@@ -453,7 +453,7 @@ class FileInputType: public WidgetType {
453453
virtual void ideal_size(int &w, int &h) {
454454
fltk::FileInput *myo = (fltk::FileInput *)o;
455455
fltk::setfont(myo->textfont(), myo->textsize());
456-
h = fltk::getdescent() + myo->textsize() + 4;
456+
h = (int) (fltk::getdescent() + myo->textsize() + 4);
457457
w -= fltk::box_dw(o->box());
458458
int ww = (int)fltk::getwidth("m",1);
459459
w = ((w + ww - 1) / ww) * ww + fltk::box_dw(o->box());
@@ -476,7 +476,7 @@ int FileInputType::textstuff(int w, fltk::Font* f, int& s, fltk::Color c) {
476476
fltk::FileInput *myo = (fltk::FileInput*)(w==4 ? ((WidgetType*)factory)->o : o);
477477
switch (w) {
478478
case 4:
479-
case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
479+
case 0: f = myo->textfont(); s = (int) myo->textsize(); c = myo->textcolor(); break;
480480
case 1: myo->textfont(f); break;
481481
case 2: myo->textsize((float)s); break;
482482
case 3: myo->textcolor(c); break;
@@ -603,7 +603,9 @@ static FluidType *FluidType_make(const char *tn, fltk::ItemGroup * menu) {
603603
fltk::Item * m;
604604
char menuName[128];
605605
int n;
606-
606+
607+
reading_file = 1; // makes labels be null
608+
607609
if (!tn || strlen(tn)==0)
608610
return 0;
609611

@@ -617,6 +619,9 @@ static FluidType *FluidType_make(const char *tn, fltk::ItemGroup * menu) {
617619
}
618620
if (m && m->user_data())
619621
r = ((FluidType*)(m->user_data()))->make();
622+
623+
reading_file = 0; // makes labels be null
624+
620625
return r;
621626
}
622627

0 commit comments

Comments
 (0)