20#include <wx/artprov.h>
22#include <wx/clipbrd.h>
24#include "../../kernel/core/ui/language.hpp"
69 wxInitAllImageHandlers();
72 this->LoadImage(file,
format,
false);
74 toptoolbar = parentFrame->CreateToolBar(wxTB_HORIZONTAL | wxTB_FLAT);
77 toptoolbar->AddSeparator();
80 toptoolbar->Realize();
113 parentFrame->SetTitle(
"NumeRe-ImageViewer: " + wxFileName(filename).GetName());
130 if (filename.GetExt() ==
"png" || filename.GetExt() ==
"bmp" || filename.GetExt() ==
"jpg" || filename.GetExt() ==
"jpeg" || filename.GetExt() ==
"gif" || filename.GetExt() ==
"tif" || filename.GetExt() ==
"tiff")
134 if (filename.GetExt() ==
"png")
135 format = wxBITMAP_TYPE_PNG;
136 if (filename.GetExt() ==
"bmp")
137 format = wxBITMAP_TYPE_BMP;
138 if (filename.GetExt() ==
"jpg" || filename.GetExt() ==
"jpeg")
139 format = wxBITMAP_TYPE_JPEG;
140 if (filename.GetExt() ==
"gif")
141 format = wxBITMAP_TYPE_GIF;
142 if (filename.GetExt() ==
"tif" || filename.GetExt() ==
"tiff")
143 format = wxBITMAP_TYPE_TIF;
165 wxArrayString filelist;
166 if (wxDir::GetAllFiles(dirname, &filelist,
"*.*", wxDIR_FILES))
168 return wxArrayString();
224 dc.GetSize(&neww, &newh);
228 if (neww/(
double)newh >
w/(
double)
h)
240 dc.DrawBitmap(
resized, 0, 0,
false );
244 dc.DrawBitmap(
resized, 0, 0,
false );
278 if (event.GetKeyCode() == WXK_ESCAPE)
295 wxCommandEvent commandevent;
296 if (event.GetDirection())
357 wxString filterString =
"PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg";
359 wxFileDialog dlg(
this, title, fileName.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR), fileName.GetName(), filterString, wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR);
362 if(dlg.ShowModal() != wxID_OK)
367 fileName = wxFileName(dlg.GetPath());
369 image.SaveFile(fileName.GetFullName());
383 if (wxTheClipboard->Open())
385 wxTheClipboard->SetData(
new wxBitmapDataObject(wxBitmap(
image)));
386 wxTheClipboard->Close();
402 wxArrayString filelist =
getFileList(filename.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
403 if (!filelist.size())
405 int nIndex = filelist.Index(filename.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + filename.GetFullName());
406 if (nIndex == wxNOT_FOUND)
409 for (
size_t i = 1; i < filelist.size(); i++)
411 if (nIndex+i == filelist.size())
431 wxArrayString filelist =
getFileList(filename.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
432 if (!filelist.size())
434 int nIndex = filelist.Index(filename.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + filename.GetFullName());
435 if (nIndex == wxNOT_FOUND)
438 for (
int i = -1; i > -(int)filelist.size(); i--)
441 nIndex = filelist.size()-i-1;
void OnCopy(wxCommandEvent &event)
This member function handles the "copy" toolbar option of the parent frame.
void OnLoseFocus(wxFocusEvent &event)
On lose focus event handler.
void OnSaveAs(wxCommandEvent &event)
This member function handles the "save as" toolbar option of the parent frame.
bool LoadNextImage(const wxFileName &filename)
This method tries to load the desired image file and returns, whether it was successful or not.
void paintNow()
Alternatively, you can use a clientDC to paint on the panel at any time. Using this generally does no...
void keyPressed(wxKeyEvent &event)
This function closes the parent frame, if the user presses the ESC key.
double getRelation() const
void OnSize(wxSizeEvent &event)
Here we call refresh to tell the panel to draw itself again. So when the user resizes the image panel...
void paintEvent(wxPaintEvent &evt)
Called by the system of by wxWidgets when the panel needs to be redrawn. You can also trigger this ca...
void OnEnter(wxMouseEvent &event)
On enter event handler focuses this panel.
void OnFocus(wxFocusEvent &event)
On focus event handler.
void OnNavigationKey(wxNavigationKeyEvent &event)
This member function chooses the next or previous image in the file list, depending on the arrow key ...
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...
void OnPreviousImage(wxCommandEvent &event)
This member function displays the previous image in the current folder.
void OnNextImage(wxCommandEvent &event)
This member function displays the next image in the current folder.
wxArrayString getFileList(const wxString &dirname)
This method returns a list of all files in the current folder (used for iterating over all images).
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...
This class handles the internal language system and returns the language strings of the selected lang...
std::string get(const std::string &sMessage, const std::vector< std::string > &vTokens) const
This member function returns the language string for the passed language identifier and replaces all ...
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 >{})