From 42b1020dc3f683d6de039b1a6e5246b4ecc988ac Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Fri, 7 Aug 2009 04:44:42 +0000 Subject: [PATCH] MsgPanel is sized dynamically based on system gui font size --- 3d-viewer/3d_frame.cpp | 4 +++- CHANGELOG.txt | 8 ++++++++ common/basicframe.cpp | 4 +++- common/msgpanel.cpp | 40 +++++++++++++++++++++++++------------- cvpcb/cvframe.cpp | 4 +++- include/wxstruct.h | 22 +++++++++++++++++---- kicad/mainframe.cpp | 3 ++- pcbnew/specctra_import.cpp | 2 +- 8 files changed, 64 insertions(+), 23 deletions(-) diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp index fcd48e6041..840e6bea8c 100644 --- a/3d-viewer/3d_frame.cpp +++ b/3d-viewer/3d_frame.cpp @@ -67,9 +67,11 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( WinEDA_BasePcbFrame* parent, SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); // Create the status line - int dims[5] = { -1, 100, 100, 100, 140 }; + static const int dims[5] = { -1, 100, 100, 100, 140 }; + CreateStatusBar( 5 ); SetStatusWidths( 5, dims ); + ReCreateMenuBar(); ReCreateHToolbar(); diff --git a/CHANGELOG.txt b/CHANGELOG.txt index b3a30f88cf..cf215a3f59 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,14 @@ KiCad ChangeLog 2009 Please add newer entries at the top, list the date and your name with email address. +2009-Aug-6 UPDATE Dick Hollenbeck +================================================================================ +++pcbnew + MsgPanel is dynamically sized based on system gui font. Before this fix + the window height was hardcoded and was too small on systems with large + fonts. See WinEDA_MsgPanel::GetRequiredHeight(); + + 2009-aug-08 UPDATE Jean-Pierre Charras ================================================================================ ++pcbnew diff --git a/common/basicframe.cpp b/common/basicframe.cpp index dfdf3b6726..555a1e6eeb 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -40,10 +40,12 @@ WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father, m_Ident = idtype; m_HToolBar = NULL; m_FrameIsActive = TRUE; - m_MsgFrameHeight = MSG_PANEL_DEFAULT_HEIGHT; + + m_MsgFrameHeight = WinEDA_MsgPanel::GetRequiredHeight(); minsize.x = 470; minsize.y = 350 + m_MsgFrameHeight; + SetSizeHints( minsize.x, minsize.y, -1, -1, -1, -1 ); /* Verification des parametres de creation */ diff --git a/common/msgpanel.cpp b/common/msgpanel.cpp index 5d5a06ffad..9c2d5127ef 100644 --- a/common/msgpanel.cpp +++ b/common/msgpanel.cpp @@ -30,6 +30,8 @@ WinEDA_MsgPanel::WinEDA_MsgPanel( WinEDA_DrawFrame* parent, int id, SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) ); SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); m_last_x = 0; + + m_fontSize = computeFontSize(); } @@ -38,6 +40,27 @@ WinEDA_MsgPanel::~WinEDA_MsgPanel() } +wxSize WinEDA_MsgPanel::computeFontSize() +{ + // Get size of the wxSYS_DEFAULT_GUI_FONT + wxSize fontSizeInPixels; + + wxScreenDC dc; + + dc.SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) ); + dc.GetTextExtent( wxT( "W" ), &fontSizeInPixels.x, &fontSizeInPixels.y ); + + return fontSizeInPixels; +} + + +int WinEDA_MsgPanel::GetRequiredHeight() +{ + // make space for two rows of text plus a number of pixels between them. + return 2 * computeFontSize().y + 0; +} + + /*************************************************/ void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event ) /*************************************************/ @@ -78,20 +101,9 @@ void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H, wxPoint pos; wxSize drawSize = GetClientSize(); - - // Get size of the font - wxSize fontSizeInPixels; - { - wxClientDC dc( this ); - - dc.SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) ); - dc.GetTextExtent( wxT( "W" ), &fontSizeInPixels.x, &fontSizeInPixels.y ); - - } // destroy wxClientDC ASAP - if( pos_X >= 0 ) { - m_last_x = pos.x = pos_X * (fontSizeInPixels.x + 2); + m_last_x = pos.x = pos_X * (m_fontSize.x + 2); } else pos.x = m_last_x; @@ -100,8 +112,8 @@ void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H, item.m_X = pos.x; - item.m_UpperY = (drawSize.y / 2) - fontSizeInPixels.y; - item.m_LowerY = drawSize.y - fontSizeInPixels.y; + item.m_UpperY = (drawSize.y / 2) - m_fontSize.y; + item.m_LowerY = drawSize.y - m_fontSize.y; item.m_UpperText = texte_H; item.m_LowerText = texte_L; diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index f2bdc53db7..662a25d64b 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -144,9 +144,11 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, long style ) : m_FrameSize.y = FRAME_MIN_SIZE_Y; // create the status bar - int dims[3] = { -1, -1, 250 }; + static const int dims[3] = { -1, -1, 250 }; + CreateStatusBar( 3 ); SetStatusWidths( 3, dims ); + ReCreateMenuBar(); ReCreateHToolbar(); diff --git a/include/wxstruct.h b/include/wxstruct.h index 85bca2267f..d4b1ae32ae 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -80,8 +80,6 @@ enum id_toolbar { /* Classes for basic main frames used in kicad */ /***********************************************/ -#define MSG_PANEL_DEFAULT_HEIGHT ( 28 ) // height of the infos display window - /******************************************************************/ /* Basic frame for kicad, eeschema, pcbnew and gerbview. */ @@ -348,14 +346,22 @@ struct MsgItem class WinEDA_MsgPanel : public wxPanel { protected: - std::vector m_Items; - int m_last_x; ///< the last used x coordinate + std::vector m_Items; + int m_last_x; ///< the last used x coordinate + wxSize m_fontSize; void showItem( wxDC& dc, const MsgItem& aItem ); void erase( wxDC* DC ); + /** + * Function getFontSize + * computes the height and width of a 'W' in the system font. + */ + static wxSize computeFontSize(); + + public: WinEDA_DrawFrame* m_Parent; int m_BgColor; // couleur de fond @@ -366,6 +372,14 @@ public: WinEDA_MsgPanel( WinEDA_DrawFrame* parent, int id, const wxPoint& pos, const wxSize& size ); ~WinEDA_MsgPanel(); + + /** + * Function GetRequiredHeight + * returns the required height (in pixels) of a WinEDA_MsgPanel. This takes + * into consideration the system gui font, wxSYS_DEFAULT_GUI_FONT. + */ + static int GetRequiredHeight(); + void OnPaint( wxPaintEvent& event ); void EraseMsgBox(); void Affiche_1_Parametre( int pos_X, const wxString& texte_H, diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index f4e68bb781..601a246456 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -48,7 +48,8 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent, SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); // Create the status line (bottom of the frame - int dims[3] = { -1, -1, 100 }; + static const int dims[3] = { -1, -1, 100 }; + CreateStatusBar( 3 ); SetStatusWidths( 3, dims ); diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index 0861ad1213..1e555edfd2 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -424,7 +424,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError ) { // module is on component layer (front) module->Flip( module->m_Pos ); - } + } module->SetOrientation( orientation ); } else