KiCad PCB EDA Suite
Loading...
Searching...
No Matches
msgpanel.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2009 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2011-2012 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
31#ifndef _MSGPANEL_H_
32#define _MSGPANEL_H_
33
34
35#include <gal/color4d.h>
36
37#include <wx/window.h>
38#include <wx/panel.h>
39
40#include <vector>
41
42using KIGFX::COLOR4D;
43
44#define MSG_PANEL_DEFAULT_PAD 6
45
46
47class EDA_MSG_PANEL;
48
49
54{
55public:
56 MSG_PANEL_ITEM( const wxString& aUpperText, const wxString& aLowerText,
57 int aPadding = MSG_PANEL_DEFAULT_PAD ) :
58 m_UpperText( aUpperText ),
59 m_LowerText( aLowerText ),
60 m_Padding( aPadding )
61 {
62 m_X = 0;
63 m_UpperY = 0;
64 m_LowerY = 0;
65 }
66
69
70 {
71 m_X = 0;
72 m_UpperY = 0;
73 m_LowerY = 0;
74 }
75
76 void SetUpperText( const wxString& aUpperText ) { m_UpperText = aUpperText; }
77 const wxString& GetUpperText() const { return m_UpperText; }
78
79 void SetLowerText( const wxString& aLowerText ) { m_LowerText = aLowerText; }
80 const wxString& GetLowerText() const { return m_LowerText; }
81
82 void SetPadding( int aPadding ) { m_Padding = aPadding; }
83 int GetPadding() const { return m_Padding; }
84
85private:
86 friend class EDA_MSG_PANEL;
87
88 int m_X;
91 wxString m_UpperText;
92 wxString m_LowerText;
94};
95
96
100class EDA_MSG_PANEL : public wxPanel
101{
102public:
103 EDA_MSG_PANEL( wxWindow* aParent, int aId,
104 const wxPoint& aPosition, const wxSize& aSize,
105 long style=wxTAB_TRAVERSAL, const wxString& name=wxPanelNameStr);
107
113 static int GetRequiredHeight( wxWindow* aWindow );
114
115 void OnPaint( wxPaintEvent& aEvent );
116 void EraseMsgBox();
117
126 void SetMessage( int aXPosition, const wxString& aUpperText, const wxString& aLowerText );
127
140 void AppendMessage( const wxString& aUpperText, const wxString& aLowerText, int aPadding = 6 );
141
148 void AppendMessage( const MSG_PANEL_ITEM& aMessageItem )
149 {
150 AppendMessage( aMessageItem.GetUpperText(), aMessageItem.GetLowerText(),
151 aMessageItem.GetPadding() );
152 }
153
154 DECLARE_EVENT_TABLE()
155
156protected:
157 void showItem( wxDC& dc, const MSG_PANEL_ITEM& aItem );
158
159 void erase( wxDC* DC );
160
164 wxSize computeTextSize( const wxString& text ) const;
165
166protected:
170};
171
172
173#endif // _MSGPANEL_H_
const char * name
Definition: DXF_plotter.cpp:57
A panel to display various information messages.
Definition: msgpanel.h:101
void SetMessage(int aXPosition, const wxString &aUpperText, const wxString &aLowerText)
Set a message at aXPosition to aUpperText and aLowerText in the message panel.
Definition: msgpanel.cpp:126
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, int aPadding=6)
Append a message to the message panel.
Definition: msgpanel.cpp:93
void AppendMessage(const MSG_PANEL_ITEM &aMessageItem)
Append aMessageItem to the message panel.
Definition: msgpanel.h:148
int m_last_x
the last used x coordinate
Definition: msgpanel.h:168
void EraseMsgBox()
Definition: msgpanel.cpp:197
wxSize m_fontSize
Definition: msgpanel.h:169
static int GetRequiredHeight(wxWindow *aWindow)
Return the required height (in pixels) of a EDA_MSG_PANEL.
Definition: msgpanel.cpp:62
wxSize computeTextSize(const wxString &text) const
Calculate the width and height of a text string using the system UI font.
void showItem(wxDC &dc, const MSG_PANEL_ITEM &aItem)
Definition: msgpanel.cpp:175
std::vector< MSG_PANEL_ITEM > m_Items
Definition: msgpanel.h:167
void OnPaint(wxPaintEvent &aEvent)
Definition: msgpanel.cpp:75
void erase(wxDC *DC)
Definition: msgpanel.cpp:205
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
const wxString & GetUpperText() const
Definition: msgpanel.h:77
void SetLowerText(const wxString &aLowerText)
Definition: msgpanel.h:79
void SetUpperText(const wxString &aUpperText)
Definition: msgpanel.h:76
const wxString & GetLowerText() const
Definition: msgpanel.h:80
int GetPadding() const
Definition: msgpanel.h:83
wxString m_UpperText
Definition: msgpanel.h:91
wxString m_LowerText
Definition: msgpanel.h:92
void SetPadding(int aPadding)
Definition: msgpanel.h:82
MSG_PANEL_ITEM(const wxString &aUpperText, const wxString &aLowerText, int aPadding=MSG_PANEL_DEFAULT_PAD)
Definition: msgpanel.h:56
#define MSG_PANEL_DEFAULT_PAD
The default number of spaces between each text string.
Definition: msgpanel.h:44
STL namespace.