NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
viewerframe.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 "viewerframe.hpp"
20#include "../NumeReWindow.h"
21
22
23BEGIN_EVENT_TABLE(ViewerFrame, wxFrame)
24 EVT_KEY_DOWN (ViewerFrame::OnKeyDown)
25 EVT_SET_FOCUS (ViewerFrame::OnFocus)
26// EVT_ENTER_WINDOW (ViewerFrame::OnEnter)
27 EVT_CLOSE (ViewerFrame::OnClose)
29
30
38void ViewerFrame::OnKeyDown(wxKeyEvent& event)
39{
40 // connecting the ESC Key with closing the image
41 if (event.GetKeyCode() == WXK_ESCAPE)
42 this->Close();
43 event.Skip();
44}
45
46
56void ViewerFrame::OnFocus(wxFocusEvent& event)
57{
58 this->SetTransparent(wxIMAGE_ALPHA_OPAQUE);
59 if (this->GetChildren().size())
60 this->GetChildren().front()->SetFocus();
61 event.Skip();
62}
63
64
73void ViewerFrame::OnEnter(wxMouseEvent& event)
74{
75 if (this->GetChildren().size())
76 this->GetChildren().front()->SetFocus();
77 else
78 this->SetFocus();
79 event.Skip();
80}
81
82
93void ViewerFrame::OnClose(wxCloseEvent& event)
94{
95 auto children = this->GetChildren();
96
97 if (children.size())
98 {
99 for (auto iter = children.begin(); iter != children.end(); iter++)
100 static_cast<wxWindow*>(*iter)->Close();
101 }
102
103 // Unregister this window to avoid multiple
104 // destroys of this instance
105 static_cast<NumeReWindow*>(GetParent())->unregisterWindow(this);
106
107 event.Skip();
108}
109
This class is the actual NumeRe main frame. The application's logic is implemented here.
Definition: NumeReWindow.h:177
This class generalizes a set of basic floating window functionalities like being closable by pressing...
Definition: viewerframe.hpp:31
void OnEnter(wxMouseEvent &event)
This event handler get the keyboard focus, if the user enters with the mouse.
Definition: viewerframe.cpp:73
void OnFocus(wxFocusEvent &event)
This event handler passes the keyboard focus down to the first child in the window list,...
Definition: viewerframe.cpp:56
void OnClose(wxCloseEvent &event)
This event handler informs all child windows that this frame will now close. It furthermore automatic...
Definition: viewerframe.cpp:93
void OnKeyDown(wxKeyEvent &event)
This event handler closes the frame, if the user presses ESC.
Definition: viewerframe.cpp:38
END_EVENT_TABLE()