From e1ff958a3cddfe3b12ef806d7cd8aef7c6806fa3 Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Wed, 10 Oct 2007 18:01:14 +0000 Subject: [PATCH] MsgPanel rewrite --- change_log.txt | 4 +- common/msgpanel.cpp | 91 +++++++++++++++++++++++++++++++++++++-------- include/wxstruct.h | 40 ++++++++++++++++++++ 3 files changed, 119 insertions(+), 16 deletions(-) diff --git a/change_log.txt b/change_log.txt index 0a42bd03d0..8ca9a545aa 100644 --- a/change_log.txt +++ b/change_log.txt @@ -12,8 +12,10 @@ email address. * bug fix: popup menu was not handling Mires, because the collector was not being asked to find them. + all - Changed English UI text "Mire" to "Target" according to this post: + * Changed English UI text "Mire" to "Target" according to this post: http://tech.groups.yahoo.com/group/kicad-users/message/1380 + * rewrote msgpanel.cpp so it retains wxStrings and therefore can repaint its + window when being uncovered, resized or whatever. 2007-Oct-9 UPDATE Dick Hollenbeck diff --git a/common/msgpanel.cpp b/common/msgpanel.cpp index a639248015..b6f05507b3 100644 --- a/common/msgpanel.cpp +++ b/common/msgpanel.cpp @@ -34,6 +34,7 @@ WinEDA_MsgPanel::WinEDA_MsgPanel( WinEDA_DrawFrame* parent, int id, WinEDA_MsgPanel::~WinEDA_MsgPanel() { + m_Items.clear(); } @@ -43,7 +44,19 @@ void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event ) { wxPaintDC dc( this ); - EraseMsgBox( &dc ); event.Skip(); + //EraseMsgBox( &dc ); + + dc.SetBackground( *wxBLACK_BRUSH ); + dc.SetBackgroundMode( wxSOLID ); + + dc.SetTextBackground( GetBackgroundColour() ); + + dc.SetFont( *g_MsgFont ); + + for( unsigned i=0; i= 0 ) - { - color &= MASKCOLOR; - dc.SetTextForeground( wxColour( - ColorRefs[color].m_Red, ColorRefs[color].m_Green, - ColorRefs[color].m_Blue ) ); - } if( pos_X >= 0 ) { @@ -95,16 +101,66 @@ void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H, else pos.x = old_pos_X; - if( !texte_H.IsEmpty() ) + MsgItem item; + + item.m_X = pos.x; + + item.m_UpperY = (DrawSize.y / 2) - FontSizeInPixels.y; + item.m_LowerY = DrawSize.y - FontSizeInPixels.y; + + item.m_UpperText = texte_H; + item.m_LowerText = texte_L; + item.m_Color = color; + + int ndx; + + // update the vector, which is sorted by m_X + int limit = m_Items.size(); + for( ndx=0; ndx item.m_X ) + { + m_Items.insert( m_Items.begin()+ndx, item ); + break; + } } - if( !texte_L.IsEmpty() ) + if( ndx==limit ) // mutually exclusive with two above if tests { - pos.y = DrawSize.y - FontSizeInPixels.y; - dc.DrawText( texte_L.GetData(), pos.x, pos.y ); + m_Items.push_back( item ); + } + + showItem( dc, item ); +} + + +void WinEDA_MsgPanel::showItem( wxClientDC& dc, const MsgItem& aItem ) +{ + int color = aItem.m_Color; + + if( color >= 0 ) + { + color &= MASKCOLOR; + dc.SetTextForeground( wxColour( ColorRefs[color].m_Red, + ColorRefs[color].m_Green, + ColorRefs[color].m_Blue ) ); + } + + if( !aItem.m_UpperText.IsEmpty() ) + { + dc.DrawText( aItem.m_UpperText.GetData(), aItem.m_X, aItem.m_UpperY ); + } + + if( !aItem.m_LowerText.IsEmpty() ) + { + dc.DrawText( aItem.m_LowerText.GetData(), aItem.m_X, aItem.m_LowerY ); } } @@ -133,13 +189,18 @@ void WinEDA_MsgPanel::EraseMsgBox( wxDC* DC ) size = GetClientSize(); color = GetBackgroundColour(); + pen.SetColour( color ); brush.SetColour( color ); brush.SetStyle( wxSOLID ); + DC->SetPen( pen ); DC->SetBrush( brush ); DC->DrawRectangle( 0, 0, size.x, size.y ); DC->SetBrush( wxNullBrush ); DC->SetPen( wxNullPen ); + + m_Items.clear(); } + diff --git a/include/wxstruct.h b/include/wxstruct.h index a1e4f92a2e..7200a3de7e 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -18,6 +18,8 @@ #include #include +#include + #define INTERNAL_UNIT_TYPE 0 // Internal unit = inch @@ -1365,8 +1367,46 @@ private: /* classe representant un ecran d'affichage des messages */ /*********************************************************/ +/** + * Struct MsgItem + * is used privately by WinEDA_MsgPanel as the item type its vector. + * These items are the pairs of text strings shown in the MsgPanel. + */ +struct MsgItem +{ + int m_X; + int m_UpperY; + int m_LowerY; + wxString m_UpperText; + wxString m_LowerText; + int m_Color; + + /** + * Function operator= + * overload the assignment operator so that the wxStrings get copied + * properly when copying a MsgItem. + * No, actually I'm not sure this needed, C++ compiler may auto-generate it. + */ + MsgItem& operator=( const MsgItem& rv ) + { + m_X = rv.m_X; + m_UpperY = rv.m_UpperY; + m_LowerY = rv.m_LowerY; + m_UpperText = rv.m_UpperText; // overloaded operator=() + m_LowerText = rv.m_LowerText; // overloaded operator=() + m_Color = rv.m_Color; + return *this; + } +}; + + class WinEDA_MsgPanel : public wxPanel { +protected: + std::vector m_Items; + + void showItem( wxClientDC& dc, const MsgItem& aItem ); + public: WinEDA_DrawFrame* m_Parent; int m_BgColor; // couleur de fond