summaryrefslogtreecommitdiff
path: root/wx+
diff options
context:
space:
mode:
Diffstat (limited to 'wx+')
-rw-r--r--wx+/bitmap_button.h6
-rw-r--r--wx+/create_pch.cpp8
-rw-r--r--wx+/grid.cpp64
-rw-r--r--wx+/grid.h2
-rw-r--r--wx+/image_resources.cpp10
-rw-r--r--wx+/mouse_move_dlg.cpp76
-rw-r--r--wx+/mouse_move_dlg.h32
-rw-r--r--wx+/pch.h103
-rw-r--r--wx+/popup_dlg.cpp5
-rw-r--r--wx+/toggle_button.h3
10 files changed, 66 insertions, 243 deletions
diff --git a/wx+/bitmap_button.h b/wx+/bitmap_button.h
index 5674f66b..4e5adb87 100644
--- a/wx+/bitmap_button.h
+++ b/wx+/bitmap_button.h
@@ -74,7 +74,13 @@ inline
void setImage(wxBitmapButton& button, const wxBitmap& bmp)
{
if (!isEqual(button.GetBitmapLabel(), bmp))
+ {
button.SetBitmapLabel(bmp);
+
+ //wxWidgets excels at screwing up consistently once again:
+ //the first call to SetBitmapLabel() *implicitly* sets the disabled bitmap, too, subsequent calls, DON'T!
+ button.SetBitmapDisabled(bmp.ConvertToDisabled()); //inefficiency: wxBitmap::ConvertToDisabled() implicitly converts to wxImage!
+ }
}
}
diff --git a/wx+/create_pch.cpp b/wx+/create_pch.cpp
deleted file mode 100644
index be54115f..00000000
--- a/wx+/create_pch.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// **************************************************************************
-// * 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 *
-// **************************************************************************
-
-//dummy file for Visual Studio to compile precompiled header:
-//associating pch with any other cpp file will trigger a full pch rebuild each time code is changed! \ No newline at end of file
diff --git a/wx+/grid.cpp b/wx+/grid.cpp
index 95baaf3b..30192548 100644
--- a/wx+/grid.cpp
+++ b/wx+/grid.cpp
@@ -57,6 +57,8 @@ const wxColor COLOR_LABEL_GRADIENT_FROM_FOCUS = COLOR_LABEL_GRADIENT_FROM;
const wxColor COLOR_LABEL_GRADIENT_TO_FOCUS = getColorSelectionGradientFrom();
const wxColor colorGridLine = wxColour(192, 192, 192); //light grey
+
+const bool fillGapAfterColumns = true; //draw rows/column label to fill full window width; may become an instance variable some time?
}
//----------------------------------------------------------------------------------------------------------------
@@ -246,7 +248,7 @@ public:
Connect(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(SubWindow::onEraseBackGround), nullptr, this);
//SetDoubleBuffered(true); slow as hell!
-
+
SetBackgroundStyle(wxBG_STYLE_PAINT);
Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(SubWindow::onFocus), nullptr, this);
@@ -333,8 +335,14 @@ private:
On OS X there is no such propagation! => we need a redirection (the same wxGrid implements)
*/
- if (!sendEventNow(event))
- event.Skip();
+
+ //new wxWidgets 3.0 screw-up for GTK2: wxScrollHelperEvtHandler::ProcessEvent() ignores wxEVT_MOUSEWHEEL events
+ //thereby breaking the scenario of redirection to parent we need here (but also breaking their very own wxGrid sample)
+ //=> call wxScrolledWindow mouse wheel handler directly
+ parent_.HandleOnMouseWheel(event);
+
+ //if (!sendEventNow(event))
+ // event.Skip();
}
void onPaintEvent(wxPaintEvent& event)
@@ -627,11 +635,25 @@ private:
const int width = it->width_; //don't use unsigned for calculations!
if (labelAreaTL.x > rect.GetRight())
- return; //done
+ return; //done, rect is fully covered
if (labelAreaTL.x + width > rect.x)
drawColumnLabel(dc, wxRect(labelAreaTL, wxSize(width, colLabelHeight)), col, it->type_);
labelAreaTL.x += width;
}
+ if (labelAreaTL.x > rect.GetRight())
+ return; //done, rect is fully covered
+
+ //fill gap after columns and cover full width
+ if (fillGapAfterColumns)
+ {
+ int totalWidth = 0;
+ for (const ColumnWidth& cw : absWidths)
+ totalWidth += cw.width_;
+ const int clientWidth = GetClientSize().GetWidth(); //need reliable, stable width in contrast to rect.width
+
+ if (totalWidth < clientWidth)
+ drawColumnLabel(dc, wxRect(labelAreaTL, wxSize(clientWidth - totalWidth, colLabelHeight)), absWidths.size(), DUMMY_COLUMN_TYPE);
+ }
}
void drawColumnLabel(wxDC& dc, const wxRect& rect, size_t col, ColumnType colType)
@@ -672,10 +694,10 @@ private:
{
if (!event.LeftDClick()) //double-clicks never seem to arrive here; why is this checked at all???
if (Opt<int> colWidth = refParent().getColWidth(action->col))
- activeResizing.reset(new ColumnResizing(*this, action->col, *colWidth, event.GetPosition().x));
+ activeResizing = make_unique<ColumnResizing>(*this, action->col, *colWidth, event.GetPosition().x);
}
else //a move or single click
- activeMove.reset(new ColumnMove(*this, action->col, event.GetPosition().x));
+ activeMove = make_unique<ColumnMove>(*this, action->col, event.GetPosition().x);
}
event.Skip();
}
@@ -769,7 +791,7 @@ private:
{
if (const Opt<ColAction> action = refParent().clientPosToColumnAction(event.GetPosition()))
{
- highlightCol.reset(new size_t(action->col));
+ highlightCol = make_unique<size_t>(action->col);
if (action->wantResize)
SetCursor(wxCURSOR_SIZEWE); //set window-local only! :)
@@ -811,7 +833,13 @@ private:
{
if (const Opt<ColumnType> colType = refParent().colToType(action->col))
sendEventNow(GridClickEvent(EVENT_GRID_COL_LABEL_MOUSE_RIGHT, event, -1, *colType)); //notify right click
+ else assert(false);
}
+ else
+ //notify right click (on free space after last column)
+ if (fillGapAfterColumns)
+ sendEventNow(GridClickEvent(EVENT_GRID_COL_LABEL_MOUSE_RIGHT, event, -1, DUMMY_COLUMN_TYPE));
+
event.Skip();
}
@@ -878,9 +906,13 @@ private:
std::vector<ColumnWidth> absWidths = refParent().getColWidths(); //resolve stretched widths
{
- int totalWidth = 0;
+ int totalRowWidth = 0;
for (const ColumnWidth& cw : absWidths)
- totalWidth += cw.width_;
+ totalRowWidth += cw.width_;
+
+ //fill gap after columns and cover full width
+ if (fillGapAfterColumns)
+ totalRowWidth = std::max(totalRowWidth, GetClientSize().GetWidth());
if (auto prov = refParent().getDataProvider())
{
@@ -889,7 +921,7 @@ private:
//draw background lines
for (int row = rowFirst; row < rowLast; ++row)
{
- const wxRect rowRect(cellAreaTL + wxPoint(0, row * rowHeight), wxSize(totalWidth, rowHeight));
+ const wxRect rowRect(cellAreaTL + wxPoint(0, row * rowHeight), wxSize(totalRowWidth, rowHeight));
RecursiveDcClipper dummy3(dc, rowRect);
prov->renderRowBackgound(dc, rowRect, row, refParent().IsThisEnabled(), drawAsSelected(row));
}
@@ -960,15 +992,15 @@ private:
if (!event.RightDown() || !refParent().isSelected(row)) //do NOT start a new selection if user right-clicks on a selected area!
{
if (event.ControlDown())
- activeSelection.reset(new MouseSelection(*this, row, !refParent().isSelected(row)));
+ activeSelection = make_unique<MouseSelection>(*this, row, !refParent().isSelected(row));
else if (event.ShiftDown())
{
- activeSelection.reset(new MouseSelection(*this, selectionAnchor, true));
+ activeSelection = make_unique<MouseSelection>(*this, selectionAnchor, true);
refParent().clearSelection(ALLOW_GRID_EVENT);
}
else
{
- activeSelection.reset(new MouseSelection(*this, row, true));
+ activeSelection = make_unique<MouseSelection>(*this, row, true);
refParent().clearSelection(ALLOW_GRID_EVENT);
}
}
@@ -1236,7 +1268,7 @@ Grid::Grid(wxWindow* parent,
Connect(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(Grid::onEraseBackGround), nullptr, this);
Connect(wxEVT_SIZE, wxSizeEventHandler (Grid::onSizeEvent ), nullptr, this);
- Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(Grid::onKeyDown), nullptr, this);
+ Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(Grid::onKeyDown), nullptr, this);
}
@@ -1414,7 +1446,7 @@ void Grid::onKeyDown(wxKeyEvent& event)
keyCode = WXK_NUMPAD_LEFT;
}
- const ptrdiff_t rowCount = getRowCount();
+ const ptrdiff_t rowCount = getRowCount();
const ptrdiff_t cursorRow = mainWin_->getCursor();
auto moveCursorTo = [&](ptrdiff_t row)
@@ -1916,7 +1948,7 @@ void Grid::setGridCursor(size_t row)
void Grid::selectWithCursor(ptrdiff_t row)
{
const size_t anchorRow = mainWin_->getAnchor();
-
+
mainWin_->setCursor(row, anchorRow);
makeRowVisible(row);
diff --git a/wx+/grid.h b/wx+/grid.h
index aefcb549..6b6ac8a0 100644
--- a/wx+/grid.h
+++ b/wx+/grid.h
@@ -42,7 +42,7 @@ struct GridClickEvent : public wxMouseEvent
virtual wxEvent* Clone() const { return new GridClickEvent(*this); }
const ptrdiff_t row_; //-1 for invalid position, >= rowCount if out of range
- const ColumnType colType_;
+ const ColumnType colType_; //may be DUMMY_COLUMN_TYPE
};
struct GridColumnResizeEvent : public wxCommandEvent
diff --git a/wx+/image_resources.cpp b/wx+/image_resources.cpp
index 7b74c161..ba725d63 100644
--- a/wx+/image_resources.cpp
+++ b/wx+/image_resources.cpp
@@ -62,7 +62,7 @@ private:
void GlobalResources::init(const Zstring& filename)
{
- assert(bitmaps.empty() && anims.empty());
+ assert(bitmaps.empty() && anims.empty());
wxFFileInputStream input(utfCvrtTo<wxString>(filename));
if (input.IsOk()) //if not... we don't want to react too harsh here
@@ -70,12 +70,12 @@ void GlobalResources::init(const Zstring& filename)
//activate support for .png files
wxImage::AddHandler(new wxPNGHandler); //ownership passed
- wxZipInputStream resourceFile(input, wxConvUTF8);
+ wxZipInputStream streamIn(input, wxConvUTF8);
//do NOT rely on wxConvLocal! On failure shows unhelpful popup "Cannot convert from the charset 'Unknown encoding (-1)'!"
while (true)
{
- std::unique_ptr<wxZipEntry> entry(resourceFile.GetNextEntry()); //take ownership!
+ std::unique_ptr<wxZipEntry> entry(streamIn.GetNextEntry()); //take ownership!
if (!entry)
break;
@@ -83,9 +83,9 @@ void GlobalResources::init(const Zstring& filename)
//generic image loading
if (endsWith(name, L".png"))
- bitmaps.insert(std::make_pair(name, wxImage(resourceFile, wxBITMAP_TYPE_PNG)));
+ bitmaps.insert(std::make_pair(name, wxImage(streamIn, wxBITMAP_TYPE_PNG)));
else if (endsWith(name, L".gif"))
- loadAnimFromZip(resourceFile, anims[name]);
+ loadAnimFromZip(streamIn, anims[name]);
}
}
}
diff --git a/wx+/mouse_move_dlg.cpp b/wx+/mouse_move_dlg.cpp
deleted file mode 100644
index 5c2a0a97..00000000
--- a/wx+/mouse_move_dlg.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-// **************************************************************************
-// * 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 *
-// **************************************************************************
-
-#include "mouse_move_dlg.h"
-#include <vector>
-#include <zen/win.h> //includes "windows.h"
-#include <wx/stattext.h>
-#include <wx/statbmp.h>
-#include <wx/statline.h>
-#include <wx/animate.h>
-#include <wx/panel.h>
-#include <wx/gauge.h>
-#include <wx/statusbr.h>
-#include <wx/frame.h>
-#include <wx/dialog.h>
-
-using namespace zen;
-
-
-namespace
-{
-template <class Fun> inline
-void forEachChild(wxWindow& parent, Fun f)
-{
- wxWindowList& wl = parent.GetChildren();
- for (auto it = wl.begin(); it != wl.end(); ++it) //yet another wxWidgets bug keeps us from using std::for_each
- {
- wxWindow& wnd = **it;
- f(wnd);
- forEachChild(wnd, f);
- }
-}
-}
-
-MouseMoveWindow::MouseMoveWindow(wxWindow& parent, bool includeParent) : wxWindow(&parent, wxID_ANY)
-{
- wxObjectEventFunction memFunMouseDown = wxMouseEventHandler(MouseMoveWindow::LeftButtonDown); //wxWidgets macros are obviously not C++11 ready
- auto connect = [&](wxWindow& wnd)
- {
- if (dynamic_cast<wxStaticText*> (&wnd) || //redirect clicks on these "dead" controls to move dialog instead
- dynamic_cast<wxStaticBitmap*> (&wnd) ||
- dynamic_cast<wxAnimationCtrl*>(&wnd) ||
- dynamic_cast<wxGauge*> (&wnd) ||
- dynamic_cast<wxStaticLine*> (&wnd) ||
- dynamic_cast<wxStatusBar*> (&wnd) ||
- dynamic_cast<wxPanel*> (&wnd) ||
- dynamic_cast<wxFrame*> (&wnd) ||
- dynamic_cast<wxDialog*> (&wnd))
- wnd.Connect(wxEVT_LEFT_DOWN, memFunMouseDown, nullptr, this);
- };
-
- if (includeParent)
- connect(parent);
- forEachChild(parent, connect);
-
- Hide(); //this is just a dummy window so that its parent can have ownership
- Disable();
-}
-
-
-void MouseMoveWindow::LeftButtonDown(wxMouseEvent& event)
-{
- if (GetParent() && allowMove(event))
- {
- ::ReleaseCapture();
- //::SendMessage(GetHwndOf(dialogToMove_), WM_NCLBUTTONDOWN, HTCAPTION, 0);
- ::SendMessage(static_cast<HWND>(GetParent()->GetHWND()), WM_NCLBUTTONDOWN, HTCAPTION, 0);
-
- return;
- //event.Skip(); -> swallow event, to avoid other windows losing focus
- }
- event.Skip();
-}
diff --git a/wx+/mouse_move_dlg.h b/wx+/mouse_move_dlg.h
deleted file mode 100644
index 18cd38d6..00000000
--- a/wx+/mouse_move_dlg.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// **************************************************************************
-// * 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 MOUSEMOVEWINDOW_H_INCLUDED
-#define MOUSEMOVEWINDOW_H_INCLUDED
-
-#include <wx/window.h>
-
-namespace zen
-{
-/*
-move dialog by mouse-dragging contained sub-windows: just attach to parent via new in constructor:
-
-Syntax:
- new MouseMoveWindow(parent); //ownership passed to parent
-*/
-class MouseMoveWindow : public wxWindow //private wxEvtHandler
-{
-public:
- MouseMoveWindow(wxWindow& parent, bool includeParent = true); //parent including all relevant child elements
-
- virtual bool allowMove(const wxMouseEvent& event) { return true; }
-
-private:
- void LeftButtonDown(wxMouseEvent& event);
-};
-}
-
-#endif // MOUSEMOVEWINDOW_H_INCLUDED
diff --git a/wx+/pch.h b/wx+/pch.h
deleted file mode 100644
index 5bfdb6cb..00000000
--- a/wx+/pch.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// **************************************************************************
-// * 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 FFS_PRECOMPILED_HEADER
-#define FFS_PRECOMPILED_HEADER
-
-//pay attention when using this file: might cause issues!
-#ifdef NDEBUG
-#error do NOT use in release build!
-#endif
-
-//#####################################################
-
-// basic wxWidgets headers
-#ifndef WX_PRECOMP
-#define WX_PRECOMP
-#endif
-#include <wx/wxprec.h> //includes <wx/msw/wrapwin.h>
-
-//other wxWidgets headers
-#include <wx/log.h>
-#include <wx/grid.h>
-#include <wx/animate.h>
-#include <wx/app.h>
-#include <wx/arrstr.h>
-#include <wx/bitmap.h>
-#include <wx/bmpbuttn.h>
-#include <wx/button.h>
-#include <wx/checkbox.h>
-#include <wx/choice.h>
-#include <wx/clipbrd.h>
-#include <wx/cmdline.h>
-#include <wx/colour.h>
-#include <wx/config.h>
-#include <wx/dc.h>
-#include <wx/dialog.h>
-//#include <wx/dir.h> -> MSVC: avoid annoying IntelliSense error: wxZipStreamLink
-//#include <wx/zipstrm.h>
-#include <wx/dnd.h>
-#include <wx/file.h>
-#include <wx/filename.h>
-#include <wx/filepicker.h>
-#include <wx/font.h>
-#include <wx/frame.h>
-#include <wx/gauge.h>
-#include <wx/gdicmn.h>
-#include <wx/grid.h>
-#include <wx/hyperlink.h>
-#include <wx/icon.h>
-#include <wx/image.h>
-#include <wx/intl.h>
-#include <wx/log.h>
-#include <wx/menu.h>
-#include <wx/msgdlg.h>
-#include <wx/panel.h>
-#include <wx/radiobut.h>
-#include <wx/settings.h>
-#include <wx/sizer.h>
-#include <wx/statbmp.h>
-#include <wx/statbox.h>
-#include <wx/statline.h>
-#include <wx/stattext.h>
-#include <wx/stdpaths.h>
-#include <wx/stopwatch.h>
-#include <wx/stream.h>
-#include <wx/string.h>
-#include <wx/textctrl.h>
-#include <wx/thread.h>
-#include <wx/utils.h>
-#include <wx/wfstream.h>
-#include <wx/scrolwin.h>
-#include <wx/notebook.h>
-#include <wx/help.h>
-#include <wx/event.h>
-
-//STL headers
-#include <string>
-#include <vector>
-#include <set>
-#include <map>
-#include <queue>
-#include <deque>
-#include <stack>
-#include <list>
-#include <algorithm>
-#include <functional>
-#include <iterator>
-#include <numeric>
-#include <memory>
-#include <utility>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <new>
-#include <stdexcept>
-
-//Boost
-
-
-#endif //FFS_PRECOMPILED_HEADER
diff --git a/wx+/popup_dlg.cpp b/wx+/popup_dlg.cpp
index d7d1960e..66b3117e 100644
--- a/wx+/popup_dlg.cpp
+++ b/wx+/popup_dlg.cpp
@@ -6,12 +6,15 @@
#include "popup_dlg.h"
#include <wx/app.h>
-#include <wx+/mouse_move_dlg.h>
#include <wx+/std_button_order.h>
#include <wx+/font_size.h>
#include <wx+/image_resources.h>
#include "popup_dlg_generated.h"
+#ifdef ZEN_WIN
+#include <wx+/mouse_move_dlg.h>
+#endif
+
using namespace zen;
namespace
diff --git a/wx+/toggle_button.h b/wx+/toggle_button.h
index 858082d3..e532d9d8 100644
--- a/wx+/toggle_button.h
+++ b/wx+/toggle_button.h
@@ -8,6 +8,7 @@
#define TOGGLEBUTTON_H_INCLUDED
#include <wx/bmpbuttn.h>
+#include <wx+/bitmap_button.h>
class ToggleButton : public wxBitmapButton
{
@@ -68,7 +69,7 @@ inline
void ToggleButton::setActive(bool value)
{
active = value;
- SetBitmapLabel(active ? activeBmp_ : inactiveBmp_);
+ zen::setImage(*this, active ? activeBmp_ : inactiveBmp_);
}
#endif // TOGGLEBUTTON_H_INCLUDED
bgstack15