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: 2010/10/11 06:30:33 $
00006   Version:   $Revision: 1.9 $
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 //Drag and drop
00061 #include <wx/dnd.h>
00062 #include <wx/dataobj.h>
00063 #include "wx/listctrl.h"
00064 // not all ports have support for EVT_CONTEXT_MENU yet, don't define
00065 // USE_CONTEXT_MENU for those which don't
00066 #if defined(__WXMOTIF__) || defined(__WXPM__) || defined(__WXX11__) || defined(__WXMGL__)
00067     #define USE_CONTEXT_MENU 0
00068 #else
00069     #define USE_CONTEXT_MENU 1
00070 #endif
00071 
00072 
00073 namespace bbtk
00074 {
00075   //================================================================
00076   class WxGUIPackageBrowser2;
00077   //================================================================
00078 
00079 
00080   //================================================================
00082   class BBTK_EXPORT WxGUIPackageBrowser2User
00083   {
00084   public:
00085     WxGUIPackageBrowser2User() {}
00086     virtual ~WxGUIPackageBrowser2User() {}
00088     virtual void WxGUIPackageBrowser2Run() {}
00089   };
00090   //================================================================
00091 
00092 
00093   //================================================================
00094   class WxGUIBlackBoxInfo : public wxPanel
00095   {
00096   public:
00097     WxGUIBlackBoxInfo(wxWindow* parent);
00098     ~WxGUIBlackBoxInfo();
00099 
00100     void UpdateInfo(BlackBoxDescriptor* descr);
00101     void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
00102   private:
00103     BlackBoxDescriptor* mDescriptor;
00104     wxStaticText* mName;
00105     wxStaticText* mDescription;
00106     wxStaticText* mAuthor;
00107     wxStaticText* mCategory;
00108 
00109     wxListCtrl* mInputList;
00110     wxListCtrl* mOutputList;
00111   } ;
00112   //================================================================
00113 
00114   //================================================================
00115   class WxGUIBlackBoxListUser
00116   {
00117   public:
00118     WxGUIBlackBoxListUser() {}
00119     virtual ~WxGUIBlackBoxListUser() {}
00120 
00121     // User callback when a box is selected in the list
00122     virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
00123   };
00124   //================================================================
00125 
00126   //================================================================
00127   class WxGUIBlackBoxList: public wxListCtrl
00128   {
00129   public:
00130     WxGUIBlackBoxList(wxWindow *parent,
00131                    const wxWindowID id,
00132                    const wxPoint& pos,
00133                    const wxSize& size,
00134                    long style);
00135 
00136     // Set the user of the object
00137     void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
00138 
00139     // add one item to the listctrl in report mode
00140     void Insert(BlackBoxDescriptor::Pointer d);
00141 
00142     //
00143     void OnColClick(wxListEvent& event);
00144     void OnColRightClick(wxListEvent& event);
00145     void OnColBeginDrag(wxListEvent& event);
00146     void OnColDragging(wxListEvent& event);
00147     void OnColEndDrag(wxListEvent& event);
00148     void OnBeginDrag(wxListEvent& event);
00149     void OnBeginRDrag(wxListEvent& event);
00150     void OnBeginLabelEdit(wxListEvent& event);
00151     void OnEndLabelEdit(wxListEvent& event);
00152     void OnDeleteItem(wxListEvent& event);
00153     void OnDeleteAllItems(wxListEvent& event);
00154 #if WXWIN_COMPATIBILITY_2_4
00155     void OnGetInfo(wxListEvent& event);
00156     void OnSetInfo(wxListEvent& event);
00157 #endif
00158     void OnSelected(wxListEvent& event);
00159     void OnDeselected(wxListEvent& event);
00160     void OnListKeyDown(wxListEvent& event);
00161     void OnActivated(wxListEvent& event);
00162     void OnFocused(wxListEvent& event);
00163     void OnCacheHint(wxListEvent& event);
00164 
00165     void OnChar(wxKeyEvent& event);
00166 
00167 #if USE_CONTEXT_MENU
00168     void OnContextMenu(wxContextMenuEvent& event);
00169 #endif
00170 
00171     void OnRightClick(wxMouseEvent& event);
00172 
00173 private:
00174     void ShowContextMenu(const wxPoint& pos);
00175     //    wxLog *m_logOld;
00176     void SetColumnImage(int col, int image);
00177 
00178     void LogEvent(const wxListEvent& event, const wxChar *eventName);
00179     void LogColEvent(const wxListEvent& event, const wxChar *eventName);
00180 
00181     virtual wxString OnGetItemText(long item, long column) const;
00182     virtual int OnGetItemColumnImage(long item, long column) const;
00183     virtual wxListItemAttr *OnGetItemAttr(long item) const;
00184 
00185     WxGUIBlackBoxListUser* mUser;
00186 
00187     wxListItemAttr m_attr;
00188 
00189     //    DECLARE_NO_COPY_CLASS(WxGUIBlackBoxListCtrl)
00190     DECLARE_EVENT_TABLE()
00191 };
00192   //================================================================
00193 
00194   //================================================================
00196   class BBTK_EXPORT WxGUIPackageBrowser2 : public wxPanel,
00197                                            public WxGUIBlackBoxListUser
00198   {
00199   public:
00200     WxGUIPackageBrowser2( wxWindow *parent,
00201                          WxGUIPackageBrowser2User* user = 0 );
00202     ~WxGUIPackageBrowser2();
00203 
00204     void IncludeAll();
00205     void BuildFromFactory(Factory::Pointer f);
00206     void RebuildList();
00207     bool IsVisible(BlackBoxDescriptor::Pointer d);
00208 
00209     void OnFilter(wxCommandEvent&);
00210 
00211     // User callback when a box is selected in the list
00212     void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
00213 
00214         //RaC
00215         BlackBoxDescriptor* GetActualSelected();
00216         Factory::Pointer GetFactory();
00217 
00218   private:
00219     wxAuiManager                                m_mgr;
00220     WxGUIPackageBrowser2User*   mUser;
00221     Interpreter::Pointer                mInterpreter;
00222     Factory::Pointer                    mFactory;
00223     WxGUIBlackBoxList*                  mBoxList;
00224     WxGUIBlackBoxInfo*                  mBoxInfo;
00225 
00226     wxTextCtrl                                  *mPackageFilter;
00227     wxTextCtrl                                  *mNameFilter;
00228     wxTextCtrl                                  *mDescriptionFilter;
00229     wxTextCtrl                                  *mCategoryFilter;
00230     wxTextCtrl                                  *mInputTypeFilter;
00231     wxTextCtrl                                  *mOutputTypeFilter;
00232     wxTextCtrl                                  *mInputNatureFilter;
00233     wxTextCtrl                                  *mOutputNatureFilter;
00234 
00235     wxCheckBox                                  *mShowWidgetsFilter;
00236     wxCheckBox                                  *mShowAdaptorsFilter;
00237     wxCheckBox                                  *mShowGUIsFilter;
00238 
00239         //RaC
00240         BlackBoxDescriptor          *_actualSelected;
00241 
00242     bool findnpos(const std::string &strA, const std::string &strB );
00243 
00244    DECLARE_EVENT_TABLE()
00245   };
00246   //================================================================
00247 
00248 
00249   //================================================================
00251   class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
00252                                               //, public WxGUICommandUser
00253   {
00254   public:
00255     WxGUIPackageBrowser2Window( wxWindow *parent, wxString title, wxSize size);
00256     ~WxGUIPackageBrowser2Window();
00257     //    void Open(const std::string& filename) { mBrowser2->Open(filename); }
00258     //    void WxGUICommandEnter(const std::string& s);
00259 
00260 
00261   private :
00262 
00263     WxGUIPackageBrowser2* mBrowser;
00264 
00265   };
00266    //================================================================
00267 
00268 
00269 } // namespace bbtk
00270 
00271 
00272 #endif // __bbtkWxGUIPackageBrowser_h__
00273 
00274 #endif //_USE_WXWIDGETS_

Generated on Thu May 31 14:12:03 2012 for BBTK by  doxygen 1.5.7.1