From 385c38912e8227f45891db52fc682bb5782e1d29 Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 1 May 2008 18:03:45 +0000 Subject: STR #1908 add Fl_Widget* add_extra(Fl_Widget*) function to Fl_File_Chooser class git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6120 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_File_Chooser.cxx | 41 ++++++++++++++++++++++++++++++------ src/Fl_File_Chooser.fl | 55 ++++++++++++++++++++++++++++++++++++++---------- src/Fl_File_Chooser2.cxx | 7 ++++++ 3 files changed, 86 insertions(+), 17 deletions(-) diff --git a/src/Fl_File_Chooser.cxx b/src/Fl_File_Chooser.cxx index 842e7f5bb..fb588cb7d 100644 --- a/src/Fl_File_Chooser.cxx +++ b/src/Fl_File_Chooser.cxx @@ -25,7 +25,7 @@ // http://www.fltk.org/str.php // -// generated by Fast Light User Interface Designer (fluid) version 1.0108 +// generated by Fast Light User Interface Designer (fluid) version 1.0300 #include "../FL/Fl_File_Chooser.H" #include @@ -202,9 +202,9 @@ Fl_File_Chooser::Fl_File_Chooser(const char *d, const char *p, int t, const char { Fl_Group* o = new Fl_Group(10, 275, 470, 95); { Fl_Group* o = new Fl_Group(10, 275, 470, 20); { previewButton = new Fl_Check_Button(10, 275, 73, 20, "Preview"); + previewButton->shortcut(0x80070); previewButton->down_box(FL_DOWN_BOX); previewButton->value(1); - previewButton->shortcut(0x80070); previewButton->callback((Fl_Callback*)cb_previewButton); previewButton->label(preview_label); } // Fl_Check_Button* previewButton @@ -298,10 +298,12 @@ int e; prefs_.get("preview", e, 1); preview(e); Fl_Group::current(prev_current); + ext_group=(Fl_Widget*)0; } Fl_File_Chooser::~Fl_File_Chooser() { Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this); +if(ext_group)window->remove(ext_group); delete window; delete favWindow; } @@ -391,19 +393,19 @@ Fl_Color Fl_File_Chooser::textcolor() { return (fileList->textcolor()); } -void Fl_File_Chooser::textfont(Fl_Font f) { +void Fl_File_Chooser::textfont(uchar f) { fileList->textfont(f); } -Fl_Font Fl_File_Chooser::textfont() { +uchar Fl_File_Chooser::textfont() { return (fileList->textfont()); } -void Fl_File_Chooser::textsize(Fl_Font_Size s) { +void Fl_File_Chooser::textsize(uchar s) { fileList->textsize(s); } -Fl_Font_Size Fl_File_Chooser::textsize() { +uchar Fl_File_Chooser::textsize() { return (fileList->textsize()); } @@ -439,6 +441,33 @@ int Fl_File_Chooser::visible() { return window->visible(); } +Fl_Widget* Fl_File_Chooser::add_extra(Fl_Widget* gr) { + Fl_Widget* ret=ext_group; + if (gr==ext_group) { + return ret; + } + if (ext_group) { + int sh=ext_group->h()+4; +Fl_Widget* svres=window->resizable(); +window->resizable(NULL); +window->size(window->w(),window->h()-sh); +window->remove(ext_group); +ext_group=NULL; +window->resizable(svres); + } + if (gr) { + int nh=window->h()+gr->h()+4; +Fl_Widget* svres=window->resizable(); +window->resizable(NULL); +window->size(window->w(),nh); +gr->position(2,okButton->y()+okButton->h()+2); +window->add(gr); +ext_group=gr; +window->resizable(svres); + } + return ret; +} + // // End of "$Id$". // diff --git a/src/Fl_File_Chooser.fl b/src/Fl_File_Chooser.fl index b40fb615d..80b5b589d 100644 --- a/src/Fl_File_Chooser.fl +++ b/src/Fl_File_Chooser.fl @@ -1,5 +1,5 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0108 +version 1.0300 header_name {../FL/Fl_File_Chooser.H} code_name {.cxx} comment {// @@ -28,7 +28,7 @@ comment {// // // http://www.fltk.org/str.php // -} {in_source in_header +} {selected in_source in_header } decl {\#include } {} @@ -53,22 +53,21 @@ class FL_EXPORT Fl_File_Chooser {open decl {void showChoiceCB();} {} decl {void update_favorites();} {} decl {void update_preview();} {} - Function {Fl_File_Chooser(const char *d, const char *p, int t, const char *title)} {open - } { + Function {Fl_File_Chooser(const char *d, const char *p, int t, const char *title)} {} { code {Fl_Group *prev_current = Fl_Group::current();} {} Fl_Window window { label {Choose File} callback {fileName->value(""); fileList->deselect(); Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this); -window->hide();} - private xywh {388 284 490 380} type Double resizable +window->hide();} open + private xywh {507 327 490 380} type Double resizable code0 {if (title) window->label(title);} code1 {\#include } code2 {\#include } code3 {\#include } modal visible } { - Fl_Group {} { + Fl_Group {} {open private xywh {10 10 470 25} } { Fl_Choice showChoice { @@ -104,7 +103,7 @@ window->hide();} private xywh {305 45 175 225} box DOWN_BOX labelsize 100 align 80 } } - Fl_Group {} { + Fl_Group {} {open private xywh {10 275 470 95} } { Fl_Group {} {open @@ -220,11 +219,13 @@ type(t); int e; prefs_.get("preview", e, 1); preview(e); -Fl_Group::current(prev_current);} {selected - } +Fl_Group::current(prev_current);} {} + code {ext_group=(Fl_Widget*)0;} {} } - Function {~Fl_File_Chooser()} {} { + Function {~Fl_File_Chooser()} {open + } { code {Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this); +if(ext_group)window->remove(ext_group); delete window; delete favWindow;} {} } @@ -406,6 +407,38 @@ else } decl {static Fl_File_Sort_F *sort;} {public } + decl {Fl_Widget* ext_group;} {} + decl {bool ext_managed;} {} + Function {add_extra(Fl_Widget* gr)} {open return_type {Fl_Widget*} + } { + code {Fl_Widget* ret=ext_group;} {} + codeblock {if (gr==ext_group)} {open + } { + code {return ret;} {} + } + codeblock {if (ext_group)} {open + } { + code {int sh=ext_group->h()+4; +Fl_Widget* svres=window->resizable(); +window->resizable(NULL); +window->size(window->w(),window->h()-sh); +window->remove(ext_group); +ext_group=NULL; +window->resizable(svres);} {} + } + codeblock {if (gr)} {open + } { + code {int nh=window->h()+gr->h()+4; +Fl_Widget* svres=window->resizable(); +window->resizable(NULL); +window->size(window->w(),nh); +gr->position(2,okButton->y()+okButton->h()+2); +window->add(gr); +ext_group=gr; +window->resizable(svres);} {} + } + code {return ret;} {} + } } decl {FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname,int relative=0);} {public diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx index 44d5534ad..c7d481df4 100644 --- a/src/Fl_File_Chooser2.cxx +++ b/src/Fl_File_Chooser2.cxx @@ -41,6 +41,13 @@ // quote_pathname() - Quote a pathname for a menu. // unquote_pathname() - Unquote a pathname from a menu. // +// Fl_File_Chooser::add_extra() - add extra widget at the bottom, return pointer +// to previous extra widget or NULL if none, +// If argument is NULL extra widget removed. +// NOTE! file chooser don't delete extra widget in +// destructor! To prevent memory leakage don't forget +// delete unused extra widgets by yuorself. +// // // Include necessary headers. -- cgit v1.2.3