MsgPanel is sized dynamically based on system gui font size

This commit is contained in:
dickelbeck 2009-08-07 04:44:42 +00:00
parent 896c69757d
commit 42b1020dc3
8 changed files with 64 additions and 23 deletions

View File

@ -67,9 +67,11 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( WinEDA_BasePcbFrame* parent,
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
// Create the status line // Create the status line
int dims[5] = { -1, 100, 100, 100, 140 }; static const int dims[5] = { -1, 100, 100, 100, 140 };
CreateStatusBar( 5 ); CreateStatusBar( 5 );
SetStatusWidths( 5, dims ); SetStatusWidths( 5, dims );
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();

View File

@ -4,6 +4,14 @@ KiCad ChangeLog 2009
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2009-Aug-6 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++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 <jean-pierre.charras@gipsa-lab.inpg.fr> 2009-aug-08 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
++pcbnew ++pcbnew

View File

@ -40,10 +40,12 @@ WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father,
m_Ident = idtype; m_Ident = idtype;
m_HToolBar = NULL; m_HToolBar = NULL;
m_FrameIsActive = TRUE; m_FrameIsActive = TRUE;
m_MsgFrameHeight = MSG_PANEL_DEFAULT_HEIGHT;
m_MsgFrameHeight = WinEDA_MsgPanel::GetRequiredHeight();
minsize.x = 470; minsize.x = 470;
minsize.y = 350 + m_MsgFrameHeight; minsize.y = 350 + m_MsgFrameHeight;
SetSizeHints( minsize.x, minsize.y, -1, -1, -1, -1 ); SetSizeHints( minsize.x, minsize.y, -1, -1, -1, -1 );
/* Verification des parametres de creation */ /* Verification des parametres de creation */

View File

@ -30,6 +30,8 @@ WinEDA_MsgPanel::WinEDA_MsgPanel( WinEDA_DrawFrame* parent, int id,
SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) ); SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) );
SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
m_last_x = 0; 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 ) 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; wxPoint pos;
wxSize drawSize = GetClientSize(); 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 ) 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 else
pos.x = m_last_x; 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_X = pos.x;
item.m_UpperY = (drawSize.y / 2) - fontSizeInPixels.y; item.m_UpperY = (drawSize.y / 2) - m_fontSize.y;
item.m_LowerY = drawSize.y - fontSizeInPixels.y; item.m_LowerY = drawSize.y - m_fontSize.y;
item.m_UpperText = texte_H; item.m_UpperText = texte_H;
item.m_LowerText = texte_L; item.m_LowerText = texte_L;

View File

@ -144,9 +144,11 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, long style ) :
m_FrameSize.y = FRAME_MIN_SIZE_Y; m_FrameSize.y = FRAME_MIN_SIZE_Y;
// create the status bar // create the status bar
int dims[3] = { -1, -1, 250 }; static const int dims[3] = { -1, -1, 250 };
CreateStatusBar( 3 ); CreateStatusBar( 3 );
SetStatusWidths( 3, dims ); SetStatusWidths( 3, dims );
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();

View File

@ -80,8 +80,6 @@ enum id_toolbar {
/* Classes for basic main frames used in kicad */ /* 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. */ /* Basic frame for kicad, eeschema, pcbnew and gerbview. */
@ -348,14 +346,22 @@ struct MsgItem
class WinEDA_MsgPanel : public wxPanel class WinEDA_MsgPanel : public wxPanel
{ {
protected: protected:
std::vector<MsgItem> m_Items; std::vector<MsgItem> m_Items;
int m_last_x; ///< the last used x coordinate int m_last_x; ///< the last used x coordinate
wxSize m_fontSize;
void showItem( wxDC& dc, const MsgItem& aItem ); void showItem( wxDC& dc, const MsgItem& aItem );
void erase( wxDC* DC ); void erase( wxDC* DC );
/**
* Function getFontSize
* computes the height and width of a 'W' in the system font.
*/
static wxSize computeFontSize();
public: public:
WinEDA_DrawFrame* m_Parent; WinEDA_DrawFrame* m_Parent;
int m_BgColor; // couleur de fond 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( WinEDA_DrawFrame* parent, int id, const wxPoint& pos, const wxSize& size );
~WinEDA_MsgPanel(); ~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 OnPaint( wxPaintEvent& event );
void EraseMsgBox(); void EraseMsgBox();
void Affiche_1_Parametre( int pos_X, const wxString& texte_H, void Affiche_1_Parametre( int pos_X, const wxString& texte_H,

View File

@ -48,7 +48,8 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent,
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
// Create the status line (bottom of the frame // Create the status line (bottom of the frame
int dims[3] = { -1, -1, 100 }; static const int dims[3] = { -1, -1, 100 };
CreateStatusBar( 3 ); CreateStatusBar( 3 );
SetStatusWidths( 3, dims ); SetStatusWidths( 3, dims );

View File

@ -424,7 +424,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
{ {
// module is on component layer (front) // module is on component layer (front)
module->Flip( module->m_Pos ); module->Flip( module->m_Pos );
} }
module->SetOrientation( orientation ); module->SetOrientation( orientation );
} }
else else