Fix wxStatusBar with field controls under wxQt

Postpone the creation of the QStatusBar fields until the first call to
SetStatusText(). This is to account for any field control added by the
user and also to avoid having to call UpdateFields() multiple times.

wxSTB_ELLIPSIZE_XXX and wxSTB_SHOW_TIPS supports are also implemented now.

The statbar sample is also updated: The OnSize() handler is removed because
it doesn't do much. that is: it is defined to keep the bitmap centered in the
status bar field it occupies if it is resized. but this is already done by the
wxStaticBitmap control, at least under wxMSW, wxGTK3 and wxQt.
This commit is contained in:
ali kettab 2023-11-20 16:11:31 +01:00
parent 02610d5d4b
commit 5c46947c57
3 changed files with 109 additions and 40 deletions

View file

@ -10,7 +10,6 @@
#include "wx/statusbr.h"
class QLabel;
class QStatusBar;
class WXDLLIMPEXP_CORE wxStatusBar : public wxStatusBarBase
@ -25,6 +24,7 @@ public:
long style = wxSTB_DEFAULT_STYLE,
const wxString& name = wxASCII_STR(wxStatusBarNameStr));
virtual void SetStatusWidths(int n, const int widths_field[]) override;
virtual bool GetFieldRect(int i, wxRect& rect) const override;
virtual void SetMinHeight(int height) override;
virtual int GetBorderX() const override;
@ -40,7 +40,7 @@ private:
void UpdateFields();
QStatusBar *m_qtStatusBar = nullptr;
wxVector<QLabel*> m_qtPanes;
std::vector<QWidget*> m_qtPanes;
wxDECLARE_DYNAMIC_CLASS(wxStatusBar);
};