From 740c1003590d4af8112939a775f2a0b20b2f5ae7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 7 Feb 2015 22:49:27 +0000 Subject: Update sensitivity of Set File button correctly. --- src/wx/fonts_dialog.cc | 18 +++++++++++++++++- src/wx/fonts_dialog.h | 4 +++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wx/fonts_dialog.cc b/src/wx/fonts_dialog.cc index 99d570263..a4a3d26c4 100644 --- a/src/wx/fonts_dialog.cc +++ b/src/wx/fonts_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -70,8 +70,11 @@ FontsDialog::FontsDialog (wxWindow* parent, shared_ptr content) SetSizerAndFit (overall_sizer); _set_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FontsDialog::set_file_clicked, this)); + _fonts->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&FontsDialog::selection_changed, this)); + _fonts->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&FontsDialog::selection_changed, this)); setup (); + update_sensitivity (); } void @@ -134,3 +137,16 @@ FontsDialog::set_file_clicked () setup (); } + +void +FontsDialog::selection_changed () +{ + update_sensitivity (); +} + +void +FontsDialog::update_sensitivity () +{ + int const item = _fonts->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + _set_file->Enable (item != -1); +} diff --git a/src/wx/fonts_dialog.h b/src/wx/fonts_dialog.h index c7ca789b8..76eae3ec2 100644 --- a/src/wx/fonts_dialog.h +++ b/src/wx/fonts_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,8 @@ public: private: void setup (); void set_file_clicked (); + void update_sensitivity (); + void selection_changed (); boost::weak_ptr _content; wxListCtrl* _fonts; -- cgit v1.2.3