MsgPanel rewrite

This commit is contained in:
dickelbeck 2007-10-10 18:01:14 +00:00
parent fdc6112661
commit e1ff958a3c
3 changed files with 119 additions and 16 deletions

View File

@ -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 <dick@softplc.com>

View File

@ -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<m_Items.size(); ++i )
showItem( dc, m_Items[i] );
event.Skip();
}
@ -75,18 +88,11 @@ void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H,
dc.SetBackground( *wxBLACK_BRUSH );
dc.SetBackgroundMode( wxSOLID );
// dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextBackground( GetBackgroundColour() );
dc.SetFont( *g_MsgFont );
dc.GetTextExtent( wxT( "W" ), &FontSizeInPixels.x, &FontSizeInPixels.y );
if( color >= 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<limit; ++ndx )
{
pos.y = (DrawSize.y / 2) - FontSizeInPixels.y;;
dc.DrawText( texte_H.GetData(), pos.x, pos.y );
// replace any item with same X
if( m_Items[ndx].m_X == item.m_X )
{
m_Items[ndx] = item;
break;
}
if( m_Items[ndx].m_X > 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();
}

View File

@ -18,6 +18,8 @@
#include <wx/laywin.h>
#include <wx/snglinst.h>
#include <vector>
#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<MsgItem> m_Items;
void showItem( wxClientDC& dc, const MsgItem& aItem );
public:
WinEDA_DrawFrame* m_Parent;
int m_BgColor; // couleur de fond