diff options
Diffstat (limited to 'wx+/tooltip.cpp')
-rw-r--r-- | wx+/tooltip.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/wx+/tooltip.cpp b/wx+/tooltip.cpp index a3fa770d..c56d80a1 100644 --- a/wx+/tooltip.cpp +++ b/wx+/tooltip.cpp @@ -27,10 +27,9 @@ const int TIP_WINDOW_OFFSET_DIP = 30; class Tooltip::TooltipDlgGenerated : public wxDialog { public: - TooltipDlgGenerated(wxWindow* parent) : wxDialog(parent, wxID_ANY, L"" /*title*/, wxDefaultPosition, wxDefaultSize, 0 /*style*/) + TooltipDlgGenerated(wxWindow* parent) : //Suse Linux/X11: needs parent window, else there are z-order issues + wxDialog(parent, wxID_ANY, L"" /*title*/, wxDefaultPosition, wxDefaultSize, 0 /*style*/) { - //Suse Linux/X11: needs parent window, else there are z-order issues - SetSizeHints(wxDefaultSize, wxDefaultSize); SetExtraStyle(this->GetExtraStyle() | wxWS_EX_TRANSIENT); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOBK)); //both required: on Ubuntu background is black, foreground white! @@ -44,11 +43,11 @@ public: bSizer158->Add(staticTextMain_, 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5); SetSizer(bSizer158); - Layout(); - bSizer158->Fit(this); } + bool AcceptsFocus() const override { return false; } //any benefit? + wxStaticText* staticTextMain_ = nullptr; wxStaticBitmap* bitmapLeft_ = nullptr; }; @@ -61,21 +60,28 @@ void Tooltip::show(const wxString& text, wxPoint mousePos, const wxImage* img) const wxImage& newImg = img ? *img : wxNullImage; - if (!lastUsedImg_.IsSameAs(newImg)) + const bool imgChanged = !newImg.IsSameAs(lastUsedImg_); + const bool txtChanged = text != tipWindow_->staticTextMain_->GetLabelText(); + + if (imgChanged) { lastUsedImg_ = newImg; setImage(*tipWindow_->bitmapLeft_, newImg); - tipWindow_->Refresh(); //needed if bitmap size changed! + // tipWindow_->Refresh(); //needed if bitmap size changed! ->??? } - if (text != tipWindow_->staticTextMain_->GetLabelText()) + if (txtChanged) { tipWindow_->staticTextMain_->SetLabelText(text); tipWindow_->staticTextMain_->Wrap(fastFromDIP(600)); } - tipWindow_->GetSizer()->SetSizeHints(tipWindow_); //~=Fit() + SetMinSize() - //Linux: Fit() seems to be broken => this needs to be called EVERY time inside show, not only if text or bmp change + if (imgChanged || txtChanged) + { + //tipWindow_->Layout(); -> apparently not needed!? + tipWindow_->GetSizer()->SetSizeHints(tipWindow_); //~=Fit() + SetMinSize() + //Linux: Fit() seems to be broken => call EVERY time inside show, not only if text or bmp change -> still true?!? + } const wxPoint newPos = wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft ? mousePos - wxPoint(fastFromDIP(TIP_WINDOW_OFFSET_DIP) + tipWindow_->GetSize().GetWidth(), 0) : @@ -98,6 +104,7 @@ void Tooltip::hide() #if GTK_MAJOR_VERSION == 2 //the tooltip sometimes turns blank or is not shown again after it was hidden: e.g. drag-selection on middle grid tipWindow_->Destroy(); //apply brute force: tipWindow_ = nullptr; // + lastUsedImg_ = wxNullImage; #elif GTK_MAJOR_VERSION == 3 tipWindow_->Hide(); |