MsgPanel rewrite
This commit is contained in:
+76
-15
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user