Try with KIPLATFORM

This commit is contained in:
Alex 2021-12-16 07:56:21 +03:00 committed by Jeff Young
parent b0cca4a89e
commit c4a4862e8f
5 changed files with 31 additions and 8 deletions

View File

@ -37,6 +37,7 @@
#include <sch_reference_list.h>
#include <schematic.h>
#include <tools/sch_editor_control.h>
#include <kiplatform/ui.h>
#include <widgets/grid_text_button_helpers.h>
#include <widgets/wx_grid.h>
#include <wx/grid.h>
@ -1170,14 +1171,8 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnTableItemContextMenu( wxGridEvent& event )
void DIALOG_SYMBOL_FIELDS_TABLE::OnSizeFieldList( wxSizeEvent& event )
{
// GetClientSize subtracts scrollbars width on Windows.
// On other platforms, the visible area must be computed manually.
#ifdef __WINDOWS__
int nameColWidth = m_fieldsCtrl->GetClientSize().x - m_showColWidth - m_groupByColWidth;
#else
int nameColWidth = event.GetSize().GetX() - m_showColWidth - m_groupByColWidth
- wxSystemSettings::GetMetric( wxSYS_VSCROLL_X );
#endif
int nameColWidth = KIPLATFORM::UI::GetUnobscuredSize( m_fieldsCtrl ).x - m_showColWidth
- m_groupByColWidth;
// GTK loses its head and messes these up when resizing the splitter bar:
m_fieldsCtrl->GetColumn( SHOW_FIELD_COLUMN )->SetWidth( m_showColWidth );

View File

@ -120,3 +120,10 @@ double KIPLATFORM::UI::GetSystemScaleFactor( const wxWindow* aWindow )
return val;
}
wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow )
{
return wxSize( aWindow->GetSize().GetX() - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ),
aWindow->GetSize().GetY() - wxSystemSettings::GetMetric( wxSYS_HSCROLL_Y ) );
}

View File

@ -101,6 +101,14 @@ namespace KIPLATFORM
* @return System scale factor in use, defaulting to the wxWidgets method
*/
double GetSystemScaleFactor( const wxWindow* aWindow );
/**
* Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl, wxGrid)
* that won't be obscured by scrollbars.
* @param aWindow pointer to the scrollable widget to check
* @return Viewport size that won't be obscured by scrollbars
*/
wxSize GetUnobscuredSize( const wxWindow* aWindow );
}
}

View File

@ -120,3 +120,9 @@ double KIPLATFORM::UI::GetSystemScaleFactor( const wxWindow* aWindow )
{
return aWindow->GetContentScaleFactor();
}
wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow )
{
return aWindow->GetClientSize();
}

View File

@ -119,3 +119,10 @@ double KIPLATFORM::UI::GetSystemScaleFactor( const wxWindow* aWindow )
{
return aWindow->GetContentScaleFactor();
}
wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow )
{
return wxSize( aWindow->GetSize().GetX() - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ),
aWindow->GetSize().GetY() - wxSystemSettings::GetMetric( wxSYS_HSCROLL_Y ) );
}