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::ReparentModal( wxNonOwnedWindow* aWindow )
87{
88 // Not needed on this platform
89}
90
91
92void KIPLATFORM::UI::ReparentWindow( wxNonOwnedWindow* aWindow, wxTopLevelWindow* aParent )
93{
94 // Not needed on this platform (used only on macOS for child window ordering)
95}
96
97
99{
100 // Not needed on this platform
101}
102
103
104bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor )
105{
106 switch( aCursor )
107 {
108 case wxCURSOR_BULLSEYE:
109 case wxCURSOR_HAND:
110 case wxCURSOR_ARROW:
111 return true;
112 default:
113 return false;
114 }
115}
116
117
118void KIPLATFORM::UI::LargeChoiceBoxHack( wxChoice* aChoice )
119{
120 // Not implemented
121}
122
123
124void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice )
125{
126 // Not implemented
127}
128
129
130double KIPLATFORM::UI::GetPixelScaleFactor( const wxWindow* aWindow )
131{
132 return aWindow->GetContentScaleFactor();
133}
134
135
136double KIPLATFORM::UI::GetContentScaleFactor( const wxWindow* aWindow )
137{
138 return aWindow->GetDPIScaleFactor();
139}
140
141
142wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow )
143{
144 return aWindow->GetClientSize();
145}
146
147
148void KIPLATFORM::UI::SetOverlayScrolling( const wxWindow* aWindow, bool overlay )
149{
150 // Not implemented
151}
152
153
155{
156 return true;
157}
158
159
161{
162 return wxGetMousePosition();
163}
164
165
166bool KIPLATFORM::UI::WarpPointer( wxWindow* aWindow, int aX, int aY )
167{
168 aWindow->WarpPointer( aX, aY );
169 return true;
170}
171
172
173void KIPLATFORM::UI::ImmControl( wxWindow* aWindow, bool aEnable )
174{
175 if ( !aEnable )
176 {
177 ImmAssociateContext( aWindow->GetHWND(), NULL );
178 }
179 else
180 {
181 ImmAssociateContextEx( aWindow->GetHWND(), 0, IACE_DEFAULT );
182 }
183}
184
185
186void KIPLATFORM::UI::ImeNotifyCancelComposition( wxWindow* aWindow )
187{
188 const HIMC himc = ImmGetContext( aWindow->GetHWND() );
189 ImmNotifyIME( himc, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
190 ImmReleaseContext( aWindow->GetHWND(), himc );
191}
192
193
194bool KIPLATFORM::UI::InfiniteDragPrepareWindow( wxWindow* aWindow )
195{
196 return true;
197}
198
199
201{
202 // Not needed on this platform
203}
204
205
206void KIPLATFORM::UI::SetFloatLevel( wxWindow* aWindow )
207{
208}
209
210void KIPLATFORM::UI::ReleaseChildWindow( wxNonOwnedWindow* aWindow )
211{
212 // Not needed on this platform
213}
214
215
216void KIPLATFORM::UI::AllowNetworkFileSystems( wxDialog* aDialog )
217{
218 // Not needed on Windows - file dialogs show network filesystems by default
219}
bool AllowIconsInMenus()
If the user has disabled icons system-wide, we check that here.
Definition wxgtk/ui.cpp:295
void SetFloatLevel(wxWindow *aWindow)
Intended to set the floating window level in macOS on a window.
Definition wxgtk/ui.cpp:424
void GetInfoBarColours(wxColour &aFGColour, wxColour &aBGColour)
Return the background and foreground colors for info bars in the current scheme.
Definition wxgtk/ui.cpp:68
void ReparentWindow(wxNonOwnedWindow *aWindow, wxTopLevelWindow *aParent)
Definition wxgtk/ui.cpp:174
void ReleaseChildWindow(wxNonOwnedWindow *aWindow)
Release a modal window's parent-child relationship with its parent window.
Definition wxgtk/ui.cpp:711
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:240
void FixupCancelButtonCmdKeyCollision(wxWindow *aWindow)
Definition wxgtk/ui.cpp:180
void SetOverlayScrolling(const wxWindow *aWindow, bool overlay)
Used to set overlay/non-overlay scrolling mode in a window.
Definition wxgtk/ui.cpp:288
wxPoint GetMousePosition()
Returns the mouse position in screen coordinates.
Definition wxgtk/ui.cpp:706
void ImmControl(wxWindow *aWindow, bool aEnable)
Configures the IME mode of a given control handle.
Definition wxgtk/ui.cpp:405
double GetPixelScaleFactor(const wxWindow *aWindow)
Tries to determine the pixel scaling factor currently in use for the window.
Definition wxgtk/ui.cpp:261
void InfiniteDragReleaseWindow()
On Wayland, allows the cursor to freely move again after a drag (see InfiniteDragPrepareWindow).
Definition wxgtk/ui.cpp:700
void EnsureVisible(wxWindow *aWindow)
Ensure that a window is visible on the screen.
Definition wxgtk/ui.cpp:162
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:186
double GetContentScaleFactor(const wxWindow *aWindow)
Tries to determine the content scaling factor currently in use for the window.
Definition wxgtk/ui.cpp:274
void ImeNotifyCancelComposition(wxWindow *aWindow)
Asks the IME to cancel.
Definition wxgtk/ui.cpp:410
void LargeChoiceBoxHack(wxChoice *aChoice)
Configure a wxChoice control to support a lot of entries by disabling functionality that makes adding...
Definition wxgtk/ui.cpp:222
bool WarpPointer(wxWindow *aWindow, int aX, int aY)
Move the mouse cursor to a specific position relative to the window.
Definition wxgtk/ui.cpp:339
wxColour GetDialogBGColour()
Definition wxgtk/ui.cpp:62
bool IsWindowActive(wxWindow *aWindow)
Check to see if the given window is the currently active window (e.g.
Definition wxgtk/ui.cpp:147
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition wxgtk/ui.cpp:281
void ForceFocus(wxWindow *aWindow)
Pass the current focus to the window.
Definition wxgtk/ui.cpp:125
bool InfiniteDragPrepareWindow(wxWindow *aWindow)
On Wayland, restricts the pointer movement to a rectangle slightly bigger than the given wxWindow.
Definition wxgtk/ui.cpp:693
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:168
bool IsDarkTheme()
Determine if the desktop interface is currently using a dark theme or a light theme.
Definition wxgtk/ui.cpp:49
void AllowNetworkFileSystems(wxDialog *aDialog)
Configure a file dialog to show network and virtual file systems.
Definition wxgtk/ui.cpp:717
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > overlay