KiCad PCB EDA Suite
Loading...
Searching...
No Matches
wxmsw/ui.cpp
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) 2020 Ian McInerney <Ian.S.McInerney at ieee.org>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <windows.h>
22
23#include <kiplatform/ui.h>
24
25#include <wx/cursor.h>
26#include <wx/dialog.h>
27#include <wx/nonownedwnd.h>
28#include <wx/window.h>
29#include <wx/msw/registry.h>
30
31
33{
34#if wxCHECK_VERSION( 3, 3, 0 )
35 wxSystemAppearance appearance = wxSystemSettings::GetAppearance();
36 return appearance.IsDark();
37#else
38 wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
39
40 // Weighted W3C formula
41 double brightness = ( bg.Red() / 255.0 ) * 0.299 +
42 ( bg.Green() / 255.0 ) * 0.587 +
43 ( bg.Blue() / 255.0 ) * 0.117;
44
45 return brightness < 0.5;
46#endif
47}
48
49
51{
52 return wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
53}
54
55
56void KIPLATFORM::UI::GetInfoBarColours( wxColour& aFGColour, wxColour& aBGColour )
57{
58 aBGColour = wxSystemSettings::GetColour( wxSYS_COLOUR_INFOBK );
59 aFGColour = wxSystemSettings::GetColour( wxSYS_COLOUR_INFOTEXT );
60}
61
62
63void KIPLATFORM::UI::ForceFocus( wxWindow* aWindow )
64{
65 aWindow->SetFocus();
66}
67
68
69bool KIPLATFORM::UI::IsWindowActive( wxWindow* aWindow )
70{
71 if(! aWindow )
72 {
73 return false;
74 }
75
76 return ( aWindow->GetHWND() == GetForegroundWindow() );
77}
78
79
80void KIPLATFORM::UI::EnsureVisible( wxWindow* aWindow )
81{
82 // Not needed on this platform
83}
84
85
86void KIPLATFORM::UI::StabilizeWindowPosition( wxWindow* aWindow )
87{
88 // Not needed on this platform
89}
90
91
92void KIPLATFORM::UI::ReparentModal( wxNonOwnedWindow* aWindow )
93{
94 // Not needed on this platform
95}
96
97
98void KIPLATFORM::UI::ReparentWindow( wxNonOwnedWindow* aWindow, wxTopLevelWindow* aParent )
99{
100 // Not needed on this platform (used only on macOS for child window ordering)
101}
102
103
105{
106 // Not needed on this platform
107}
108
109
110bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor )
111{
112 switch( aCursor )
113 {
114 case wxCURSOR_BULLSEYE:
115 case wxCURSOR_HAND:
116 case wxCURSOR_ARROW:
117 return true;
118 default:
119 return false;
120 }
121}
122
123
124void KIPLATFORM::UI::LargeChoiceBoxHack( wxChoice* aChoice )
125{
126 // Not implemented
127}
128
129
130void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice )
131{
132 // Not implemented
133}
134
135
136double KIPLATFORM::UI::GetPixelScaleFactor( const wxWindow* aWindow )
137{
138 return aWindow->GetContentScaleFactor();
139}
140
141
142double KIPLATFORM::UI::GetContentScaleFactor( const wxWindow* aWindow )
143{
144 return aWindow->GetDPIScaleFactor();
145}
146
147
148wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow )
149{
150 return aWindow->GetClientSize();
151}
152
153
154void KIPLATFORM::UI::SetOverlayScrolling( const wxWindow* aWindow, bool overlay )
155{
156 // Not implemented
157}
158
159
161{
162 return true;
163}
164
165
167{
168 return wxGetMousePosition();
169}
170
171
172bool KIPLATFORM::UI::WarpPointer( wxWindow* aWindow, int aX, int aY )
173{
174 aWindow->WarpPointer( aX, aY );
175 return true;
176}
177
178
179void KIPLATFORM::UI::ImmControl( wxWindow* aWindow, bool aEnable )
180{
181 if ( !aEnable )
182 {
183 ImmAssociateContext( aWindow->GetHWND(), NULL );
184 }
185 else
186 {
187 ImmAssociateContextEx( aWindow->GetHWND(), 0, IACE_DEFAULT );
188 }
189}
190
191
192void KIPLATFORM::UI::ImeNotifyCancelComposition( wxWindow* aWindow )
193{
194 const HIMC himc = ImmGetContext( aWindow->GetHWND() );
195 ImmNotifyIME( himc, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
196 ImmReleaseContext( aWindow->GetHWND(), himc );
197}
198
199
200bool KIPLATFORM::UI::InfiniteDragPrepareWindow( wxWindow* aWindow )
201{
202 return true;
203}
204
205
207{
208 // Not needed on this platform
209}
210
211
212void KIPLATFORM::UI::SetFloatLevel( wxWindow* aWindow )
213{
214}
215
216void KIPLATFORM::UI::ReleaseChildWindow( wxNonOwnedWindow* aWindow )
217{
218 // Not needed on this platform
219}
220
221
222void KIPLATFORM::UI::AllowNetworkFileSystems( wxDialog* aDialog )
223{
224 // Not needed on Windows - file dialogs show network filesystems by default
225}
226
227
228void KIPLATFORM::UI::CancelPendingScroll( wxDataViewCtrl* aCtrl )
229{
230 // Not needed on this platform; the native control does not race on model resets.
231}
bool AllowIconsInMenus()
If the user has disabled icons system-wide, we check that here.
Definition wxgtk/ui.cpp:308
void SetFloatLevel(wxWindow *aWindow)
Intended to set the floating window level in macOS on a window.
Definition wxgtk/ui.cpp:437
void GetInfoBarColours(wxColour &aFGColour, wxColour &aBGColour)
Return the background and foreground colors for info bars in the current scheme.
Definition wxgtk/ui.cpp:69
void ReparentWindow(wxNonOwnedWindow *aWindow, wxTopLevelWindow *aParent)
Definition wxgtk/ui.cpp:187
void ReleaseChildWindow(wxNonOwnedWindow *aWindow)
Release a modal window's parent-child relationship with its parent window.
Definition wxgtk/ui.cpp:442
void EllipsizeChoiceBox(wxChoice *aChoice)
Configure a wxChoice control to ellipsize the shown text in the button with the ellipses placed at th...
Definition wxgtk/ui.cpp:253
void FixupCancelButtonCmdKeyCollision(wxWindow *aWindow)
Definition wxgtk/ui.cpp:193
void SetOverlayScrolling(const wxWindow *aWindow, bool overlay)
Used to set overlay/non-overlay scrolling mode in a window.
Definition wxgtk/ui.cpp:301
wxPoint GetMousePosition()
Returns the mouse position in screen coordinates.
Definition wxgtk/ui.cpp:766
void ImmControl(wxWindow *aWindow, bool aEnable)
Configures the IME mode of a given control handle.
Definition wxgtk/ui.cpp:418
void StabilizeWindowPosition(wxWindow *aWindow)
Prepare a top-level window for reliable position round-tripping.
Definition wxgtk/ui.cpp:169
double GetPixelScaleFactor(const wxWindow *aWindow)
Tries to determine the pixel scaling factor currently in use for the window.
Definition wxgtk/ui.cpp:274
void InfiniteDragReleaseWindow()
On Wayland, allows the cursor to freely move again after a drag (see InfiniteDragPrepareWindow).
Definition wxgtk/ui.cpp:760
void EnsureVisible(wxWindow *aWindow)
Ensure that a window is visible on the screen.
Definition wxgtk/ui.cpp:163
bool IsStockCursorOk(wxStockCursor aCursor)
Checks if we designated a stock cursor for this OS as "OK" or else we may need to load a custom one.
Definition wxgtk/ui.cpp:199
double GetContentScaleFactor(const wxWindow *aWindow)
Tries to determine the content scaling factor currently in use for the window.
Definition wxgtk/ui.cpp:287
void ImeNotifyCancelComposition(wxWindow *aWindow)
Asks the IME to cancel.
Definition wxgtk/ui.cpp:423
void LargeChoiceBoxHack(wxChoice *aChoice)
Configure a wxChoice control to support a lot of entries by disabling functionality that makes adding...
Definition wxgtk/ui.cpp:235
bool WarpPointer(wxWindow *aWindow, int aX, int aY)
Move the mouse cursor to a specific position relative to the window.
Definition wxgtk/ui.cpp:352
wxColour GetDialogBGColour()
Definition wxgtk/ui.cpp:63
bool IsWindowActive(wxWindow *aWindow)
Check to see if the given window is the currently active window (e.g.
Definition wxgtk/ui.cpp:148
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition wxgtk/ui.cpp:294
void ForceFocus(wxWindow *aWindow)
Pass the current focus to the window.
Definition wxgtk/ui.cpp:126
bool InfiniteDragPrepareWindow(wxWindow *aWindow)
On Wayland, restricts the pointer movement to a rectangle slightly bigger than the given wxWindow.
Definition wxgtk/ui.cpp:753
void ReparentModal(wxNonOwnedWindow *aWindow)
Move a window's parent to be the top-level window and force the window to be on top.
Definition wxgtk/ui.cpp:181
void CancelPendingScroll(wxDataViewCtrl *aCtrl)
Cancel any pending scroll-to-item request on aCtrl.
Definition wxgtk/ui.cpp:457
bool IsDarkTheme()
Determine if the desktop interface is currently using a dark theme or a light theme.
Definition wxgtk/ui.cpp:50
void AllowNetworkFileSystems(wxDialog *aDialog)
Configure a file dialog to show network and virtual file systems.
Definition wxgtk/ui.cpp:448
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > overlay