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 "report_severity.h" // enum SEVERITY
30#include <wx/string.h>
31#include <wx/font.h>
32
33class wxSize;
34class wxTextCtrl;
35class wxTextEntry;
36class wxWindow;
37class wxMenuItem;
38class wxMenu;
39
44#define INDETERMINATE_STATE _( "-- mixed values --" )
45#define INDETERMINATE_ACTION _( "-- leave unchanged --" )
46
47namespace KIUI
48{
49
54int GetStdMargin();
55
60wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow );
61
62wxFont GetMonospacedUIFont();
63
64wxFont GetControlFont( wxWindow* aWindow );
65wxFont GetInfoFont( wxWindow* aWindow );
66wxFont GetDockedPaneFont( wxWindow* aWindow );
67wxFont GetStatusFont( wxWindow* aWindow );
68
83bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = nullptr );
84
88void SelectReferenceNumber( wxTextEntry* aTextEntry );
89
95wxString EllipsizeStatusText( wxWindow* aWindow, const wxString& aString );
96
102wxString EllipsizeMenuText( const wxString& aString );
103
109bool IsInputControlFocused( wxWindow* aFocus = nullptr );
110
118bool IsInputControlEditable( wxWindow* aControl );
119
121
126void Disable( wxWindow* aWindow );
127
128extern const wxString s_FocusStealableInputName;
129
130
141void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmap& aImage );
142
143
154wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wxBitmap& aImage,
155 wxItemKind aType = wxITEM_NORMAL );
156
157
169wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wxString& aHelpText,
170 const wxBitmap& aImage, wxItemKind aType = wxITEM_NORMAL );
171
172
183wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const wxString& aText,
184 const wxBitmap& aImage );
185
186
199wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const wxString& aText,
200 const wxString& aHelpText, const wxBitmap& aImage );
201}
202
203SEVERITY SeverityFromString( const wxString& aSeverity );
204
205wxString SeverityToString( const SEVERITY& aSeverity );
206
207#endif // UI_COMMON_H
wxFont GetMonospacedUIFont()
Definition: ui_common.cpp:89
int GetStdMargin()
Get the standard margin around a widget in the KiCad UI.
Definition: ui_common.cpp:45
wxFont GetDockedPaneFont(wxWindow *aWindow)
Definition: ui_common.cpp:139
wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:127
bool IsInputControlFocused(wxWindow *aFocus=nullptr)
Check if a input control has focus.
Definition: ui_common.cpp:260
bool IsInputControlEditable(wxWindow *aControl)
Check if a input control has focus.
Definition: ui_common.cpp:297
void AddBitmapToMenuItem(wxMenuItem *aMenu, const wxBitmap &aImage)
Add a bitmap to a menuitem.
Definition: ui_common.cpp:355
wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:210
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:151
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
Definition: ui_common.cpp:369
bool IsModalDialogFocused()
Definition: ui_common.cpp:314
wxFont GetControlFont(wxWindow *aWindow)
Definition: ui_common.cpp:157
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:192
const wxString s_FocusStealableInputName
Definition: ui_common.cpp:42
void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:225
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:74
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:163
void Disable(wxWindow *aWindow)
Makes a window read-only.
Definition: ui_common.cpp:320
SEVERITY
SEVERITY SeverityFromString(const wxString &aSeverity)
Definition: ui_common.cpp:52
wxString SeverityToString(const SEVERITY &aSeverity)
Definition: ui_common.cpp:63