Kicad manager: fix some issues about the wxStatusBar:
- fix broken code KICAD_MANAGER_FRAME::PrintPrjInfo() - fix issues created by using KISTATUSBAR instead of wxStatusBar (the user field count differs because there are 4 other fields added) - do do use a fixed size in KISTATUSBAR for FIELD_OFFSET_BGJOB_TEXT field: fixed field size does not work fine if the text to display is not known Fixes #16535 https://gitlab.com/kicad/code/kicad/-/issues/16535
This commit is contained in:
parent
50cad558cf
commit
1649b7dd56
|
@ -34,7 +34,6 @@
|
|||
#include <notifications_manager.h>
|
||||
#include <bitmaps.h>
|
||||
|
||||
|
||||
#define FIELD_OFFSET_BGJOB_TEXT 0
|
||||
#define FIELD_OFFSET_BGJOB_GAUGE 1
|
||||
#define FIELD_OFFSET_BGJOB_CANCEL 2
|
||||
|
@ -60,10 +59,11 @@ KISTATUSBAR::KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id ) :
|
|||
for( int i = 0; i < aNumberFields; i++ )
|
||||
widths[i] = -1;
|
||||
|
||||
widths[aNumberFields + FIELD_OFFSET_BGJOB_TEXT] = 200; // background status text field
|
||||
widths[aNumberFields + FIELD_OFFSET_BGJOB_GAUGE] = 75; // background progress button
|
||||
widths[aNumberFields + FIELD_OFFSET_BGJOB_CANCEL] = 20; // background stop button
|
||||
widths[aNumberFields + FIELD_OFFSET_NOTIFICATION_BUTTON] = 20; // notifications button
|
||||
widths[aNumberFields + FIELD_OFFSET_BGJOB_TEXT] = -1; // background status text field
|
||||
// (variable size)
|
||||
widths[aNumberFields + FIELD_OFFSET_BGJOB_GAUGE] = 75; // background progress button
|
||||
widths[aNumberFields + FIELD_OFFSET_BGJOB_CANCEL] = 20; // background stop button
|
||||
widths[aNumberFields + FIELD_OFFSET_NOTIFICATION_BUTTON] = 20; // notifications button
|
||||
#ifdef __WXOSX__
|
||||
// offset from the right edge
|
||||
widths[aNumberFields + ExtraFields - 1] = 10;
|
||||
|
|
|
@ -30,6 +30,15 @@ class wxButton;
|
|||
class wxStaticText;
|
||||
class BITMAP_BUTTON;
|
||||
|
||||
/**
|
||||
* KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
|
||||
* It displays the fields needed by the caller, and room for 4 other fields (see kistatusbar.cpp)
|
||||
* Background text (FIELD_OFFSET_BGJOB_TEXT offset id)
|
||||
* Background gauge widget (FIELD_OFFSET_BGJOB_GAUGE offset id)
|
||||
* Background background stop button (FIELD_OFFSET_BGJOB_CANCEL offset id)
|
||||
* Background notifications button (FIELD_OFFSET_NOTIFICATION_BUTTON offset id)
|
||||
*/
|
||||
|
||||
class KISTATUSBAR : public wxStatusBar
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -142,7 +142,12 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl
|
|||
|
||||
// Create the status line (bottom of the frame). Left half is for project name; right half
|
||||
// is for Reporter (currently used by archiver/unarchiver and PCM).
|
||||
CreateStatusBar( 3 );
|
||||
// Note: this is a KISTATUSBAR status bar. Therefore the specified number of fields
|
||||
// is the extra number of fields, not the full field count.
|
||||
// We need here 2 fields: the extra fiels to display the project name, and another field
|
||||
// to display a info (specific to Windows) using the FIELD_OFFSET_BGJOB_TEXT id offset (=1)
|
||||
// So the extra field count is 1
|
||||
CreateStatusBar( 1 );
|
||||
Pgm().GetBackgroundJobMonitor().RegisterStatusBar( (KISTATUSBAR*) GetStatusBar() );
|
||||
Pgm().GetNotificationsManager().RegisterStatusBar( (KISTATUSBAR*) GetStatusBar() );
|
||||
GetStatusBar()->SetFont( KIUI::GetStatusFont( this ) );
|
||||
|
@ -864,7 +869,13 @@ void KICAD_MANAGER_FRAME::PrintPrjInfo()
|
|||
|
||||
wxString status = wxString::Format( _( "Project: %s" ), Prj().GetProjectFullName() );
|
||||
wxStatusBar* statusBar = GetStatusBar();
|
||||
int width = statusBar->GetSize().GetWidth() / 2;
|
||||
wxRect fieldRect;
|
||||
int width = -1;
|
||||
|
||||
// Only GetFieldRect() returns the current size for variable size fields
|
||||
// Other methods return -1 for the width of these fields.
|
||||
if( statusBar->GetFieldRect( 0, fieldRect ) )
|
||||
width = fieldRect.GetWidth();
|
||||
|
||||
if( width > 20 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue