KiCad PCB EDA Suite
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, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2011-2012 Wayne Stambaugh <stambaughw@gmail.com>
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 
42 using KIGFX::COLOR4D;
43 
44 #define MSG_PANEL_DEFAULT_PAD 6
45 
46 
47 class EDA_MSG_PANEL;
48 
49 
54 {
55 public:
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 
85 private:
86  friend class EDA_MSG_PANEL;
87 
88  int m_X;
89  int m_UpperY;
90  int m_LowerY;
91  wxString m_UpperText;
92  wxString m_LowerText;
93  int m_Padding;
94 };
95 
96 
97 typedef std::vector<MSG_PANEL_ITEM> MSG_PANEL_ITEMS;
98 
99 
103 class EDA_MSG_PANEL : public wxPanel
104 {
105 public:
106  EDA_MSG_PANEL( wxWindow* aParent, int aId,
107  const wxPoint& aPosition, const wxSize& aSize,
108  long style=wxTAB_TRAVERSAL, const wxString& name=wxPanelNameStr);
109  ~EDA_MSG_PANEL();
110 
116  static int GetRequiredHeight( wxWindow* aWindow );
117 
118  void OnPaint( wxPaintEvent& aEvent );
119  void EraseMsgBox();
120 
129  void SetMessage( int aXPosition, const wxString& aUpperText, const wxString& aLowerText );
130 
143  void AppendMessage( const wxString& aUpperText, const wxString& aLowerText, int aPadding = 6 );
144 
151  void AppendMessage( const MSG_PANEL_ITEM& aMessageItem )
152  {
153  AppendMessage( aMessageItem.GetUpperText(), aMessageItem.GetLowerText(),
154  aMessageItem.GetPadding() );
155  }
156 
157  DECLARE_EVENT_TABLE()
158 
159 protected:
160  void showItem( wxDC& dc, const MSG_PANEL_ITEM& aItem );
161 
162  void erase( wxDC* DC );
163 
167  wxSize computeTextSize( const wxString& text ) const;
168 
170  int m_last_x;
171  wxSize m_fontSize;
172 };
173 
174 
175 #endif // _MSGPANEL_H_
EDA_MSG_PANEL(wxWindow *aParent, int aId, const wxPoint &aPosition, const wxSize &aSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxPanelNameStr)
Definition: msgpanel.cpp:41
void showItem(wxDC &dc, const MSG_PANEL_ITEM &aItem)
Definition: msgpanel.cpp:176
MSG_PANEL_ITEMS m_Items
Definition: msgpanel.h:169
static int GetRequiredHeight(wxWindow *aWindow)
Return the required height (in pixels) of a EDA_MSG_PANEL.
Definition: msgpanel.cpp:63
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:127
wxString m_LowerText
Definition: msgpanel.h:92
A panel to display various information messages.
Definition: msgpanel.h:103
const wxString & GetLowerText() const
Definition: msgpanel.h:80
void AppendMessage(const MSG_PANEL_ITEM &aMessageItem)
Append aMessageItem to the message panel.
Definition: msgpanel.h:151
void OnPaint(wxPaintEvent &aEvent)
Definition: msgpanel.cpp:76
#define MSG_PANEL_DEFAULT_PAD
The default number of spaces between each text string.
Definition: msgpanel.h:44
const wxString & GetUpperText() const
Definition: msgpanel.h:77
wxSize m_fontSize
Definition: msgpanel.h:171
MSG_PANEL_ITEM(const wxString &aUpperText, const wxString &aLowerText, int aPadding=MSG_PANEL_DEFAULT_PAD)
Definition: msgpanel.h:56
wxSize computeTextSize(const wxString &text) const
Calculate the width and height of a text string using the system UI font.
void EraseMsgBox()
Definition: msgpanel.cpp:198
int m_last_x
the last used x coordinate
Definition: msgpanel.h:170
void SetLowerText(const wxString &aLowerText)
Definition: msgpanel.h:79
void erase(wxDC *DC)
Definition: msgpanel.cpp:206
const char * name
Definition: DXF_plotter.cpp:56
void SetPadding(int aPadding)
Definition: msgpanel.h:82
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:53
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, int aPadding=6)
Append a message to the message panel.
Definition: msgpanel.cpp:94
void SetUpperText(const wxString &aUpperText)
Definition: msgpanel.h:76
wxString m_UpperText
Definition: msgpanel.h:91
int GetPadding() const
Definition: msgpanel.h:83
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103