NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
imagepanel.hpp
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 <wx/wx.h>
20#include <wx/sizer.h>
21
22#include "../../common/datastructures.h"
23
24class ImagePanel : public wxPanel
25{
26 wxImage image;
27 wxBitmap resized;
28 wxToolBar* toptoolbar;
29 wxString currentFile;
30 wxFrame* parentFrame;
32 wxArrayString getFileList(const wxString& dirname);
33 void LoadImage(const wxString& filename, wxBitmapType = wxBITMAP_TYPE_ANY, bool doUpdateFrame = true);
34 bool LoadNextImage(const wxFileName& filename);
35
36
37public:
38 ImagePanel(wxFrame* parent, wxString file, wxBitmapType format);
39
40 void paintEvent(wxPaintEvent & evt);
41 void paintNow();
42 void OnSize(wxSizeEvent& event);
43 void render(wxDC& dc);
44
45 double getRelation() const
46 {return w/(double)h;}
47
48 wxToolBar* getToolbar() {return toptoolbar;}
49
50 // some useful events
51 /*
52 void mouseMoved(wxMouseEvent& event);
53 void mouseDown(wxMouseEvent& event);
54 void mouseWheelMoved(wxMouseEvent& event);
55 void mouseReleased(wxMouseEvent& event);
56 void rightClick(wxMouseEvent& event);
57 void mouseLeftWindow(wxMouseEvent& event);*/
58 void keyPressed(wxKeyEvent& event);
59 void OnNavigationKey(wxNavigationKeyEvent& event);
60 void OnEnter(wxMouseEvent& event);
61 void OnFocus(wxFocusEvent& event);
62 void OnLoseFocus(wxFocusEvent& event);
63 //void keyReleased(wxKeyEvent& event);
64
65 void OnSaveAs(wxCommandEvent& event);
66 void OnCopy(wxCommandEvent& event);
67 void OnNextImage(wxCommandEvent& event);
68 void OnPreviousImage(wxCommandEvent& event);
69
70
71 DECLARE_EVENT_TABLE()
72};
73
74
void OnCopy(wxCommandEvent &event)
This member function handles the "copy" toolbar option of the parent frame.
Definition: imagepanel.cpp:381
void OnLoseFocus(wxFocusEvent &event)
On lose focus event handler.
Definition: imagepanel.cpp:339
wxToolBar * getToolbar()
Definition: imagepanel.hpp:48
void OnSaveAs(wxCommandEvent &event)
This member function handles the "save as" toolbar option of the parent frame.
Definition: imagepanel.cpp:354
bool LoadNextImage(const wxFileName &filename)
This method tries to load the desired image file and returns, whether it was successful or not.
Definition: imagepanel.cpp:128
void paintNow()
Alternatively, you can use a clientDC to paint on the panel at any time. Using this generally does no...
Definition: imagepanel.cpp:203
void keyPressed(wxKeyEvent &event)
This function closes the parent frame, if the user presses the ESC key.
Definition: imagepanel.cpp:275
double getRelation() const
Definition: imagepanel.hpp:45
void OnSize(wxSizeEvent &event)
Here we call refresh to tell the panel to draw itself again. So when the user resizes the image panel...
Definition: imagepanel.cpp:259
ImagePanel(wxFrame *parent, wxString file, wxBitmapType format)
ImagePanel constructor.
Definition: imagepanel.cpp:66
wxImage image
Definition: imagepanel.hpp:26
void paintEvent(wxPaintEvent &evt)
Called by the system of by wxWidgets when the panel needs to be redrawn. You can also trigger this ca...
Definition: imagepanel.cpp:182
void OnEnter(wxMouseEvent &event)
On enter event handler focuses this panel.
Definition: imagepanel.cpp:311
void OnFocus(wxFocusEvent &event)
On focus event handler.
Definition: imagepanel.cpp:325
wxBitmap resized
Definition: imagepanel.hpp:27
wxString currentFile
Definition: imagepanel.hpp:29
wxToolBar * toptoolbar
Definition: imagepanel.hpp:28
void OnNavigationKey(wxNavigationKeyEvent &event)
This member function chooses the next or previous image in the file list, depending on the arrow key ...
Definition: imagepanel.cpp:292
void render(wxDC &dc)
Here we do the actual rendering. I put it in a separate method so that it can work no matter what typ...
Definition: imagepanel.cpp:221
wxFrame * parentFrame
Definition: imagepanel.hpp:30
void OnPreviousImage(wxCommandEvent &event)
This member function displays the previous image in the current folder.
Definition: imagepanel.cpp:428
void OnNextImage(wxCommandEvent &event)
This member function displays the next image in the current folder.
Definition: imagepanel.cpp:399
wxArrayString getFileList(const wxString &dirname)
This method returns a list of all files in the current folder (used for iterating over all images).
Definition: imagepanel.cpp:163
void LoadImage(const wxString &filename, wxBitmapType=wxBITMAP_TYPE_ANY, bool doUpdateFrame=true)
This method loads the specified file, updates the parent frame's size (if desired) and displays the i...
Definition: imagepanel.cpp:100
auto format(const std::locale &loc, const CharT *fmt, const Streamable &tp) -> decltype(to_stream(std::declval< std::basic_ostream< CharT > & >(), fmt, tp), std::basic_string< CharT >{})
Definition: date.h:6249