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@verizon.net>
6  * Copyright (C) 1992-2015 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 
55 {
56  int m_X;
57  int m_UpperY;
58  int m_LowerY;
59  wxString m_UpperText;
60  wxString m_LowerText;
61  int m_Padding;
62 
63  friend class EDA_MSG_PANEL;
64 
65 public:
66  MSG_PANEL_ITEM( const wxString& aUpperText, const wxString& aLowerText,
67  int aPadding = MSG_PANEL_DEFAULT_PAD ) :
68  m_UpperText( aUpperText ),
69  m_LowerText( aLowerText ),
70  m_Padding( aPadding )
71  {
72  m_X = 0;
73  m_UpperY = 0;
74  m_LowerY = 0;
75  }
76 
79 
80  {
81  m_X = 0;
82  m_UpperY = 0;
83  m_LowerY = 0;
84  }
85 
86  void SetUpperText( const wxString& aUpperText ) { m_UpperText = aUpperText; }
87  const wxString& GetUpperText() const { return m_UpperText; }
88 
89  void SetLowerText( const wxString& aLowerText ) { m_LowerText = aLowerText; }
90  const wxString& GetLowerText() const { return m_LowerText; }
91 
92  void SetPadding( int aPadding ) { m_Padding = aPadding; }
93  int GetPadding() const { return m_Padding; }
94 };
95 
96 
97 typedef std::vector<MSG_PANEL_ITEM> MSG_PANEL_ITEMS;
98 
99 
104 class EDA_MSG_PANEL : public wxPanel
105 {
106 protected:
108  int m_last_x;
109  wxSize m_fontSize;
110 
111  void showItem( wxDC& dc, const MSG_PANEL_ITEM& aItem );
112 
113  void erase( wxDC* DC );
114 
119  static wxSize computeFontSize();
120 
124  wxSize computeTextSize( const wxString& text ) const;
125 
126 public:
127  EDA_MSG_PANEL( wxWindow* aParent, int aId,
128  const wxPoint& aPosition, const wxSize& aSize,
129  long style=wxTAB_TRAVERSAL, const wxString &name=wxPanelNameStr);
130  ~EDA_MSG_PANEL();
131 
137  static int GetRequiredHeight();
138 
139  void OnPaint( wxPaintEvent& aEvent );
140  void EraseMsgBox();
141 
151  void SetMessage( int aXPosition, const wxString& aUpperText, const wxString& aLowerText );
152 
166  void AppendMessage( const wxString& aUpperText, const wxString& aLowerText, int aPadding = 6 );
167 
175  void AppendMessage( const MSG_PANEL_ITEM& aMessageItem )
176  {
177  AppendMessage( aMessageItem.GetUpperText(), aMessageItem.GetLowerText(),
178  aMessageItem.GetPadding() );
179  }
180 
181  DECLARE_EVENT_TABLE()
182 };
183 
184 
185 #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:43
void showItem(wxDC &dc, const MSG_PANEL_ITEM &aItem)
Definition: msgpanel.cpp:196
MSG_PANEL_ITEMS m_Items
Definition: msgpanel.h:107
void SetMessage(int aXPosition, const wxString &aUpperText, const wxString &aLowerText)
Function SetMessage sets a message at aXPosition to aUpperText and aLowerText in the message panel.
Definition: msgpanel.cpp:147
wxString m_LowerText
Definition: msgpanel.h:60
EDA_MSG_PANEL is a panel to display various information messages.
Definition: msgpanel.h:104
const wxString & GetLowerText() const
Definition: msgpanel.h:90
void AppendMessage(const MSG_PANEL_ITEM &aMessageItem)
Function AppendMessage appends aMessageItem to the message panel.
Definition: msgpanel.h:175
void OnPaint(wxPaintEvent &aEvent)
Definition: msgpanel.cpp:96
#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:87
wxSize m_fontSize
Definition: msgpanel.h:109
MSG_PANEL_ITEM(const wxString &aUpperText, const wxString &aLowerText, int aPadding=MSG_PANEL_DEFAULT_PAD)
Definition: msgpanel.h:66
wxSize computeTextSize(const wxString &text) const
Calculate the width and height of a text string using the system UI font.
Definition: msgpanel.cpp:82
void EraseMsgBox()
Definition: msgpanel.cpp:210
int m_last_x
the last used x coordinate
Definition: msgpanel.h:108
void SetLowerText(const wxString &aLowerText)
Definition: msgpanel.h:89
void erase(wxDC *DC)
Definition: msgpanel.cpp:218
const char * name
Definition: DXF_plotter.cpp:59
void SetPadding(int aPadding)
Definition: msgpanel.h:92
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
static wxSize computeFontSize()
Function getFontSize computes the height and width of a 'W' in the system font.
Definition: msgpanel.cpp:61
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:54
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, int aPadding=6)
Function AppendMessage appends a message to the message panel.
Definition: msgpanel.cpp:114
void SetUpperText(const wxString &aUpperText)
Definition: msgpanel.h:86
static int GetRequiredHeight()
Function GetRequiredHeight returns the required height (in pixels) of a EDA_MSG_PANEL.
Definition: msgpanel.cpp:75
wxString m_UpperText
Definition: msgpanel.h:59
int GetPadding() const
Definition: msgpanel.h:93
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100