]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxGUIPackageBrowser2.h
*** empty log message ***
[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/04 08:04:05 $
7   Version:   $Revision: 1.1 $
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
44 #include "wx/listctrl.h"
45 // not all ports have support for EVT_CONTEXT_MENU yet, don't define
46 // USE_CONTEXT_MENU for those which don't
47 #if defined(__WXMOTIF__) || defined(__WXPM__) || defined(__WXX11__) || defined(__WXMGL__)
48     #define USE_CONTEXT_MENU 0
49 #else
50     #define USE_CONTEXT_MENU 1
51 #endif
52
53
54 namespace bbtk
55 {
56   //================================================================
57   class WxGUIPackageBrowser2;
58   //================================================================
59  
60
61   //================================================================
62   /// Abstract class which defines the callbacks invoked by WxGUIPackageBrowser2
63   class BBTK_EXPORT WxGUIPackageBrowser2User
64   {
65   public:
66     WxGUIPackageBrowser2User() {}
67     ~WxGUIPackageBrowser2User() {}
68     /// Callback invoked when the 'run' button is pressed
69     virtual void WxGUIPackageBrowser2Run() {}
70   };
71   //================================================================
72
73  
74   //================================================================
75   class WxGUIBlackBoxInfo : public wxPanel
76   {
77   public:
78     WxGUIBlackBoxInfo(wxWindow* parent);
79     ~WxGUIBlackBoxInfo();
80
81     void UpdateInfo(BlackBoxDescriptor* descr);
82     void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
83   private:
84     BlackBoxDescriptor* mDescriptor;
85     wxStaticText* mName;
86     wxStaticText* mDescription;
87     wxStaticText* mAuthor;
88     wxStaticText* mCategory;
89       
90     wxListCtrl* mInputList;
91     wxListCtrl* mOutputList;
92   } ;
93   //================================================================
94   
95   //================================================================
96   class WxGUIBlackBoxListUser
97   {
98   public:
99     WxGUIBlackBoxListUser() {}
100     virtual ~WxGUIBlackBoxListUser() {}
101     
102     // User callback when a box is selected in the list 
103     virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
104   };
105   //================================================================
106
107   //================================================================
108   class WxGUIBlackBoxList: public wxListCtrl
109   {
110   public:
111     WxGUIBlackBoxList(wxWindow *parent,
112                    const wxWindowID id,
113                    const wxPoint& pos,
114                    const wxSize& size,
115                    long style);
116
117     // Set the user of the object
118     void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
119
120     // add one item to the listctrl in report mode
121     void Insert(BlackBoxDescriptor* d);
122     
123     // 
124     void OnColClick(wxListEvent& event);
125     void OnColRightClick(wxListEvent& event);
126     void OnColBeginDrag(wxListEvent& event);
127     void OnColDragging(wxListEvent& event);
128     void OnColEndDrag(wxListEvent& event);
129     void OnBeginDrag(wxListEvent& event);
130     void OnBeginRDrag(wxListEvent& event);
131     void OnBeginLabelEdit(wxListEvent& event);
132     void OnEndLabelEdit(wxListEvent& event);
133     void OnDeleteItem(wxListEvent& event);
134     void OnDeleteAllItems(wxListEvent& event);
135 #if WXWIN_COMPATIBILITY_2_4
136     void OnGetInfo(wxListEvent& event);
137     void OnSetInfo(wxListEvent& event);
138 #endif
139     void OnSelected(wxListEvent& event);
140     void OnDeselected(wxListEvent& event);
141     void OnListKeyDown(wxListEvent& event);
142     void OnActivated(wxListEvent& event);
143     void OnFocused(wxListEvent& event);
144     void OnCacheHint(wxListEvent& event);
145
146     void OnChar(wxKeyEvent& event);
147
148 #if USE_CONTEXT_MENU
149     void OnContextMenu(wxContextMenuEvent& event);
150 #endif
151
152     void OnRightClick(wxMouseEvent& event);
153
154 private:
155     void ShowContextMenu(const wxPoint& pos);
156     //    wxLog *m_logOld;
157     void SetColumnImage(int col, int image);
158
159     void LogEvent(const wxListEvent& event, const wxChar *eventName);
160     void LogColEvent(const wxListEvent& event, const wxChar *eventName);
161
162     virtual wxString OnGetItemText(long item, long column) const;
163     virtual int OnGetItemColumnImage(long item, long column) const;
164     virtual wxListItemAttr *OnGetItemAttr(long item) const;
165     
166     WxGUIBlackBoxListUser* mUser;
167
168     wxListItemAttr m_attr;
169
170     //    DECLARE_NO_COPY_CLASS(WxGUIBlackBoxListCtrl)
171     DECLARE_EVENT_TABLE()
172 };
173   //================================================================
174
175   //================================================================
176   /// A package browser panel
177   class BBTK_EXPORT WxGUIPackageBrowser2 : public wxPanel,
178                                            public WxGUIBlackBoxListUser
179   {
180   public:
181     WxGUIPackageBrowser2( wxWindow *parent, 
182                          WxGUIPackageBrowser2User* user = 0 );
183     ~WxGUIPackageBrowser2();
184
185     void IncludeAll();
186     void BuildFromFactory(Factory* f);
187     void RebuildList();
188     bool IsVisible(BlackBoxDescriptor* d);
189
190     void OnFilter(wxCommandEvent&);
191  
192     // User callback when a box is selected in the list 
193     void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
194
195   private:
196     WxGUIPackageBrowser2User* mUser;
197     Interpreter* mInterpreter;
198     Factory* mFactory;
199     WxGUIBlackBoxList* mBoxList;
200     WxGUIBlackBoxInfo* mBoxInfo;
201
202     wxTextCtrl* mPackageFilter;
203     wxTextCtrl* mNameFilter;
204     wxTextCtrl* mDescriptionFilter;
205     wxTextCtrl* mCategoryFilter;
206     wxTextCtrl* mInputTypeFilter;
207     wxTextCtrl* mOutputTypeFilter;
208
209    DECLARE_EVENT_TABLE()  
210   };
211   //================================================================
212
213   
214   //================================================================
215   /// Browser2 in a frame 
216   class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
217                                               //, public WxGUICommandUser
218   {
219   public:
220     WxGUIPackageBrowser2Window( wxWindow *parent, wxString title, wxSize size);
221     ~WxGUIPackageBrowser2Window();
222     //    void Open(const std::string& filename) { mBrowser2->Open(filename); }
223     //    void WxGUICommandEnter(const std::string& s);
224
225
226   private :
227     
228     WxGUIPackageBrowser2* mBrowser;
229   };
230    //================================================================
231  
232
233 } // namespace bbtk
234
235
236 #endif // __bbtkWxGUIPackageBrowser_h__
237
238 #endif //_USE_WXWIDGETS_