1 /*=========================================================================
4 Module: $RCSfile: bbtkWxGUIPackageBrowser2.h,v $
6 Date: $Date: 2008/07/23 11:46:11 $
7 Version: $Revision: 1.5 $
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.
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.
17 =========================================================================*//**
18 * \brief Short description in one line
20 * Long description which
21 * can span multiple lines
33 #ifdef _USE_WXWIDGETS_
36 #ifndef __bbtkWxGUIPackageBrowser2_h__
37 #define __bbtkWxGUIPackageBrowser2_h__
42 #include "bbtkInterpreter.h"
43 #include <wx/aui/aui.h>
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
51 #define USE_CONTEXT_MENU 1
57 //================================================================
58 class WxGUIPackageBrowser2;
59 //================================================================
62 //================================================================
63 /// Abstract class which defines the callbacks invoked by WxGUIPackageBrowser2
64 class BBTK_EXPORT WxGUIPackageBrowser2User
67 WxGUIPackageBrowser2User() {}
68 virtual ~WxGUIPackageBrowser2User() {}
69 /// Callback invoked when the 'run' button is pressed
70 virtual void WxGUIPackageBrowser2Run() {}
72 //================================================================
75 //================================================================
76 class WxGUIBlackBoxInfo : public wxPanel
79 WxGUIBlackBoxInfo(wxWindow* parent);
82 void UpdateInfo(BlackBoxDescriptor* descr);
83 void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
85 BlackBoxDescriptor* mDescriptor;
87 wxStaticText* mDescription;
88 wxStaticText* mAuthor;
89 wxStaticText* mCategory;
91 wxListCtrl* mInputList;
92 wxListCtrl* mOutputList;
94 //================================================================
96 //================================================================
97 class WxGUIBlackBoxListUser
100 WxGUIBlackBoxListUser() {}
101 virtual ~WxGUIBlackBoxListUser() {}
103 // User callback when a box is selected in the list
104 virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
106 //================================================================
108 //================================================================
109 class WxGUIBlackBoxList: public wxListCtrl
112 WxGUIBlackBoxList(wxWindow *parent,
118 // Set the user of the object
119 void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
121 // add one item to the listctrl in report mode
122 void Insert(BlackBoxDescriptor::Pointer d);
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);
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);
147 void OnChar(wxKeyEvent& event);
150 void OnContextMenu(wxContextMenuEvent& event);
153 void OnRightClick(wxMouseEvent& event);
156 void ShowContextMenu(const wxPoint& pos);
158 void SetColumnImage(int col, int image);
160 void LogEvent(const wxListEvent& event, const wxChar *eventName);
161 void LogColEvent(const wxListEvent& event, const wxChar *eventName);
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;
167 WxGUIBlackBoxListUser* mUser;
169 wxListItemAttr m_attr;
171 // DECLARE_NO_COPY_CLASS(WxGUIBlackBoxListCtrl)
172 DECLARE_EVENT_TABLE()
174 //================================================================
176 //================================================================
177 /// A package browser panel
178 class BBTK_EXPORT WxGUIPackageBrowser2 : public wxPanel,
179 public WxGUIBlackBoxListUser
182 WxGUIPackageBrowser2( wxWindow *parent,
183 WxGUIPackageBrowser2User* user = 0 );
184 ~WxGUIPackageBrowser2();
187 void BuildFromFactory(Factory::Pointer f);
189 bool IsVisible(BlackBoxDescriptor::Pointer d);
191 void OnFilter(wxCommandEvent&);
193 // User callback when a box is selected in the list
194 void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
198 WxGUIPackageBrowser2User* mUser;
199 Interpreter::Pointer mInterpreter;
200 Factory::Pointer mFactory;
201 WxGUIBlackBoxList* mBoxList;
202 WxGUIBlackBoxInfo* mBoxInfo;
204 wxTextCtrl* mPackageFilter;
205 wxTextCtrl* mNameFilter;
206 wxTextCtrl* mDescriptionFilter;
207 wxTextCtrl* mCategoryFilter;
208 wxTextCtrl* mInputTypeFilter;
209 wxTextCtrl* mOutputTypeFilter;
210 wxTextCtrl* mInputNatureFilter;
211 wxTextCtrl* mOutputNatureFilter;
213 wxCheckBox* mShowWidgetsFilter;
214 wxCheckBox* mShowAdaptorsFilter;
215 wxCheckBox* mShowGUIsFilter;
217 DECLARE_EVENT_TABLE()
219 //================================================================
222 //================================================================
223 /// Browser2 in a frame
224 class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
225 //, public WxGUICommandUser
228 WxGUIPackageBrowser2Window( wxWindow *parent, wxString title, wxSize size);
229 ~WxGUIPackageBrowser2Window();
230 // void Open(const std::string& filename) { mBrowser2->Open(filename); }
231 // void WxGUICommandEnter(const std::string& s);
236 WxGUIPackageBrowser2* mBrowser;
238 //================================================================
244 #endif // __bbtkWxGUIPackageBrowser_h__
246 #endif //_USE_WXWIDGETS_