NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
ImagePanel Class Reference

#include <imagepanel.hpp>

Inheritance diagram for ImagePanel:
Collaboration diagram for ImagePanel:

Public Member Functions

 ImagePanel (wxFrame *parent, wxString file, wxBitmapType format)
 ImagePanel constructor. More...
 
void paintEvent (wxPaintEvent &evt)
 Called by the system of by wxWidgets when the panel needs to be redrawn. You can also trigger this call by calling Refresh()/Update(). More...
 
void paintNow ()
 Alternatively, you can use a clientDC to paint on the panel at any time. Using this generally does not free you from catching paint events, since it is possible that e.g. the window manager throws away your drawing when the window comes to the background, and expects you will redraw it when the window comes back (by sending a paint event). More...
 
void OnSize (wxSizeEvent &event)
 Here we call refresh to tell the panel to draw itself again. So when the user resizes the image panel the image should be resized too. More...
 
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 type of DC (e.g. wxPaintDC or wxClientDC) is used. More...
 
double getRelation () const
 
wxToolBar * getToolbar ()
 
void keyPressed (wxKeyEvent &event)
 This function closes the parent frame, if the user presses the ESC key. More...
 
void OnNavigationKey (wxNavigationKeyEvent &event)
 This member function chooses the next or previous image in the file list, depending on the arrow key pressed by the user. More...
 
void OnEnter (wxMouseEvent &event)
 On enter event handler focuses this panel. More...
 
void OnFocus (wxFocusEvent &event)
 On focus event handler. More...
 
void OnLoseFocus (wxFocusEvent &event)
 On lose focus event handler. More...
 
void OnSaveAs (wxCommandEvent &event)
 This member function handles the "save as" toolbar option of the parent frame. More...
 
void OnCopy (wxCommandEvent &event)
 This member function handles the "copy" toolbar option of the parent frame. More...
 
void OnNextImage (wxCommandEvent &event)
 This member function displays the next image in the current folder. More...
 
void OnPreviousImage (wxCommandEvent &event)
 This member function displays the previous image in the current folder. More...
 

Private Member Functions

wxArrayString getFileList (const wxString &dirname)
 This method returns a list of all files in the current folder (used for iterating over all images). More...
 
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 image as a bitmap. More...
 
bool LoadNextImage (const wxFileName &filename)
 This method tries to load the desired image file and returns, whether it was successful or not. More...
 

Private Attributes

wxImage image
 
wxBitmap resized
 
wxToolBar * toptoolbar
 
wxString currentFile
 
wxFrame * parentFrame
 
int w
 
int h
 
int sized_w
 
int sized_h
 

Detailed Description

Definition at line 24 of file imagepanel.hpp.

Constructor & Destructor Documentation

◆ ImagePanel()

ImagePanel::ImagePanel ( wxFrame *  parent,
wxString  file,
wxBitmapType  format 
)

ImagePanel constructor.

Parameters
parentwxFrame*
filewxString
formatwxBitmapType

Definition at line 66 of file imagepanel.cpp.

References _guilang, date::format(), Language::get(), ID_COPYIMAGE, ID_NEXTIMAGE, ID_PREVIOUSIMAGE, ID_SAVEIMAGE, OnCopy(), OnNextImage(), OnPreviousImage(), and OnSaveAs().

Here is the call graph for this function:

Member Function Documentation

◆ getFileList()

wxArrayString ImagePanel::getFileList ( const wxString &  dirname)
private

This method returns a list of all files in the current folder (used for iterating over all images).

Parameters
dirnameconst wxString&
Returns
wxArrayString

Definition at line 163 of file imagepanel.cpp.

Referenced by OnNextImage(), and OnPreviousImage().

◆ getRelation()

double ImagePanel::getRelation ( ) const
inline

Definition at line 45 of file imagepanel.hpp.

References h, and w.

Referenced by LoadImage(), and NumeReWindow::openImage().

◆ getToolbar()

wxToolBar * ImagePanel::getToolbar ( )
inline

Definition at line 48 of file imagepanel.hpp.

References toptoolbar.

◆ keyPressed()

void ImagePanel::keyPressed ( wxKeyEvent &  event)

This function closes the parent frame, if the user presses the ESC key.

Parameters
eventwxKeyEvent&
Returns
void

Definition at line 275 of file imagepanel.cpp.

◆ LoadImage()

void ImagePanel::LoadImage ( const wxString &  filename,
wxBitmapType  format = wxBITMAP_TYPE_ANY,
bool  doUpdateFrame = true 
)
private

This method loads the specified file, updates the parent frame's size (if desired) and displays the image as a bitmap.

Parameters
filenameconst wxString&
formatwxBitmapType
doUpdateFramebool
Returns
void

Definition at line 100 of file imagepanel.cpp.

References currentFile, date::format(), getRelation(), h, image, paintNow(), parentFrame, sized_h, sized_w, and w.

Referenced by LoadNextImage().

Here is the call graph for this function:

◆ LoadNextImage()

bool ImagePanel::LoadNextImage ( const wxFileName &  filename)
private

This method tries to load the desired image file and returns, whether it was successful or not.

Parameters
filenameconst wxFileName&
Returns
bool

Definition at line 128 of file imagepanel.cpp.

References date::format(), and LoadImage().

Referenced by OnNextImage(), and OnPreviousImage().

Here is the call graph for this function:

◆ OnCopy()

void ImagePanel::OnCopy ( wxCommandEvent &  event)

This member function handles the "copy" toolbar option of the parent frame.

