summaryrefslogtreecommitdiff
path: root/wx+/tooltip.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:18:53 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:18:53 +0200
commit32cb97237e7691d31977ab503c6ea4511e8eb3a8 (patch)
tree4e97b53e9f7b74e8cc5d7548507d9e82ae38e36f /wx+/tooltip.cpp
parent4.6 (diff)
downloadFreeFileSync-32cb97237e7691d31977ab503c6ea4511e8eb3a8.tar.gz
FreeFileSync-32cb97237e7691d31977ab503c6ea4511e8eb3a8.tar.bz2
FreeFileSync-32cb97237e7691d31977ab503c6ea4511e8eb3a8.zip
5.0
Diffstat (limited to 'wx+/tooltip.cpp')
-rw-r--r--wx+/tooltip.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/wx+/tooltip.cpp b/wx+/tooltip.cpp
index 9c2587b2..7b4c51e0 100644
--- a/wx+/tooltip.cpp
+++ b/wx+/tooltip.cpp
@@ -1,7 +1,7 @@
// **************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
-// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
+// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved *
// **************************************************************************
#include "tooltip.h"
@@ -9,6 +9,8 @@
#include <wx/sizer.h>
#include <wx/statbmp.h>
#include <wx/settings.h>
+#include <wx/app.h>
+#include <wx+/image_tools.h>
using namespace zen;
@@ -46,7 +48,7 @@ public:
};
-Tooltip::Tooltip() : tipWindow(new PopupFrameGenerated(NULL)), lastBmp(NULL)
+Tooltip::Tooltip() : tipWindow(new PopupFrameGenerated(NULL))
{
#ifdef FFS_WIN //neither looks good nor works at all on Linux
tipWindow->Disable(); //prevent window stealing focus!
@@ -61,13 +63,12 @@ Tooltip::~Tooltip()
}
-void Tooltip::show(const wxString& text, wxPoint pos, const wxBitmap* bmp)
+void Tooltip::show(const wxString& text, wxPoint mousePos, const wxBitmap* bmp)
{
- if (bmp != lastBmp)
- {
- lastBmp = bmp;
- tipWindow->m_bitmapLeft->SetBitmap(bmp == NULL ? wxNullBitmap : *bmp);
- }
+ const wxBitmap& newBmp = bmp ? *bmp : wxNullBitmap;
+
+ if (!isEqual(tipWindow->m_bitmapLeft->GetBitmap(), newBmp))
+ tipWindow->m_bitmapLeft->SetBitmap(newBmp);
if (text != tipWindow->m_staticTextMain->GetLabel())
{
@@ -75,14 +76,16 @@ void Tooltip::show(const wxString& text, wxPoint pos, const wxBitmap* bmp)
tipWindow->m_staticTextMain->Wrap(600);
}
-#ifdef FFS_LINUX
- tipWindow->Fit(); //Alas Fit() seems to be somewhat broken => this needs to be called EVERY time inside show, not only if text or bmp change.
-#endif
+ tipWindow->Fit(); //Linux: Fit() seems to be somewhat broken => this needs to be called EVERY time inside show, not only if text or bmp change
+
+ const wxPoint newPos = wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft ?
+ mousePos - wxPoint(30 + tipWindow->GetSize().GetWidth(), 0) :
+ mousePos + wxPoint(30, 0);
- if (pos != tipWindow->GetScreenPosition())
- tipWindow->SetSize(pos.x + 30, pos.y, wxDefaultCoord, wxDefaultCoord);
+ if (newPos != tipWindow->GetScreenPosition())
+ tipWindow->SetSize(newPos.x, newPos.y, wxDefaultCoord, wxDefaultCoord);
//attention!!! possible endless loop: mouse pointer must NOT be within tipWindow!
- //Else it will trigger a wxEVT_LEAVE_WINDOW which will hide the window, causing the window to be shown again via this method, etc.
+ //else it will trigger a wxEVT_LEAVE_WINDOW on middle grid which will hide the window, causing the window to be shown again via this method, etc.
if (!tipWindow->IsShown())
tipWindow->Show();
bgstack15