Add platform-specific code to allow wxChoice to ellipsize
Fixes https://gitlab.com/kicad/code/kicad/issues/5377
This commit is contained in:
parent
c0d381e588
commit
06f01d0d8a
|
@ -35,6 +35,8 @@
|
||||||
#include <filename_resolver.h>
|
#include <filename_resolver.h>
|
||||||
#include <pcbnew/class_module.h>
|
#include <pcbnew/class_module.h>
|
||||||
|
|
||||||
|
#include <kiplatform/ui.h>
|
||||||
|
|
||||||
|
|
||||||
DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager,
|
DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager,
|
||||||
MODULE_3D_SETTINGS* aModelItem, wxString& prevModelSelectDir, int& prevModelWildcard ) :
|
MODULE_3D_SETTINGS* aModelItem, wxString& prevModelSelectDir, int& prevModelWildcard ) :
|
||||||
|
@ -117,6 +119,12 @@ DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheMana
|
||||||
m_FileTree->SetFilterIndex( 0 );
|
m_FileTree->SetFilterIndex( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix the filter box on the file selector widget so that it always shows the start of the filter
|
||||||
|
// string in the combobox. Otherwise it will only show the end of the string, which is empty for
|
||||||
|
// all but the all supported filters option.
|
||||||
|
wxChoice* filterBox = m_FileTree->GetFilterListCtrl();
|
||||||
|
KIPLATFORM::UI::EllipsizeChoiceBox( filterBox );
|
||||||
|
|
||||||
m_FileTree->SetPath( m_previousDir );
|
m_FileTree->SetPath( m_previousDir );
|
||||||
updateDirChoiceList();
|
updateDirChoiceList();
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,13 @@
|
||||||
|
|
||||||
#include <kiplatform/ui.h>
|
#include <kiplatform/ui.h>
|
||||||
|
|
||||||
|
#include <wx/choice.h>
|
||||||
#include <wx/nonownedwnd.h>
|
#include <wx/nonownedwnd.h>
|
||||||
#include <wx/settings.h>
|
#include <wx/settings.h>
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
|
||||||
bool KIPLATFORM::UI::IsDarkTheme()
|
bool KIPLATFORM::UI::IsDarkTheme()
|
||||||
{
|
{
|
||||||
|
@ -68,3 +71,23 @@ bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice )
|
||||||
|
{
|
||||||
|
// This function is based on the code inside the function post_process_ui in gtkfilechooserwidget.c
|
||||||
|
GList* cells = gtk_cell_layout_get_cells( GTK_CELL_LAYOUT( aChoice->m_widget ) );
|
||||||
|
|
||||||
|
if( !cells )
|
||||||
|
return;
|
||||||
|
|
||||||
|
GtkCellRenderer* cell = (GtkCellRenderer*) cells->data;
|
||||||
|
|
||||||
|
if( !cell )
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_object_set( G_OBJECT( cell ), "ellipsize", PANGO_ELLIPSIZE_END, NULL );
|
||||||
|
|
||||||
|
// Only the list of cells must be freed, the renderer isn't ours to free
|
||||||
|
g_list_free( cells );
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <wx/cursor.h>
|
#include <wx/cursor.h>
|
||||||
|
|
||||||
|
class wxChoice;
|
||||||
class wxNonOwnedWindow;
|
class wxNonOwnedWindow;
|
||||||
class wxWindow;
|
class wxWindow;
|
||||||
|
|
||||||
|
@ -76,6 +77,14 @@ namespace KIPLATFORM
|
||||||
* @param aCursor is wxStockCursor we want to see if its acceptable
|
* @param aCursor is wxStockCursor we want to see if its acceptable
|
||||||
*/
|
*/
|
||||||
bool IsStockCursorOk( wxStockCursor aCursor );
|
bool IsStockCursorOk( wxStockCursor aCursor );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure a wxChoice control to ellipsize the shown text in the button with the ellipses
|
||||||
|
* placed at the end of the string.
|
||||||
|
*
|
||||||
|
* @param aChoice is the choice box to ellipsize
|
||||||
|
*/
|
||||||
|
void EllipsizeChoiceBox( wxChoice* aChoice );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ bool KIPLATFORM::UI::IsDarkTheme()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
long val = 0;
|
long val = 0;
|
||||||
|
|
||||||
if( !themeKey.QueryValue( lightModeKey, &val ) )
|
if( !themeKey.QueryValue( lightModeKey, &val ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -88,4 +88,10 @@ bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor )
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice )
|
||||||
|
{
|
||||||
|
// Not implemented
|
||||||
|
}
|
||||||
|
|
|
@ -84,4 +84,10 @@ bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor )
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice )
|
||||||
|
{
|
||||||
|
// Not implemented
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue