]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxGUIPackageBrowser2.h
=== MAJOR RELEASE ====
[bbtk.git] / kernel / src / bbtkWxGUIPackageBrowser2.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkWxGUIPackageBrowser2.h,v $
5   Language:  C++
6   Date:      $Date: 2008/04/18 12:59:16 $
7   Version:   $Revision: 1.3 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*//**
18  * \brief Short description in one line
19  * 
20  * Long description which 
21  * can span multiple lines
22  */
23 /**
24  * \file 
25  * \brief 
26  */
27 /**
28  * \class bbtk::
29  * \brief 
30  */
31
32
33 #ifdef _USE_WXWIDGETS_
34
35         
36 #ifndef __bbtkWxGUIPackageBrowser2_h__
37 #define __bbtkWxGUIPackageBrowser2_h__
38
39
40 #include "bbtkWx.h"
41
42 #include "bbtkInterpreter.h"
43 #include <wx/aui/aui.h>
44
45 #include "wx/listctrl.h"
46 // not all ports have support for EVT_CONTEXT_MENU yet, don't define
47 // USE_CONTEXT_MENU for those which don't
48 #if defined(__WXMOTIF__) || defined(__WXPM__) || defined(__WXX11__) || defined(__WXMGL__)
49     #define USE_CONTEXT_MENU 0
50 #else
51     #define USE_CONTEXT_MENU 1
52 #endif
53
54
55 namespace bbtk
56 {
57   //================================================================
58   class WxGUIPackageBrowser2;
59   //================================================================
60  
61
62   //================================================================
63   /// Abstract class which defines the callbacks invoked by WxGUIPackageBrowser2
64   class BBTK_EXPORT WxGUIPackageBrowser2User
65   {
66   public:
67     WxGUIPackageBrowser2User() {}
68     ~WxGUIPackageBrowser2User() {}
69     /// Callback invoked when the 'run' button is pressed
70     virtual void WxGUIPackageBrowser2Run() {}
71   };
72   //================================================================
73
74  
75   //================================================================
76   class WxGUIBlackBoxInfo : public wxPanel
77   {
78   public:
79     WxGUIBlackBoxInfo(wxWindow* parent);
80     ~WxGUIBlackBoxInfo();
81
82     void UpdateInfo(BlackBoxDescriptor::Pointer descr);
83     void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
84   private:
85     BlackBoxDescriptor* mDescriptor;
86     wxStaticText* mName;
87     wxStaticText* mDescription;
88     wxStaticText* mAuthor;
89     wxStaticText* mCategory;
90       
91     wxListCtrl* mInputList;
92     wxListCtrl* mOutputList;
93   } ;
94   //================================================================
95   
96   //================================================================
97   class WxGUIBlackBoxListUser
98   {
99   public:
100     WxGUIBlackBoxListUser() {}
101     virtual ~WxGUIBlackBoxListUser() {}
102     
103     // User callback when a box is selected in the list 
104     virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor::Pointer ) {}
105   };
106   //================================================================
107
108   //================================================================
109   class WxGUIBlackBoxList: public wxListCtrl
110   {
111   public:
112     WxGUIBlackBoxList(wxWindow *parent,
113                    const wxWindowID id,
114                    const wxPoint& pos,
115                    const wxSize& size,
116                    long style);
117
118     // Set the user of the object
119     void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
120
121     // add one item to the listctrl in report mode
122     void Insert(BlackBoxDescriptor::Pointer d);
123     
124     // 
125     void OnColClick(wxListEvent& event);
126     void OnColRightClick(wxListEvent& event);
127     void OnColBeginDrag(wxListEvent& event);
128     void OnColDragging(wxListEvent& event);
129     void OnColEndDrag(wxListEvent& event);
130     void OnBeginDrag(wxListEvent& event);
131     void OnBeginRDrag(wxListEvent& event);
132     void OnBeginLabelEdit(wxListEvent& event);
133     void OnEndLabelEdit(wxListEvent& event);
134     void OnDeleteItem(wxListEvent& event);
135     void OnDeleteAllItems(wxListEvent& event);
136 #if WXWIN_COMPATIBILITY_2_4
137     void OnGetInfo(wxListEvent& event);
138     void OnSetInfo(wxListEvent& event);
139 #endif
140     void OnSelected(wxListEvent& event);
141     void OnDeselected(wxListEvent& event);
142     void OnListKeyDown(wxListEvent& event);
143     void OnActivated(wxListEvent& event);
144     void OnFocused(wxListEvent& event);
145     void OnCacheHint(wxListEvent& event);
146
147     void OnChar(wxKeyEvent& event);
148
149 #if USE_CONTEXT_MENU
150     void OnContextMenu(wxContextMenuEvent& event);
151 #endif
152
153     void OnRightClick(wxMouseEvent& event);
154
155 private:
156     void ShowContextMenu(const wxPoint& pos);
157     //    wxLog *m_logOld;
158     void SetColumnImage(int col, int image);
159
160     void LogEvent(const wxListEvent& event, const wxChar *eventName);
161     void LogColEvent(const wxListEvent& event, const wxChar *eventName);
162
163     virtual wxString OnGetItemText(long item, long column) const;
164     virtual int OnGetItemColumnImage(long item, long column) const;
165     virtual wxListItemAttr *OnGetItemAttr(long item) const;
166     
167     WxGUIBlackBoxListUser* mUser;
168
169     wxListItemAttr m_attr;
170
171     //    DECLARE_NO_COPY_CLASS(WxGUIBlackBoxListCtrl)
172     DECLARE_EVENT_TABLE()
173 };
174   //================================================================
175
176   //================================================================
177   /// A package browser panel
178   class BBTK_EXPORT WxGUIPackageBrowser2 : public wxPanel,
179                                            public WxGUIBlackBoxListUser
180   {
181   public:
182     WxGUIPackageBrowser2( wxWindow *parent, 
183                          WxGUIPackageBrowser2User* user = 0 );
184     ~WxGUIPackageBrowser2();
185
186     void IncludeAll();
187     void BuildFromFactory(Factory::Pointer f);
188     void RebuildList();
189     bool IsVisible(BlackBoxDescriptor::Pointer d);
190
191     void OnFilter(wxCommandEvent&);
192  
193     // User callback when a box is selected in the list 
194     void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor::Pointer );
195
196   private:
197     wxAuiManager m_mgr;
198     WxGUIPackageBrowser2User* mUser;
199     Interpreter::Pointer mInterpreter;
200     Factory::Pointer mFactory;
201     WxGUIBlackBoxList* mBoxList;
202     WxGUIBlackBoxInfo* mBoxInfo;
203
204     wxTextCtrl* mPackageFilter;
205     wxTextCtrl* mNameFilter;
206     wxTextCtrl* mDescriptionFilter;
207     wxTextCtrl* mCategoryFilter;
208     wxTextCtrl* mInputTypeFilter;
209     wxTextCtrl* mOutputTypeFilter;
210
211    DECLARE_EVENT_TABLE()  
212   };
213   //================================================================
214
215   
216   //================================================================
217   /// Browser2 in a frame 
218   class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
219                                               //, public WxGUICommandUser
220   {
221   public:
222     WxGUIPackageBrowser2Window( wxWindow *parent, wxString title, wxSize size);
223     ~WxGUIPackageBrowser2Window();
224     //    void Open(const std::string& filename) { mBrowser2->Open(filename); }
225     //    void WxGUICommandEnter(const std::string& s);
226
227
228   private :
229     
230     WxGUIPackageBrowser2* mBrowser;
231   };
232    //================================================================
233  
234
235 } // namespace bbtk
236
237
238 #endif // __bbtkWxGUIPackageBrowser_h__
239
240 #endif //_USE_WXWIDGETS_