Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

GlobalWxFuncs.h

Go to the documentation of this file.
00001 #ifndef _GlobalWxFuncs_h
00002 #define _GlobalWxFuncs_h
00003 
00004 // ************** Precompiled header file of wxWindows ********************
00005 #include "wx/wxprec.h"
00006 
00007 #ifndef WX_PRECOMP 
00008         #include "wx/wx.h"
00009 #endif
00010 // ************** Precompiled header file of wxWindows ********************
00011 
00012 #include <string>
00013 
00014 #include <wx/listctrl.h>
00015 
00016 using std::string;
00017 
00018 
00019 static const string gGetListCtrlStr(wxListCtrl *pListCtrl)
00020 {
00021         string s="";
00022         
00023         Int iNumOfItems = pListCtrl->GetItemCount();
00024         for(Int i=0; i<iNumOfItems; ++i)
00025         {
00026                 s += (pListCtrl->GetItemText(i) + "|" ).c_str();
00027         }
00028         return s;       
00029 }
00030 static void gDisplayInfoOnListCtrl(wxListCtrl *pListCtrl, const string sStr, const string sDelimiter)
00031 {// Note: sStr HAS to terminate by sDelimiter.
00032         
00033         // Clear item in list ctrl.
00034         pListCtrl-> DeleteAllItems();
00035         
00036         unsigned int iDelimiterLength = sDelimiter.length();
00037         unsigned int iPos;
00038         unsigned int iLastPos = 0;
00039         while(string::npos != (iPos = sStr.find(sDelimiter, iLastPos)))
00040         {
00041                 // Append item in m_pSongsListCtrl
00042                 Int iRowNum = pListCtrl->InsertItem(pListCtrl->GetItemCount(), (sStr.substr(iLastPos, iPos - iLastPos)).c_str());
00043                 
00044                 // Select the appended item.
00045                 pListCtrl->SetItemState(iRowNum, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
00046                 
00047                 iLastPos = iPos + iDelimiterLength;
00048         }
00049 }
00050 static void gDeleteItemFromFileListCtrl(wxListCtrl *pListCtrl, Int iRowNum)
00051 {
00052         long lItemIndex = pListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
00053 
00054         if( lItemIndex == iRowNum)
00055         {
00056                 if(pListCtrl->DeleteItem(iRowNum))
00057                 {
00058                         Int iNumOfItem = pListCtrl->GetItemCount();
00059                         if(iNumOfItem !=0)
00060                         {
00061                                 if(iNumOfItem <= iRowNum)
00062                                 {
00063                                         iRowNum--;                                      
00064                                 }
00065                                 pListCtrl->SetItemState(iRowNum, wxLIST_STATE_SELECTED , wxLIST_STATE_SELECTED);
00066                                 pListCtrl->EnsureVisible(iRowNum);
00067                         }
00068                 }
00069         }
00070         else // Row to be deleted is not selected.
00071         {
00072                 pListCtrl->DeleteItem(iRowNum);
00073         }
00074 }
00075 #endif // _GlobalWxFuncs_h

Generated on Wed Feb 25 01:15:11 2004 for eDonkeyFilesManager by doxygen 1.3.2