diff options
Diffstat (limited to 'wx+')
-rw-r--r-- | wx+/choice_enum.h | 7 | ||||
-rw-r--r-- | wx+/grid.cpp | 11 | ||||
-rw-r--r-- | wx+/grid.h | 4 | ||||
-rw-r--r-- | wx+/shell_execute.h | 12 | ||||
-rw-r--r-- | wx+/std_button_order.h | 140 | ||||
-rw-r--r-- | wx+/tooltip.cpp | 4 | ||||
-rw-r--r-- | wx+/zlib_wrap.cpp | 4 |
7 files changed, 159 insertions, 23 deletions
diff --git a/wx+/choice_enum.h b/wx+/choice_enum.h index adef88cc..f780af87 100644 --- a/wx+/choice_enum.h +++ b/wx+/choice_enum.h @@ -64,12 +64,7 @@ template <class Enum> void updateTooltipEnumVal(const EnumDescrList<Enum>& mappi - - - - - -//--------------- inline impelementation ------------------------------------------- +//--------------- impelementation ------------------------------------------- template <class Enum> void setEnumVal(const EnumDescrList<Enum>& mapping, wxChoice& ctrl, Enum value) { diff --git a/wx+/grid.cpp b/wx+/grid.cpp index a0af0671..46c0c406 100644 --- a/wx+/grid.cpp +++ b/wx+/grid.cpp @@ -20,7 +20,7 @@ #include "image_tools.h" #include "rtl.h" -#ifdef FFS_LINUX +#ifdef ZEN_LINUX #include <gtk/gtk.h> #endif @@ -939,6 +939,7 @@ public: void setCursor(size_t row, size_t compPos) { cursor = std::make_pair(row, compPos); + activeSelection.reset(); //e.g. user might search with F3 while holding down left mouse button selectionAnchor = row; } std::pair<size_t, size_t> getCursor() const { return cursor; } // (row, component position) @@ -1781,9 +1782,9 @@ void Grid::showScrollBars(Grid::ScrollBarStatus horizontal, Grid::ScrollBarStatu showScrollbarX = horizontal; showScrollbarY = vertical; -#if defined FFS_WIN || defined FFS_MAC +#if defined ZEN_WIN || defined ZEN_MAC //handled by Grid::SetScrollbar -#elif defined FFS_LINUX //get rid of scrollbars, but preserve scrolling behavior! +#elif defined ZEN_LINUX //get rid of scrollbars, but preserve scrolling behavior! //the following wxGTK approach is pretty much identical to wxWidgets 2.9 ShowScrollbars() code! auto mapStatus = [](ScrollBarStatus sbStatus) -> GtkPolicyType @@ -1834,7 +1835,7 @@ void Grid::showScrollBars(Grid::ScrollBarStatus horizontal, Grid::ScrollBarStatu */ } -#if defined FFS_WIN || defined FFS_MAC +#if defined ZEN_WIN || defined ZEN_MAC void Grid::SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh) { ScrollBarStatus sbStatus = SB_SHOW_AUTOMATIC; @@ -1866,7 +1867,7 @@ void Grid::SetScrollbar(int orientation, int position, int thumbSize, int range, #endif //get rid of scrollbars, but preserve scrolling behavior! -#ifdef FFS_WIN +#ifdef ZEN_WIN #ifdef __MINGW32__ //MinGW is clueless... #define WM_MOUSEHWHEEL 0x020E #endif @@ -204,11 +204,11 @@ private: virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size); //required since wxWidgets 2.9 if SetTargetWindow() is used -#if defined FFS_WIN || defined FFS_MAC +#if defined ZEN_WIN || defined ZEN_MAC virtual void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh); //get rid of scrollbars, but preserve scrolling behavior! #endif -#ifdef FFS_WIN +#ifdef ZEN_WIN virtual WXLRESULT MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); //support horizontal mouse wheel #endif diff --git a/wx+/shell_execute.h b/wx+/shell_execute.h index a069fdb3..8965186e 100644 --- a/wx+/shell_execute.h +++ b/wx+/shell_execute.h @@ -13,12 +13,12 @@ #include <zen/utf.h> #include <wx/msgdlg.h> -#ifdef FFS_WIN -#include <zen/last_error.h> +#ifdef ZEN_WIN +#include <zen/sys_error.h> //#include <zen/string_tools.h> #include <zen/win.h> //includes "windows.h" -#elif defined FFS_LINUX || defined FFS_MAC +#elif defined ZEN_LINUX || defined ZEN_MAC #include <zen/thread.h> #include <stdlib.h> //::system() //#include <wx/utils.h> @@ -40,7 +40,7 @@ namespace { void shellExecute(const Zstring& command, ExecutionType type = EXEC_TYPE_ASYNC) { -#ifdef FFS_WIN +#ifdef ZEN_WIN //parse commandline std::vector<std::wstring> argv; int argc = 0; @@ -74,7 +74,7 @@ void shellExecute(const Zstring& command, ExecutionType type = EXEC_TYPE_ASYNC) if (!::ShellExecuteEx(&execInfo)) //__inout LPSHELLEXECUTEINFO lpExecInfo { wxString cmdFmt = L"File: " + filename + L"\nArg: " + arguments; - wxMessageBox(_("Invalid command line:") + L"\n" + cmdFmt + L"\n\n" + getLastErrorFormatted()); + wxMessageBox(_("Invalid command line:") + L"\n" + cmdFmt + L"\n\n" + formatSystemError(L"ShellExecuteEx", getLastError())); return; } @@ -86,7 +86,7 @@ void shellExecute(const Zstring& command, ExecutionType type = EXEC_TYPE_ASYNC) ::WaitForSingleObject(execInfo.hProcess, INFINITE); } -#elif defined FFS_LINUX || defined FFS_MAC +#elif defined ZEN_LINUX || defined ZEN_MAC /* we cannot use wxExecute due to various issues: - screws up encoding on OS X for non-ASCII characters diff --git a/wx+/std_button_order.h b/wx+/std_button_order.h new file mode 100644 index 00000000..71fc2334 --- /dev/null +++ b/wx+/std_button_order.h @@ -0,0 +1,140 @@ +// ************************************************************************** +// * 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) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// ************************************************************************** + +#ifndef STD_BUTTON_ORDER_H_18347032147831732143214 +#define STD_BUTTON_ORDER_H_18347032147831732143214 + +#include <wx/sizer.h> +#include <wx/button.h> + +namespace zen +{ +struct StdButtons +{ + StdButtons() : btnYes(nullptr), btnNo(nullptr), btnCancel(nullptr) {} + StdButtons& setAffirmative (wxButton* btn) { btnYes = btn; return *this; } + StdButtons& setNegative (wxButton* btn) { btnNo = btn; return *this; } + StdButtons& setCancel (wxButton* btn) { btnCancel = btn; return *this; } + + wxButton* btnYes; + wxButton* btnNo; + wxButton* btnCancel; +}; + +void setStandardButtonOrder(wxBoxSizer& sizer, const StdButtons& buttons = StdButtons()); +//sizer width will change! => call wxWindow::Fit and wxWindow::Layout + + + + + + + + + + + +//--------------- impelementation ------------------------------------------- +inline +void setStandardButtonOrder(wxBoxSizer& sizer, const StdButtons& buttons) +{ + assert(sizer.GetOrientation() == wxHORIZONTAL); + + StdButtons buttonsTmp = buttons; + + auto detach = [&](wxButton*& btn) + { + if (btn) + { + assert(btn->GetContainingSizer() == &sizer); + if (btn->IsShown()) + { + bool rv = sizer.Detach(btn); + assert(rv); + if (!rv) + btn = nullptr; + } + else + btn = nullptr; + } + }; + + detach(buttonsTmp.btnYes); + detach(buttonsTmp.btnNo); + detach(buttonsTmp.btnCancel); + +#if defined ZEN_WIN + //Windows User Experience Interaction Guidelines: http://msdn.microsoft.com/en-us/library/windows/desktop/aa511453.aspx#sizing + const int spaceH = 6; //OK + const int spaceRimH = 10; //OK + const int spaceRimV = 8; //compromise; consider additional top row from static line; exact values: top 8, bottom 9 +#elif defined ZEN_LINUX + //GNOME Human Interface Guidelines: https://developer.gnome.org/hig-book/3.2/hig-book.html#alert-spacing + const int spaceH = 6; //OK + const int spaceRimH = 12; //OK + const int spaceRimV = 12; //OK +#elif defined ZEN_MAC + //OS X Human Interface Guidelines: http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Windows/Windows.html + const int spaceH = 14; //OK + const int spaceRimH = 20; //OK + const int spaceRimV = 11; //compromise; custom button height (of 30 pix) is considered, although the button is drawn smaller; otherwise 15 seems to have been optimal +#endif + + bool firstButtonSet = false; + auto attach = [&](wxButton* btn) + { + if (btn) + { + if (firstButtonSet) + sizer.Add(spaceH, 0); + else + firstButtonSet = true; + sizer.Add(btn, 0, wxTOP | wxBOTTOM | wxALIGN_CENTER_VERTICAL, spaceRimV); + assert(btn->GetSize().GetHeight() == 30); //see comment for OS X above + } + }; + + //set border on left considering existing items + if (sizer.GetChildren().GetCount() > 0) //for yet another retarded reason wxWidgets will have wxSizer::GetItem(0) cause an assert rather than just return nullptr as documented + if (wxSizerItem* item = sizer.GetItem(static_cast<size_t>(0))) + { + assert(item->GetBorder() <= spaceRimV); //pragmatic check: other controls in the sizer should not have a larger border + int flag = item->GetFlag(); + if (flag & wxLEFT) + { + flag &= ~wxLEFT; + item->SetFlag(flag); + } + sizer.Insert(static_cast<size_t>(0), spaceRimH, 0); + } + + sizer.Add(spaceRimH, 0); +#if defined ZEN_WIN + attach(buttonsTmp.btnYes); + attach(buttonsTmp.btnNo); + attach(buttonsTmp.btnCancel); + +#elif defined ZEN_LINUX + attach(buttonsTmp.btnNo); + attach(buttonsTmp.btnCancel); + attach(buttonsTmp.btnYes); + +#elif defined ZEN_MAC + if (buttonsTmp.btnNo) + { + attach(buttonsTmp.btnNo); + sizer.Add(42 - spaceH, 0); //OS X Human Interface Guidelines: "position it at least 24 pixels away from the “safe” buttons" -> however 42 is used in practice! + } + attach(buttonsTmp.btnCancel); + attach(buttonsTmp.btnYes); +#endif + sizer.Add(spaceRimH, 0); + + assert(buttonsTmp.btnCancel || buttonsTmp.btnYes); //OS X: there should be at least one button following the gap after the "dangerous" no-button +} +} + +#endif //STD_BUTTON_ORDER_H_18347032147831732143214 diff --git a/wx+/tooltip.cpp b/wx+/tooltip.cpp index 5dc64c90..ebf3c61c 100644 --- a/wx+/tooltip.cpp +++ b/wx+/tooltip.cpp @@ -43,7 +43,7 @@ public: this->Layout(); bSizer158->Fit(this); -#if defined FFS_WIN //prevent window stealing focus! +#if defined ZEN_WIN //prevent window stealing focus! Disable(); //= dark/grey text and image on Linux; no visible difference on OS X #endif } @@ -92,7 +92,7 @@ void Tooltip::hide() { if (tipWindow) { -#ifdef FFS_LINUX +#ifdef ZEN_LINUX //on wxGTK the tooltip is sometimes not shown again after it was hidden: e.g. drag-selection on middle grid tipWindow->Destroy(); //apply brute force: tipWindow = nullptr; // diff --git a/wx+/zlib_wrap.cpp b/wx+/zlib_wrap.cpp index cfa0f615..eccf8698 100644 --- a/wx+/zlib_wrap.cpp +++ b/wx+/zlib_wrap.cpp @@ -5,9 +5,9 @@ // ************************************************************************** #include "zlib_wrap.h" -#ifdef FFS_WIN +#ifdef ZEN_WIN #include <wx/../../src/zlib/zlib.h> //not really a "nice" place to look for a stable solution -#elif defined FFS_LINUX || defined FFS_MAC +#elif defined ZEN_LINUX || defined ZEN_MAC #include <zlib.h> //let's pray this is the same version wxWidgets is linking against! #endif |