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-2024 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
108 void OnPaint( wxPaintEvent& aEvent );
109 void OnDPIChanged( wxDPIChangedEvent& aEvent );
110 void EraseMsgBox();
111
112 wxSize DoGetBestSize() const override;
113 wxSize DoGetBestClientSize() const override;
114
123 void SetMessage( int aXPosition, const wxString& aUpperText, const wxString& aLowerText );
124
137 void AppendMessage( const wxString& aUpperText, const wxString& aLowerText, int aPadding = 6 );
138
145 void AppendMessage( const MSG_PANEL_ITEM& aMessageItem )
146 {
147 AppendMessage( aMessageItem.GetUpperText(), aMessageItem.GetLowerText(),
148 aMessageItem.GetPadding() );
149 }
150
151 DECLARE_EVENT_TABLE()
152
153protected:
154 void updateFontSize();
155
156 void showItem( wxDC& dc, const MSG_PANEL_ITEM& aItem );
157
158 void erase( wxDC* DC );
159
160protected:
164};
165
166
167#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:144
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, int aPadding=6)
Append a message to the message panel.
Definition: msgpanel.cpp:111
void OnDPIChanged(wxDPIChangedEvent &aEvent)
Definition: msgpanel.cpp:84
wxSize DoGetBestSize() const override
Definition: msgpanel.cpp:72
void updateFontSize()
Definition: msgpanel.cpp:65
void AppendMessage(const MSG_PANEL_ITEM &aMessageItem)
Append aMessageItem to the message panel.
Definition: msgpanel.h:145
int m_last_x
the last used x coordinate
Definition: msgpanel.h:162
void EraseMsgBox()
Definition: msgpanel.cpp:215
wxSize m_fontSize
Definition: msgpanel.h:163
wxSize DoGetBestClientSize() const override
Definition: msgpanel.cpp:78
void showItem(wxDC &dc, const MSG_PANEL_ITEM &aItem)
Definition: msgpanel.cpp:193
std::vector< MSG_PANEL_ITEM > m_Items
Definition: msgpanel.h:161
void OnPaint(wxPaintEvent &aEvent)
Definition: msgpanel.cpp:93
void erase(wxDC *DC)
Definition: msgpanel.cpp:223
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.