1 /*=========================================================================
3 Module: $RCSfile: bbtkWxGUIPackageBrowser2.h,v $
5 Date: $Date: 2008/10/17 08:18:15 $
6 Version: $Revision: 1.6 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief Short description in one line
35 * Long description which
36 * can span multiple lines
48 #ifdef _USE_WXWIDGETS_
51 #ifndef __bbtkWxGUIPackageBrowser2_h__
52 #define __bbtkWxGUIPackageBrowser2_h__
57 #include "bbtkInterpreter.h"
58 #include <wx/aui/aui.h>
60 #include "wx/listctrl.h"
61 // not all ports have support for EVT_CONTEXT_MENU yet, don't define
62 // USE_CONTEXT_MENU for those which don't
63 #if defined(__WXMOTIF__) || defined(__WXPM__) || defined(__WXX11__) || defined(__WXMGL__)
64 #define USE_CONTEXT_MENU 0
66 #define USE_CONTEXT_MENU 1
72 //================================================================
73 class WxGUIPackageBrowser2;
74 //================================================================
77 //================================================================
78 /// Abstract class which defines the callbacks invoked by WxGUIPackageBrowser2
79 class BBTK_EXPORT WxGUIPackageBrowser2User
82 WxGUIPackageBrowser2User() {}
83 virtual ~WxGUIPackageBrowser2User() {}
84 /// Callback invoked when the 'run' button is pressed
85 virtual void WxGUIPackageBrowser2Run() {}
87 //================================================================
90 //================================================================
91 class WxGUIBlackBoxInfo : public wxPanel
94 WxGUIBlackBoxInfo(wxWindow* parent);
97 void UpdateInfo(BlackBoxDescriptor* descr);
98 void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
100 BlackBoxDescriptor* mDescriptor;
102 wxStaticText* mDescription;
103 wxStaticText* mAuthor;
104 wxStaticText* mCategory;
106 wxListCtrl* mInputList;
107 wxListCtrl* mOutputList;
109 //================================================================
111 //================================================================
112 class WxGUIBlackBoxListUser
115 WxGUIBlackBoxListUser() {}
116 virtual ~WxGUIBlackBoxListUser() {}
118 // User callback when a box is selected in the list
119 virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
121 //================================================================
123 //================================================================
124 class WxGUIBlackBoxList: public wxListCtrl
127 WxGUIBlackBoxList(wxWindow *parent,
133 // Set the user of the object
134 void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
136 // add one item to the listctrl in report mode
137 void Insert(BlackBoxDescriptor::Pointer d);
140 void OnColClick(wxListEvent& event);
141 void OnColRightClick(wxListEvent& event);
142 void OnColBeginDrag(wxListEvent& event);
143 void OnColDragging(wxListEvent& event);
144 void OnColEndDrag(wxListEvent& event);
145 void OnBeginDrag(wxListEvent& event);
146 void OnBeginRDrag(wxListEvent& event);
147 void OnBeginLabelEdit(wxListEvent& event);
148 void OnEndLabelEdit(wxListEvent& event);
149 void OnDeleteItem(wxListEvent& event);
150 void OnDeleteAllItems(wxListEvent& event);
151 #if WXWIN_COMPATIBILITY_2_4
152 void OnGetInfo(wxListEvent& event);
153 void OnSetInfo(wxListEvent& event);
155 void OnSelected(wxListEvent& event);
156 void OnDeselected(wxListEvent& event);
157 void OnListKeyDown(wxListEvent& event);
158 void OnActivated(wxListEvent& event);
159 void OnFocused(wxListEvent& event);
160 void OnCacheHint(wxListEvent& event);
162 void OnChar(wxKeyEvent& event);
165 void OnContextMenu(wxContextMenuEvent& event);
168 void OnRightClick(wxMouseEvent& event);
171 void ShowContextMenu(const wxPoint& pos);
173 void SetColumnImage(int col, int image);
175 void LogEvent(const wxListEvent& event, const wxChar *eventName);
176 void LogColEvent(const wxListEvent& event, const wxChar *eventName);
178 virtual wxString OnGetItemText(long item, long column) const;
179 virtual int OnGetItemColumnImage(long item, long column) const;
180 virtual wxListItemAttr *OnGetItemAttr(long item) const;
182 WxGUIBlackBoxListUser* mUser;
184 wxListItemAttr m_attr;
186 // DECLARE_NO_COPY_CLASS(WxGUIBlackBoxListCtrl)
187 DECLARE_EVENT_TABLE()
189 //================================================================
191 //================================================================
192 /// A package browser panel
193 class BBTK_EXPORT WxGUIPackageBrowser2 : public wxPanel,
194 public WxGUIBlackBoxListUser
197 WxGUIPackageBrowser2( wxWindow *parent,
198 WxGUIPackageBrowser2User* user = 0 );
199 ~WxGUIPackageBrowser2();
202 void BuildFromFactory(Factory::Pointer f);
204 bool IsVisible(BlackBoxDescriptor::Pointer d);
206 void OnFilter(wxCommandEvent&);
208 // User callback when a box is selected in the list
209 void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
213 WxGUIPackageBrowser2User* mUser;
214 Interpreter::Pointer mInterpreter;
215 Factory::Pointer mFactory;
216 WxGUIBlackBoxList* mBoxList;
217 WxGUIBlackBoxInfo* mBoxInfo;
219 wxTextCtrl* mPackageFilter;
220 wxTextCtrl* mNameFilter;
221 wxTextCtrl* mDescriptionFilter;
222 wxTextCtrl* mCategoryFilter;
223 wxTextCtrl* mInputTypeFilter;
224 wxTextCtrl* mOutputTypeFilter;
225 wxTextCtrl* mInputNatureFilter;
226 wxTextCtrl* mOutputNatureFilter;
228 wxCheckBox* mShowWidgetsFilter;
229 wxCheckBox* mShowAdaptorsFilter;
230 wxCheckBox* mShowGUIsFilter;
232 DECLARE_EVENT_TABLE()
234 //================================================================
237 //================================================================
238 /// Browser2 in a frame
239 class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
240 //, public WxGUICommandUser
243 WxGUIPackageBrowser2Window( wxWindow *parent, wxString title, wxSize size);
244 ~WxGUIPackageBrowser2Window();
245 // void Open(const std::string& filename) { mBrowser2->Open(filename); }
246 // void WxGUICommandEnter(const std::string& s);
251 WxGUIPackageBrowser2* mBrowser;
253 //================================================================
259 #endif // __bbtkWxGUIPackageBrowser_h__
261 #endif //_USE_WXWIDGETS_