From: Guy H <da...@us...> - 2004-10-13 23:26:55
|
Update of /cvsroot/anyedit/AnyEditToolkit/GuiLib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9285/AnyEditToolkit/GuiLib Modified Files: GuiListEdit.cpp GuiListEdit.h Log Message: 1. Removed some unnecessary code 2. Code cleaned 3. Added option to set which buttons are displayed Index: GuiListEdit.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditToolkit/GuiLib/GuiListEdit.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GuiListEdit.h 10 Oct 2004 18:50:09 -0000 1.3 --- GuiListEdit.h 13 Oct 2004 23:26:46 -0000 1.4 *************** *** 27,38 **** #include "GuiContainer.h" #include "GuiMiniTool.h" - #include "GuiNormalButton.h" class GUILIBDLLEXPORT CGuiListEdit : public CStatic { - DECLARE_DYNAMIC(CGuiListEdit) public: ! enum Border{STYLE3D = 0, STYLEPRESS = 1, STYLEFRAME = 2}; ! private: CGuiContainer m_wndContainer; CGuiMiniTool m_wndMiniTool; --- 27,44 ---- #include "GuiContainer.h" #include "GuiMiniTool.h" class GUILIBDLLEXPORT CGuiListEdit : public CStatic { public: ! // Ctor/Dtor ! CGuiListEdit(); ! virtual ~CGuiListEdit(); ! ! // Public Declarations ! enum Border {STYLE3D = 0, STYLEPRESS = 1, STYLEFRAME = 2}; ! enum Buttons {BtnInsert = 0x0001, BtnDelete = 0x0002, BtnUp = 0x0004, BtnDown = 0x0008}; ! ! protected: ! // Members CGuiContainer m_wndContainer; CGuiMiniTool m_wndMiniTool; *************** *** 40,68 **** COLORREF m_clrface; Border m_border; public: ! virtual void OnSelectionChanged () {} ! void Delete(); ! void Insert(); ! void Up(); ! void Down(); ! void SetStyle(Border border); ! CString GetText(int nItem); ! void AddItem(CString m_szCad); ! int GetNumItem(); ! CGuiNormalButton m_toolBtn; CListCtrl* GetListCtrl(); public: ! CGuiListEdit(); ! virtual ~CGuiListEdit(); protected: ! bool m_bNewItem; ! DECLARE_MESSAGE_MAP() virtual void PreSubclassWindow(); ! public: ! BOOL EditItem (int iIndex); ! void RemoveItem(int nItem); ! BOOL SelectItem(int nItem); ! int GetSelItem(void); //{{AFX_MSG(CGuiListEdit) --- 46,91 ---- COLORREF m_clrface; Border m_border; + bool m_bNewItem; + UINT m_uButtons; + + DECLARE_DYNAMIC(CGuiListEdit) + public: ! // Data Access ! CString GetText(int nItem) const; ! int GetNumItem(); ! int GetSelItem(); CListCtrl* GetListCtrl(); + public: ! // Operations - items ! void AddItem(const CString& sText); ! BOOL EditItem (int iIndex); ! void RemoveItem(int nItem); ! BOOL SelectItem(int nItem); ! ! // Operations - buttons ! void Delete(); ! void Insert(); ! void Up(); ! void Down(); ! ! // Operations - style ! void SetBorderStyle(Border border); ! void SetVisibleButtons(UINT uButtons); ! ! public: ! // Overridables ! virtual void OnSelectionChanged () {} protected: ! // Overrides virtual void PreSubclassWindow(); ! ! // Helpers ! bool ToggleButton(bool bShow, int nIndex, int nImage, UINT uCmd, const CString& sToolTip); ! ! protected: ! DECLARE_MESSAGE_MAP() //{{AFX_MSG(CGuiListEdit) Index: GuiListEdit.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditToolkit/GuiLib/GuiListEdit.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GuiListEdit.cpp 11 Oct 2004 18:01:23 -0000 1.4 --- GuiListEdit.cpp 13 Oct 2004 23:26:46 -0000 1.5 *************** *** 35,39 **** #define LST_DOWN 558 #define LST_LIST 559 ! #define DROPBUTTON 560 // CGuiListEdit --- 35,44 ---- #define LST_DOWN 558 #define LST_LIST 559 ! ! #define DOCKBAROFFICE_ARROW_DOWN 9 ! #define DOCKBAROFFICE_ARROW_UP 11 ! #define DOCKBAROFFICE_DELETE 8 ! #define DOCKBAROFFICE_INSERT 10 ! // CGuiListEdit *************** *** 45,52 **** --- 50,61 ---- m_clrface = GuiDrawLayer::GetRGBColorFace(); m_bNewItem = false; + m_pWndList = NULL; + m_uButtons = BtnInsert | BtnDelete | BtnUp | BtnDown; } CGuiListEdit::~CGuiListEdit() { + if (m_pWndList != NULL) + delete m_pWndList; } *************** *** 84,88 **** } ! CString CGuiListEdit::GetText(int nItem) { if (nItem < 0) return _T(""); --- 93,97 ---- } ! CString CGuiListEdit::GetText(int nItem) const { if (nItem < 0) return _T(""); *************** *** 97,104 **** } ! void CGuiListEdit::AddItem(CString m_szCad) { ! int nItem=m_pWndList->GetItemCount(); ! nItem=m_pWndList->InsertItem(nItem, m_szCad); m_pWndList->SetItemData (nItem, 0); } --- 106,114 ---- } ! void CGuiListEdit::AddItem(const CString& sText) { ! ASSERT(m_pWndList != NULL); ! int nItem = m_pWndList->GetItemCount(); ! nItem = m_pWndList->InsertItem(nItem, sText); m_pWndList->SetItemData (nItem, 0); } *************** *** 131,135 **** m_pWndList->GetItemRect(0, &rc, LVIS_SELECTED | LVIS_FOCUSED); CEdit* mEdit = m_pWndList->EditLabel(nItem); - CSize szBtn = m_toolBtn.GetSizeButton(); mEdit->SetWindowPos (NULL, -1, -1, rc.Width () - 10, rc.Height (), --- 141,144 ---- *************** *** 203,217 **** m_wndContainer.AddComponen(&m_wndMiniTool); - /*m_toolBtn.Create(_T(""),WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_OWNERDRAW,CRect(0,0,0,0),this,DROPBUTTON); - m_toolBtn.SetCaption(_T(" ... ")); - m_toolBtn.SetStyleButton(CGuiNormalButton::STL_SEMIFLAT); - */ m_pWndList = (CListCtrl*) m_wndContainer.AddComponen(RUNTIME_CLASS(CListCtrl), LST_LIST, WS_VISIBLE | WS_CHILD); m_wndMiniTool.SetImageList(IDB_GUI_DOCKBAROFFICE, 14, 12, RGB(255, 0, 255)); ! m_wndMiniTool.AddButton(9, LST_DOWN, NULL, _T(""), _T("Item Down")); ! m_wndMiniTool.AddButton(11, LST_UP, NULL, _T(""), _T("Item Up")); ! m_wndMiniTool.AddButton(8, LST_DELETE, NULL, _T(""), _T("Delete")); ! m_wndMiniTool.AddButton(10, LST_INSERT, NULL, _T(""), _T("Insert")); m_wndMiniTool.AutoSize(TRUE); m_wndMiniTool.SetBorder(CGuiMiniTool::STYLEPRESS); --- 212,219 ---- m_wndContainer.AddComponen(&m_wndMiniTool); m_pWndList = (CListCtrl*) m_wndContainer.AddComponen(RUNTIME_CLASS(CListCtrl), LST_LIST, WS_VISIBLE | WS_CHILD); m_wndMiniTool.SetImageList(IDB_GUI_DOCKBAROFFICE, 14, 12, RGB(255, 0, 255)); ! SetVisibleButtons(m_uButtons); m_wndMiniTool.AutoSize(TRUE); m_wndMiniTool.SetBorder(CGuiMiniTool::STYLEPRESS); *************** *** 235,241 **** } ! void CGuiListEdit::SetStyle(Border border) { m_border = border; } --- 237,245 ---- } ! void CGuiListEdit::SetBorderStyle(Border border) { m_border = border; + if (GetSafeHwnd() != NULL) + Invalidate(); } *************** *** 402,403 **** --- 406,440 ---- return TRUE; } + + void CGuiListEdit::SetVisibleButtons(UINT uButtons) + { + m_uButtons = uButtons; + if (GetSafeHwnd() == NULL) + return; + + // Add and remove buttons: + int nIndex = 0; + if (ToggleButton(m_uButtons & BtnDown ? true : false, nIndex, DOCKBAROFFICE_ARROW_DOWN, LST_DOWN, _T("Item Down"))) + nIndex++; + if (ToggleButton(m_uButtons & BtnUp ? true : false, nIndex, DOCKBAROFFICE_ARROW_UP, LST_UP, _T("Item Up"))) + nIndex++; + if (ToggleButton(m_uButtons & BtnDelete ? true : false, nIndex, DOCKBAROFFICE_DELETE, LST_DELETE, _T("Delete"))) + nIndex++; + if (ToggleButton(m_uButtons & BtnInsert ? true : false, nIndex, DOCKBAROFFICE_INSERT, LST_INSERT, _T("Insert"))) + nIndex++; + } + + bool CGuiListEdit::ToggleButton(bool bShow, int nIndex, int nImage, UINT uCmd, const CString& sToolTip) + { + int nCurrentIndex = m_wndMiniTool.GetButtonIndex(uCmd); + bool bVisible = false; + if (bShow) + { + if (nCurrentIndex == -1) + m_wndMiniTool.InsertButton(nIndex, nImage, uCmd, NULL, _T(""), sToolTip); + bVisible = true; + } + else if (nCurrentIndex != -1) + m_wndMiniTool.DelButton(nCurrentIndex); + return bVisible; + } |