Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  *
  14.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
  15.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  18.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  19.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  20.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  21.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  22.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  23.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  24.  * POSSIBILITY OF SUCH DAMAGE.
  25.  */
  26. /////////////////////////////////////////////////////////////////////////////
  27. // Name:        sashtest.h
  28. // Purpose:     Layout window/sash sample
  29. // Author:      Julian Smart
  30. // Modified by:
  31. // Created:     04/01/98
  32. // RCS-ID:      $Id: sashtest.h,v 1.5 2005/06/02 12:04:24 JS Exp $
  33. // Copyright:   (c) Julian Smart
  34. // Licence:     wxWindows license
  35. /////////////////////////////////////////////////////////////////////////////
  36. /////////////////////////////////////////////////////////////////////////////
  37. // Name:        treectrl.h
  38. // Purpose:     wxTreeCtrl sample
  39. // Author:      Julian Smart
  40. // Modified by:
  41. // Created:     04/01/98
  42. // RCS-ID:      $Id: treetest.h,v 1.50 2006/11/04 11:26:51 VZ Exp $
  43. // Copyright:   (c) Julian Smart
  44. // Licence:     wxWindows license
  45. /////////////////////////////////////////////////////////////////////////////
  46. /////////////////////////////////////////////////////////////////////////////
  47. // Name:        dialogs.h
  48. // Purpose:     Common dialogs demo
  49. // Author:      Julian Smart
  50. // Modified by: ABX (2004) - adjustementd for conditional building
  51. // Created:     04/01/98
  52. // RCS-ID:      $Id: dialogs.h,v 1.50 2006/10/08 14:12:59 VZ Exp $
  53. // Copyright:   (c) Julian Smart
  54. // Licence:     wxWindows license
  55. /////////////////////////////////////////////////////////////////////////////
  56.  
  57. #ifndef __OPJ_VIEWER_H__
  58. #define __OPJ_VIEWER_H__
  59.  
  60. // For compilers that support precompilation, includes "wx/wx.h".
  61. #include "wx/wxprec.h"
  62.  
  63. #ifdef __BORLANDC__
  64. #pragma hdrstop
  65. #endif
  66.  
  67. #ifndef WX_PRECOMP
  68. #include "wx/wx.h"
  69. #include "wx/mdi.h"
  70. #endif
  71.  
  72. #include "wx/toolbar.h"
  73. #include "wx/laywin.h"
  74. #include "wx/treectrl.h"
  75.  
  76. #include "icon1.xpm"
  77. #include "icon2.xpm"
  78. #include "icon3.xpm"
  79. #include "icon4.xpm"
  80. #include "icon5.xpm"
  81.  
  82. #include "wx/filedlg.h"
  83. #include "wx/toolbar.h"
  84. #include <wx/filename.h>
  85. #include <wx/busyinfo.h>
  86. #include <wx/cmdline.h>
  87. #include <wx/file.h>
  88. #include "wx/notebook.h"
  89. #include <wx/numdlg.h>
  90.  
  91. #include "wx/propdlg.h"
  92. #include "wx/spinctrl.h"
  93.  
  94. #include <wx/dnd.h>
  95. #include "wx/wxhtml.h"
  96. #include "wx/statline.h"
  97. #include <wx/fs_mem.h>
  98.  
  99. #include <wx/imaglist.h>
  100.  
  101. #include "wx/toolbar.h"
  102. #include "wx/artprov.h"
  103.  
  104. #include "libopenjpeg/openjpeg.h"
  105.  
  106. //#include "imagj2k.h"
  107. //#include "imagjp2.h"
  108. //#include "imagmj2.h"
  109. #include "imagjpeg2000.h"
  110. #ifdef USE_MXF
  111. #include "imagmxf.h"
  112. #endif // USE_MXF
  113.  
  114. #ifdef __WXMSW__
  115. typedef unsigned __int64 int8byte;
  116. #endif // __WXMSW__
  117.  
  118. #ifdef __WXGTK__
  119. typedef unsigned long long int8byte;
  120. #endif // __WXGTK__
  121.  
  122. #define USE_GENERIC_TREECTRL 0
  123. #define USE_PENCIL_ON_CANVAS 0
  124.  
  125. #if USE_GENERIC_TREECTRL
  126. #include "wx/generic/treectlg.h"
  127. #ifndef wxTreeCtrl
  128. #define wxTreeCtrl wxGenericTreeCtrl
  129. #define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
  130. #endif
  131. #endif
  132.  
  133. #define OPJ_APPLICATION             wxT("OPJViewer")
  134. #define OPJ_APPLICATION_NAME            wxT("OpenJPEG Viewer")
  135. #define OPJ_APPLICATION_VERSION         wxT("0.4 beta")
  136. #define OPJ_APPLICATION_TITLEBAR        OPJ_APPLICATION_NAME wxT(" ") OPJ_APPLICATION_VERSION
  137. #define OPJ_APPLICATION_COPYRIGHT       wxT("(C) 2007-2008, Giuseppe Baruffa")
  138. #define OPJ_APPLICATION_VENDOR      wxT("OpenJPEG")
  139.  
  140. #ifdef __WXMSW__
  141. #define OPJ_APPLICATION_PLATFORM    wxT("Windows")
  142. #endif
  143.  
  144. #ifdef __WXGTK__
  145. #define OPJ_APPLICATION_PLATFORM    wxT("Linux")
  146. #endif
  147.  
  148. #define OPJ_FRAME_WIDTH   800
  149. #define OPJ_FRAME_HEIGHT  600
  150.  
  151. #define OPJ_BROWSER_WIDTH 300
  152. #define OPJ_PEEKER_HEIGHT 130
  153.  
  154. #define OPJ_CANVAS_BORDER 10
  155. #define OPJ_CANVAS_COLOUR *wxWHITE
  156.  
  157.  
  158.  
  159. #ifdef USE_JPWL
  160.  
  161. //#define MYJPWL_MAX_NO_TILESPECS JPWL_MAX_NO_TILESPECS
  162. #define MYJPWL_MAX_NO_TILESPECS 4
  163.  
  164. #endif // USE_JPWL
  165.  
  166.  
  167. class OPJDecoThread;
  168. class OPJEncoThread;
  169. class OPJParseThread;
  170. WX_DEFINE_ARRAY_PTR(wxThread *, wxArrayThread);
  171. class OPJChildFrame;
  172.  
  173. //////////////////////////////////
  174. // this is our main application //
  175. //////////////////////////////////
  176. class OPJViewerApp: public wxApp
  177. {
  178.         // public methods and variables
  179.         public:
  180.  
  181.                 // class constructor
  182.                 OPJViewerApp() { m_showImages = true; m_showButtons = false; }
  183.  
  184.                 // other methods
  185.                 bool OnInit(void);
  186.                 int OnExit(void);
  187.                 void SetShowImages(bool show) { m_showImages = show; }
  188.                 bool ShowImages() const { return m_showImages; }
  189.                 void ShowCmdLine(const wxCmdLineParser& parser);
  190.  
  191.                 // all the threads currently alive - as soon as the thread terminates, it's
  192.                 // removed from the array
  193.                 wxArrayThread m_deco_threads, m_parse_threads, m_enco_threads;
  194.  
  195.                 // crit section protects access to all of the arrays below
  196.                 wxCriticalSection m_deco_critsect, m_parse_critsect, m_enco_critsect;
  197.  
  198.                 // semaphore used to wait for the threads to exit, see OPJFrame::OnQuit()
  199.                 wxSemaphore m_deco_semAllDone, m_parse_semAllDone, m_enco_semAllDone;
  200.  
  201.                 // the last exiting thread should post to m_semAllDone if this is true
  202.                 // (protected by the same m_critsect)
  203.                 bool m_deco_waitingUntilAllDone, m_parse_waitingUntilAllDone, m_enco_waitingUntilAllDone;
  204.  
  205.                 // the list of all filenames written in the command line
  206.                 wxArrayString m_filelist;
  207.  
  208.                 // displaying engine parameters
  209.                 int m_resizemethod;
  210.  
  211.                 // decoding engine parameters
  212.                 bool m_enabledeco, m_enableparse;
  213.                 int m_reducefactor, m_qualitylayers, m_components, m_framenum;
  214. #ifdef USE_JPWL
  215.                 bool m_enablejpwl, m_enablejpwle;
  216.                 int m_expcomps, m_maxtiles;
  217.                 int m_framewidth, m_frameheight;
  218. #endif // USE_JPWL
  219.  
  220.                 // encoding engine parameters
  221.                 wxString m_subsampling, m_origin, m_rates, m_comment, m_index, m_quality;
  222.                 wxString m_cbsize, m_prsize, m_tsize, m_torigin, m_poc;
  223.                 bool m_enablecomm, m_enableidx, m_multicomp, m_irreversible, m_enablesop, m_enableeph;
  224.                 bool m_enablebypass, m_enablereset, m_enablerestart, m_enablevsc, m_enableerterm;
  225.                 bool m_enablesegmark, m_enablepoc;
  226.                 bool m_enablequality;
  227.                 int m_resolutions, m_progression;
  228. #ifdef USE_JPWL
  229.                 int m_hprotsel[MYJPWL_MAX_NO_TILESPECS], m_pprotsel[MYJPWL_MAX_NO_TILESPECS];
  230.                 int m_htileval[MYJPWL_MAX_NO_TILESPECS], m_ptileval[MYJPWL_MAX_NO_TILESPECS],
  231.                         m_ppackval[MYJPWL_MAX_NO_TILESPECS];
  232.                 int m_sensisel[MYJPWL_MAX_NO_TILESPECS], m_stileval[MYJPWL_MAX_NO_TILESPECS];
  233. #endif // USE_JPWL
  234.  
  235.                 // some layout settings
  236.                 bool m_showtoolbar, m_showbrowser, m_showpeeker;
  237.                 int m_browserwidth, m_peekerheight;
  238.  
  239.                 // application configuration
  240.                 wxConfig *OPJconfig;
  241.  
  242.         // private methods and variables
  243.         private:
  244.                 bool m_showImages, m_showButtons;
  245.  
  246. };
  247.  
  248. DECLARE_APP(OPJViewerApp)
  249.  
  250. ///////////////////////////////////////////
  251. // this canvas is used to draw the image //
  252. ///////////////////////////////////////////
  253. class OPJCanvas: public wxScrolledWindow
  254. {
  255.         // public methods and variables
  256.         public:
  257.  
  258.                 // class constructor
  259.                 OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos, const wxSize& size);
  260.  
  261.                 virtual void OnDraw(wxDC& dc);
  262.                 void OnEvent(wxMouseEvent& event);
  263.                 void WriteText(const wxString& text) {
  264. #ifndef __WXGTK__
  265.                         wxMutexGuiEnter();
  266. #endif //__WXGTK__
  267.                         wxLogMessage(text);
  268. #ifndef __WXGTK__
  269.                         wxMutexGuiLeave();
  270. #endif //__WXGTK__
  271.                 }
  272.  
  273.                 void OnThreadSignal(wxCommandEvent& event);
  274.  
  275.                 OPJDecoThread *CreateDecoThread(void);
  276.                 OPJEncoThread *CreateEncoThread(void);
  277.  
  278.  
  279.                 OPJChildFrame *m_childframe;
  280.  
  281.                 wxBitmap  m_image, m_image100;
  282.                 wxFileName m_fname, m_savename;
  283.                 long m_zooml;
  284.  
  285.         DECLARE_EVENT_TABLE()
  286. };
  287.  
  288. ///////////////////////////////////////////////////
  289. // the data associated to each tree leaf or node //
  290. ///////////////////////////////////////////////////
  291. class OPJMarkerData : public wxTreeItemData
  292. {
  293.         // public methods and variables
  294.         public:
  295.  
  296.                 // class constructor
  297.                 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; }
  298.  
  299.                 void ShowInfo(wxTreeCtrl *tree);
  300.                 const wxChar *GetDesc1() const { return m_desc.c_str(); }
  301.                 const wxChar *GetDesc2() const { return m_filestring.c_str(); }
  302.                 wxFileOffset m_start, m_length;
  303.                 wxString m_desc;
  304.  
  305.         // private methods and variables
  306.         private:
  307.                 wxString m_filestring;
  308. };
  309.  
  310.  
  311. class OPJMarkerTree : public wxTreeCtrl
  312. {
  313. public:
  314.     enum
  315.     {
  316.         TreeCtrlIcon_File,
  317.         TreeCtrlIcon_FileSelected,
  318.         TreeCtrlIcon_Folder,
  319.         TreeCtrlIcon_FolderSelected,
  320.         TreeCtrlIcon_FolderOpened
  321.     };
  322.  
  323.     OPJMarkerTree() { };
  324.     OPJMarkerTree(wxWindow *parent, OPJChildFrame *subframe, wxFileName fname, wxString name, const wxWindowID id,
  325.                const wxPoint& pos, const wxSize& size,
  326.                long style);
  327.     virtual ~OPJMarkerTree(){};
  328.         OPJParseThread *CreateParseThread(wxTreeItemId parentid = 0x00, OPJChildFrame *subframe = NULL);
  329.     void WriteText(const wxString& text) { wxMutexGuiEnter(); wxLogMessage(text); wxMutexGuiLeave(); }
  330.  
  331.         wxFileName m_fname;
  332.         wxTextCtrl *m_peektextCtrl;
  333.         OPJChildFrame *m_childframe;
  334.  
  335.     /*void OnBeginDrag(wxTreeEvent& event);
  336.     void OnBeginRDrag(wxTreeEvent& event);
  337.     void OnEndDrag(wxTreeEvent& event);*/
  338.     /*void OnBeginLabelEdit(wxTreeEvent& event);
  339.     void OnEndLabelEdit(wxTreeEvent& event);*/
  340.     /*void OnDeleteItem(wxTreeEvent& event);*/
  341.     /*void OnContextMenu(wxContextMenuEvent& event);*/
  342.     void OnItemMenu(wxTreeEvent& event);
  343.     /*void OnGetInfo(wxTreeEvent& event);
  344.     void OnSetInfo(wxTreeEvent& event);*/
  345.     /*void OnItemExpanded(wxTreeEvent& event);*/
  346.     void OnItemExpanding(wxTreeEvent& event);
  347.     /*void OnItemCollapsed(wxTreeEvent& event);
  348.     void OnItemCollapsing(wxTreeEvent& event);*/
  349.     void OnSelChanged(wxTreeEvent& event);
  350.     /*void OnSelChanging(wxTreeEvent& event);*/
  351.     /*void OnTreeKeyDown(wxTreeEvent& event);*/
  352.     /*void OnItemActivated(wxTreeEvent& event);*/
  353.     /*void OnItemRClick(wxTreeEvent& event);*/
  354.     /*void OnRMouseDown(wxMouseEvent& event);
  355.     void OnRMouseUp(wxMouseEvent& event);
  356.     void OnRMouseDClick(wxMouseEvent& event);*/
  357.     /*void GetItemsRecursively(const wxTreeItemId& idParent,
  358.                              wxTreeItemIdValue cookie = 0);*/
  359.  
  360.     void CreateImageList(int size = 16);
  361.     void CreateButtonsImageList(int size = 11);
  362.  
  363.     /*void AddTestItemsToTree(size_t numChildren, size_t depth);*/
  364.     /*void DoSortChildren(const wxTreeItemId& item, bool reverse = false)
  365.         { m_reverseSort = reverse; wxTreeCtrl::SortChildren(item); }*/
  366.     /*void DoEnsureVisible() { if (m_lastItem.IsOk()) EnsureVisible(m_lastItem); }*/
  367.     /*void DoToggleIcon(const wxTreeItemId& item);*/
  368.     /*void ShowMenu(wxTreeItemId id, const wxPoint& pt);*/
  369.  
  370.     int ImageSize(void) const { return m_imageSize; }
  371.  
  372.     void SetLastItem(wxTreeItemId id) { m_lastItem = id; }
  373.  
  374. protected:
  375.     /*virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);*/
  376.  
  377.     // is this the test item which we use in several event handlers?
  378.     /*bool IsTestItem(const wxTreeItemId& item)
  379.     {
  380.         // the test item is the first child folder
  381.         return GetItemParent(item) == GetRootItem() && !GetPrevSibling(item);
  382.     }*/
  383.  
  384. private:
  385.     /*void AddItemsRecursively(const wxTreeItemId& idParent,
  386.                              size_t nChildren,
  387.                              size_t depth,
  388.                              size_t folder);*/
  389.  
  390.     void LogEvent(const wxChar *name, const wxTreeEvent& event);
  391.  
  392.     int          m_imageSize;               // current size of images
  393.     bool         m_reverseSort;             // flag for OnCompareItems
  394.     wxTreeItemId m_lastItem,                // for OnEnsureVisible()
  395.                  m_draggedItem;             // item being dragged right now
  396.  
  397.     // NB: due to an ugly wxMSW hack you _must_ use DECLARE_DYNAMIC_CLASS()
  398.     //     if you want your overloaded OnCompareItems() to be called.
  399.     //     OTOH, if you don't want it you may omit the next line - this will
  400.     //     make default (alphabetical) sorting much faster under wxMSW.
  401.     DECLARE_DYNAMIC_CLASS(OPJMarkerTree)
  402.     DECLARE_EVENT_TABLE()
  403. };
  404.  
  405. // this hash map stores all the trees of currently opened images, with an integer key
  406. WX_DECLARE_HASH_MAP(int, OPJMarkerTree*, wxIntegerHash, wxIntegerEqual, OPJMarkerTreeHash);
  407.  
  408. // this hash map stores all the children of currently opened images, with an integer key
  409. WX_DECLARE_HASH_MAP(int, OPJChildFrame*, wxIntegerHash, wxIntegerEqual, OPJChildFrameHash);
  410.  
  411. // Define a new frame
  412. class OPJFrame: public wxMDIParentFrame
  413. {
  414.   public:
  415.  
  416.     OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
  417.  
  418.     ~OPJFrame(void);
  419.         void OnSize(wxSizeEvent& WXUNUSED(event));
  420.     void OnAbout(wxCommandEvent& WXUNUSED(event));
  421.     void OnFileOpen(wxCommandEvent& WXUNUSED(event));
  422.     void OnFileSaveAs(wxCommandEvent& WXUNUSED(event));
  423.     void OnMemoryOpen(wxCommandEvent& WXUNUSED(event));
  424.     void OnQuit(wxCommandEvent& WXUNUSED(event));
  425.     void OnClose(wxCommandEvent& WXUNUSED(event));
  426.     void OnZoom(wxCommandEvent& WXUNUSED(event));
  427.         void OnFit(wxCommandEvent& event);
  428.         void OnToggleBrowser(wxCommandEvent& WXUNUSED(event));
  429.         void OnTogglePeeker(wxCommandEvent& WXUNUSED(event));
  430.         void OnToggleToolbar(wxCommandEvent& WXUNUSED(event));
  431.         void OnReload(wxCommandEvent& event);
  432.         void OnPrevFrame(wxCommandEvent& event);
  433.         void OnHomeFrame(wxCommandEvent& event);
  434.         void OnNextFrame(wxCommandEvent& event);
  435.         void OnLessLayers(wxCommandEvent& event);
  436.         void OnAllLayers(wxCommandEvent& event);
  437.         void OnMoreLayers(wxCommandEvent& event);
  438.         void OnLessRes(wxCommandEvent& event);
  439.         void OnFullRes(wxCommandEvent& event);
  440.         void OnMoreRes(wxCommandEvent& event);
  441.         void OnPrevComp(wxCommandEvent& event);
  442.         void OnAllComps(wxCommandEvent& event);
  443.         void OnNextComp(wxCommandEvent& event);
  444.         void OnSetsEnco(wxCommandEvent& event);
  445.         void OnSetsDeco(wxCommandEvent& event);
  446.         void OnSashDrag(wxSashEvent& event);
  447.         void OpenFiles(wxArrayString paths, wxArrayString filenames);
  448.         void SaveFile(wxArrayString paths, wxArrayString filenames);
  449.         void OnNotebook(wxNotebookEvent& event);
  450.         void Rescale(int scale, OPJChildFrame *child);
  451.         void OnThreadLogmsg(wxCommandEvent& event);
  452.  
  453.         OPJMarkerTreeHash m_treehash;
  454.         OPJChildFrameHash m_childhash;
  455.     wxSashLayoutWindow* markerTreeWindow;
  456.     wxSashLayoutWindow* loggingWindow;
  457.         wxToolBar* tool_bar;
  458.     void Resize(int number);
  459.         wxNotebook *m_bookCtrl;
  460.         wxNotebook *m_bookCtrlbottom;
  461.     wxTextCtrl *m_textCtrlbrowse;
  462.  
  463.   private:
  464.     void TogStyle(int id, long flag);
  465.  
  466.     void DoSort(bool reverse = false);
  467.  
  468.     wxPanel *m_panel;
  469.     wxTextCtrl *m_textCtrl;
  470.  
  471.     void DoSetBold(bool bold = true);
  472.  
  473. protected:
  474.     wxSashLayoutWindow* m_topWindow;
  475.     wxSashLayoutWindow* m_leftWindow2;
  476.  
  477. DECLARE_EVENT_TABLE()
  478. };
  479.  
  480. class OPJChildFrame: public wxMDIChildFrame
  481. {
  482.   public:
  483.     OPJCanvas *m_canvas;
  484.     OPJChildFrame(OPJFrame *parent, wxFileName fname, int winnumber, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
  485.     ~OPJChildFrame(void);
  486.     void OnActivate(wxActivateEvent& event);
  487.         /*void OnQuit(wxCommandEvent& WXUNUSED(event));*/
  488.         void OnClose(wxCloseEvent& event);
  489.         void OnGotFocus(wxFocusEvent& event);
  490.         void OnLostFocus(wxFocusEvent& event);
  491.     OPJFrame *m_frame;
  492.         wxFileName m_fname;
  493.         int m_winnumber;
  494.  
  495.         unsigned long  m_twidth, m_theight, m_tx, m_ty;
  496.  
  497.         DECLARE_EVENT_TABLE()
  498. };
  499.  
  500. // frame and main menu ids
  501. enum {
  502.         OPJFRAME_FILEEXIT = wxID_EXIT,
  503.         OPJFRAME_HELPABOUT = wxID_ABOUT,
  504.         OPJFRAME_FILEOPEN,
  505.         OPJFRAME_MEMORYOPEN,
  506.         OPJFRAME_FILESAVEAS,
  507.         OPJFRAME_FILETOGGLEB,
  508.         OPJFRAME_FILETOGGLEP,
  509.         OPJFRAME_FILETOGGLET,
  510.         OPJFRAME_VIEWZOOM,
  511.         OPJFRAME_VIEWFIT,
  512.         OPJFRAME_VIEWRELOAD,
  513.         OPJFRAME_VIEWPREVFRAME,
  514.         OPJFRAME_VIEWHOMEFRAME,
  515.         OPJFRAME_VIEWNEXTFRAME,
  516.         OPJFRAME_VIEWLESSLAYERS,
  517.         OPJFRAME_VIEWALLLAYERS,
  518.         OPJFRAME_VIEWMORELAYERS,
  519.         OPJFRAME_VIEWLESSRES,
  520.         OPJFRAME_VIEWFULLRES,
  521.         OPJFRAME_VIEWMORERES,
  522.         OPJFRAME_VIEWPREVCOMP,
  523.         OPJFRAME_VIEWALLCOMPS,
  524.         OPJFRAME_VIEWNEXTCOMP,
  525.         OPJFRAME_FILECLOSE,
  526.         OPJFRAME_SETSENCO,
  527.         OPJFRAME_SETSDECO,
  528.  
  529.         OPJFRAME_BROWSEWIN = 10000,
  530.         OPJFRAME_LOGWIN,
  531.         OPJFRAME_TOOLBAR,
  532.  
  533.         OPJFRAME_THREADLOGMSG,
  534.         OPJCANVAS_THREADSIGNAL
  535. };
  536.  
  537.  
  538. // menu and control ids
  539. enum
  540. {
  541.     TreeTest_Quit = wxID_EXIT,
  542.     TreeTest_About = wxID_ABOUT,
  543.     TreeTest_TogButtons = wxID_HIGHEST,
  544.     TreeTest_TogTwist,
  545.     TreeTest_TogLines,
  546.     TreeTest_TogEdit,
  547.     TreeTest_TogHideRoot,
  548.     TreeTest_TogRootLines,
  549.     TreeTest_TogBorder,
  550.     TreeTest_TogFullHighlight,
  551.     TreeTest_SetFgColour,
  552.     TreeTest_SetBgColour,
  553.     TreeTest_ResetStyle,
  554.     TreeTest_Highlight,
  555.     TreeTest_Dump,
  556.     TreeTest_DumpSelected,
  557.     TreeTest_Count,
  558.     TreeTest_CountRec,
  559.     TreeTest_Sort,
  560.     TreeTest_SortRev,
  561.     TreeTest_SetBold,
  562.     TreeTest_ClearBold,
  563.     TreeTest_Rename,
  564.     TreeTest_Delete,
  565.     TreeTest_DeleteChildren,
  566.     TreeTest_DeleteAll,
  567.     TreeTest_Recreate,
  568.     TreeTest_ToggleImages,
  569.     TreeTest_ToggleButtons,
  570.     TreeTest_SetImageSize,
  571.     TreeTest_ToggleSel,
  572.     TreeTest_CollapseAndReset,
  573.     TreeTest_EnsureVisible,
  574.     TreeTest_AddItem,
  575.     TreeTest_InsertItem,
  576.     TreeTest_IncIndent,
  577.     TreeTest_DecIndent,
  578.     TreeTest_IncSpacing,
  579.     TreeTest_DecSpacing,
  580.     TreeTest_ToggleIcon,
  581.     TreeTest_Select,
  582.     TreeTest_Unselect,
  583.     TreeTest_SelectRoot,
  584.     TreeTest_Ctrl = 1000,
  585.         BOTTOM_NOTEBOOK_ID,
  586.         LEFT_NOTEBOOK_ID
  587. };
  588.  
  589. class OPJEncoThread : public wxThread
  590. {
  591. public:
  592.     OPJEncoThread(OPJCanvas *canvas);
  593.  
  594.     // thread execution starts here
  595.     virtual void *Entry();
  596.  
  597.     // called when the thread exits - whether it terminates normally or is
  598.     // stopped with Delete() (but not when it is Kill()ed!)
  599.     virtual void OnExit();
  600.  
  601.     // write something to the text control
  602.     void WriteText(const wxString& text);
  603.  
  604. public:
  605.     unsigned m_count;
  606.     OPJCanvas *m_canvas;
  607. };
  608.  
  609. class OPJDecoThread : public wxThread
  610. {
  611. public:
  612.     OPJDecoThread(OPJCanvas *canvas);
  613.  
  614.     // thread execution starts here
  615.     virtual void *Entry();
  616.  
  617.     // called when the thread exits - whether it terminates normally or is
  618.     // stopped with Delete() (but not when it is Kill()ed!)
  619.     virtual void OnExit();
  620.  
  621.     // write something to the text control
  622.     void WriteText(const wxString& text);
  623.  
  624. public:
  625.     unsigned m_count;
  626.     OPJCanvas *m_canvas;
  627. };
  628.  
  629. class OPJParseThread : public wxThread
  630. {
  631. public:
  632.     OPJParseThread(OPJMarkerTree *tree, wxTreeItemId parentid = 0x00);
  633.  
  634.     // thread execution starts here
  635.     virtual void *Entry();
  636.  
  637.     // called when the thread exits - whether it terminates normally or is
  638.     // stopped with Delete() (but not when it is Kill()ed!)
  639.     virtual void OnExit();
  640.  
  641.     // write something to the text control
  642.     void WriteText(const wxString& text);
  643.         void LoadFile(wxFileName fname);
  644.         void ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOffset length, wxTreeItemId parentid);
  645.         void ParseJP2File(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit, wxTreeItemId parentid);
  646.  
  647.     unsigned m_count;
  648.     OPJMarkerTree *m_tree;
  649.         wxTreeItemId m_parentid;
  650.  
  651. private:
  652.         int jpeg2000parse(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
  653.                         wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
  654.         int box_handler_function(int boxtype, wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
  655.                         wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
  656.  
  657. };
  658.  
  659.  
  660. // Drag and drop files target
  661. class OPJDnDFile: public wxFileDropTarget
  662. {
  663. public:
  664.     OPJDnDFile(OPJFrame *pOwner) { m_pOwner = pOwner; }
  665.     virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
  666.  
  667. private:
  668.     OPJFrame *m_pOwner;
  669. };
  670.  
  671.  
  672.  
  673. // Property sheet dialog: encoder
  674. class OPJEncoderDialog: public wxPropertySheetDialog
  675. {
  676. DECLARE_CLASS(OPJEncoderDialog)
  677. public:
  678.     OPJEncoderDialog(wxWindow* parent, int dialogType);
  679.     ~OPJEncoderDialog();
  680.  
  681.         wxBookCtrlBase* m_settingsNotebook;
  682.  
  683.     wxPanel* CreateMainSettingsPage(wxWindow* parent);
  684.     wxPanel* CreatePart1_1SettingsPage(wxWindow* parent);
  685.     wxPanel* CreatePart1_2SettingsPage(wxWindow* parent);
  686. /*    wxPanel* CreatePart3SettingsPage(wxWindow* parent);*/
  687.         void OnEnableComm(wxCommandEvent& event);
  688.         void OnEnableIdx(wxCommandEvent& event);
  689.         void OnEnablePoc(wxCommandEvent& event);
  690.         void OnRadioQualityRate(wxCommandEvent& event);
  691. #ifdef USE_JPWL
  692.         void OnEnableJPWL(wxCommandEvent& event);
  693.         wxPanel* CreatePart11SettingsPage(wxWindow* parent);
  694.         /*wxCheckBox *m_enablejpwlCheck;*/
  695.         wxChoice *m_hprotChoice[MYJPWL_MAX_NO_TILESPECS];
  696.         wxSpinCtrl *m_htileCtrl[MYJPWL_MAX_NO_TILESPECS];
  697.         wxChoice *m_pprotChoice[MYJPWL_MAX_NO_TILESPECS];
  698.         wxSpinCtrl *m_ptileCtrl[MYJPWL_MAX_NO_TILESPECS];
  699.         wxSpinCtrl *m_ppackCtrl[MYJPWL_MAX_NO_TILESPECS];
  700.         wxChoice *m_sensiChoice[MYJPWL_MAX_NO_TILESPECS];
  701.         wxSpinCtrl *m_stileCtrl[MYJPWL_MAX_NO_TILESPECS];
  702.         void OnHprotSelect(wxCommandEvent& event);
  703.         void OnPprotSelect(wxCommandEvent& event);
  704.         void OnSensiSelect(wxCommandEvent& event);
  705. #endif // USE_JPWL
  706.  
  707.         wxTextCtrl *m_subsamplingCtrl, *m_originCtrl, *m_rateCtrl, *m_commentCtrl;
  708.         wxRadioButton *m_rateRadio, *m_qualityRadio;
  709.         wxTextCtrl *m_indexCtrl, *m_qualityCtrl, *m_cbsizeCtrl, *m_prsizeCtrl, *m_pocCtrl;
  710.         wxTextCtrl *m_tsizeCtrl, *m_toriginCtrl;
  711.         wxRadioBox *progressionBox;
  712.         wxCheckBox *m_enablecommCheck, *m_enableidxCheck, *m_mctCheck, *m_irrevCheck;
  713.         wxCheckBox *m_sopCheck, *m_ephCheck, *m_enablebypassCheck, *m_enableresetCheck,
  714.                 *m_enablerestartCheck, *m_enablevscCheck, *m_enableertermCheck, *m_enablesegmarkCheck;
  715.         wxCheckBox *m_enablepocCheck, *m_enablejpwlCheck;
  716.         wxSpinCtrl *m_resolutionsCtrl;
  717.  
  718. protected:
  719.  
  720.     enum {
  721.                 OPJENCO_ENABLEJPWL = 100,
  722.                 OPJENCO_RATEFACTOR,
  723.                 OPJENCO_RATERADIO,
  724.                 OPJENCO_QUALITYFACTOR,
  725.                 OPJENCO_QUALITYRADIO,
  726.                 OPJENCO_RESNUMBER,
  727.                 OPJENCO_CODEBLOCKSIZE,
  728.                 OPJENCO_PRECINCTSIZE,
  729.                 OPJENCO_TILESIZE,
  730.                 OPJENCO_PROGRESSION,
  731.                 OPJENCO_SUBSAMPLING,
  732.                 OPJENCO_ENABLESOP,
  733.                 OPJENCO_ENABLEEPH,
  734.                 OPJENCO_ENABLEBYPASS,
  735.                 OPJENCO_ENABLERESET,
  736.                 OPJENCO_ENABLERESTART,
  737.                 OPJENCO_ENABLEVSC,
  738.                 OPJENCO_ENABLEERTERM,
  739.                 OPJENCO_ENABLESEGMARK,
  740.                 OPJENCO_ENABLEPOC,
  741.                 OPJENCO_ROICOMP,
  742.                 OPJENCO_ROISHIFT,
  743.                 OPJENCO_IMORIG,
  744.                 OPJENCO_TILORIG,
  745.                 OPJENCO_ENABLEMCT,
  746.                 OPJENCO_ENABLEIRREV,
  747.                 OPJENCO_ENABLEINDEX,
  748.                 OPJENCO_INDEXNAME,
  749.                 OPJENCO_POCSPEC,
  750.                 OPJENCO_ENABLECOMM,
  751.                 OPJENCO_COMMENTTEXT,
  752.                 OPJENCO_HPROT,
  753.                 OPJENCO_HTILE,
  754.                 OPJENCO_PPROT,
  755.                 OPJENCO_PTILE,
  756.                 OPJENCO_PPACK,
  757.                 OPJENCO_SENSI,
  758.                 OPJENCO_STILE
  759.     };
  760.  
  761. DECLARE_EVENT_TABLE()
  762. };
  763.  
  764. // Property sheet dialog: decoder
  765. class OPJDecoderDialog: public wxPropertySheetDialog
  766. {
  767. DECLARE_CLASS(OPJDecoderDialog)
  768. public:
  769.     OPJDecoderDialog(wxWindow* parent, int dialogType);
  770.     ~OPJDecoderDialog();
  771.  
  772.         wxBookCtrlBase* m_settingsNotebook;
  773.         wxCheckBox *m_enabledecoCheck, *m_enableparseCheck;
  774.         wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl;
  775.         wxRadioBox* m_resizeBox;
  776.  
  777.         void OnEnableDeco(wxCommandEvent& event);
  778.  
  779.     wxPanel* CreateMainSettingsPage(wxWindow* parent);
  780.     wxPanel* CreatePart1SettingsPage(wxWindow* parent);
  781.     wxPanel* CreatePart3SettingsPage(wxWindow* parent);
  782. #ifdef USE_JPWL
  783.         void OnEnableJPWL(wxCommandEvent& event);
  784.     wxPanel* CreatePart11SettingsPage(wxWindow* parent);
  785.         wxSpinCtrl *m_expcompsCtrl, *m_framenumCtrl, *m_maxtilesCtrl;
  786.         wxCheckBox *m_enablejpwlCheck;
  787. #endif // USE_JPWL
  788.  
  789.  
  790. protected:
  791.  
  792.     enum {
  793.                 OPJDECO_RESMETHOD = 100,
  794.                 OPJDECO_REDUCEFACTOR,
  795.                 OPJDECO_QUALITYLAYERS,
  796.                 OPJDECO_NUMCOMPS,
  797.                 OPJDECO_ENABLEDECO,
  798.                 OPJDECO_ENABLEPARSE,
  799.                 OPJDECO_ENABLEJPWL,
  800.                 OPJDECO_EXPCOMPS,
  801.                 OPJDECO_MAXTILES,
  802.                 OPJDECO_FRAMENUM
  803.     };
  804.  
  805. DECLARE_EVENT_TABLE()
  806. };
  807.  
  808. #endif //__OPJ_VIEWER_H__
  809.  
  810.  
  811.  
  812.