NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
viewerbook.cpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2017 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#include "viewerbook.hpp"
20
21BEGIN_EVENT_TABLE(ViewerBook, wxAuiNotebook)
22 EVT_AUINOTEBOOK_DRAG_MOTION (-1, ViewerBook::OnTabMove)
24
25
26
35void ViewerBook::OnTabMove(wxAuiNotebookEvent& event)
36{
37 int tab = GetTabFromPoint(wxGetMousePosition());
38
39 if (tab != wxNOT_FOUND)
40 ChangeSelection(tab);
41
42 event.Skip();
43}
44
45
56int ViewerBook::GetTabFromPoint(const wxPoint& pt)
57{
58 wxPoint client_pt = ScreenToClient(pt);
59 wxAuiTabCtrl* tabCtrl = GetTabCtrlFromPoint(client_pt);
60
61 if (!tabCtrl)
62 {
63 return wxNOT_FOUND;
64 }
65
66 wxPoint tl = tabCtrl->GetScreenRect().GetTopLeft();
67 wxWindow* win;
68 bool success = tabCtrl->TabHitTest(pt.x-tl.x, pt.y-tl.y, &win);
69
70 if (!success)
71 return wxNOT_FOUND;
72
73 return m_tabs.GetIdxFromWindow(win);
74}
75
void OnTabMove(wxAuiNotebookEvent &event)
This event handler fixes the issue that the control does not correctly update the selected page durin...
Definition: viewerbook.cpp:35
int GetTabFromPoint(const wxPoint &pt)
Returns the tab at the defined absolute coordinates. Actually more or less the same than the generic ...
Definition: viewerbook.cpp:56
END_EVENT_TABLE()