2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkWxGUIPackageBrowser2.h,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.10 $
34 =========================================================================*/
40 * \brief Short description in one line
42 * Long description which
43 * can span multiple lines
55 #ifdef _USE_WXWIDGETS_
58 #ifndef __bbtkWxGUIPackageBrowser2_h__
59 #define __bbtkWxGUIPackageBrowser2_h__
64 #include "bbtkInterpreter.h"
65 #include <wx/aui/aui.h>
69 #include <wx/dataobj.h>
70 #include "wx/listctrl.h"
71 // not all ports have support for EVT_CONTEXT_MENU yet, don't define
72 // USE_CONTEXT_MENU for those which don't
73 #if defined(__WXMOTIF__) || defined(__WXPM__) || defined(__WXX11__) || defined(__WXMGL__)
74 #define USE_CONTEXT_MENU 0
76 #define USE_CONTEXT_MENU 1
82 //================================================================
83 class WxGUIPackageBrowser2;
84 //================================================================
87 //================================================================
88 /// Abstract class which defines the callbacks invoked by WxGUIPackageBrowser2
89 class BBTK_EXPORT WxGUIPackageBrowser2User
92 WxGUIPackageBrowser2User() {}
93 virtual ~WxGUIPackageBrowser2User() {}
94 /// Callback invoked when the 'run' button is pressed
95 virtual void WxGUIPackageBrowser2Run() {}
97 //================================================================
100 //================================================================
101 class WxGUIBlackBoxInfo : public wxPanel
104 WxGUIBlackBoxInfo(wxWindow* parent);
105 ~WxGUIBlackBoxInfo();
107 void UpdateInfo(BlackBoxDescriptor* descr);
108 void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
109 void OnEraseBackGround( wxEvent& );
111 BlackBoxDescriptor* mDescriptor;
113 wxStaticText* mDescription;
114 wxStaticText* mAuthor;
115 wxStaticText* mCategory;
117 wxListCtrl* mInputList;
118 wxListCtrl* mOutputList;
120 //================================================================
122 //================================================================
123 class WxGUIBlackBoxListUser
126 WxGUIBlackBoxListUser() {}
127 virtual ~WxGUIBlackBoxListUser() {}
129 // User callback when a box is selected in the list
130 virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
132 //================================================================
134 //================================================================
135 class WxGUIBlackBoxList: public wxListCtrl
138 WxGUIBlackBoxList(wxWindow *parent,
144 // Set the user of the object
145 void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
147 // add one item to the listctrl in report mode
148 void Insert(BlackBoxDescriptor::Pointer d);
151 void OnColClick(wxListEvent& event);
152 void OnColRightClick(wxListEvent& event);
153 void OnColBeginDrag(wxListEvent& event);
154 void OnColDragging(wxListEvent& event);
155 void OnColEndDrag(wxListEvent& event);
156 void OnBeginDrag(wxListEvent& event);
157 void OnBeginRDrag(wxListEvent& event);
158 void OnBeginLabelEdit(wxListEvent& event);
159 void OnEndLabelEdit(wxListEvent& event);
160 void OnDeleteItem(wxListEvent& event);
161 void OnDeleteAllItems(wxListEvent& event);
162 #if WXWIN_COMPATIBILITY_2_4
163 void OnGetInfo(wxListEvent& event);
164 void OnSetInfo(wxListEvent& event);
166 void OnSelected(wxListEvent& event);
167 void OnDeselected(wxListEvent& event);
168 void OnListKeyDown(wxListEvent& event);
169 void OnActivated(wxListEvent& event);
170 void OnFocused(wxListEvent& event);
171 void OnCacheHint(wxListEvent& event);
172 void OnChar(wxKeyEvent& event);
175 void OnContextMenu(wxContextMenuEvent& event);
178 void OnRightClick(wxMouseEvent& event);
181 void ShowContextMenu(const wxPoint& pos);
183 void SetColumnImage(int col, int image);
185 void LogEvent(const wxListEvent& event, const wxChar *eventName);
186 void LogColEvent(const wxListEvent& event, const wxChar *eventName);
188 virtual wxString OnGetItemText(long item, long column) const;
189 virtual int OnGetItemColumnImage(long item, long column) const;
190 virtual wxListItemAttr *OnGetItemAttr(long item) const;
192 WxGUIBlackBoxListUser* mUser;
194 wxListItemAttr m_attr;
197 // DECLARE_NO_COPY_CLASS(WxGUIBlackBoxListCtrl)
198 DECLARE_EVENT_TABLE()
200 //================================================================
202 //================================================================
203 /// A package browser panel
204 class BBTK_EXPORT WxGUIPackageBrowser2 : public wxPanel,
205 public WxGUIBlackBoxListUser
208 WxGUIPackageBrowser2( wxWindow *parent,
209 WxGUIPackageBrowser2User* user = 0 );
210 ~WxGUIPackageBrowser2();
213 void BuildFromFactory(Factory::Pointer f);
215 bool IsVisible(BlackBoxDescriptor::Pointer d);
217 void OnFilter(wxCommandEvent&);
218 void OnEraseBackGround( wxEvent& );
220 // User callback when a box is selected in the list
221 void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
224 BlackBoxDescriptor* GetActualSelected();
225 Factory::Pointer GetFactory();
229 WxGUIPackageBrowser2User* mUser;
230 Interpreter::Pointer mInterpreter;
231 Factory::Pointer mFactory;
232 WxGUIBlackBoxList* mBoxList;
233 WxGUIBlackBoxInfo* mBoxInfo;
235 wxTextCtrl *mPackageFilter;
236 wxTextCtrl *mNameFilter;
237 wxTextCtrl *mDescriptionFilter;
238 wxTextCtrl *mCategoryFilter;
239 wxTextCtrl *mInputTypeFilter;
240 wxTextCtrl *mOutputTypeFilter;
241 wxTextCtrl *mInputNatureFilter;
242 wxTextCtrl *mOutputNatureFilter;
244 wxCheckBox *mShowWidgetsFilter;
245 wxCheckBox *mShowAdaptorsFilter;
246 wxCheckBox *mShowGUIsFilter;
250 BlackBoxDescriptor *_actualSelected;
252 bool findnpos(const std::string &strA, const std::string &strB );
254 DECLARE_EVENT_TABLE()
256 //================================================================
259 //================================================================
260 /// Browser2 in a frame
261 class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
262 //, public WxGUICommandUser
265 WxGUIPackageBrowser2Window( wxWindow *parent, wxString title, wxSize size);
266 ~WxGUIPackageBrowser2Window();
267 // void Open(const std::string& filename) { mBrowser2->Open(filename); }
268 // void WxGUICommandEnter(const std::string& s);
273 WxGUIPackageBrowser2* mBrowser;
276 //================================================================
282 #endif // __bbtkWxGUIPackageBrowser_h__
284 #endif //_USE_WXWIDGETS_