summaryrefslogtreecommitdiff
path: root/wx+
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-05-10 11:21:56 -0400
committerB. Stack <bgstack15@gmail.com>2024-05-10 11:21:56 -0400
commit7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7 (patch)
tree3ed84995318afbd82d5d98a2ba044f9ba58b57c6 /wx+
parentadd upstream 13.5 (diff)
downloadFreeFileSync-13.6.tar.gz
FreeFileSync-13.6.tar.bz2
FreeFileSync-13.6.zip
add upstream 13.613.6
Diffstat (limited to 'wx+')
-rw-r--r--wx+/app_main.h2
-rw-r--r--wx+/async_task.h2
-rw-r--r--wx+/context_menu.h2
-rw-r--r--wx+/dc.h4
-rw-r--r--wx+/file_drop.h2
-rw-r--r--wx+/graph.cpp4
-rw-r--r--wx+/grid.cpp18
-rw-r--r--wx+/grid.h4
-rw-r--r--wx+/image_resources.cpp2
-rw-r--r--wx+/image_tools.cpp6
-rw-r--r--wx+/image_tools.h3
-rw-r--r--wx+/popup_dlg.cpp4
-rw-r--r--wx+/popup_dlg.h2
-rw-r--r--wx+/std_button_layout.h2
-rw-r--r--wx+/tooltip.cpp15
-rw-r--r--wx+/window_layout.h4
-rw-r--r--wx+/window_tools.h13
17 files changed, 49 insertions, 40 deletions
diff --git a/wx+/app_main.h b/wx+/app_main.h
index 17a59d7b..c1fd2441 100644
--- a/wx+/app_main.h
+++ b/wx+/app_main.h
@@ -7,7 +7,7 @@
#ifndef APP_MAIN_H_08215601837818347575856
#define APP_MAIN_H_08215601837818347575856
-#include <wx/window.h>
+//#include <wx/window.h>
#include <wx/app.h>
diff --git a/wx+/async_task.h b/wx+/async_task.h
index 5a3e7caa..85f0d9d0 100644
--- a/wx+/async_task.h
+++ b/wx+/async_task.h
@@ -7,7 +7,7 @@
#ifndef ASYNC_TASK_H_839147839170432143214321
#define ASYNC_TASK_H_839147839170432143214321
-#include <functional>
+//#include <functional>
#include <zen/thread.h>
#include <zen/scope_guard.h>
#include <zen/stl_tools.h>
diff --git a/wx+/context_menu.h b/wx+/context_menu.h
index 92d8504c..1e2d4d69 100644
--- a/wx+/context_menu.h
+++ b/wx+/context_menu.h
@@ -7,7 +7,7 @@
#ifndef CONTEXT_MENU_H_18047302153418174632141234
#define CONTEXT_MENU_H_18047302153418174632141234
-#include <map>
+//#include <map>
#include <vector>
#include <functional>
#include <wx/app.h>
diff --git a/wx+/dc.h b/wx+/dc.h
index 522e3bc8..161765a0 100644
--- a/wx+/dc.h
+++ b/wx+/dc.h
@@ -9,10 +9,10 @@
#include <unordered_map>
#include <optional>
-#include <zen/basic_math.h>
+//#include <zen/basic_math.h>
#include <wx/dcbuffer.h> //for macro: wxALWAYS_NATIVE_DOUBLE_BUFFER
#include <wx/dcscreen.h>
-#include <wx/bmpbndl.h>
+//#include <wx/bmpbndl.h>
// #include <gtk/gtk.h>
diff --git a/wx+/file_drop.h b/wx+/file_drop.h
index 16c2b519..e9cb9e72 100644
--- a/wx+/file_drop.h
+++ b/wx+/file_drop.h
@@ -8,7 +8,7 @@
#define FILE_DROP_H_09457802957842560325626
#include <vector>
-#include <functional>
+//#include <functional>
#include <zen/zstring.h>
#include <wx/window.h>
#include <wx/event.h>
diff --git a/wx+/graph.cpp b/wx+/graph.cpp
index ad7fd3ec..da5c1d98 100644
--- a/wx+/graph.cpp
+++ b/wx+/graph.cpp
@@ -7,10 +7,10 @@
#include "graph.h"
#include <cassert>
#include <algorithm>
-#include <numeric>
+//#include <numeric>
#include <zen/basic_math.h>
#include <zen/scope_guard.h>
-#include <zen/perf.h>
+//#include <zen/perf.h>
using namespace zen;
diff --git a/wx+/grid.cpp b/wx+/grid.cpp
index 07196eaf..1c8897a1 100644
--- a/wx+/grid.cpp
+++ b/wx+/grid.cpp
@@ -6,13 +6,13 @@
#include "grid.h"
#include <cassert>
-#include <set>
+//#include <set>
#include <chrono>
#include <wx/settings.h>
-#include <wx/listbox.h>
+//#include <wx/listbox.h>
#include <wx/tooltip.h>
#include <wx/timer.h>
-#include <wx/utils.h>
+//#include <wx/utils.h>
#include <zen/basic_math.h>
#include <zen/string_tools.h>
#include <zen/scope_guard.h>
@@ -142,7 +142,7 @@ wxRect GridData::drawCellBorder(wxDC& dc, const wxRect& rect) //returns remainin
}
-void GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring& text, int alignment, const wxSize* textExtentHint)
+void GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring_view text, int alignment, const wxSize* textExtentHint)
{
/* Performance Notes (Windows):
- wxDC::GetTextExtent() is by far the most expensive call (20x more expensive than wxDC::DrawText())
@@ -157,9 +157,9 @@ void GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring& te
return;
//truncate large texts and add ellipsis
- wxString textTrunc = text;
- wxSize extentTrunc = textExtentHint ? *textExtentHint : dc.GetTextExtent(text);
- assert(!textExtentHint || *textExtentHint == dc.GetTextExtent(text)); //"trust, but verify" :>
+ wxString textTrunc(&text[0], text.size());
+ wxSize extentTrunc = textExtentHint ? *textExtentHint : dc.GetTextExtent(textTrunc);
+ assert(!textExtentHint || *textExtentHint == dc.GetTextExtent(textTrunc)); //"trust, but verify" :>
if (extentTrunc.GetWidth() > rect.width)
{
@@ -180,13 +180,13 @@ void GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring& te
}
const size_t middle = (low + high) / 2; //=> never 0 when "high - low > 1"
- const wxString candidate = getUnicodeSubstring(text, 0, middle) + ELLIPSIS;
+ /*const*/ wxString candidate = getUnicodeSubstring<wxString>(text, 0, middle) + ELLIPSIS;
const wxSize extentCand = dc.GetTextExtent(candidate); //perf: most expensive call of this routine!
if (extentCand.GetWidth() <= rect.width)
{
low = middle;
- textTrunc = candidate;
+ textTrunc = std::move(candidate);
extentTrunc = extentCand;
}
else
diff --git a/wx+/grid.h b/wx+/grid.h
index 471ba31b..57a8ffe3 100644
--- a/wx+/grid.h
+++ b/wx+/grid.h
@@ -8,7 +8,7 @@
#define GRID_H_834702134831734869987
#include <memory>
-#include <numeric>
+//#include <numeric>
#include <optional>
#include <vector>
#include <zen/stl_tools.h>
@@ -122,7 +122,7 @@ public:
static wxColor getColorSelectionGradientFrom();
static wxColor getColorSelectionGradientTo();
- static void drawCellText(wxDC& dc, const wxRect& rect, const std::wstring& text,
+ static void drawCellText(wxDC& dc, const wxRect& rect, const std::wstring_view text,
int alignment = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, const wxSize* textExtentHint = nullptr);
static wxRect drawCellBorder(wxDC& dc, const wxRect& rect); //returns inner rectangle
diff --git a/wx+/image_resources.cpp b/wx+/image_resources.cpp
index 6157f381..3e162651 100644
--- a/wx+/image_resources.cpp
+++ b/wx+/image_resources.cpp
@@ -5,7 +5,7 @@
// *****************************************************************************
#include "image_resources.h"
-#include <map>
+//#include <map>
#include <zen/utf.h>
#include <zen/thread.h>
#include <zen/file_io.h>
diff --git a/wx+/image_tools.cpp b/wx+/image_tools.cpp
index e95797ca..4dfa7b30 100644
--- a/wx+/image_tools.cpp
+++ b/wx+/image_tools.cpp
@@ -8,6 +8,8 @@
#include <zen/string_tools.h>
#include <zen/scope_guard.h>
#include <wx/app.h>
+#include <wx/dcmemory.h>
+#include <wx+/dc.h>
#include <xBRZ/src/xbrz_tools.h>
using namespace zen;
@@ -173,7 +175,7 @@ wxImage zen::createImageFromText(const wxString& text, const wxFont& font, const
std::vector<std::pair<wxString, wxSize>> lineInfo; //text + extent
for (const wxString& line : splitCpy(text, L'\n', SplitOnEmpty::allow))
- lineInfo.emplace_back(line, line.empty() ? wxSize() : dc.GetTextExtent(line));
+ lineInfo.emplace_back(line, dc.GetTextExtent(line)); //GetTextExtent() returns (0, 0) for empty string!
//------------------------------------------------------------------------------------------------
int maxWidth = 0;
@@ -181,7 +183,7 @@ wxImage zen::createImageFromText(const wxString& text, const wxFont& font, const
for (const auto& [lineText, lineSize] : lineInfo)
{
maxWidth = std::max(maxWidth, lineSize.GetWidth());
- lineHeight = std::max(lineHeight, lineSize.GetHeight()); //wxWidgets comment "GetTextExtent will return 0 for empty string"
+ lineHeight = std::max(lineHeight, lineSize.GetHeight());
}
if (maxWidth == 0 || lineHeight == 0)
return wxNullImage;
diff --git a/wx+/image_tools.h b/wx+/image_tools.h
index 79b15e3a..8374a26f 100644
--- a/wx+/image_tools.h
+++ b/wx+/image_tools.h
@@ -9,9 +9,8 @@
#include <numeric>
#include <wx/image.h>
-#include <wx/dcmemory.h>
#include <zen/basic_math.h>
-#include <wx+/dc.h>
+#include <wx/colour.h>
namespace zen
diff --git a/wx+/popup_dlg.cpp b/wx+/popup_dlg.cpp
index 5ab17564..d6c25fc8 100644
--- a/wx+/popup_dlg.cpp
+++ b/wx+/popup_dlg.cpp
@@ -10,7 +10,7 @@
#include <wx/app.h>
#include <wx/display.h>
#include <wx/sound.h>
-#include "app_main.h"
+//#include "app_main.h"
#include "bitmap_button.h"
#include "no_flicker.h"
#include "window_layout.h"
@@ -36,7 +36,7 @@ void setBestInitialSize(wxRichTextCtrl& ctrl, const wxString& text, wxSize maxSi
const int rowGap = 0;
int maxLineWidth = 0;
- int rowHeight = 0;
+ int rowHeight = 0; //alternative: just call ctrl.GetCharHeight()!?
int rowCount = 0;
bool haveLineWrap = false;
diff --git a/wx+/popup_dlg.h b/wx+/popup_dlg.h
index cabf13f5..92a60b42 100644
--- a/wx+/popup_dlg.h
+++ b/wx+/popup_dlg.h
@@ -11,7 +11,7 @@
#include <unordered_map>
#include <zen/zstring.h>
#include <wx/window.h>
-#include <wx/bitmap.h>
+#include <wx/image.h>
#include <wx/string.h>
#include <wx/textctrl.h>
diff --git a/wx+/std_button_layout.h b/wx+/std_button_layout.h
index 86558026..9a38ec1b 100644
--- a/wx+/std_button_layout.h
+++ b/wx+/std_button_layout.h
@@ -7,7 +7,7 @@
#ifndef STD_BUTTON_LAYOUT_H_183470321478317214
#define STD_BUTTON_LAYOUT_H_183470321478317214
-#include <algorithm>
+//#include <algorithm>
#include <wx/sizer.h>
#include <wx/button.h>
#include "dc.h"
diff --git a/wx+/tooltip.cpp b/wx+/tooltip.cpp
index 14df955c..5b6b5f45 100644
--- a/wx+/tooltip.cpp
+++ b/wx+/tooltip.cpp
@@ -8,10 +8,10 @@
#include <wx/dialog.h>
#include <wx/stattext.h>
#include <wx/sizer.h>
-#include <wx/statbmp.h>
+//#include <wx/statbmp.h>
#include <wx/settings.h>
#include <wx/app.h>
-#include "image_tools.h"
+//#include "image_tools.h"
#include "bitmap_button.h"
#include "dc.h"
#include <gtk/gtk.h>
@@ -21,7 +21,7 @@ using namespace zen;
namespace
{
-const int TIP_WINDOW_OFFSET_DIP = 30;
+const int TIP_WINDOW_OFFSET_DIP = 20;
}
@@ -88,13 +88,14 @@ void Tooltip::show(const wxString& text, wxPoint mousePos, const wxImage* img)
//=> call wxWindow::Show() to "execute"
#endif
- const wxPoint newPos = wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft ?
- mousePos - wxPoint(dipToWxsize(TIP_WINDOW_OFFSET_DIP) + tipWindow_->GetSize().GetWidth(), 0) :
- mousePos + wxPoint(dipToWxsize(TIP_WINDOW_OFFSET_DIP), 0);
+ const wxPoint newPos = mousePos + wxPoint(wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft ?
+ - dipToWxsize(TIP_WINDOW_OFFSET_DIP) - tipWindow_->GetSize().GetWidth() :
+ dipToWxsize(TIP_WINDOW_OFFSET_DIP),
+ dipToWxsize(TIP_WINDOW_OFFSET_DIP));
if (newPos != tipWindow_->GetScreenPosition())
tipWindow_->Move(newPos);
- //attention!!! possible endless loop: mouse pointer must NOT be within tipWindow!
+ //caveat: possible endless loop! mouse pointer must NOT be within tipWindow!
//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())
diff --git a/wx+/window_layout.h b/wx+/window_layout.h
index 553485bd..05b9316e 100644
--- a/wx+/window_layout.h
+++ b/wx+/window_layout.h
@@ -7,8 +7,8 @@
#ifndef WINDOW_LAYOUT_H_23849632846734343234532
#define WINDOW_LAYOUT_H_23849632846734343234532
-#include <zen/basic_math.h>
-#include <wx/window.h>
+//#include <zen/basic_math.h>
+//#include <wx/window.h>
#include <wx/spinctrl.h>
#include <zen/scope_guard.h>
#include <gtk/gtk.h>
diff --git a/wx+/window_tools.h b/wx+/window_tools.h
index 19b89176..94cb2c32 100644
--- a/wx+/window_tools.h
+++ b/wx+/window_tools.h
@@ -54,6 +54,15 @@ wxTopLevelWindow* getTopLevelWindow(wxWindow* child)
even if the user is currently busy using a different app! More curiosity: this foreground focus stealing happens only during the *first* SetFocus() after app start!
It also can be avoided by changing focus back and forth with some other app after start => wxWidgets bug or Win32 feature??? */
+inline
+void setFocusIfActive(wxWindow& win) //don't steal keyboard focus when currently using a different foreground application
+{
+ if (wxTopLevelWindow* topWin = getTopLevelWindow(&win))
+ if (topWin->IsActive()) //Linux/macOS: already behaves just like ::GetForegroundWindow() on Windows!
+ win.SetFocus();
+}
+
+
struct FocusPreserver
{
FocusPreserver()
@@ -70,9 +79,7 @@ struct FocusPreserver
if (oldFocusId_ != wxID_ANY)
if (wxWindow* oldFocusWin = wxWindow::FindWindowById(oldFocusId_))
- if (wxTopLevelWindow* topWin = getTopLevelWindow(oldFocusWin))
- if (topWin->IsActive()) //Linux/macOS: already behaves just like ::GetForegroundWindow() on Windows!
- oldFocusWin->SetFocus();
+ setFocusIfActive(*oldFocusWin);
}
wxWindowID getFocusId() const { return oldFocusId_; }
bgstack15