1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/******************************************************************/
/* msgpanel.cpp - fonctions des classes du type WinEDA_MsgPanel */
/******************************************************************/
#ifdef __GNUG__
#pragma implementation
#endif
#include "fctsys.h"
#include "wxstruct.h"
#include "common.h"
#include "colors.h"
/* table des evenements captes par un WinEDA_MsgPanel */
BEGIN_EVENT_TABLE( WinEDA_MsgPanel, wxPanel )
EVT_PAINT( WinEDA_MsgPanel::OnPaint )
END_EVENT_TABLE()
/***********************************************************/
/* Fonctions de base de WinEDA_MsgPanel: l'ecran de messages */
/***********************************************************/
WinEDA_MsgPanel::WinEDA_MsgPanel( WinEDA_DrawFrame* parent, int id,
const wxPoint& pos, const wxSize& size ) :
wxPanel( parent, id, pos, size )
{
m_Parent = parent;
SetFont( *g_MsgFont );
m_last_x = 0;
}
WinEDA_MsgPanel::~WinEDA_MsgPanel()
{
}
/*************************************************/
void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event )
/*************************************************/
{
wxPaintDC dc( this );
erase( &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();
}
/*****************************************************************************/
void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H,
const wxString& texte_L, int color )
/*****************************************************************************/
/*
* Routine d'affichage d'un parametre.
* pos_X = cadrage horizontal
* si pos_X < 0 : la position horizontale est la derniere
* valeur demandee >= 0
* texte_H = texte a afficher en ligne superieure.
* si "", par d'affichage sur cette ligne
* texte_L = texte a afficher en ligne inferieure.
* si "", par d'affichage sur cette ligne
* color = couleur d'affichage
*/
{
wxPoint pos;
wxSize drawSize = GetClientSize();
// Get size of the font
wxSize fontSizeInPixels;
{
wxClientDC dc( this );
dc.SetFont( *g_MsgFont );
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);
}
else
pos.x = m_last_x;
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 )
{
// 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( ndx==limit ) // mutually exclusive with two above if tests
{
m_Items.push_back( item );
}
Refresh();
}
void WinEDA_MsgPanel::showItem( wxDC& 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 );
}
}
/****************************************/
void WinEDA_MsgPanel::EraseMsgBox()
/****************************************/
{
m_Items.clear();
m_last_x = 0;
Refresh();
}
/*******************************************/
void WinEDA_MsgPanel::erase( wxDC* DC )
/*******************************************/
{
wxPen pen;
wxBrush brush;
wxSize size = GetClientSize();
wxColor 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 );
}