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...
 
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...
 

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 76 of file gtk/ui.cpp.

77 {
78  // This function is based on the code inside the function post_process_ui in gtkfilechooserwidget.c
79  GList* cells = gtk_cell_layout_get_cells( GTK_CELL_LAYOUT( aChoice->m_widget ) );
80 
81  if( !cells )
82  return;
83 
84  GtkCellRenderer* cell = (GtkCellRenderer*) cells->data;
85 
86  if( !cell )
87  return;
88 
89  g_object_set( G_OBJECT( cell ), "ellipsize", PANGO_ELLIPSIZE_END, NULL );
90 
91  // Only the list of cells must be freed, the renderer isn't ours to free
92  g_list_free( cells );
93 }
#define NULL

References NULL.

Referenced by DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL().

◆ FixupCancelButtonCmdKeyCollision()

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

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

57 {
58  // Not needed on this platform
59 }

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().

◆ 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 BITMAP_BUTTON::OnPaint().

◆ 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 62 of file gtk/ui.cpp.

63 {
64  switch( aCursor )
65  {
66  case wxCURSOR_BULLSEYE:
67  case wxCURSOR_HAND:
68  case wxCURSOR_ARROW:
69  return true;
70  default:
71  return false;
72  }
73 }

Referenced by CURSOR_STORE::GetStockCursor().

◆ 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 50 of file gtk/ui.cpp.

51 {
52  // Not needed on this platform
53 }

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