2 * Copyright (c) 2007, Digital Signal Processing Laboratory, Universit� degli studi di Perugia (UPG), Italy
\r
3 * All rights reserved.
\r
5 * Redistribution and use in source and binary forms, with or without
\r
6 * modification, are permitted provided that the following conditions
\r
8 * 1. Redistributions of source code must retain the above copyright
\r
9 * notice, this list of conditions and the following disclaimer.
\r
10 * 2. Redistributions in binary form must reproduce the above copyright
\r
11 * notice, this list of conditions and the following disclaimer in the
\r
12 * documentation and/or other materials provided with the distribution.
\r
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
\r
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
\r
18 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
\r
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
\r
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
\r
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
24 * POSSIBILITY OF SUCH DAMAGE.
\r
26 /////////////////////////////////////////////////////////////////////////////
\r
28 // Purpose: Layout window/sash sample
\r
29 // Author: Julian Smart
\r
31 // Created: 04/01/98
\r
32 // RCS-ID: $Id: sashtest.h,v 1.5 2005/06/02 12:04:24 JS Exp $
\r
33 // Copyright: (c) Julian Smart
\r
34 // Licence: wxWindows license
\r
35 /////////////////////////////////////////////////////////////////////////////
\r
36 /////////////////////////////////////////////////////////////////////////////
\r
38 // Purpose: wxTreeCtrl sample
\r
39 // Author: Julian Smart
\r
41 // Created: 04/01/98
\r
42 // RCS-ID: $Id: treetest.h,v 1.50 2006/11/04 11:26:51 VZ Exp $
\r
43 // Copyright: (c) Julian Smart
\r
44 // Licence: wxWindows license
\r
45 /////////////////////////////////////////////////////////////////////////////
\r
46 /////////////////////////////////////////////////////////////////////////////
\r
48 // Purpose: Common dialogs demo
\r
49 // Author: Julian Smart
\r
50 // Modified by: ABX (2004) - adjustementd for conditional building
\r
51 // Created: 04/01/98
\r
52 // RCS-ID: $Id: dialogs.h,v 1.50 2006/10/08 14:12:59 VZ Exp $
\r
53 // Copyright: (c) Julian Smart
\r
54 // Licence: wxWindows license
\r
55 /////////////////////////////////////////////////////////////////////////////
\r
57 #ifndef __OPJ_VIEWER_H__
\r
58 #define __OPJ_VIEWER_H__
\r
60 // For compilers that support precompilation, includes "wx/wx.h".
\r
61 #include "wx/wxprec.h"
\r
72 #include "wx/toolbar.h"
\r
73 #include "wx/laywin.h"
\r
74 #include "wx/treectrl.h"
\r
76 #include "icon1.xpm"
\r
77 #include "icon2.xpm"
\r
78 #include "icon3.xpm"
\r
79 #include "icon4.xpm"
\r
80 #include "icon5.xpm"
\r
82 #include "wx/filedlg.h"
\r
83 #include "wx/toolbar.h"
\r
84 #include <wx/filename.h>
\r
85 #include <wx/busyinfo.h>
\r
86 #include <wx/cmdline.h>
\r
87 #include <wx/file.h>
\r
88 #include "wx/notebook.h"
\r
89 #include <wx/numdlg.h>
\r
91 #include "wx/propdlg.h"
\r
92 #include "wx/spinctrl.h"
\r
95 #include "wx/wxhtml.h"
\r
96 #include "wx/statline.h"
\r
97 #include <wx/fs_mem.h>
\r
99 #include <wx/imaglist.h>
\r
101 #include "libopenjpeg/openjpeg.h"
\r
103 #include "imagj2k.h"
\r
104 #include "imagjp2.h"
\r
105 #include "imagmj2.h"
\r
108 typedef unsigned __int64 int8byte;
\r
109 #endif // __WXMSW__
\r
112 typedef unsigned long long int8byte;
\r
113 #endif // __WXGTK__
\r
115 #define USE_GENERIC_TREECTRL 0
\r
117 #if USE_GENERIC_TREECTRL
\r
118 #include "wx/generic/treectlg.h"
\r
120 #define wxTreeCtrl wxGenericTreeCtrl
\r
121 #define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
\r
125 #define OPJ_APPLICATION wxT("OPJViewer")
\r
126 #define OPJ_APPLICATION_NAME wxT("OpenJPEG Viewer")
\r
127 #define OPJ_APPLICATION_VERSION wxT("0.2 alpha")
\r
128 #define OPJ_APPLICATION_TITLEBAR OPJ_APPLICATION_NAME wxT(" ") OPJ_APPLICATION_VERSION
\r
129 #define OPJ_APPLICATION_COPYRIGHT wxT("(C) 2007, Giuseppe Baruffa")
\r
132 #define OPJ_APPLICATION_PLATFORM wxT("Windows")
\r
136 #define OPJ_APPLICATION_PLATFORM wxT("Linux")
\r
139 #define OPJ_CANVAS_BORDER 10
\r
140 #define OPJ_CANVAS_COLOUR *wxWHITE
\r
142 class OPJDecoThread;
\r
143 class OPJParseThread;
\r
144 WX_DEFINE_ARRAY_PTR(wxThread *, wxArrayThread);
\r
145 class OPJChildFrame;
\r
147 //////////////////////////////////
\r
148 // this is our main application //
\r
149 //////////////////////////////////
\r
150 class OPJViewerApp: public wxApp
\r
152 // public methods and variables
\r
155 // class constructor
\r
156 OPJViewerApp() { m_showImages = true; m_showButtons = false; }
\r
160 void SetShowImages(bool show) { m_showImages = show; }
\r
161 bool ShowImages() const { return m_showImages; }
\r
162 void ShowCmdLine(const wxCmdLineParser& parser);
\r
164 // all the threads currently alive - as soon as the thread terminates, it's
\r
165 // removed from the array
\r
166 wxArrayThread m_deco_threads, m_parse_threads;
\r
168 // crit section protects access to all of the arrays below
\r
169 wxCriticalSection m_deco_critsect, m_parse_critsect;
\r
171 // semaphore used to wait for the threads to exit, see OPJFrame::OnQuit()
\r
172 wxSemaphore m_deco_semAllDone, m_parse_semAllDone;
\r
174 // the last exiting thread should post to m_semAllDone if this is true
\r
175 // (protected by the same m_critsect)
\r
176 bool m_deco_waitingUntilAllDone, m_parse_waitingUntilAllDone;
\r
178 // the list of all filenames written in the command line
\r
179 wxArrayString m_filelist;
\r
181 // displaying engine parameters
\r
182 int m_resizemethod;
\r
184 // decoding engine parameters
\r
185 int m_reducefactor, m_qualitylayers, m_components, m_framenum;
\r
188 int m_expcomps, m_maxtiles;
\r
191 // private methods and variables
\r
193 bool m_showImages, m_showButtons;
\r
197 DECLARE_APP(OPJViewerApp)
\r
199 ///////////////////////////////////////////
\r
200 // this canvas is used to draw the image //
\r
201 ///////////////////////////////////////////
\r
202 class OPJCanvas: public wxScrolledWindow
\r
204 // public methods and variables
\r
207 // class constructor
\r
208 OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos, const wxSize& size);
\r
210 virtual void OnDraw(wxDC& dc);
\r
211 void OnEvent(wxMouseEvent& event);
\r
212 void WriteText(const wxString& text) { wxMutexGuiEnter(); wxLogMessage(text); wxMutexGuiLeave();}
\r
213 OPJDecoThread *CreateDecoThread(void);
\r
214 OPJChildFrame *m_childframe;
\r
216 wxBitmap m_image, m_image100;
\r
217 wxFileName m_fname;
\r
220 DECLARE_EVENT_TABLE()
\r
223 ///////////////////////////////////////////////////
\r
224 // the data associated to each tree leaf or node //
\r
225 ///////////////////////////////////////////////////
\r
226 class OPJMarkerData : public wxTreeItemData
\r
228 // public methods and variables
\r
231 // class constructor
\r
232 OPJMarkerData(const wxString& desc, const wxString& fname = wxT(""), wxFileOffset start = 0, wxFileOffset length = 0) : m_desc(desc), m_filestring(fname) { m_start = start; m_length = length; }
\r
234 void ShowInfo(wxTreeCtrl *tree);
\r
235 const wxChar *GetDesc1() const { return m_desc.c_str(); }
\r
236 const wxChar *GetDesc2() const { return m_filestring.c_str(); }
\r
237 wxFileOffset m_start, m_length;
\r
239 // private methods and variables
\r
242 wxString m_filestring;
\r
246 class OPJMarkerTree : public wxTreeCtrl
\r
252 TreeCtrlIcon_FileSelected,
\r
253 TreeCtrlIcon_Folder,
\r
254 TreeCtrlIcon_FolderSelected,
\r
255 TreeCtrlIcon_FolderOpened
\r
258 OPJMarkerTree() { };
\r
259 OPJMarkerTree(wxWindow *parent, OPJChildFrame *subframe, wxFileName fname, wxString name, const wxWindowID id,
\r
260 const wxPoint& pos, const wxSize& size,
\r
262 virtual ~OPJMarkerTree(){};
\r
263 OPJParseThread *CreateParseThread(wxTreeItemId parentid = 0x00, OPJChildFrame *subframe = NULL);
\r
264 void WriteText(const wxString& text) { wxMutexGuiEnter(); wxLogMessage(text); wxMutexGuiLeave(); }
\r
266 wxFileName m_fname;
\r
267 wxTextCtrl *m_peektextCtrl;
\r
268 OPJChildFrame *m_childframe;
\r
270 /*void OnBeginDrag(wxTreeEvent& event);
\r
271 void OnBeginRDrag(wxTreeEvent& event);
\r
272 void OnEndDrag(wxTreeEvent& event);*/
\r
273 /*void OnBeginLabelEdit(wxTreeEvent& event);
\r
274 void OnEndLabelEdit(wxTreeEvent& event);*/
\r
275 /*void OnDeleteItem(wxTreeEvent& event);*/
\r
276 /*void OnContextMenu(wxContextMenuEvent& event);*/
\r
277 void OnItemMenu(wxTreeEvent& event);
\r
278 /*void OnGetInfo(wxTreeEvent& event);
\r
279 void OnSetInfo(wxTreeEvent& event);*/
\r
280 /*void OnItemExpanded(wxTreeEvent& event);*/
\r
281 void OnItemExpanding(wxTreeEvent& event);
\r
282 /*void OnItemCollapsed(wxTreeEvent& event);
\r
283 void OnItemCollapsing(wxTreeEvent& event);*/
\r
284 void OnSelChanged(wxTreeEvent& event);
\r
285 /*void OnSelChanging(wxTreeEvent& event);*/
\r
286 /*void OnTreeKeyDown(wxTreeEvent& event);*/
\r
287 /*void OnItemActivated(wxTreeEvent& event);*/
\r
288 /*void OnItemRClick(wxTreeEvent& event);*/
\r
289 /*void OnRMouseDown(wxMouseEvent& event);
\r
290 void OnRMouseUp(wxMouseEvent& event);
\r
291 void OnRMouseDClick(wxMouseEvent& event);*/
\r
292 /*void GetItemsRecursively(const wxTreeItemId& idParent,
\r
293 wxTreeItemIdValue cookie = 0);*/
\r
295 void CreateImageList(int size = 16);
\r
296 void CreateButtonsImageList(int size = 11);
\r
298 /*void AddTestItemsToTree(size_t numChildren, size_t depth);*/
\r
299 /*void DoSortChildren(const wxTreeItemId& item, bool reverse = false)
\r
300 { m_reverseSort = reverse; wxTreeCtrl::SortChildren(item); }*/
\r
301 /*void DoEnsureVisible() { if (m_lastItem.IsOk()) EnsureVisible(m_lastItem); }*/
\r
302 /*void DoToggleIcon(const wxTreeItemId& item);*/
\r
303 /*void ShowMenu(wxTreeItemId id, const wxPoint& pt);*/
\r
305 int ImageSize(void) const { return m_imageSize; }
\r
307 void SetLastItem(wxTreeItemId id) { m_lastItem = id; }
\r
310 /*virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);*/
\r
312 // is this the test item which we use in several event handlers?
\r
313 /*bool IsTestItem(const wxTreeItemId& item)
\r
315 // the test item is the first child folder
\r
316 return GetItemParent(item) == GetRootItem() && !GetPrevSibling(item);
\r
320 /*void AddItemsRecursively(const wxTreeItemId& idParent,
\r
325 void LogEvent(const wxChar *name, const wxTreeEvent& event);
\r
327 int m_imageSize; // current size of images
\r
328 bool m_reverseSort; // flag for OnCompareItems
\r
329 wxTreeItemId m_lastItem, // for OnEnsureVisible()
\r
330 m_draggedItem; // item being dragged right now
\r
332 // NB: due to an ugly wxMSW hack you _must_ use DECLARE_DYNAMIC_CLASS()
\r
333 // if you want your overloaded OnCompareItems() to be called.
\r
334 // OTOH, if you don't want it you may omit the next line - this will
\r
335 // make default (alphabetical) sorting much faster under wxMSW.
\r
336 DECLARE_DYNAMIC_CLASS(OPJMarkerTree)
\r
337 DECLARE_EVENT_TABLE()
\r
340 // this hash map stores all the trees of currently opened images, with an integer key
\r
341 WX_DECLARE_HASH_MAP(int, OPJMarkerTree*, wxIntegerHash, wxIntegerEqual, OPJMarkerTreeHash);
\r
343 // this hash map stores all the children of currently opened images, with an integer key
\r
344 WX_DECLARE_HASH_MAP(int, OPJChildFrame*, wxIntegerHash, wxIntegerEqual, OPJChildFrameHash);
\r
346 // Define a new frame
\r
347 class OPJFrame: public wxMDIParentFrame
\r
351 OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
\r
354 void OnSize(wxSizeEvent& WXUNUSED(event));
\r
355 void OnAbout(wxCommandEvent& WXUNUSED(event));
\r
356 void OnFileOpen(wxCommandEvent& WXUNUSED(event));
\r
357 void OnQuit(wxCommandEvent& WXUNUSED(event));
\r
358 void OnClose(wxCommandEvent& WXUNUSED(event));
\r
359 void OnZoom(wxCommandEvent& WXUNUSED(event));
\r
360 void OnFit(wxCommandEvent& WXUNUSED(event));
\r
361 void OnToggleBrowser(wxCommandEvent& WXUNUSED(event));
\r
362 void OnTogglePeeker(wxCommandEvent& WXUNUSED(event));
\r
363 void OnReload(wxCommandEvent& event);
\r
364 void OnSetsDeco(wxCommandEvent& event);
\r
365 void OnSashDrag(wxSashEvent& event);
\r
366 void OpenFiles(wxArrayString paths, wxArrayString filenames);
\r
367 void OnNotebook(wxNotebookEvent& event);
\r
368 void Rescale(int scale, OPJChildFrame *child);
\r
370 OPJMarkerTreeHash m_treehash;
\r
371 OPJChildFrameHash m_childhash;
\r
372 wxSashLayoutWindow* markerTreeWindow;
\r
373 wxSashLayoutWindow* loggingWindow;
\r
374 void Resize(int number);
\r
375 wxNotebook *m_bookCtrl;
\r
376 wxNotebook *m_bookCtrlbottom;
\r
377 wxTextCtrl *m_textCtrlbrowse;
\r
380 void TogStyle(int id, long flag);
\r
382 void DoSort(bool reverse = false);
\r
385 wxTextCtrl *m_textCtrl;
\r
387 void DoSetBold(bool bold = true);
\r
390 wxSashLayoutWindow* m_topWindow;
\r
391 wxSashLayoutWindow* m_leftWindow2;
\r
393 DECLARE_EVENT_TABLE()
\r
396 class OPJChildFrame: public wxMDIChildFrame
\r
399 OPJCanvas *m_canvas;
\r
400 OPJChildFrame(OPJFrame *parent, wxFileName fname, int winnumber, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
\r
401 ~OPJChildFrame(void);
\r
402 void OnActivate(wxActivateEvent& event);
\r
403 /*void OnQuit(wxCommandEvent& WXUNUSED(event));*/
\r
404 void OnClose(wxCloseEvent& event);
\r
405 void OnGotFocus(wxFocusEvent& event);
\r
406 void OnLostFocus(wxFocusEvent& event);
\r
408 wxFileName m_fname;
\r
411 unsigned long m_twidth, m_theight, m_tx, m_ty;
\r
413 DECLARE_EVENT_TABLE()
\r
416 // frame and main menu ids
\r
418 OPJFRAME_FILEEXIT = wxID_EXIT,
\r
419 OPJFRAME_HELPABOUT = wxID_ABOUT,
\r
421 OPJFRAME_FILETOGGLEB,
\r
422 OPJFRAME_FILETOGGLEP,
\r
425 OPJFRAME_VIEWRELOAD,
\r
426 OPJFRAME_FILECLOSE,
\r
429 OPJFRAME_BROWSEWIN = 10000,
\r
434 // menu and control ids
\r
437 TreeTest_Quit = wxID_EXIT,
\r
438 TreeTest_About = wxID_ABOUT,
\r
439 TreeTest_TogButtons = wxID_HIGHEST,
\r
443 TreeTest_TogHideRoot,
\r
444 TreeTest_TogRootLines,
\r
445 TreeTest_TogBorder,
\r
446 TreeTest_TogFullHighlight,
\r
447 TreeTest_SetFgColour,
\r
448 TreeTest_SetBgColour,
\r
449 TreeTest_ResetStyle,
\r
450 TreeTest_Highlight,
\r
452 TreeTest_DumpSelected,
\r
458 TreeTest_ClearBold,
\r
461 TreeTest_DeleteChildren,
\r
462 TreeTest_DeleteAll,
\r
464 TreeTest_ToggleImages,
\r
465 TreeTest_ToggleButtons,
\r
466 TreeTest_SetImageSize,
\r
467 TreeTest_ToggleSel,
\r
468 TreeTest_CollapseAndReset,
\r
469 TreeTest_EnsureVisible,
\r
471 TreeTest_InsertItem,
\r
472 TreeTest_IncIndent,
\r
473 TreeTest_DecIndent,
\r
474 TreeTest_IncSpacing,
\r
475 TreeTest_DecSpacing,
\r
476 TreeTest_ToggleIcon,
\r
479 TreeTest_SelectRoot,
\r
480 TreeTest_Ctrl = 1000,
\r
481 BOTTOM_NOTEBOOK_ID,
\r
485 class OPJDecoThread : public wxThread
\r
488 OPJDecoThread(OPJCanvas *canvas);
\r
490 // thread execution starts here
\r
491 virtual void *Entry();
\r
493 // called when the thread exits - whether it terminates normally or is
\r
494 // stopped with Delete() (but not when it is Kill()ed!)
\r
495 virtual void OnExit();
\r
497 // write something to the text control
\r
498 void WriteText(const wxString& text);
\r
502 OPJCanvas *m_canvas;
\r
505 class OPJParseThread : public wxThread
\r
508 OPJParseThread(OPJMarkerTree *tree, wxTreeItemId parentid = 0x00);
\r
510 // thread execution starts here
\r
511 virtual void *Entry();
\r
513 // called when the thread exits - whether it terminates normally or is
\r
514 // stopped with Delete() (but not when it is Kill()ed!)
\r
515 virtual void OnExit();
\r
517 // write something to the text control
\r
518 void WriteText(const wxString& text);
\r
519 void LoadFile(wxFileName fname);
\r
520 void ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOffset length, wxTreeItemId parentid);
\r
521 void ParseJP2File(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit, wxTreeItemId parentid);
\r
524 OPJMarkerTree *m_tree;
\r
525 wxTreeItemId m_parentid;
\r
528 int jpeg2000parse(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
\r
529 wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
\r
530 int box_handler_function(int boxtype, wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
\r
531 wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
\r
536 // Drag and drop files target
\r
537 class OPJDnDFile: public wxFileDropTarget
\r
540 OPJDnDFile(OPJFrame *pOwner) { m_pOwner = pOwner; }
\r
541 virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
\r
544 OPJFrame *m_pOwner;
\r
549 // Property sheet dialog
\r
550 class OPJDecoderDialog: public wxPropertySheetDialog
\r
552 DECLARE_CLASS(OPJDecoderDialog)
\r
554 OPJDecoderDialog(wxWindow* parent, int dialogType);
\r
555 ~OPJDecoderDialog();
\r
557 wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl;
\r
558 wxRadioBox* m_resizeBox;
\r
560 wxPanel* CreateMainSettingsPage(wxWindow* parent);
\r
561 wxPanel* CreatePart1SettingsPage(wxWindow* parent);
\r
562 wxPanel* CreatePart3SettingsPage(wxWindow* parent);
\r
564 void OnEnableJPWL(wxCommandEvent& event);
\r
565 wxPanel* CreatePart11SettingsPage(wxWindow* parent);
\r
566 wxSpinCtrl *m_expcompsCtrl, *m_framenumCtrl, *m_maxtilesCtrl;
\r
567 wxCheckBox *m_enablejpwlCheck;
\r
574 OPJDECO_RESMETHOD = 100,
\r
575 OPJDECO_REDUCEFACTOR,
\r
576 OPJDECO_QUALITYLAYERS,
\r
578 OPJDECO_ENABLEJPWL,
\r
584 DECLARE_EVENT_TABLE()
\r
587 #endif //__OPJ_VIEWER_H__
\r