KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ui_common.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) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
26#ifndef UI_COMMON_H
27#define UI_COMMON_H
28
29#include <kicommon.h>
30#include "report_severity.h" // enum SEVERITY
31#include <wx/string.h>
32#include <wx/font.h>
33
34class wxBitmapBundle;
35class wxSize;
36class wxTextCtrl;
37class wxTextEntry;
38class wxWindow;
39class wxMenuItem;
40class wxMenu;
41
46#define INDETERMINATE_STATE _( "-- mixed values --" )
47#define INDETERMINATE_ACTION _( "-- leave unchanged --" )
48
49namespace KIUI
50{
51
52const int c_IndicatorSizeDIP = 10;
53
54
60
65KICOMMON_API wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow );
66
68
69KICOMMON_API wxFont GetControlFont( wxWindow* aWindow );
70KICOMMON_API wxFont GetInfoFont( wxWindow* aWindow );
71KICOMMON_API wxFont GetDockedPaneFont( wxWindow* aWindow );
72KICOMMON_API wxFont GetStatusFont( wxWindow* aWindow );
73
88KICOMMON_API bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = nullptr );
89
93KICOMMON_API void SelectReferenceNumber( wxTextEntry* aTextEntry );
94
100KICOMMON_API wxString EllipsizeStatusText( wxWindow* aWindow, const wxString& aString );
101
107KICOMMON_API wxString EllipsizeMenuText( const wxString& aString );
108
114KICOMMON_API bool IsInputControlFocused( wxWindow* aFocus = nullptr );
115
123KICOMMON_API bool IsInputControlEditable( wxWindow* aControl );
124
126
131KICOMMON_API void Disable( wxWindow* aWindow );
132
133KICOMMON_API extern const wxString s_FocusStealableInputName;
134
135
146KICOMMON_API void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmapBundle& aImage );
147
148
159KICOMMON_API wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText,
160 const wxBitmapBundle& aImage,
161 wxItemKind aType = wxITEM_NORMAL );
162
163
175KICOMMON_API wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText,
176 const wxString& aHelpText, const wxBitmapBundle& aImage,
177 wxItemKind aType = wxITEM_NORMAL );
178
179
190KICOMMON_API wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId,
191 const wxString& aText, const wxBitmapBundle& aImage );
192
193
206KICOMMON_API wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId,
207 const wxString& aText, const wxString& aHelpText,
208 const wxBitmapBundle& aImage );
209}
210
211KICOMMON_API SEVERITY SeverityFromString( const wxString& aSeverity );
212
213KICOMMON_API wxString SeverityToString( const SEVERITY& aSeverity );
214
215#endif // UI_COMMON_H
#define KICOMMON_API
Definition: kicommon.h:28
KICOMMON_API wxFont GetMonospacedUIFont()
Definition: ui_common.cpp:92
KICOMMON_API int GetStdMargin()
Get the standard margin around a widget in the KiCad UI.
Definition: ui_common.cpp:48
KICOMMON_API wxFont GetDockedPaneFont(wxWindow *aWindow)
Definition: ui_common.cpp:142
KICOMMON_API wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:130
KICOMMON_API bool IsInputControlFocused(wxWindow *aFocus=nullptr)
Check if a input control has focus.
Definition: ui_common.cpp:263
KICOMMON_API bool IsInputControlEditable(wxWindow *aControl)
Check if a input control has focus.
Definition: ui_common.cpp:300
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:213
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:154
KICOMMON_API bool IsModalDialogFocused()
Definition: ui_common.cpp:317
KICOMMON_API wxFont GetControlFont(wxWindow *aWindow)
Definition: ui_common.cpp:160
KICOMMON_API wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmapBundle &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
Definition: ui_common.cpp:372
KICOMMON_API wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
Definition: ui_common.cpp:195
KICOMMON_API const wxString s_FocusStealableInputName
Definition: ui_common.cpp:45
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:228
KICOMMON_API wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition: ui_common.cpp:77
KICOMMON_API void AddBitmapToMenuItem(wxMenuItem *aMenu, const wxBitmapBundle &aImage)
Add a bitmap to a menuitem.
Definition: ui_common.cpp:358
KICOMMON_API bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString=nullptr)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
Definition: ui_common.cpp:166
KICOMMON_API void Disable(wxWindow *aWindow)
Makes a window read-only.
Definition: ui_common.cpp:323
const int c_IndicatorSizeDIP
Definition: ui_common.h:52
SEVERITY
KICOMMON_API SEVERITY SeverityFromString(const wxString &aSeverity)
Definition: ui_common.cpp:55
KICOMMON_API wxString SeverityToString(const SEVERITY &aSeverity)
Definition: ui_common.cpp:66