1 /*=========================================================================
4 Module: $RCSfile: bbtkWxGUIPackageBrowser2.h,v $
6 Date: $Date: 2008/04/04 08:04:05 $
7 Version: $Revision: 1.1 $
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"
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
50 #define USE_CONTEXT_MENU 1
56 //================================================================
57 class WxGUIPackageBrowser2;
58 //================================================================
61 //================================================================
62 /// Abstract class which defines the callbacks invoked by WxGUIPackageBrowser2
63 class BBTK_EXPORT WxGUIPackageBrowser2User
66 WxGUIPackageBrowser2User() {}
67 ~WxGUIPackageBrowser2User() {}
68 /// Callback invoked when the 'run' button is pressed
69 virtual void WxGUIPackageBrowser2Run() {}
71 //================================================================
74 //================================================================
75 class WxGUIBlackBoxInfo : public wxPanel
78 WxGUIBlackBoxInfo(wxWindow* parent);
81 void UpdateInfo(BlackBoxDescriptor* descr);
82 void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
84 BlackBoxDescriptor* mDescriptor;
86 wxStaticText* mDescription;
87 wxStaticText* mAuthor;
88 wxStaticText* mCategory;
90 wxListCtrl* mInputList;
91 wxListCtrl* mOutputList;
93 //================================================================
95 //================================================================
96 class WxGUIBlackBoxListUser
99 WxGUIBlackBoxListUser() {}
100 virtual ~WxGUIBlackBoxListUser() {}
102 // User callback when a box is selected in the list
103 virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
105 //================================================================
107 //================================================================
108 class WxGUIBlackBoxList: public wxListCtrl
111 WxGUIBlackBoxList(wxWindow *parent,
117 // Set the user of the object
118 void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
120 // add one item to the listctrl in report mode
121 void Insert(BlackBoxDescriptor* d);
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);
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);
146 void OnChar(wxKeyEvent& event);
149 void OnContextMenu(wxContextMenuEvent& event);
152 void OnRightClick(wxMouseEvent& event);
155 void ShowContextMenu(const wxPoint& pos);
157 void SetColumnImage(int col, int image);
159 void LogEvent(const wxListEvent& event, const wxChar *eventName);
160 void LogColEvent(const wxListEvent& event, const wxChar *eventName);
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;
166 WxGUIBlackBoxListUser* mUser;
168 wxListItemAttr m_attr;
170 // DECLARE_NO_COPY_CLASS(WxGUIBlackBoxListCtrl)
171 DECLARE_EVENT_TABLE()
173 //================================================================
175 //================================================================
176 /// A package browser panel
177 class BBTK_EXPORT WxGUIPackageBrowser2 : public wxPanel,
178 public WxGUIBlackBoxListUser
181 WxGUIPackageBrowser2( wxWindow *parent,
182 WxGUIPackageBrowser2User* user = 0 );
183 ~WxGUIPackageBrowser2();
186 void BuildFromFactory(Factory* f);
188 bool IsVisible(BlackBoxDescriptor* d);
190 void OnFilter(wxCommandEvent&);
192 // User callback when a box is selected in the list
193 void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
196 WxGUIPackageBrowser2User* mUser;
197 Interpreter* mInterpreter;
199 WxGUIBlackBoxList* mBoxList;
200 WxGUIBlackBoxInfo* mBoxInfo;
202 wxTextCtrl* mPackageFilter;
203 wxTextCtrl* mNameFilter;
204 wxTextCtrl* mDescriptionFilter;
205 wxTextCtrl* mCategoryFilter;
206 wxTextCtrl* mInputTypeFilter;
207 wxTextCtrl* mOutputTypeFilter;
209 DECLARE_EVENT_TABLE()
211 //================================================================
214 //================================================================
215 /// Browser2 in a frame
216 class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
217 //, public WxGUICommandUser
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);
228 WxGUIPackageBrowser2* mBrowser;
230 //================================================================
236 #endif // __bbtkWxGUIPackageBrowser_h__
238 #endif //_USE_WXWIDGETS_