Use TransferData* methods for DIALOG_DISPLAY_OPTIONS

Replaces the existing manual evdent handling, in line with UI
Guidelines.

Also remove the wxStaticLine, which is not a standard dialog element.
This commit is contained in:
John Beard 2017-03-14 00:13:04 +08:00 committed by Wayne Stambaugh
parent bdc9ae75f5
commit ef3553c086
5 changed files with 29 additions and 137 deletions

View File

@ -64,17 +64,15 @@ void PCB_EDIT_FRAME::InstallDisplayOptionsDialog( wxCommandEvent& aEvent )
DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS( PCB_EDIT_FRAME* parent ) :
DIALOG_DISPLAY_OPTIONS_BASE( parent )
DIALOG_DISPLAY_OPTIONS_BASE( parent ),
m_parent( parent )
{
m_Parent = parent;
KIGFX::GAL_DISPLAY_OPTIONS& galOptions = m_Parent->GetGalDisplayOptions();
KIGFX::GAL_DISPLAY_OPTIONS& galOptions = m_parent->GetGalDisplayOptions();
m_galOptsPanel = new GAL_OPTIONS_PANEL( this, galOptions );
sLeftSizer->Add( m_galOptsPanel, 1, wxEXPAND, 0 );
// load settings into controls
init();
SetFocus();
m_sdbSizerOK->SetDefault();
@ -83,11 +81,9 @@ DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS( PCB_EDIT_FRAME* parent ) :
}
void DIALOG_DISPLAY_OPTIONS::init()
bool DIALOG_DISPLAY_OPTIONS::TransferDataToWindow()
{
SetFocus();
const DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_Parent->GetDisplayOptions();
const DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*) m_parent->GetDisplayOptions();
m_OptDisplayTracks->SetValue( displ_opts->m_DisplayPcbTrackFill == SKETCH );
@ -97,34 +93,30 @@ void DIALOG_DISPLAY_OPTIONS::init()
m_OptDisplayPads->SetValue( displ_opts->m_DisplayPadFill == SKETCH );
m_OptDisplayVias->SetValue( displ_opts->m_DisplayViaFill == SKETCH );
m_Show_Page_Limits->SetValue( m_Parent->ShowPageLimits() );
m_Show_Page_Limits->SetValue( m_parent->ShowPageLimits() );
m_OptDisplayModTexts->SetValue( displ_opts->m_DisplayModTextFill == SKETCH );
m_OptDisplayModOutlines->SetValue( displ_opts->m_DisplayModEdgeFill == SKETCH );
m_OptDisplayPadClearence->SetValue( displ_opts->m_DisplayPadIsol );
m_OptDisplayPadNumber->SetValue( displ_opts->m_DisplayPadNum );
m_OptDisplayPadNoConn->SetValue( m_Parent->IsElementVisible( PCB_VISIBLE( NO_CONNECTS_VISIBLE ) ) );
m_OptDisplayPadNoConn->SetValue( m_parent->IsElementVisible( PCB_VISIBLE( NO_CONNECTS_VISIBLE ) ) );
m_OptDisplayDrawings->SetValue( displ_opts->m_DisplayDrawItemsFill == SKETCH );
m_ShowNetNamesOption->SetSelection( displ_opts->m_DisplayNetNamesMode );
m_galOptsPanel->TransferDataToWindow();
}
void DIALOG_DISPLAY_OPTIONS::OnCancelClick( wxCommandEvent& event )
{
EndModal( 0 );
return true;
}
/*
* Update variables with new options
*/
void DIALOG_DISPLAY_OPTIONS::OnOkClick( wxCommandEvent& event )
bool DIALOG_DISPLAY_OPTIONS::TransferDataFromWindow()
{
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_Parent->GetDisplayOptions();
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*) m_parent->GetDisplayOptions();
m_Parent->SetShowPageLimits( m_Show_Page_Limits->GetValue() );
m_parent->SetShowPageLimits( m_Show_Page_Limits->GetValue() );
displ_opts->m_DisplayPcbTrackFill = not m_OptDisplayTracks->GetValue();
@ -141,7 +133,7 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick( wxCommandEvent& event )
displ_opts->m_DisplayPadNum = m_OptDisplayPadNumber->GetValue();
m_Parent->SetElementVisibility( PCB_VISIBLE( NO_CONNECTS_VISIBLE ),
m_parent->SetElementVisibility( PCB_VISIBLE( NO_CONNECTS_VISIBLE ),
m_OptDisplayPadNoConn->GetValue() );
displ_opts->m_DisplayDrawItemsFill = not m_OptDisplayDrawings->GetValue();
@ -150,7 +142,7 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick( wxCommandEvent& event )
m_galOptsPanel->TransferDataFromWindow();
// Apply changes to the GAL
KIGFX::VIEW* view = m_Parent->GetGalCanvas()->GetView();
KIGFX::VIEW* view = m_parent->GetGalCanvas()->GetView();
KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
@ -158,7 +150,7 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick( wxCommandEvent& event )
view->RecacheAllItems();
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
m_Parent->GetCanvas()->Refresh();
m_parent->GetCanvas()->Refresh();
EndModal( 1 );
return true;
}

View File

@ -31,17 +31,16 @@ class GAL_OPTIONS_PANEL;
class DIALOG_DISPLAY_OPTIONS : public DIALOG_DISPLAY_OPTIONS_BASE
{
private:
PCB_EDIT_FRAME* m_Parent;
GAL_OPTIONS_PANEL* m_galOptsPanel;
void init();
public:
DIALOG_DISPLAY_OPTIONS( PCB_EDIT_FRAME* parent );
~DIALOG_DISPLAY_OPTIONS() {};
void OnOkClick( wxCommandEvent& event ) override;
void OnCancelClick( wxCommandEvent& event ) override;
bool TransferDataFromWindow() override;
bool TransferDataToWindow() override;
private:
PCB_EDIT_FRAME* m_parent;
GAL_OPTIONS_PANEL* m_galOptsPanel;
};

View File

@ -104,14 +104,11 @@ DIALOG_DISPLAY_OPTIONS_BASE::DIALOG_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWi
sRightSizer->Add( s_otherSizer, 1, wxEXPAND|wxALL, 5 );
bupperSizer->Add( sRightSizer, 0, 0, 5 );
bupperSizer->Add( sRightSizer, 0, wxEXPAND, 5 );
bMainSizer->Add( bupperSizer, 1, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline1, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
@ -125,16 +122,8 @@ DIALOG_DISPLAY_OPTIONS_BASE::DIALOG_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWi
this->SetSizer( bMainSizer );
this->Layout();
bMainSizer->Fit( this );
// Connect Events
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_OPTIONS_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_OPTIONS_BASE::OnOkClick ), NULL, this );
}
DIALOG_DISPLAY_OPTIONS_BASE::~DIALOG_DISPLAY_OPTIONS_BASE()
{
// Disconnect Events
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_OPTIONS_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_OPTIONS_BASE::OnOkClick ), NULL, this );
}

View File

@ -499,9 +499,9 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag"></property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
@ -1246,87 +1246,6 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticline1</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxLI_HORIZONTAL</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property>
@ -1344,11 +1263,11 @@
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick">OnCancelClick</event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick">OnOkClick</event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>

View File

@ -23,7 +23,6 @@ class DIALOG_SHIM;
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -56,15 +55,9 @@ class DIALOG_DISPLAY_OPTIONS_BASE : public DIALOG_SHIM
wxCheckBox* m_OptDisplayPadNoConn;
wxCheckBox* m_OptDisplayDrawings;
wxCheckBox* m_Show_Page_Limits;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public: