KiCad PCB EDA Suite
KIPLATFORM::UI Namespace Reference

Functions

bool IsDarkTheme ()
 Determine if the desktop interface is currently using a dark theme or a light theme. More...
 
void ForceFocus (wxWindow *aWindow)
 Pass the current focus to the window. More...
 
bool IsWindowActive (wxWindow *aWindow)
 Check to see if the given window is the currently active window (e.g. More...
 
void ReparentQuasiModal (wxNonOwnedWindow *aWindow)
 Move a window's parent to be the top-level window and force the window to be on top. More...
 
void FixupCancelButtonCmdKeyCollision (wxWindow *aWindow)
 
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. More...
 
void EllipsizeChoiceBox (wxChoice *aChoice)
 Configure a wxChoice control to ellipsize the shown text in the button with the ellipses placed at the end of the string. More...
 
double GetSystemScaleFactor (const wxWindow *aWindow)
 Tries to determine the system scaling factor currently in use for the window. More...
 

Function Documentation

◆ EllipsizeChoiceBox()

void KIPLATFORM::UI::EllipsizeChoiceBox ( wxChoice *  aChoice)

Configure a wxChoice control to ellipsize the shown text in the button with the ellipses placed at the end of the string.

Parameters
aChoiceis the choice box to ellipsize

Definition at line 91 of file gtk/ui.cpp.

92 {
93  // This function is based on the code inside the function post_process_ui in gtkfilechooserwidget.c
94  GList* cells = gtk_cell_layout_get_cells( GTK_CELL_LAYOUT( aChoice->m_widget ) );
95 
96  if( !cells )
97  return;
98 
99  GtkCellRenderer* cell = (GtkCellRenderer*) cells->data;
100 
101  if( !cell )
102  return;
103 
104  g_object_set( G_OBJECT( cell ), "ellipsize", PANGO_ELLIPSIZE_END, NULL );
105 
106  // Only the list of cells must be freed, the renderer isn't ours to free
107  g_list_free( cells );
108 }
#define NULL

References NULL.

Referenced by DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL().

◆ FixupCancelButtonCmdKeyCollision()

void KIPLATFORM::UI::FixupCancelButtonCmdKeyCollision ( wxWindow *  aWindow)

Definition at line 71 of file gtk/ui.cpp.

72 {
73  // Not needed on this platform
74 }

Referenced by CVPCB_MAINFRAME::CVPCB_MAINFRAME(), and DIALOG_SHIM::OnPaint().

◆ ForceFocus()

void KIPLATFORM::UI::ForceFocus ( wxWindow *  aWindow)

Pass the current focus to the window.

On OSX this will forcefully give the focus to the desired window, while on MSW and GTK it will simply call the wxWidgets SetFocus() function.

Parameters
aWindowis the window to pass focus to

Definition at line 44 of file gtk/ui.cpp.

45 {
46  aWindow->SetFocus();
47 }

Referenced by NET_SELECTOR_COMBOPOPUP::doSetFocus(), DIALOG_SHIM::OnPaint(), DIALOG_DRC::OnRunDRCClick(), and DIALOG_ERC::OnRunERCClick().

◆ GetSystemScaleFactor()

double KIPLATFORM::UI::GetSystemScaleFactor ( const wxWindow *  aWindow)

Tries to determine the system scaling factor currently in use for the window.

Under wx3.0, GTK fails to properly detect the scale factor.

Parameters
aWindowpointer to the window to check
Returns
System scale factor in use, defaulting to the wxWidgets method

Definition at line 111 of file gtk/ui.cpp.

112 {
113  double val = 1.0;
114 
115  GtkWidget* widget = static_cast<GtkWidget*>( aWindow->GetHandle() );
116 
117  if( widget && gtk_check_version( 3, 10, 0 ) == NULL )
118  val = gtk_widget_get_scale_factor( widget );
119 
120  return val;
121 }
#define NULL

References NULL.

Referenced by DPI_SCALING::GetScaleFactor().

◆ IsDarkTheme()

bool KIPLATFORM::UI::IsDarkTheme ( )

Determine if the desktop interface is currently using a dark theme or a light theme.

Returns
true if a dark theme is being used.

Definition at line 31 of file gtk/ui.cpp.

32 {
33  wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
34 
35  // Weighted W3C formula
36  double brightness = ( bg.Red() / 255.0 ) * 0.299 +
37  ( bg.Green() / 255.0 ) * 0.587 +
38  ( bg.Blue() / 255.0 ) * 0.117;
39 
40  return brightness < 0.5;
41 }

Referenced by WX_AUI_TOOLBAR_ART::DrawButton(), MakeDisabledBitmap(), BITMAP_BUTTON::OnPaint(), ACTION_PLUGINS::register_action(), BITMAP_STORE::ThemeChanged(), and WX_INFOBAR::WX_INFOBAR().

◆ IsStockCursorOk()

bool KIPLATFORM::UI::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.

Parameters
aCursoris wxStockCursor we want to see if its acceptable

Definition at line 77 of file gtk/ui.cpp.

78 {
79  switch( aCursor )
80  {
81  case wxCURSOR_BULLSEYE:
82  case wxCURSOR_HAND:
83  case wxCURSOR_ARROW:
84  return true;
85  default:
86  return false;
87  }
88 }

Referenced by CURSOR_STORE::GetStockCursor().

◆ IsWindowActive()

bool KIPLATFORM::UI::IsWindowActive ( wxWindow *  aWindow)

Check to see if the given window is the currently active window (e.g.

the window in the foreground the user is interacting with).

Parameters
aWindowis the window to check

Definition at line 50 of file gtk/ui.cpp.

51 {
52  if( !aWindow )
53  return false;
54 
55  GtkWindow* window = GTK_WINDOW( aWindow->GetHandle() );
56 
57  if( window )
58  return gtk_window_is_active( window );
59 
60  // We shouldn't really ever reach this point
61  return false;
62 }

Referenced by EDA_DRAW_PANEL_GAL::onEnter(), and EDA_DRAW_PANEL_GAL::OnEvent().

◆ ReparentQuasiModal()

void KIPLATFORM::UI::ReparentQuasiModal ( wxNonOwnedWindow *  aWindow)

Move a window's parent to be the top-level window and force the window to be on top.

This only has an affect for OSX, it is a NOP for GTK and MSW.

Apple in its infinite wisdom will raise a disabled window before even passing us the event, so we have no way to stop it. Instead, we must set an order on the windows so that the quasi-modal will be pushed in front of the disabled window when it is raised.

Parameters
aWindowis the window to reparent

Definition at line 65 of file gtk/ui.cpp.

66 {
67  // Not needed on this platform
68 }

Referenced by PCB_VIEWER_TOOLS::Show3DViewer(), and DIALOG_SHIM::ShowQuasiModal().