customlist.h

Go to the documentation of this file.
00001 // $Id: customlist.h 1080 2006-05-16 13:24:45Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 #if !defined(AFX_CUSTOMLIST_H__32AE552D_C07B_4C09_9030_AB20E842FFD6__INCLUDED_)
00099 #define AFX_CUSTOMLIST_H__32AE552D_C07B_4C09_9030_AB20E842FFD6__INCLUDED_
00100 
00101 #if _MSC_VER > 1000
00102 #pragma once
00103 #endif // _MSC_VER > 1000
00104 // CustomList.h : header file
00105 //
00106 
00107 class CCustomListScrollableArea;
00108 class CCustomListRowWnd;
00109 
00111 // CCustomList - Custom List Control class. Hosts a vertical scrollbar and
00112 // a CCustomListScrollableArea
00113 
00114 class CCustomList : public CWnd
00115 {
00116     friend class CCustomListScrollableArea;
00117     friend class CCustomListRowWnd;
00118 public:
00119 //  constants
00120     static const INT32 MAXCOLUMNS ;
00121     static const INT32 MAXROWS ;
00122     static const INT32 FONTHEIGHT;
00123     static const INT32 ROWHEIGHT ;
00124     static const INT32 COLOUR_PATCH_WIDTH ;
00125     static const INT32 COLOUR_PATCH_HEIGHT;
00126     static const CString WNDCLASSNAME;
00127 
00128 
00129 public:
00130 // constructor & destructor
00131     CCustomList();
00132     virtual ~CCustomList();
00133     static BOOL RegisterWindowClass();
00134     static LRESULT CALLBACK EXPORT CustomWindowProc(HWND hWnd, UINT32 nMsg, WPARAM wParam,LPARAM lParam);
00135     void SetColumnWidth(INT32 colnum,INT32 offset);
00136 
00137     // The following block of public methods is the API actually used by Camelot. It is
00138     // almost identical to the original CCListGadget interface which it replaces
00139 
00140     static CCustomList* GetGadget(CWindowID parentID, CGadgetID gadgetID);
00141     BOOL CreateCustomHeader (UINT32 bitmapID);
00142 
00143     BOOL GetSwitchState(UINT32 itemIndex, UINT32 switchIndex) const;
00144     INT32    GetItemCount() const;
00145     BOOL GetItemString(StringBase& itemString, UINT32 itemIndex, UINT32 columnIndex) const;
00146     INT32    GetSelectedItemIndex() const;
00147 
00148     BOOL AddItem(StringBase& itemString, KernelBitmap* pItemImage = 0);
00149     BOOL AddItem(StringBase& itemString, UINT32 bitmapEnabledID, UINT32 bitmapDisabledID);
00150     BOOL AddRefsItem(UINT32 idStatusBitmap, StringBase& strItemName, StringBase& strDetails);
00151     BOOL AddColourListItem(StringBase& colourName, INT32 red, INT32 green, INT32 blue, BOOL IsSpotColour = FALSE);
00152     BOOL SetSwitchState(BOOL state, UINT32 itemIndex, UINT32 switchIndex);
00153     void SetSelectedItemIndex(INT32 NewSel);
00154     BOOL SetItemString(StringBase& itemString, UINT32 itemIndex, UINT32 columnIndex);
00155     BOOL SetEnabled(BOOL enabled);
00156     BOOL DeleteAllItems();
00157 
00158 protected:
00159     //{{AFX_VIRTUAL(CCustomList)
00160     protected:
00161     virtual void PostNcDestroy();
00162     //}}AFX_VIRTUAL
00163 
00164     //{{AFX_MSG(CCustomList)
00165     afx_msg INT32 OnCreate(LPCREATESTRUCT lpCreateStruct);
00166     afx_msg void OnVScroll(UINT32 nSBCode, UINT32 nPos, CScrollBar* pScrollBar);
00167     afx_msg void OnSetFocus(CWnd* pOldWnd);
00168     afx_msg BOOL OnMouseWheel(UINT32 nFlags, short zDelta, CPoint pt);
00169     //}}AFX_MSG
00170     DECLARE_MESSAGE_MAP()
00171 private:
00172     
00173     void NewScrollableArea();   // creates a new scrollable area wnd
00174     CScrollBar*                 GetVScrollBar()     const {return m_VScrollBar;}     // get vertical scrollbar
00175     CCustomListScrollableArea*  GetScrollableArea() const {return m_ScrollableArea;} // get the scrollable area 
00176 
00177     CCustomListScrollableArea*  m_ScrollableArea;           // the scrollable area wnd
00178     CScrollBar*                 m_VScrollBar;               // the scrollbar
00179     INT32*                      m_ColumnOffsetsArray;       // array of column offsets
00180     CBitmap                     m_hHeaderBitmap;            // header bitmap 
00181     CStatic                     m_hHeader;                  // header window 
00182 };
00183 
00185 // CCustomListScrollableArea window .  Represents the scrollable area and
00186 // hosts the list row wnds.
00187 
00188 class CCustomListScrollableArea : public CWnd
00189 {
00190     friend class CCustomListRowWnd;
00191     friend class CCustomList;
00192     ;
00193 protected:
00194     // constructor, destructor
00195     CCustomListScrollableArea(CCustomList* parent);
00196     virtual ~CCustomListScrollableArea();
00197 
00198     CCustomListRowWnd*  AddRow();
00199     void                SelectRow(INT32 RowNum);
00200     void                HandleScrollMessage(UINT32 nSBCode, UINT32 nPos);
00201     CCustomListRowWnd*  GetRow(INT32 row);
00202     INT32                   GetHeight() const {return m_RowCount * CCustomList::ROWHEIGHT ;}
00203 
00204 
00205 
00206 protected:
00207     // Generated message map functions
00208     //{{AFX_VIRTUAL(CCustomListScrollableArea)
00209     protected:
00210     virtual void PostNcDestroy();
00211     //}}AFX_VIRTUAL
00212     //{{AFX_MSG(CCustomListScrollableArea)
00213     afx_msg void OnSize(UINT32 nType, INT32 cx, INT32 cy);
00214     //}}AFX_MSG
00215     DECLARE_MESSAGE_MAP()
00216 
00217 private:
00218     CCustomListRowWnd** m_ListRowsArray;        // the array of row wnd objects
00219     INT32                   m_ScrollPos ;           // the current scroll pos
00220     INT32                   m_CurrentSelectedRow;   // the currently selected row
00221     CFont               m_Font;                 // the font
00222     INT32                   m_RowCount;             // current row count 
00223     CCustomList* m_Parent;                      // the parent CCustomList
00224 };
00225 
00227 // CCustomListRowWnd window. A single row object within a scrollable area
00228 // object. Contains text, controls and bitmaps in column positions.
00229 
00230 class CCustomListRowWnd : public CWnd
00231 {
00232     friend CCustomListScrollableArea; // grant full access to my parent
00233 public:
00234     // construct with the parent Scrollable Area
00235     CCustomListRowWnd   (INT32 i, CCustomListScrollableArea* parent);
00236     virtual ~CCustomListRowWnd();
00237 
00238     void AddText(INT32 col, CString text);
00239     void SetText(INT32 col, CString text);
00240     void AddCheck(INT32 col);
00241     void AddBitmap(INT32 col, HBITMAP bmp1, HBITMAP bmp2, DWORD dwBackColour=0xFFFFFFFF);
00242     void SetChecked(INT32 col,BOOL checked);
00243     bool IsChecked(INT32 col) const;
00244     CString GetText(INT32 col) const;
00245 
00246 private:
00247     HBRUSH GetBackgroundBrush(){return (m_Selected ? m_BackBrushSel:m_BackBrush ); }
00248 
00249     const INT32 m_RowNum;                       // index of this row in the list
00250     CCustomListScrollableArea* m_Parent;    // pointer to our parent
00251     CBrush m_BackBrush;                     // background brush
00252     CBrush m_BackBrushSel;                  // background brush to use when selected
00253     CObject** m_ColumnObjects;              // array of our column aligned objects
00254     bool m_Selected;                        // true if this row is selected
00255 
00256 
00257 protected:
00258 
00259 // Overrides
00260     // ClassWizard generated virtual function overrides
00261     //{{AFX_VIRTUAL(CCustomListRowWnd)
00262     protected:
00263     virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
00264     virtual void PostNcDestroy();
00265     //}}AFX_VIRTUAL
00266 
00267 // Generated message map functions
00268 
00269     //{{AFX_MSG(CCustomListRowWnd)
00270     afx_msg void OnLButtonUp(UINT32 nFlags, CPoint point);
00271     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00272     afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT32 nCtlColor);
00273     afx_msg void OnLButtonDblClk(UINT32 nFlags, CPoint point);
00274     afx_msg void OnKeyDown(UINT32 nChar, UINT32 nRepCnt, UINT32 nFlags);
00275     afx_msg UINT32 OnGetDlgCode();
00276     afx_msg void OnDestroy();
00277     //}}AFX_MSG
00278     DECLARE_MESSAGE_MAP()
00279 };
00280 
00281 
00282 //{{AFX_INSERT_LOCATION}}
00283 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00284 
00285 #endif // !defined(AFX_CUSTOMLIST_H__32AE552D_C07B_4C09_9030_AB20E842FFD6__INCLUDED_)

Generated on Sat Nov 10 03:48:19 2007 for Camelot by  doxygen 1.4.4