cclistga.h

Go to the documentation of this file.
00001 // $Id: cclistga.h 1282 2006-06-09 09:46:49Z 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 
00099 #ifndef INC_CCLISTGADGET
00100 #define INC_CCLISTGADGET
00101 
00102 #include <afx.h>
00103 #include <afxtempl.h>
00104 #include <afxcoll.h>
00105 //#include "ccobject.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "dlgtypes.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "fixstr16.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 
00110 #define ID_HEADER   179 // an arbitrary ID for the header
00111 // These defines have to be even to avoid having to pad bitmap scanlines
00112 // **************************************************************************************************
00113 #define SWITCH_MARGIN   8 // the margin (in pixels) we leave to the left of the first switch 
00114 #define SWITCH_SEPARATOR 4 // the width (in pixels) separating two consecutive switches
00115 #define SWITCH_WIDTH    12 // width of switch bitmap
00116 //***************************************************************************************************
00117 #define SWITCH_HEIGHT   12   // height of switch bitmap
00118 #define SWITCHES_SUPPORTED  3 // max no of switches supported
00119 #define COLOUR_PATCH_WIDTH  12
00120 #define COLOUR_PATCH_HEIGHT 12
00121 #define MAX_NO_ITEMS 64 // maximum no of items the list can have - quite conservative to save Win32s GDI memory
00122 
00123 
00124 /********************************************************************************************
00125 
00126 >   class CCListGadget  :   public CC_CLASS_MEMDUMP
00127 
00128     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
00129     Created:    1/08/96
00130     Purpose:     wrapper class for the Win95 listview control
00131 
00132     SeeAlso:    PrintSepsTab; PrintImagesetterTab;
00133 
00134 ********************************************************************************************/
00135 
00136 class CCListGadget  :   public CC_CLASS_MEMDUMP
00137 {
00138 CC_DECLARE_MEMDUMP(CCListGadget)
00139 
00140 public:
00141     CCListGadget() {};
00142     ~CCListGadget();
00143 
00144     // Static function to create a new gadget from a res template ID and a window ID/handle
00145     // On creation all list gadgets are added to a global list
00146     static CCListGadget* Create(CWindowID parentID, CGadgetID gadgetID);
00147 
00148     // Static function to retrieve a pointer to a list gadget knowing its resource ID and the parent's handle
00149     static CCListGadget* GetGadget(CWindowID parentID, CGadgetID gadgetID);
00150 
00151     // Function to create a custom header from a bitmap resource
00152     BOOL CreateCustomHeader (UINT32 bitmapID);
00153 
00154     // Function to add switches (ex. check/tick boxes) to the list control. Up to 3 switches per item are supported.
00155     BOOL SetSwitches(UINT32 noOfSwitches, UINT32 idBitmapOn, UINT32 idBitmapOff, UINT32 idDisabledBitmapOn, UINT32 idDisabledBitmapOff);
00156 
00157     // Gets the current number of switches
00158     UINT32 GetNumberOfSwitches();
00159 
00160     // Sets the text for a non-custom header
00161     BOOL SetHeaderString(StringBase& string, UINT32 colIndex);
00162 
00163     // Function to set the columns for the list
00164     BOOL SetNumberOfColumns(UINT32 nColumns);
00165 
00166     // Gets the current number of columns
00167     UINT32 GetNumberOfColumns();
00168 
00169     // Changes the width of a column. By default all columns created by SetColumns() have the same width
00170     BOOL SetColumnWidth(INT32 colIndex, INT32 width);
00171 
00172     // Retrieves the current width of a column based on its 0-based index
00173     INT32 GetColumnWidth(INT32 columnIndex);
00174 
00175     // Sets the state of a switch (determines whether the bitmapOn or bitmapOf is shown)
00176     BOOL SetSwitchState(BOOL state, UINT32 itemIndex, UINT32 switchIndex);
00177 
00178     // Retrieves the current state of a switch (ON/OFF)
00179     BOOL GetSwitchState(UINT32 itemIndex, UINT32 switchIndex);
00180 
00181     // Adds an item to the list (pItemImage points to an optional bitmap associated with the item and displayed to its right
00182     BOOL AddItem(StringBase& itemString, KernelBitmap* pItemImage = 0);
00183 
00184     // Used if the the listitem is a actually a colour - it displays a square colour patch next to the color name
00185     BOOL AddColourListItem(StringBase& colourName, INT32 red, INT32 green, INT32 blue, BOOL IsSpotColour = FALSE);
00186 
00187     // Adds an item to the list, creating the associated image from a bitmap resource ID
00188     BOOL AddItem(StringBase& itemString, UINT32 bitmapEnabledID, UINT32 bitmapDisabledID);
00189 
00190     // Inserts an item at a certain position in the list
00191     BOOL InsertItem(UINT32 index, StringBase& itemString, KernelBitmap* pItemImage = 0);
00192 
00193     // Inserts an item at a certain position in the list, creating the associated image from a bitmap resource ID
00194     BOOL InsertItem(UINT32 index, StringBase& itemString, UINT32 bitmapID);
00195 
00196     // Sets the text for an item or one of its components
00197     BOOL SetItemString(StringBase& itemString, UINT32 itemIndex, UINT32 columnIndex);
00198 
00199     // Retrieve the text of an item or one of its components
00200     BOOL GetItemString(StringBase& itemString, UINT32 itemIndex, UINT32 columnIndex);
00201     
00202     // Does exactly that
00203     BOOL DeleteAllItems();
00204 
00205     // Returns the index of the item currently selected, -1 if none
00206     INT32 GetSelectedItemIndex();
00207 
00208     // Sets the given item to be selected (and deselects all other items)
00209     void SetSelectedItemIndex(INT32 NewSel);
00210     
00211     // Returns the number of items contained in the list
00212     INT32 GetItemCount();
00213 
00214 
00215 
00216 private:
00217     CGadgetID listID; // the resource template ID
00218     CWindowID formID; // the handle of the parent dialog box or tab
00219     CFont gadgetFont; // used only on Win32s
00220     UINT32 columns; 
00221     UINT32 switches;
00222     BOOL isEnabled;
00223     HBITMAP CreateScreenCompatibleBitmap(INT32 width, INT32 height);
00224     HIMAGELIST CreateImageList(INT32 imageWidth, INT32 imageHeight);
00225     HIMAGELIST hStateEnabled; // handle to state image list to be shown when the control is enabled (white background)
00226     HIMAGELIST hStateDisabled; // handle to state image list to be shown when the control is disabled ( gray background)
00227     HIMAGELIST hImageListEnabled; // handle to the the item image list - in the enabled state
00228     HIMAGELIST hImageListDisabled; // handle to the item image list - when disabled
00229     HWND hHeader;
00230     HBITMAP hHeaderBitmap;
00231     INT32 switchColumnWidth; // width of the bitmap containing the switches - needed when resizing the columns
00232     INT32 SwitchLeftCoord[3]; // we only support up to 3 switches !
00233     CCListGadget(CWindowID parentID, CGadgetID gadgetID); // private constructor, called by ::Create()
00234     BOOL SetBitmapBkgToSystem(HBITMAP hBitmap); // will set the bkg of the bitmap to the bkg of dialog boxes - called when the colour scheme changes
00235     BOOL AddToList(); // add the gadget to the global list
00236     BOOL isColourList;
00237     // Function to handle clicks inside the client area - called by the DialogManager
00238     // Returns TRUE if the click resulted in a change in the state of the control, FALSE othewise
00239     BOOL OnGadgetClicked();
00240     static BOOL OnSysColorChange(CWindowID dialogID);
00241     // We are using our own enabler function as the Windows one looks awful (called by the DialogManager)
00242     // DO NOT call DialogManager::EnableGadget on a control before you have created it!
00243     BOOL SetEnabled(BOOL enabled);
00244     // Clean-up function - called by the DialogManager when the associated interface object receives WM_DESTROY
00245     static void OnDialogClose(CWindowID dialogID);
00246     // The actual killer function 
00247     void DestroyGadget();
00248     // Support class - entry in the global list
00249     class ListEntry : public CObject
00250     {
00251     public:
00252         ListEntry(CWindowID wndID, CGadgetID gdgtID, CCListGadget* ptrListGadget)   :   parentID(wndID), gadgetID(gdgtID), pListGadget(ptrListGadget) {};
00253         CWindowID parentID;
00254         CGadgetID gadgetID;
00255         CCListGadget* pListGadget;
00256     };
00257     // The global list - actually, an array
00258     static CTypedPtrArray<CObArray, ListEntry*> GadgetList;
00259     friend class DialogManager;
00260 };
00261 
00262     
00263 
00264 #endif

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