home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wpobj.zip / CLRPALET.CSC < prev    next >
Text File  |  1993-10-27  |  7KB  |  229 lines

  1. /****************************************************************************\
  2.  * MODULE NAME: ClrPalet.CSC
  3.  *
  4.  * DESCRIPTION:
  5.  *   Object class definition file for ColorPalette object class.
  6. \****************************************************************************/
  7. ### Note: The header preceding this comment will be emitted in all files.
  8. ###    Any comments to go public should be preceeded with '--'
  9. ###    Any comments to remain private should be preceeded with '#'
  10.  
  11. ## Include the class definition for the parent class
  12. ##
  13. include <wpclrpal.sc>
  14.  
  15. ## Define the object class name and various attributes used by the SOM
  16. ## compiler in generating skeletons for the new methods and overrides that
  17. ## will be needed to implement this object class.
  18. ##
  19. class: ColorPalette,
  20.        external stem   = clrp,
  21.        local,
  22.        external prefix = clrp_,
  23.        classprefix     = clrpM_,
  24.        major version   = 1,
  25.        minor version   = 2;
  26. --
  27. -- OBJECT CLASS: ColorPalette
  28. --
  29. -- CLASS HIERARCHY:
  30. --
  31. --     SOMObject
  32. --       └── WPObject
  33. --             └── WPAbstract
  34. --                   └── WPPalette
  35. --                         └──  WPColorPalette
  36. --                                  └──  ColorPalette
  37. --
  38. -- DESCRIPTION:
  39. --     This object class can act as a stand-alone object class that creates
  40. --     a palette of named colors that can be dragged and dropped much like the
  41. --     system color palette. It can also be used as a replacement object class
  42. --     for the WPColorPalette class - thus replacing the color palette object
  43. --     in the System Setup folder and any other color palettes that the user
  44. --   may have already created.
  45. --
  46. --     Each element of the named color palette contains a sample swatch of the
  47. --     color and the name of that color. Editing a color in the named color
  48. --     palette invokes the Color Wheel control.
  49. --
  50. --     The purpose of this class is to illustrate how the system provided
  51. --     WPPalette object class works, and how the programmer can create his own
  52. --   customized palette of icons, menus, or any other sort of attribute that
  53. --   can be applied using drag and drop.
  54. --
  55.  
  56. ## Specify the parent class name
  57. ##
  58. parent: WPColorPalette;
  59.  
  60. ## Specify the release order of methods. To ensure binary compatability,
  61. ## always add new methods at the END of the release order and never remove
  62. ## any entries from the release order of a ship-level object class.
  63. ##
  64. release order:
  65.         SetEditDlgHandle,
  66.         QueryEditDlgHandle,
  67.         QuerySampleShape;
  68.  
  69. ## Passthru PUBLIC definitions to the .h file
  70. ##
  71. passthru: C.h, after;
  72.  
  73. endpassthru;   /* C.h */
  74.  
  75. ## Passthru PRIVATE definitions to the .ph file: definitions that class
  76. ## client code will not need, but may be required in another internal C
  77. ## file or the resource file.
  78. ##
  79. passthru: C.ph;
  80.  
  81. #define ID_CLRPALET                    1
  82. #define IDDLG_COLORPICKINGDIALOG    10
  83. #define DID_COLORWHEEL                801
  84. #define DID_UNDO                    802
  85. #define DID_HELP                    803
  86. #define DID_BOGUS                    804
  87. #define DID_SPINR                    805
  88. #define DID_SPING                    806
  89. #define DID_SPINB                    807
  90. #define COLOR_WHEEL_CLASS            "ColorWheelControlClass"
  91.  
  92. #define MSG_EDITCELL        WM_USER
  93. #define MSG_SETRGBSPINBTNS    WM_USER    + 1
  94.  
  95. endpassthru;   /* C.ph */
  96.  
  97. ## Passthru IMPLEMENTATION definitions to the .ih file: definitions and
  98. ## includes that are only required in the C source code.
  99. ##
  100. passthru: C.ih;
  101.  
  102. /* These two definitions make our compiled size smaller: otherwise SOM will
  103.  * add a lot of debug code in on our behalf whenever we call a method
  104.  * and around each method call itself.
  105.  */
  106. #define SOM_NoTest 1        /* Disables somTestCls on method resolution */
  107. #define _RETAIL             /* Disables xxxMethodDebug() functions */
  108.  
  109. /* Include standard PM header files
  110.  */
  111. #define INCL_WIN
  112. #define INCL_GPI
  113. #define INCL_DOS
  114. #define INCL_WINWORKPLACE
  115. #define INCL_WPCLASS
  116. #define INCL_WPFOLDER
  117. #include <os2.h>
  118. #include "clrpalet.ph"
  119.  
  120. /* Include C runtime library functions that we might need
  121.  */
  122. #include <string.h>
  123. #include <stdio.h>
  124. #include <memory.h>
  125. #include <stdlib.h>
  126.  
  127. /* Include the colour wheel control header file and define its window
  128.  * procedure and class name
  129.  */
  130. #include "pdsctls.h"
  131.  
  132. MRESULT EXPENTRY ClrWheelWndProc(
  133.     HWND   hWnd,
  134.     ULONG  msg,
  135.     MPARAM mp1,
  136.     MPARAM mp2);
  137.  
  138. /* Dialog procedure that allows the user to change the color of an
  139.  * element within the palette
  140.  */
  141. MRESULT EXPENTRY ColorPickingDialog(
  142.     HWND    hwnd,
  143.     ULONG    msg,
  144.     MPARAM    mp1,
  145.     MPARAM    mp2);
  146.  
  147. /* Data structure used by ColorPickingDialog
  148.  */
  149. typedef struct _COLORPICKDATA
  150. {
  151.     ColorPalette    *Palette;        /* Palette object */
  152.     PCELL            pCell;            /* Cell being edited */
  153.     ULONG            ulRGBOriginal;    /* Original color of the cell */
  154.     BOOL            fSpinSet;        /* Spinbutton is setting the color */
  155. } COLORPICKDATA;
  156.  
  157. /* Global variables
  158.  */
  159. HMODULE vhmodClrPalet        = NULLHANDLE;
  160.  
  161. endpassthru;   /* .ih */
  162.  
  163. ## Define instance data
  164. ##
  165. data:
  166.    HWND        hwndEditDlg;        /* Editing dialog handle */
  167.    HWND        hwndColorSample;    /* Sample control that we are talking with */
  168.    PCELL    pSelectedCell;        /* Currently selected cell */
  169.  
  170. ## Specify the methods and method overrides needed to implement this
  171. ## object class. The SOM compiler will generate skeletons for each of
  172. ## these methods in our source code.
  173. ##
  174. methods:
  175.  
  176. ## Define instance methods
  177.  
  178. BOOL    SetEditDlgHandle( HWND    hwndEditDlg );
  179. --
  180. -- NEW METHOD: SetEditDlgHandle
  181. --
  182. -- DESCRIPTION:
  183. --   Store the handle of the color picking dialog window.
  184. --
  185.  
  186. HWND    QueryEditDlgHandle( );
  187. --
  188. -- NEW METHOD: QueryEditDlgHandle
  189. --
  190. -- DESCRIPTION:
  191. --   Retrieve the handle of the color picking dialog window. Return NULL
  192. --   if the dialog has not yet been created.
  193. --
  194.  
  195. BOOL    QuerySampleShape( PPOINTL    pPoints, PULONG pcPoints );
  196. --
  197. -- NEW METHOD: QuerySampleShape
  198. --
  199. -- DESCRIPTION:
  200. --   Describes the shape to be drawn for each color swatch. The pcPoints
  201. --   variable must always be filled out, to indicate how many points are
  202. --   contained in the pPoints array. pPoints either contains an array of
  203. --   POINTL structures that this method should fill out or it can be NULL
  204. --   to indicate that cPoints is being queried.
  205. --
  206. --   The point coordinates are specified in percentage coordinates.
  207. --
  208.  
  209. ## Specify instance methods being overridden
  210.  
  211. ## Define class methods
  212.  
  213. ## Specify class methods being overridden
  214.  
  215. override wpPaintCell;
  216.  
  217. override wpEditCell;
  218.  
  219. override wpRedrawCell;
  220.  
  221. override wpSetup;
  222.  
  223. override wpclsInitData, class;
  224.  
  225. override wpclsQueryIconData, class;
  226.  
  227. override wpclsQueryStyle, class;
  228.  
  229.