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/nonownedwnd.h>
27#include <wx/window.h>
28#include <wx/msw/registry.h>
29
30
32{
33#if wxCHECK_VERSION( 3, 3, 0 )
34 wxSystemAppearance appearance = wxSystemSettings::GetAppearance();
35 return appearance.IsDark();
36#else
37 wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
38
39 // Weighted W3C formula
40 double brightness = ( bg.Red() / 255.0 ) * 0.299 +
41 ( bg.Green() / 255.0 ) * 0.587 +
42 ( bg.Blue() / 255.0 ) * 0.117;
43
44 return brightness < 0.5;
45#endif
46}
47
48
50{
51 return wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
52}
53
54
55void KIPLATFORM::UI::GetInfoBarColours( wxColour& aFGColour, wxColour& aBGColour )
56{
57 aBGColour = wxSystemSettings::GetColour( wxSYS_COLOUR_INFOBK );
58 aFGColour = wxSystemSettings::GetColour( wxSYS_COLOUR_INFOTEXT );
59}
60
61
62void KIPLATFORM::UI::ForceFocus( wxWindow* aWindow )
63{
64 aWindow->SetFocus();
65}
66
67
68bool KIPLATFORM::UI::IsWindowActive( wxWindow* aWindow )
69{
70 if(! aWindow )
71 {
72 return false;
73 }
74
75 return ( aWindow->GetHWND() == GetForegroundWindow() );
76}
77
78
79void KIPLATFORM::UI::EnsureVisible( wxWindow* aWindow )
80{
81 // Not needed on this platform
82}
83
84
85void KIPLATFORM::UI::ReparentModal( wxNonOwnedWindow* aWindow )
86{
87 // Not needed on this platform
88}
89
90
91void KIPLATFORM::UI::ReparentWindow( wxNonOwnedWindow* aWindow, wxTopLevelWindow* aParent )
92{
93 // Not needed on this platform (used only on macOS for child window ordering)
94}
95
96
98{
99 // Not needed on this platform
100}
101
102
103bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor )
104{
105 switch( aCursor )
106 {
107 case wxCURSOR_BULLSEYE:
108 case wxCURSOR_HAND:
109 case wxCURSOR_ARROW:
110 return true;
111 default:
112 return false;
113 }
114}
115
116
117void KIPLATFORM::UI::LargeChoiceBoxHack( wxChoice* aChoice )
118{
119 // Not implemented
120}
121
122
123void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice )
124{
125 // Not implemented
126}
127
128
129double KIPLATFORM::UI::GetPixelScaleFactor( const wxWindow* aWindow )
130{
131 return aWindow->GetContentScaleFactor();
132}
133
134
135double KIPLATFORM::UI::GetContentScaleFactor( const wxWindow* aWindow )
136{
137 return aWindow->GetDPIScaleFactor();
138}
139
140
141wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow )
142{
143 return aWindow->GetClientSize();
144}
145
146
147void KIPLATFORM::UI::SetOverlayScrolling( const wxWindow* aWindow, bool overlay )
148{
149 // Not implemented
150}
151
152
154{
155 return true;
156}
157
158
160{
161 return wxGetMousePosition();
162}
163
164
165bool KIPLATFORM::UI::WarpPointer( wxWindow* aWindow, int aX, int aY )
166{
167 aWindow->WarpPointer( aX, aY );
168 return true;
169}
170
171
172void KIPLATFORM::UI::ImmControl( wxWindow* aWindow, bool aEnable )
173{
174 if ( !aEnable )
175 {
176 ImmAssociateContext( aWindow->GetHWND(), NULL );
177 }
178 else
179 {
180 ImmAssociateContextEx( aWindow->GetHWND(), 0, IACE_DEFAULT );
181 }
182}
183
184
185void KIPLATFORM::UI::ImeNotifyCancelComposition( wxWindow* aWindow )
186{
187 const HIMC himc = ImmGetContext( aWindow->GetHWND() );
188 ImmNotifyIME( himc, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
189 ImmReleaseContext( aWindow->GetHWND(), himc );
190}
191
192
193bool KIPLATFORM::UI::InfiniteDragPrepareWindow( wxWindow* aWindow )
194{
195 return true;
196}
197
198
200{
201 // Not needed on this platform
202}
203
204
205void KIPLATFORM::UI::SetFloatLevel( wxWindow* aWindow )
206{
207}
bool AllowIconsInMenus()
If the user has disabled icons system-wide, we check that here.
Definition wxgtk/ui.cpp:278
void SetFloatLevel(wxWindow *aWindow)
Intended to set the floating window level in macOS on a window.
Definition wxgtk/ui.cpp:407
void GetInfoBarColours(wxColour &aFGColour, wxColour &aBGColour)
Return the background and foreground colors for info bars in the current scheme.
Definition wxgtk/ui.cpp:67
void ReparentWindow(wxNonOwnedWindow *aWindow, wxTopLevelWindow *aParent)
Definition wxgtk/ui.cpp:157
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:223
void FixupCancelButtonCmdKeyCollision(wxWindow *aWindow)
Definition wxgtk/ui.cpp:163
void SetOverlayScrolling(const wxWindow *aWindow, bool overlay)
Used to set overlay/non-overlay scrolling mode in a window.
Definition wxgtk/ui.cpp:271
wxPoint GetMousePosition()
Returns the mouse position in screen coordinates.
Definition wxgtk/ui.cpp:689
void ImmControl(wxWindow *aWindow, bool aEnable)
Configures the IME mode of a given control handle.
Definition wxgtk/ui.cpp:388
double GetPixelScaleFactor(const wxWindow *aWindow)
Tries to determine the pixel scaling factor currently in use for the window.
Definition wxgtk/ui.cpp:244
void InfiniteDragReleaseWindow()
On Wayland, allows the cursor to freely move again after a drag (see InfiniteDragPrepareWindow).
Definition wxgtk/ui.cpp:683
void EnsureVisible(wxWindow *aWindow)
Ensure that a window is visible on the screen.
Definition wxgtk/ui.cpp:145
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:169
double GetContentScaleFactor(const wxWindow *aWindow)
Tries to determine the content scaling factor currently in use for the window.
Definition wxgtk/ui.cpp:257
void ImeNotifyCancelComposition(wxWindow *aWindow)
Asks the IME to cancel.
Definition wxgtk/ui.cpp:393
void LargeChoiceBoxHack(wxChoice *aChoice)
Configure a wxChoice control to support a lot of entries by disabling functionality that makes adding...
Definition wxgtk/ui.cpp:205
bool WarpPointer(wxWindow *aWindow, int aX, int aY)
Move the mouse cursor to a specific position relative to the window.
Definition wxgtk/ui.cpp:322
wxColour GetDialogBGColour()
Definition wxgtk/ui.cpp:61
bool IsWindowActive(wxWindow *aWindow)
Check to see if the given window is the currently active window (e.g.
Definition wxgtk/ui.cpp:130
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition wxgtk/ui.cpp:264
void ForceFocus(wxWindow *aWindow)
Pass the current focus to the window.
Definition wxgtk/ui.cpp:124
bool InfiniteDragPrepareWindow(wxWindow *aWindow)
On Wayland, restricts the pointer movement to a rectangle slightly bigger than the given wxWindow.
Definition wxgtk/ui.cpp:676
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:151
bool IsDarkTheme()
Determine if the desktop interface is currently using a dark theme or a light theme.
Definition wxgtk/ui.cpp:48
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > overlay