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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
26
27#pragma once
28
29#include <optional>
30#include <vector>
31
32#include <gal/color4d.h>
33
34#include <wx/window.h>
35#include <wx/panel.h>
36
37using KIGFX::COLOR4D;
38
39#define MSG_PANEL_DEFAULT_PAD 6
40
41
42class EDA_MSG_PANEL;
43class KIID;
44
45
50{
51public:
52 MSG_PANEL_ITEM( const wxString& aUpperText, const wxString& aLowerText,
53 int aPadding = MSG_PANEL_DEFAULT_PAD ) :
54 m_UpperText( aUpperText ),
55 m_LowerText( aLowerText ),
56 m_Padding( aPadding )
57 {
58 m_X = 0;
59 m_UpperY = 0;
60 m_LowerY = 0;
61 }
62
65
66 {
67 m_X = 0;
68 m_UpperY = 0;
69 m_LowerY = 0;
70 }
71
72 void SetUpperText( const wxString& aUpperText ) { m_UpperText = aUpperText; }
73 const wxString& GetUpperText() const { return m_UpperText; }
74
75 void SetLowerText( const wxString& aLowerText ) { m_LowerText = aLowerText; }
76 const wxString& GetLowerText() const { return m_LowerText; }
77
78 void SetPadding( int aPadding ) { m_Padding = aPadding; }
79 int GetPadding() const { return m_Padding; }
80
81private:
82 friend class EDA_MSG_PANEL;
83
84 int m_X;
87 wxString m_UpperText;
88 wxString m_LowerText;
90};
91
92
96class EDA_MSG_PANEL : public wxPanel
97{
98public:
99 EDA_MSG_PANEL( wxWindow* aParent, int aId,
100 const wxPoint& aPosition, const wxSize& aSize,
101 long style=wxTAB_TRAVERSAL, const wxString& name=wxPanelNameStr );
103
104 void OnPaint( wxPaintEvent& aEvent );
105 void OnDPIChanged( wxDPIChangedEvent& aEvent );
106 void OnSize( wxSizeEvent& aEvent );
107 void EraseMsgBox();
108
109 wxSize DoGetBestSize() const override;
110 wxSize DoGetBestClientSize() const override;
111
124 void AppendMessage( const wxString& aUpperText, const wxString& aLowerText, int aPadding = 6 );
125
132 void AppendMessage( const MSG_PANEL_ITEM& aMessageItem )
133 {
134 AppendMessage( aMessageItem.GetUpperText(), aMessageItem.GetLowerText(),
135 aMessageItem.GetPadding() );
136 }
137
138 DECLARE_EVENT_TABLE()
139
140protected:
141 void updateFontSize();
142
143 void rebuildItems();
144
145 void updateItemPos( MSG_PANEL_ITEM& aItem );
146
147 void showItem( wxDC& dc, const MSG_PANEL_ITEM& aItem );
148
149 void erase( wxDC* DC );
150
151protected:
155};
156
157
164std::optional<wxString> GetMsgPanelDisplayUuid( const KIID& aKiid );
const char * name
A panel to display various information messages.
Definition msgpanel.h:97
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, int aPadding=6)
Append a message to the message panel.
Definition msgpanel.cpp:153
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:132
int m_last_x
the last used x coordinate
Definition msgpanel.h:153
EDA_MSG_PANEL(wxWindow *aParent, int aId, const wxPoint &aPosition, const wxSize &aSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxPanelNameStr)
Definition msgpanel.cpp:42
void EraseMsgBox()
Definition msgpanel.cpp:189
void updateItemPos(MSG_PANEL_ITEM &aItem)
Definition msgpanel.cpp:126
wxSize m_fontSize
Definition msgpanel.h:154
void rebuildItems()
Definition msgpanel.cpp:93
wxSize DoGetBestClientSize() const override
Definition msgpanel.cpp:78
void showItem(wxDC &dc, const MSG_PANEL_ITEM &aItem)
Definition msgpanel.cpp:167
std::vector< MSG_PANEL_ITEM > m_Items
Definition msgpanel.h:152
void OnPaint(wxPaintEvent &aEvent)
Definition msgpanel.cpp:108
void erase(wxDC *DC)
Definition msgpanel.cpp:197
void OnSize(wxSizeEvent &aEvent)
Definition msgpanel.cpp:102
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Definition kiid.h:44
EDA_MSG_PANEL items for displaying messages.
Definition msgpanel.h:50
const wxString & GetUpperText() const
Definition msgpanel.h:73
void SetLowerText(const wxString &aLowerText)
Definition msgpanel.h:75
void SetUpperText(const wxString &aUpperText)
Definition msgpanel.h:72
const wxString & GetLowerText() const
Definition msgpanel.h:76
friend class EDA_MSG_PANEL
Definition msgpanel.h:82
int GetPadding() const
Definition msgpanel.h:79
wxString m_UpperText
Definition msgpanel.h:87
wxString m_LowerText
Definition msgpanel.h:88
void SetPadding(int aPadding)
Definition msgpanel.h:78
MSG_PANEL_ITEM(const wxString &aUpperText, const wxString &aLowerText, int aPadding=MSG_PANEL_DEFAULT_PAD)
Definition msgpanel.h:52
#define MSG_PANEL_DEFAULT_PAD
The default number of spaces between each text string.
Definition msgpanel.h:39
std::optional< wxString > GetMsgPanelDisplayUuid(const KIID &aKiid)
Get a formatted UUID string for display in the message panel, according to the current advanced confi...
Definition msgpanel.cpp:216
STL namespace.