summaryrefslogtreecommitdiff
path: root/wx+/tooltip.cpp
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2023-01-22 13:56:55 -0500
committerB. Stack <bgstack15@gmail.com>2023-01-22 13:56:55 -0500
commit75e05bc441382db69c842a64c562738cb749214e (patch)
tree698b60b3b4b914bf7958cf1174d0373909bf1e8f /wx+/tooltip.cpp
parentadd upstream 11.29 (diff)
downloadFreeFileSync-75e05bc441382db69c842a64c562738cb749214e.tar.gz
FreeFileSync-75e05bc441382db69c842a64c562738cb749214e.tar.bz2
FreeFileSync-75e05bc441382db69c842a64c562738cb749214e.zip
add upstream 12.0
Diffstat (limited to 'wx+/tooltip.cpp')
-rw-r--r--wx+/tooltip.cpp27
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();
bgstack15