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
92{
93 // Not needed on this platform
94}
95
96
97bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor )
98{
99 switch( aCursor )
100 {
101 case wxCURSOR_BULLSEYE:
102 case wxCURSOR_HAND:
103 case wxCURSOR_ARROW:
104 return true;
105 default:
106 return false;
107 }
108}
109
110
111void KIPLATFORM::UI::LargeChoiceBoxHack( wxChoice* aChoice )
112{
113 // Not implemented
114}
115
116
117void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice )
118{
119 // Not implemented
120}
121
122
123double KIPLATFORM::UI::GetPixelScaleFactor( const wxWindow* aWindow )
124{
125 return aWindow->GetContentScaleFactor();
126}
127
128
129double KIPLATFORM::UI::GetContentScaleFactor( const wxWindow* aWindow )
130{
131 return aWindow->GetDPIScaleFactor();
132}
133
134
135wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow )
136{
137 return aWindow->GetClientSize();
138}
139
140
141void KIPLATFORM::UI::SetOverlayScrolling( const wxWindow* aWindow, bool overlay )
142{
143 // Not implemented
144}
145
146
148{
149 return true;
150}
151
152
154{
155 return wxGetMousePosition();
156}
157
158
159bool KIPLATFORM::UI::WarpPointer( wxWindow* aWindow, int aX, int aY )
160{
161 aWindow->WarpPointer( aX, aY );
162 return true;
163}
164
165
166void KIPLATFORM::UI::ImmControl( wxWindow* aWindow, bool aEnable )
167{
168 if ( !aEnable )
169 {
170 ImmAssociateContext( aWindow->GetHWND(), NULL );
171 }
172 else
173 {
174 ImmAssociateContextEx( aWindow->GetHWND(), 0, IACE_DEFAULT );
175 }
176}
177
178
179void KIPLATFORM::UI::ImeNotifyCancelComposition( wxWindow* aWindow )
180{
181 const HIMC himc = ImmGetContext( aWindow->GetHWND() );
182 ImmNotifyIME( himc, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
183 ImmReleaseContext( aWindow->GetHWND(), himc );
184}
185
186
187bool KIPLATFORM::UI::InfiniteDragPrepareWindow( wxWindow* aWindow )
188{
189 return true;
190}
191
192
194{
195 // Not needed on this platform
196}
197
198
199void KIPLATFORM::UI::SetFloatLevel( wxWindow* aWindow )
200{
201}
bool AllowIconsInMenus()
If the user has disabled icons system-wide, we check that here.
Definition: wxgtk/ui.cpp:272
void SetFloatLevel(wxWindow *aWindow)
Intended to set the floating window level in macOS on a window.
Definition: wxgtk/ui.cpp:401
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 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:217
void FixupCancelButtonCmdKeyCollision(wxWindow *aWindow)
Definition: wxgtk/ui.cpp:157
void SetOverlayScrolling(const wxWindow *aWindow, bool overlay)
Used to set overlay/non-overlay scrolling mode in a window.
Definition: wxgtk/ui.cpp:265
wxPoint GetMousePosition()
Returns the mouse position in screen coordinates.
Definition: wxgtk/ui.cpp:683
void ImmControl(wxWindow *aWindow, bool aEnable)
Configures the IME mode of a given control handle.
Definition: wxgtk/ui.cpp:382
double GetPixelScaleFactor(const wxWindow *aWindow)
Tries to determine the pixel scaling factor currently in use for the window.
Definition: wxgtk/ui.cpp:238
void InfiniteDragReleaseWindow()
On Wayland, allows the cursor to freely move again after a drag (see InfiniteDragPrepareWindow).
Definition: wxgtk/ui.cpp:677
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:163
double GetContentScaleFactor(const wxWindow *aWindow)
Tries to determine the content scaling factor currently in use for the window.
Definition: wxgtk/ui.cpp:251
void ImeNotifyCancelComposition(wxWindow *aWindow)
Asks the IME to cancel.
Definition: wxgtk/ui.cpp:387
void LargeChoiceBoxHack(wxChoice *aChoice)
Configure a wxChoice control to support a lot of entries by disabling functionality that makes adding...
Definition: wxgtk/ui.cpp:199
bool WarpPointer(wxWindow *aWindow, int aX, int aY)
Move the mouse cursor to a specific position relative to the window.
Definition: wxgtk/ui.cpp:316
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:258
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:670
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
Definition: playground.cpp:46