bbtkWxGUIPackageBrowser2.h

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002   Program:   bbtk
00003   Module:    $RCSfile: bbtkWxGUIPackageBrowser2.h,v $
00004   Language:  C++
00005   Date:      $Date: 2008/10/17 08:18:15 $
00006   Version:   $Revision: 1.6 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013 *
00014 *  This software is governed by the CeCILL-B license under French law and 
00015 *  abiding by the rules of distribution of free software. You can  use, 
00016 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
00017 *  license as circulated by CEA, CNRS and INRIA at the following URL 
00018 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
00019 *  or in the file LICENSE.txt.
00020 *
00021 *  As a counterpart to the access to the source code and  rights to copy,
00022 *  modify and redistribute granted by the license, users are provided only
00023 *  with a limited warranty  and the software's author,  the holder of the
00024 *  economic rights,  and the successive licensors  have only  limited
00025 *  liability. 
00026 *
00027 *  The fact that you are presently reading this means that you have had
00028 *  knowledge of the CeCILL-B license and that you accept its terms.
00029 * ------------------------------------------------------------------------ */                                                                         
00030 
00031 
00048 #ifdef _USE_WXWIDGETS_
00049 
00050         
00051 #ifndef __bbtkWxGUIPackageBrowser2_h__
00052 #define __bbtkWxGUIPackageBrowser2_h__
00053 
00054 
00055 #include "bbtkWx.h"
00056 
00057 #include "bbtkInterpreter.h"
00058 #include <wx/aui/aui.h>
00059 
00060 #include "wx/listctrl.h"
00061 // not all ports have support for EVT_CONTEXT_MENU yet, don't define
00062 // USE_CONTEXT_MENU for those which don't
00063 #if defined(__WXMOTIF__) || defined(__WXPM__) || defined(__WXX11__) || defined(__WXMGL__)
00064     #define USE_CONTEXT_MENU 0
00065 #else
00066     #define USE_CONTEXT_MENU 1
00067 #endif
00068 
00069 
00070 namespace bbtk
00071 {
00072   //================================================================
00073   class WxGUIPackageBrowser2;
00074   //================================================================
00075  
00076 
00077   //================================================================
00079   class BBTK_EXPORT WxGUIPackageBrowser2User
00080   {
00081   public:
00082     WxGUIPackageBrowser2User() {}
00083     virtual ~WxGUIPackageBrowser2User() {}
00085     virtual void WxGUIPackageBrowser2Run() {}
00086   };
00087   //================================================================
00088 
00089  
00090   //================================================================
00091   class WxGUIBlackBoxInfo : public wxPanel
00092   {
00093   public:
00094     WxGUIBlackBoxInfo(wxWindow* parent);
00095     ~WxGUIBlackBoxInfo();
00096 
00097     void UpdateInfo(BlackBoxDescriptor* descr);
00098     void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
00099   private:
00100     BlackBoxDescriptor* mDescriptor;
00101     wxStaticText* mName;
00102     wxStaticText* mDescription;
00103     wxStaticText* mAuthor;
00104     wxStaticText* mCategory;
00105       
00106     wxListCtrl* mInputList;
00107     wxListCtrl* mOutputList;
00108   } ;
00109   //================================================================
00110   
00111   //================================================================
00112   class WxGUIBlackBoxListUser
00113   {
00114   public:
00115     WxGUIBlackBoxListUser() {}
00116     virtual ~WxGUIBlackBoxListUser() {}
00117     
00118     // User callback when a box is selected in the list 
00119     virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
00120   };
00121   //================================================================
00122 
00123   //================================================================
00124   class WxGUIBlackBoxList: public wxListCtrl
00125   {
00126   public:
00127     WxGUIBlackBoxList(wxWindow *parent,
00128                    const wxWindowID id,
00129                    const wxPoint& pos,
00130                    const wxSize& size,
00131                    long style);
00132 
00133     // Set the user of the object
00134     void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
00135 
00136     // add one item to the listctrl in report mode
00137     void Insert(BlackBoxDescriptor::Pointer d);
00138     
00139     // 
00140     void OnColClick(wxListEvent& event);
00141     void OnColRightClick(wxListEvent& event);
00142     void OnColBeginDrag(wxListEvent& event);
00143     void OnColDragging(wxListEvent& event);
00144     void OnColEndDrag(wxListEvent& event);
00145     void OnBeginDrag(wxListEvent& event);
00146     void OnBeginRDrag(wxListEvent& event);
00147     void OnBeginLabelEdit(wxListEvent& event);
00148     void OnEndLabelEdit(wxListEvent& event);
00149     void OnDeleteItem(wxListEvent& event);
00150     void OnDeleteAllItems(wxListEvent& event);
00151 #if WXWIN_COMPATIBILITY_2_4
00152     void OnGetInfo(wxListEvent& event);
00153     void OnSetInfo(wxListEvent& event);
00154 #endif
00155     void OnSelected(wxListEvent& event);
00156     void OnDeselected(wxListEvent& event);
00157     void OnListKeyDown(wxListEvent& event);
00158     void OnActivated(wxListEvent& event);
00159     void OnFocused(wxListEvent& event);
00160     void OnCacheHint(wxListEvent& event);
00161 
00162     void OnChar(wxKeyEvent& event);
00163 
00164 #if USE_CONTEXT_MENU
00165     void OnContextMenu(wxContextMenuEvent& event);
00166 #endif
00167 
00168     void OnRightClick(wxMouseEvent& event);
00169 
00170 private:
00171     void ShowContextMenu(const wxPoint& pos);
00172     //    wxLog *m_logOld;
00173     void SetColumnImage(int col, int image);
00174 
00175     void LogEvent(const wxListEvent& event, const wxChar *eventName);
00176     void LogColEvent(const wxListEvent& event, const wxChar *eventName);
00177 
00178     virtual wxString OnGetItemText(long item, long column) const;
00179     virtual int OnGetItemColumnImage(long item, long column) const;
00180     virtual wxListItemAttr *OnGetItemAttr(long item) const;
00181     
00182     WxGUIBlackBoxListUser* mUser;
00183 
00184     wxListItemAttr m_attr;
00185 
00186     //    DECLARE_NO_COPY_CLASS(WxGUIBlackBoxListCtrl)
00187     DECLARE_EVENT_TABLE()
00188 };
00189   //================================================================
00190 
00191   //================================================================
00193   class BBTK_EXPORT WxGUIPackageBrowser2 : public wxPanel,
00194                                            public WxGUIBlackBoxListUser
00195   {
00196   public:
00197     WxGUIPackageBrowser2( wxWindow *parent, 
00198                          WxGUIPackageBrowser2User* user = 0 );
00199     ~WxGUIPackageBrowser2();
00200 
00201     void IncludeAll();
00202     void BuildFromFactory(Factory::Pointer f);
00203     void RebuildList();
00204     bool IsVisible(BlackBoxDescriptor::Pointer d);
00205 
00206     void OnFilter(wxCommandEvent&);
00207  
00208     // User callback when a box is selected in the list 
00209     void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
00210 
00211   private:
00212     wxAuiManager m_mgr;
00213     WxGUIPackageBrowser2User* mUser;
00214     Interpreter::Pointer mInterpreter;
00215     Factory::Pointer mFactory;
00216     WxGUIBlackBoxList* mBoxList;
00217     WxGUIBlackBoxInfo* mBoxInfo;
00218 
00219     wxTextCtrl* mPackageFilter;
00220     wxTextCtrl* mNameFilter;
00221     wxTextCtrl* mDescriptionFilter;
00222     wxTextCtrl* mCategoryFilter;
00223     wxTextCtrl* mInputTypeFilter;
00224     wxTextCtrl* mOutputTypeFilter;
00225     wxTextCtrl* mInputNatureFilter;
00226     wxTextCtrl* mOutputNatureFilter;
00227 
00228     wxCheckBox* mShowWidgetsFilter;
00229     wxCheckBox* mShowAdaptorsFilter;
00230     wxCheckBox* mShowGUIsFilter;
00231 
00232    DECLARE_EVENT_TABLE()  
00233   };
00234   //================================================================
00235 
00236   
00237   //================================================================
00239   class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
00240                                               //, public WxGUICommandUser
00241   {
00242   public:
00243     WxGUIPackageBrowser2Window( wxWindow *parent, wxString title, wxSize size);
00244     ~WxGUIPackageBrowser2Window();
00245     //    void Open(const std::string& filename) { mBrowser2->Open(filename); }
00246     //    void WxGUICommandEnter(const std::string& s);
00247 
00248 
00249   private :
00250     
00251     WxGUIPackageBrowser2* mBrowser;
00252   };
00253    //================================================================
00254  
00255 
00256 } // namespace bbtk
00257 
00258 
00259 #endif // __bbtkWxGUIPackageBrowser_h__
00260 
00261 #endif //_USE_WXWIDGETS_

Generated on Wed Nov 12 11:37:08 2008 for BBTK by  doxygen 1.5.6