From 37d2057beecebfcea9b7b5d4cd3ca922cb5786c9 Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Tue, 10 Feb 2009 20:02:51 +0000 Subject: [PATCH] remove flashing/redrawing of text edit dialog --- eeschema/dialog_edit_label.cpp | 20 +++++++++++++++++++- eeschema/dialog_edit_label.h | 24 ++++++++++++++++++++---- eeschema/dialog_edit_label_base.cpp | 2 -- eeschema/dialog_edit_label_base.fbp | 2 +- eeschema/dialog_edit_label_base.h | 1 - eeschema/edit_label.cpp | 3 +-- 6 files changed, 41 insertions(+), 11 deletions(-) diff --git a/eeschema/dialog_edit_label.cpp b/eeschema/dialog_edit_label.cpp index 6facece53d..f92dfe8a31 100644 --- a/eeschema/dialog_edit_label.cpp +++ b/eeschema/dialog_edit_label.cpp @@ -17,6 +17,24 @@ #include "general.h" #include "dialog_edit_label.h" + +int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText ) +{ + int ret; + + DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText ); + + // doing any post construction resizing is better done here than in + // OnInitDialog() since it tends to flash/redraw the dialog less. + dialog->init(); + + ret = dialog->ShowModal(); + dialog->Destroy(); + return ret; +} + + + DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* CurrentText ) : DialogLabelEditor_Base( parent ) { @@ -25,7 +43,7 @@ DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* C } -void DialogLabelEditor::OnInitDialog( wxInitDialogEvent& event ) +void DialogLabelEditor::init() { wxString msg; diff --git a/eeschema/dialog_edit_label.h b/eeschema/dialog_edit_label.h index d82f3cfb07..000c166238 100644 --- a/eeschema/dialog_edit_label.h +++ b/eeschema/dialog_edit_label.h @@ -10,19 +10,35 @@ #include "dialog_edit_label_base.h" -class DialogLabelEditor : public DialogLabelEditor_Base +class DialogLabelEditor : public DialogLabelEditor_Base { private: WinEDA_SchematicFrame * m_Parent; SCH_TEXT * m_CurrentText; -public: + void init(); + +protected: + // these are protected so that the static ShowModally() gets used. DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText); ~DialogLabelEditor(){}; + + +public: + + /** + * Function ShowModally + * is a static function that constructs and then displays one of these dialogs. + * @param parent + * @param CurrentText is one of several classes derived from SCH_TEXT + * @return int - the result Dialog::ShowModal() + */ + static int ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText ); + private: void OnInitDialog( wxInitDialogEvent& event ); - void OnButtonOKClick( wxCommandEvent& event ); - void OnButtonCANCEL_Click( wxCommandEvent& event ); + void OnButtonOKClick( wxCommandEvent& event ); + void OnButtonCANCEL_Click( wxCommandEvent& event ); void TextPropertiesAccept( wxCommandEvent& event ); }; diff --git a/eeschema/dialog_edit_label_base.cpp b/eeschema/dialog_edit_label_base.cpp index 3e15ebd1b0..9d745b984c 100644 --- a/eeschema/dialog_edit_label_base.cpp +++ b/eeschema/dialog_edit_label_base.cpp @@ -82,7 +82,6 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, this->Layout(); // Connect Events - this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DialogLabelEditor_Base::OnInitDialog ) ); m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnButtonOKClick ), NULL, this ); m_buttonCANCEL->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnButtonCANCEL_Click ), NULL, this ); } @@ -90,7 +89,6 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, DialogLabelEditor_Base::~DialogLabelEditor_Base() { // Disconnect Events - this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DialogLabelEditor_Base::OnInitDialog ) ); m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnButtonOKClick ), NULL, this ); m_buttonCANCEL->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnButtonCANCEL_Click ), NULL, this ); } diff --git a/eeschema/dialog_edit_label_base.fbp b/eeschema/dialog_edit_label_base.fbp index fe51986ed7..f5b18b4c98 100644 --- a/eeschema/dialog_edit_label_base.fbp +++ b/eeschema/dialog_edit_label_base.fbp @@ -53,7 +53,7 @@ - OnInitDialog + diff --git a/eeschema/dialog_edit_label_base.h b/eeschema/dialog_edit_label_base.h index b3e9ddea74..cc462652d6 100644 --- a/eeschema/dialog_edit_label_base.h +++ b/eeschema/dialog_edit_label_base.h @@ -50,7 +50,6 @@ class DialogLabelEditor_Base : public wxDialog wxButton* m_buttonCANCEL; // Virtual event handlers, overide them in your derived class - virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); } virtual void OnButtonOKClick( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCANCEL_Click( wxCommandEvent& event ){ event.Skip(); } diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 3ccb657e46..2de3111550 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -137,8 +137,7 @@ void WinEDA_SchematicFrame::EditSchematicText( SCH_TEXT* TextStruct, DrawPanel->CursorOff( DC ); RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode ); - DialogLabelEditor* dialog = new DialogLabelEditor( this, TextStruct ); - dialog->ShowModal(); dialog->Destroy(); + DialogLabelEditor::ShowModally( this, TextStruct ); RedrawOneStruct( DrawPanel, DC, TextStruct, GR_DEFAULT_DRAWMODE ); DrawPanel->CursorOn( DC );