1 /*=========================================================================
3 Module: $RCSfile: bbtkWxGUIPackageBrowser2.h,v $
5 Date: $Date: 2010/10/11 06:30:33 $
6 Version: $Revision: 1.9 $
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>
62 #include <wx/dataobj.h>
63 #include "wx/listctrl.h"
64 // not all ports have support for EVT_CONTEXT_MENU yet, don't define
65 // USE_CONTEXT_MENU for those which don't
66 #if defined(__WXMOTIF__) || defined(__WXPM__) || defined(__WXX11__) || defined(__WXMGL__)
67 #define USE_CONTEXT_MENU 0
69 #define USE_CONTEXT_MENU 1
75 //================================================================
76 class WxGUIPackageBrowser2;
77 //================================================================
80 //================================================================
81 /// Abstract class which defines the callbacks invoked by WxGUIPackageBrowser2
82 class BBTK_EXPORT WxGUIPackageBrowser2User
85 WxGUIPackageBrowser2User() {}
86 virtual ~WxGUIPackageBrowser2User() {}
87 /// Callback invoked when the 'run' button is pressed
88 virtual void WxGUIPackageBrowser2Run() {}
90 //================================================================
93 //================================================================
94 class WxGUIBlackBoxInfo : public wxPanel
97 WxGUIBlackBoxInfo(wxWindow* parent);
100 void UpdateInfo(BlackBoxDescriptor* descr);
101 void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
103 BlackBoxDescriptor* mDescriptor;
105 wxStaticText* mDescription;
106 wxStaticText* mAuthor;
107 wxStaticText* mCategory;
109 wxListCtrl* mInputList;
110 wxListCtrl* mOutputList;
112 //================================================================
114 //================================================================
115 class WxGUIBlackBoxListUser
118 WxGUIBlackBoxListUser() {}
119 virtual ~WxGUIBlackBoxListUser() {}
121 // User callback when a box is selected in the list
122 virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
124 //================================================================
126 //================================================================
127 class WxGUIBlackBoxList: public wxListCtrl
130 WxGUIBlackBoxList(wxWindow *parent,
136 // Set the user of the object
137 void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
139 // add one item to the listctrl in report mode
140 void Insert(BlackBoxDescriptor::Pointer d);
143 void OnColClick(wxListEvent& event);
144 void OnColRightClick(wxListEvent& event);
145 void OnColBeginDrag(wxListEvent& event);
146 void OnColDragging(wxListEvent& event);
147 void OnColEndDrag(wxListEvent& event);
148 void OnBeginDrag(wxListEvent& event);
149 void OnBeginRDrag(wxListEvent& event);
150 void OnBeginLabelEdit(wxListEvent& event);
151 void OnEndLabelEdit(wxListEvent& event);
152 void OnDeleteItem(wxListEvent& event);
153 void OnDeleteAllItems(wxListEvent& event);
154 #if WXWIN_COMPATIBILITY_2_4
155 void OnGetInfo(wxListEvent& event);
156 void OnSetInfo(wxListEvent& event);
158 void OnSelected(wxListEvent& event);
159 void OnDeselected(wxListEvent& event);
160 void OnListKeyDown(wxListEvent& event);
161 void OnActivated(wxListEvent& event);
162 void OnFocused(wxListEvent& event);
163 void OnCacheHint(wxListEvent& event);
165 void OnChar(wxKeyEvent& event);
168 void OnContextMenu(wxContextMenuEvent& event);
171 void OnRightClick(wxMouseEvent& event);
174 void ShowContextMenu(const wxPoint& pos);
176 void SetColumnImage(int col, int image);
178 void LogEvent(const wxListEvent& event, const wxChar *eventName);
179 void LogColEvent(const wxListEvent& event, const wxChar *eventName);
181 virtual wxString OnGetItemText(long item, long column) const;
182 virtual int OnGetItemColumnImage(long item, long column) const;
183 virtual wxListItemAttr *OnGetItemAttr(long item) const;
185 WxGUIBlackBoxListUser* mUser;
187 wxListItemAttr m_attr;
189 // DECLARE_NO_COPY_CLASS(WxGUIBlackBoxListCtrl)
190 DECLARE_EVENT_TABLE()
192 //================================================================
194 //================================================================
195 /// A package browser panel
196 class BBTK_EXPORT WxGUIPackageBrowser2 : public wxPanel,
197 public WxGUIBlackBoxListUser
200 WxGUIPackageBrowser2( wxWindow *parent,
201 WxGUIPackageBrowser2User* user = 0 );
202 ~WxGUIPackageBrowser2();
205 void BuildFromFactory(Factory::Pointer f);
207 bool IsVisible(BlackBoxDescriptor::Pointer d);
209 void OnFilter(wxCommandEvent&);
211 // User callback when a box is selected in the list
212 void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
215 BlackBoxDescriptor* GetActualSelected();
216 Factory::Pointer GetFactory();
220 WxGUIPackageBrowser2User* mUser;
221 Interpreter::Pointer mInterpreter;
222 Factory::Pointer mFactory;
223 WxGUIBlackBoxList* mBoxList;
224 WxGUIBlackBoxInfo* mBoxInfo;
226 wxTextCtrl *mPackageFilter;
227 wxTextCtrl *mNameFilter;
228 wxTextCtrl *mDescriptionFilter;
229 wxTextCtrl *mCategoryFilter;
230 wxTextCtrl *mInputTypeFilter;
231 wxTextCtrl *mOutputTypeFilter;
232 wxTextCtrl *mInputNatureFilter;
233 wxTextCtrl *mOutputNatureFilter;
235 wxCheckBox *mShowWidgetsFilter;
236 wxCheckBox *mShowAdaptorsFilter;
237 wxCheckBox *mShowGUIsFilter;
240 BlackBoxDescriptor *_actualSelected;
242 bool findnpos(const std::string &strA, const std::string &strB );
244 DECLARE_EVENT_TABLE()
246 //================================================================
249 //================================================================
250 /// Browser2 in a frame
251 class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
252 //, public WxGUICommandUser
255 WxGUIPackageBrowser2Window( wxWindow *parent, wxString title, wxSize size);
256 ~WxGUIPackageBrowser2Window();
257 // void Open(const std::string& filename) { mBrowser2->Open(filename); }
258 // void WxGUICommandEnter(const std::string& s);
263 WxGUIPackageBrowser2* mBrowser;
266 //================================================================
272 #endif // __bbtkWxGUIPackageBrowser_h__
274 #endif //_USE_WXWIDGETS_