From cc1e467b7262aa320656b0e81c8aa2de5f3099fd Mon Sep 17 00:00:00 2001 From: Karel Matas Date: Mon, 24 Jun 2013 15:17:23 +0200 Subject: [PATCH] ManageDBDialog: added Close button --- src/gui_dialogs.cxx | 3 +++ src/gui_dialogs.hxx | 23 ++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/gui_dialogs.cxx b/src/gui_dialogs.cxx index b567578..4be7eb4 100755 --- a/src/gui_dialogs.cxx +++ b/src/gui_dialogs.cxx @@ -200,6 +200,7 @@ ManageDBDialog::Item::Item ( int x, int y, int w, int h, const char *l ) menu_->add("Download"); l_desc_ = new Fl_Box( x, l_name_->y()+l_name_->h(), w, rh, "Description"); l_desc_->align(FL_ALIGN_LEFT+FL_ALIGN_INSIDE); + this->end(); this->resizable(0); this->size(w,l_name_->h()+l_desc_->h()); } @@ -238,6 +239,8 @@ ManageDBDialog::ManageDBDialog ( int w, int h, const char *l ) : Fl_Double_Window(w,h,l) { last_y_ = 5; + b_close_ = new Fl_Button( w-65, h-25, 60, 20, "Close" ); + b_close_->callback( scb_close, (void*)this ); end(); set_modal(); } diff --git a/src/gui_dialogs.hxx b/src/gui_dialogs.hxx index 3d5ccfd..abc8b07 100755 --- a/src/gui_dialogs.hxx +++ b/src/gui_dialogs.hxx @@ -274,10 +274,10 @@ class ManageDBDialog : public Fl_Double_Window class Item : public Fl_Group { private: - Fl_Box *l_name_; - Fl_Box *l_ver_; - Fl_Menu_Button *menu_; - Fl_Box *l_desc_; + Fl_Box *l_name_ = nullptr; + Fl_Box *l_ver_ = nullptr; + Fl_Menu_Button *menu_ = nullptr; + Fl_Box *l_desc_ = nullptr; string title_; string version_; string description_; @@ -292,10 +292,11 @@ class ManageDBDialog : public Fl_Double_Window { version_ = s; l_ver_->label(version_.c_str()); l_ver_->labelcolor(c); } }; private: - int last_y_; + int last_y_ = 0; + Fl_Button *b_close_ = nullptr; public: - ManageDBDialog ( int w, int h, const char *l="Manage Database" ); + ManageDBDialog ( int w=300, int h=200, const char *l="Manage Database" ); ~ManageDBDialog(){}; void add_item ( const string &name, const string &version, @@ -304,11 +305,15 @@ class ManageDBDialog : public Fl_Double_Window void *cb_data=nullptr ); inline Item *item ( const string &name ) { - for ( int i=0; ititle() == name ) - return (Item*)child(i); + for ( int i=0; i(child(i)); + if ( pi && pi->title() == name ) + return pi; + } return nullptr; } + inline static void scb_close ( Fl_Widget *w, void *p ) + { ((ManageDBDialog*)p)->hide(); }; }; -- 2.11.4.GIT