From f52d03fb7ed75ea8c97a6cbd40c4ed219fbc8087 Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Mon, 21 Dec 2009 01:15:01 +0000 Subject: [PATCH] position column titles --- CHANGELOG.txt | 3 + pcbnew/dialog_layers_setup.cpp | 90 +++++++++++++------- pcbnew/dialog_layers_setup_base.cpp | 21 +---- pcbnew/dialog_layers_setup_base.fbp | 123 ++-------------------------- pcbnew/dialog_layers_setup_base.h | 6 +- 5 files changed, 79 insertions(+), 164 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 2887393596..6b7d631b24 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -9,6 +9,9 @@ email address. ++pcbnew Renamed dialog_layers_setup* files. Got rid of the header file since there was only one file including it. + Auto-position the column titles based on flexgridsizer colun widths. + Added m_TitlePanel with contrasting background color (whose color value may not + be ideal for all platforms). 2009-Dec-11 UPDATE Dick Hollenbeck diff --git a/pcbnew/dialog_layers_setup.cpp b/pcbnew/dialog_layers_setup.cpp index ca1fc7227f..62f70de326 100644 --- a/pcbnew/dialog_layers_setup.cpp +++ b/pcbnew/dialog_layers_setup.cpp @@ -69,7 +69,10 @@ private: BOARD* m_Pcb; - void init(); + wxStaticText* m_NameStaticText; + wxStaticText* m_EnabledStaticText; + wxStaticText* m_TypeStaticText; + void setLayerCheckBox( int layer, bool isChecked ); void setCopperLayerCheckBoxes( int copperCount ); @@ -117,6 +120,26 @@ private: return (wxChoice*) getCTLs( aLayer ).choice; } + void moveTitles() + { + wxArrayInt widths = m_LayerListFlexGridSizer->GetColWidths(); + + int offset = 0; + wxSize txtz; + + txtz = m_NameStaticText->GetSize(); +// m_NameStaticText->Move( 0, 5 ); + m_NameStaticText->Move( offset + (widths[0] - txtz.x)/2, 5 ); + offset += widths[0]; + + txtz = m_EnabledStaticText->GetSize(); + m_EnabledStaticText->Move( offset + (widths[1] - txtz.x)/2, 5 ); + offset += widths[1]; + + txtz = m_TypeStaticText->GetSize(); + m_TypeStaticText->Move( offset + (widths[2] - txtz.x)/2, 5 ); + } + public: DIALOG_LAYERS_SETUP( WinEDA_PcbFrame* parent ); @@ -124,6 +147,18 @@ public: bool Show( bool show ); // overload stock function + /** + * Function Layout + * overrides the standard Layout() function so that the column titles can + * be positioned using information in the flexgridsizer. + */ + bool Layout() + { + bool ret = DIALOG_LAYERS_SETUP_BASE::Layout(); + + moveTitles(); + return ret; + } }; @@ -214,9 +249,33 @@ DIALOG_LAYERS_SETUP::DIALOG_LAYERS_SETUP( WinEDA_PcbFrame* parent ) : m_Parent = parent; m_Pcb = m_Parent->GetBoard(); - init(); + m_CopperLayerCount = m_Pcb->GetCopperLayerCount(); + showCopperChoice( m_CopperLayerCount ); + + showBoardLayerNames(); + + m_EnabledLayers = m_Pcb->GetEnabledLayers(); + showSelectedLayerCheckBoxes( m_EnabledLayers ); + showPresets( m_EnabledLayers ); + + showLayerTypes(); SetAutoLayout( true ); + + // these 3 controls are handled outside wxformbuilder so that we can add + // them without a sizer. Then we position them manually based on the column + // widths from m_LayerListFexGridSizer->GetColWidths() + m_NameStaticText = new wxStaticText( m_TitlePanel, -1, _("Name"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TitlePanel->AddChild( m_NameStaticText ); + + m_EnabledStaticText = new wxStaticText( m_TitlePanel, -1, _("Enabled"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TitlePanel->AddChild( m_NameStaticText ); + + m_TypeStaticText = new wxStaticText( m_TitlePanel, -1, _("Type"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TitlePanel->AddChild( m_TypeStaticText ); + + m_TitlePanel->SetMinSize( wxSize( -1, m_AdhesFrontName->GetSize().y+10 ) ); + Layout(); Center(); @@ -332,31 +391,6 @@ void DIALOG_LAYERS_SETUP::showLayerTypes() } -/********************************************************************/ -void DIALOG_LAYERS_SETUP::init() -/********************************************************************/ -{ - m_CopperLayerCount = m_Pcb->GetCopperLayerCount(); - showCopperChoice( m_CopperLayerCount ); - - showBoardLayerNames(); - - m_EnabledLayers = m_Pcb->GetEnabledLayers(); - showSelectedLayerCheckBoxes( m_EnabledLayers ); - showPresets( m_EnabledLayers ); - - showLayerTypes(); - - // @todo overload a layout function so we can reposition the column titles, - // which should probably not go in a sizer of their own so that we do not have - // to fight to position them, Dick. Will work this out next. - - - // Adjust the vertical scroll rate so our list scrolls always one full line each time. -// m_LayersListPanel->SetScrollRate( 0, m_textCtrl1[0]->GetSize().y ); -} - - int DIALOG_LAYERS_SETUP::getUILayerMask() { int layerMaskResult = 0; @@ -609,7 +643,6 @@ bool DIALOG_LAYERS_SETUP::testLayerNames() } - void DisplayDialogLayerSetup( WinEDA_PcbFrame* parent ) { DIALOG_LAYERS_SETUP frame( parent ); @@ -617,4 +650,3 @@ void DisplayDialogLayerSetup( WinEDA_PcbFrame* parent ) frame.ShowModal(); frame.Destroy(); } - diff --git a/pcbnew/dialog_layers_setup_base.cpp b/pcbnew/dialog_layers_setup_base.cpp index d9679a9c80..8b1b7300c6 100644 --- a/pcbnew/dialog_layers_setup_base.cpp +++ b/pcbnew/dialog_layers_setup_base.cpp @@ -49,25 +49,12 @@ DIALOG_LAYERS_SETUP_BASE::DIALOG_LAYERS_SETUP_BASE( wxWindow* parent, wxWindowID wxBoxSizer* bCaptionsSizer; bCaptionsSizer = new wxBoxSizer( wxHORIZONTAL ); - m_LayerNameCaption = new wxStaticText( this, wxID_ANY, _("Name"), wxDefaultPosition, wxSize( -1,-1 ), wxALIGN_CENTRE ); - m_LayerNameCaption->Wrap( -1 ); - m_LayerNameCaption->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); + m_TitlePanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER|wxTAB_TRAVERSAL ); + m_TitlePanel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVECAPTION ) ); - bCaptionsSizer->Add( m_LayerNameCaption, 0, wxALIGN_CENTER_VERTICAL, 5 ); + bCaptionsSizer->Add( m_TitlePanel, 1, wxEXPAND, 5 ); - m_LayerEnabledCaption = new wxStaticText( this, wxID_ANY, _("Enabled"), wxDefaultPosition, wxSize( -1,-1 ), wxALIGN_CENTRE ); - m_LayerEnabledCaption->Wrap( -1 ); - m_LayerEnabledCaption->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); - - bCaptionsSizer->Add( m_LayerEnabledCaption, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - m_LayerTypeCaption = new wxStaticText( this, wxID_ANY, _("Type"), wxDefaultPosition, wxSize( -1,-1 ), wxALIGN_CENTRE ); - m_LayerTypeCaption->Wrap( -1 ); - m_LayerTypeCaption->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); - - bCaptionsSizer->Add( m_LayerTypeCaption, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - sbLayersSizer->Add( bCaptionsSizer, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, 5 ); + sbLayersSizer->Add( bCaptionsSizer, 0, wxALIGN_CENTER|wxEXPAND, 5 ); m_LayersListPanel = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxALWAYS_SHOW_SB|wxRAISED_BORDER|wxTAB_TRAVERSAL|wxVSCROLL ); m_LayersListPanel->SetScrollRate( 0, 5 ); diff --git a/pcbnew/dialog_layers_setup_base.fbp b/pcbnew/dialog_layers_setup_base.fbp index 8a57ee4b76..c10eec12c6 100644 --- a/pcbnew/dialog_layers_setup_base.fbp +++ b/pcbnew/dialog_layers_setup_base.fbp @@ -230,7 +230,7 @@ 5 - wxALIGN_CENTER|wxLEFT|wxRIGHT + wxALIGN_CENTER|wxEXPAND 0 @@ -239,132 +239,27 @@ none 5 - wxALIGN_CENTER_VERTICAL - 0 - - + wxEXPAND + 1 + + wxSYS_COLOUR_ACTIVECAPTION 1 - ,90,92,-1,70,0 + 0 wxID_ANY - Name - m_LayerNameCaption + m_TitlePanel protected - -1,-1 - wxALIGN_CENTRE + - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 0 - - - - 1 - - ,90,92,-1,70,0 - 0 - wxID_ANY - Enabled - - - m_LayerEnabledCaption - protected - - -1,-1 - wxALIGN_CENTRE - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - - - 1 - - ,90,92,-1,70,0 - 0 - wxID_ANY - Type - - - m_LayerTypeCaption - protected - - -1,-1 - wxALIGN_CENTRE - - - - - - -1 + wxRAISED_BORDER|wxTAB_TRAVERSAL diff --git a/pcbnew/dialog_layers_setup_base.h b/pcbnew/dialog_layers_setup_base.h index f3e8871818..f01bf30219 100644 --- a/pcbnew/dialog_layers_setup_base.h +++ b/pcbnew/dialog_layers_setup_base.h @@ -18,9 +18,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -126,9 +126,7 @@ class DIALOG_LAYERS_SETUP_BASE : public wxDialog protected: wxChoice* m_PresetsChoice; wxChoice* m_CopperLayersChoice; - wxStaticText* m_LayerNameCaption; - wxStaticText* m_LayerEnabledCaption; - wxStaticText* m_LayerTypeCaption; + wxPanel* m_TitlePanel; wxScrolledWindow* m_LayersListPanel; wxFlexGridSizer* m_LayerListFlexGridSizer; wxStaticText* m_AdhesFrontName;