Parameters
eventwxCommandEvent&
Returns
void

Definition at line 381 of file imagepanel.cpp.

References image.

Referenced by ImagePanel().

◆ OnEnter()

void ImagePanel::OnEnter ( wxMouseEvent &  event)

On enter event handler focuses this panel.

Parameters
eventwxMouseEvent&
Returns
void

Definition at line 311 of file imagepanel.cpp.

◆ OnFocus()

void ImagePanel::OnFocus ( wxFocusEvent &  event)

On focus event handler.

Parameters
eventwxFocusEvent&
Returns
void

Definition at line 325 of file imagepanel.cpp.

◆ OnLoseFocus()

void ImagePanel::OnLoseFocus ( wxFocusEvent &  event)

On lose focus event handler.

Parameters
eventwxFocusEvent&
Returns
void

Definition at line 339 of file imagepanel.cpp.

◆ OnNavigationKey()

void ImagePanel::OnNavigationKey ( wxNavigationKeyEvent &  event)

This member function chooses the next or previous image in the file list, depending on the arrow key pressed by the user.

Parameters
eventwxNavigationKeyEvent&
Returns
void

Definition at line 292 of file imagepanel.cpp.

References OnNextImage(), and OnPreviousImage().

Here is the call graph for this function:

◆ OnNextImage()

void ImagePanel::OnNextImage ( wxCommandEvent &  event)

This member function displays the next image in the current folder.

Parameters
eventwxCommandEvent&
Returns
void

Definition at line 399 of file imagepanel.cpp.

References currentFile, getFileList(), and LoadNextImage().

Referenced by ImagePanel(), and OnNavigationKey().

Here is the call graph for this function:

◆ OnPreviousImage()

void ImagePanel::OnPreviousImage ( wxCommandEvent &  event)

This member function displays the previous image in the current folder.

Parameters
eventwxCommandEvent&
Returns
void

Definition at line 428 of file imagepanel.cpp.

References currentFile, getFileList(), and LoadNextImage().

Referenced by ImagePanel(), and OnNavigationKey().

Here is the call graph for this function:

◆ OnSaveAs()

void ImagePanel::OnSaveAs ( wxCommandEvent &  event)

This member function handles the "save as" toolbar option of the parent frame.

Parameters
eventwxCommandEvent&
Returns
void

Definition at line 354 of file imagepanel.cpp.

References _guilang, currentFile, Language::get(), and image.

Referenced by ImagePanel().

Here is the call graph for this function:

◆ OnSize()

void ImagePanel::OnSize ( wxSizeEvent &  event)

Here we call refresh to tell the panel to draw itself again. So when the user resizes the image panel the image should be resized too.

Parameters
eventwxSizeEvent&
Returns
void

Definition at line 259 of file imagepanel.cpp.

◆ paintEvent()

void ImagePanel::paintEvent ( wxPaintEvent &  evt)

Called by the system of by wxWidgets when the panel needs to be redrawn. You can also trigger this call by calling Refresh()/Update().

Parameters
evtwxPaintEvent&
Returns
void

Definition at line 182 of file imagepanel.cpp.

References render().

Here is the call graph for this function:

◆ paintNow()

void ImagePanel::paintNow ( )

Alternatively, you can use a clientDC to paint on the panel at any time. Using this generally does not free you from catching paint events, since it is possible that e.g. the window manager throws away your drawing when the window comes to the background, and expects you will redraw it when the window comes back (by sending a paint event).

Returns
void

Definition at line 203 of file imagepanel.cpp.

References render().

Referenced by LoadImage().

Here is the call graph for this function:

◆ render()

void ImagePanel::render ( wxDC &  dc)

Here we do the actual rendering. I put it in a separate method so that it can work no matter what type of DC (e.g. wxPaintDC or wxClientDC) is used.

Parameters
dcwxDC&
Returns
void

Definition at line 221 of file imagepanel.cpp.

References h, image, resized, sized_h, sized_w, and w.

Referenced by paintEvent(), and paintNow().

Member Data Documentation

◆ currentFile

wxString ImagePanel::currentFile
private

Definition at line 29 of file imagepanel.hpp.

Referenced by LoadImage(), OnNextImage(), OnPreviousImage(), and OnSaveAs().

◆ h

int ImagePanel::h
private

Definition at line 31 of file imagepanel.hpp.

Referenced by getRelation(), LoadImage(), and render().

◆ image

wxImage ImagePanel::image
private

Definition at line 26 of file imagepanel.hpp.

Referenced by LoadImage(), OnCopy(), OnSaveAs(), and render().

◆ parentFrame

wxFrame* ImagePanel::parentFrame
private

Definition at line 30 of file imagepanel.hpp.

Referenced by LoadImage().

◆ resized

wxBitmap ImagePanel::resized
private

Definition at line 27 of file imagepanel.hpp.

Referenced by render().

◆ sized_h

int ImagePanel::sized_h
private

Definition at line 31 of file imagepanel.hpp.

Referenced by LoadImage(), and render().

◆ sized_w

int ImagePanel::sized_w
private

Definition at line 31 of file imagepanel.hpp.

Referenced by LoadImage(), and render().

◆ toptoolbar

wxToolBar* ImagePanel::toptoolbar
private

Definition at line 28 of file imagepanel.hpp.

Referenced by getToolbar().

◆ w

int ImagePanel::w
private

Definition at line 31 of file imagepanel.hpp.

Referenced by getRelation(), LoadImage(), and render().


The documentation for this class was generated from the following files: