home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wpobj.zip / CLRPALET.IH < prev    next >
Text File  |  1993-11-10  |  20KB  |  671 lines

  1.  
  2. /*
  3.  * This file was generated by the SOM Compiler.
  4.  * FileName: clrpalet.ih.
  5.  * Generated using:
  6.  *     SOM Precompiler spc: 1.22
  7.  *     SOM Emitter emitih: 1.59
  8.  */
  9.  
  10. /*
  11.  * 
  12.  * 
  13.  * MODULE NAME: ClrPalet.CSC
  14.  * 
  15.  * DESCRIPTION:
  16.  *   Object class definition file for ColorPalette object class.
  17.  */
  18.  
  19.  
  20. #ifndef clrpalet_ih
  21. #define clrpalet_ih
  22.  
  23.  
  24. /*
  25.  * Passthru lines: File: "C.ih", "before"
  26.  */
  27.  
  28. /* These two definitions make our compiled size smaller: otherwise SOM will
  29.  * add a lot of debug code in on our behalf whenever we call a method
  30.  * and around each method call itself.
  31.  */
  32. #define SOM_NoTest 1        /* Disables somTestCls on method resolution */
  33. #define _RETAIL             /* Disables xxxMethodDebug() functions */
  34.  
  35. /* Include standard PM header files
  36.  */
  37. #define INCL_WIN
  38. #define INCL_GPI
  39. #define INCL_DOS
  40. #define INCL_WINWORKPLACE
  41. #define INCL_WPCLASS
  42. #define INCL_WPFOLDER
  43. #include <os2.h>
  44. #include "clrpalet.ph"
  45.  
  46. /* Include C runtime library functions that we might need
  47.  */
  48. #include <string.h>
  49. #include <stdio.h>
  50. #include <memory.h>
  51. #include <stdlib.h>
  52.  
  53. /* Include the colour wheel control header file and define its window
  54.  * procedure and class name
  55.  */
  56. #include "pdsctls.h"
  57.  
  58. MRESULT EXPENTRY ClrWheelWndProc(
  59.     HWND   hWnd,
  60.     ULONG  msg,
  61.     MPARAM mp1,
  62.     MPARAM mp2);
  63.  
  64. /* Dialog procedure that allows the user to change the color of an
  65.  * element within the palette
  66.  */
  67. MRESULT EXPENTRY ColorPickingDialog(
  68.     HWND    hwnd,
  69.     ULONG    msg,
  70.     MPARAM    mp1,
  71.     MPARAM    mp2);
  72.  
  73. /* Data structure used by ColorPickingDialog
  74.  */
  75. typedef struct _COLORPICKDATA
  76. {
  77.     ColorPalette    *Palette;        /* Palette object */
  78.     PCELL            pCell;            /* Cell being edited */
  79.     ULONG            ulRGBOriginal;    /* Original color of the cell */
  80.     BOOL            fSpinSet;        /* Spinbutton is setting the color */
  81. } COLORPICKDATA;
  82.  
  83. /* Global variables
  84.  */
  85. HMODULE vhmodClrPalet        = NULLHANDLE;
  86.  
  87.  
  88. #include "clrpalet.h"
  89.  
  90. /*
  91.  * Set the scope of methods functions
  92.  */
  93. #ifndef SOM_Scope
  94. #ifdef __cplusplus
  95. #define SOM_Scope extern "C"
  96. #else
  97. #define SOM_Scope extern
  98. #endif
  99. #endif
  100.  
  101. #ifndef SOM_CurrentClass
  102. #define SOM_CurrentClass ColorPaletteCClassData.parentMtab
  103. #endif
  104.  
  105. #define ColorPalette_MaxNoMethods 3
  106.  
  107. /*
  108.  * Instance data
  109.  */
  110. typedef struct {
  111.     HWND hwndEditDlg;
  112.     HWND hwndColorSample;
  113.     PCELL pSelectedCell;
  114. } ColorPaletteData;
  115.  
  116. /*
  117.  * Instance variable access macros
  118.  */
  119. #define _hwndEditDlg (somThis->hwndEditDlg)
  120. #define _hwndColorSample (somThis->hwndColorSample)
  121. #define _pSelectedCell (somThis->pSelectedCell)
  122.  
  123. /*
  124.  * Getdata macro
  125.  */
  126. #define ColorPaletteGetData(somSelf) \
  127.     ((ColorPaletteData *) \
  128.         SOM_DataResolve(somSelf, ColorPaletteCClassData.instanceDataToken))
  129.  
  130. /*
  131.  * Trace/Debug macro
  132.  */
  133. #ifndef ColorPaletteMethodDebug
  134. #define ColorPaletteMethodDebug(c,m) SOMMethodDebug(c,m)
  135. #endif
  136.  
  137. /*
  138.  * Begin stuff that only goes in the primary file
  139.  */
  140. #ifdef ColorPalette_Class_Source
  141.  
  142. /*
  143.  * Current class macros for Instance and Meta classes.
  144.  */
  145. #undef SOMMeta
  146. #define SOMMeta M_ColorPaletteCClassData.parentMtab
  147. #undef SOMInstance
  148. #define SOMInstance ColorPaletteCClassData.parentMtab
  149.  
  150. #ifndef M_ColorPalette_Class_Source
  151. #define M_ColorPalette_Class_Source
  152. #endif    /* M_ColorPalette_Class_Source */
  153.  
  154. /*
  155.  * Generate the Apply Stubs.
  156.  */
  157. #pragma linkage(somAP_SetEditDlgHandle, system)
  158. static BOOL   SOMLINK somAP_SetEditDlgHandle(ColorPalette *somSelf,
  159.         somId __id,
  160.         somId __desc,
  161.         va_list __ap)
  162. {
  163.     HWND hwndEditDlg = va_arg(__ap, HWND);
  164.     __ap; __id; __desc;           /* Referenced to prevent warning msg */
  165.  
  166.     return (ColorPalette_SetEditDlgHandle(somSelf,hwndEditDlg));
  167. }
  168.  
  169. #pragma linkage(somAP_QueryEditDlgHandle, system)
  170. static HWND   SOMLINK somAP_QueryEditDlgHandle(ColorPalette *somSelf,
  171.         somId __id,
  172.         somId __desc,
  173.         va_list __ap)
  174. {
  175.     __ap; __id; __desc;           /* Referenced to prevent warning msg */
  176.  
  177.     return (ColorPalette_QueryEditDlgHandle(somSelf));
  178. }
  179.  
  180. #pragma linkage(somAP_QuerySampleShape, system)
  181. static BOOL   SOMLINK somAP_QuerySampleShape(ColorPalette *somSelf,
  182.         somId __id,
  183.         somId __desc,
  184.         va_list __ap)
  185. {
  186.     PPOINTL pPoints = va_arg(__ap, PPOINTL);
  187.     PULONG pcPoints = va_arg(__ap, PULONG);
  188.     __ap; __id; __desc;           /* Referenced to prevent warning msg */
  189.  
  190.     return (ColorPalette_QuerySampleShape(somSelf,pPoints,pcPoints));
  191. }
  192.  
  193.  
  194. /*
  195.  * Overridden method: wpPaintCell
  196.  */
  197. #pragma linkage(clrp_wpPaintCell, system)
  198. SOM_Scope VOID   SOMLINK clrp_wpPaintCell(ColorPalette *somSelf,
  199.         PCELL pCell,
  200.         HPS hps,
  201.         PRECTL prcl,
  202.         BOOL fHilite);
  203. #ifndef parent_wpPaintCell
  204. static char *somMN_wpPaintCell = "wpPaintCell";
  205. static somId somId_wpPaintCell = &somMN_wpPaintCell;
  206. #define parent_wpPaintCell(somSelf,pCell,hps,prcl,fHilite) \
  207.     ((SOM_ParentResolveE(WPPalette, SOM_CurrentClass, wpPaintCell)) \
  208.      (somSelf,pCell,hps,prcl,fHilite))
  209. #endif
  210. #define ColorPaletteParent_wpPaintCell parent_wpPaintCell
  211.  
  212. /*
  213.  * Overridden method: wpEditCell
  214.  */
  215. #pragma linkage(clrp_wpEditCell, system)
  216. SOM_Scope BOOL   SOMLINK clrp_wpEditCell(ColorPalette *somSelf,
  217.         PCELL pCell,
  218.         HWND hwndPal);
  219. #ifndef parent_wpEditCell
  220. static char *somMN_wpEditCell = "wpEditCell";
  221. static somId somId_wpEditCell = &somMN_wpEditCell;
  222. #define parent_wpEditCell(somSelf,pCell,hwndPal) \
  223.     ((SOM_ParentResolveE(WPPalette, SOM_CurrentClass, wpEditCell)) \
  224.      (somSelf,pCell,hwndPal))
  225. #endif
  226. #define ColorPaletteParent_wpEditCell parent_wpEditCell
  227.  
  228. /*
  229.  * Overridden method: wpRedrawCell
  230.  */
  231. #pragma linkage(clrp_wpRedrawCell, system)
  232. SOM_Scope BOOL   SOMLINK clrp_wpRedrawCell(ColorPalette *somSelf,
  233.         PCELL pCell);
  234. #ifndef parent_wpRedrawCell
  235. static char *somMN_wpRedrawCell = "wpRedrawCell";
  236. static somId somId_wpRedrawCell = &somMN_wpRedrawCell;
  237. #define parent_wpRedrawCell(somSelf,pCell) \
  238.     ((SOM_ParentResolveE(WPPalette, SOM_CurrentClass, wpRedrawCell)) \
  239.      (somSelf,pCell))
  240. #endif
  241. #define ColorPaletteParent_wpRedrawCell parent_wpRedrawCell
  242.  
  243. /*
  244.  * Overridden method: wpSetup
  245.  */
  246. #pragma linkage(clrp_wpSetup, system)
  247. SOM_Scope BOOL   SOMLINK clrp_wpSetup(ColorPalette *somSelf,
  248.         PSZ pszSetupString);
  249. #ifndef parent_wpSetup
  250. static char *somMN_wpSetup = "wpSetup";
  251. static somId somId_wpSetup = &somMN_wpSetup;
  252. #define parent_wpSetup(somSelf,pszSetupString) \
  253.     ((SOM_ParentResolveE(WPObject, SOM_CurrentClass, wpSetup)) \
  254.      (somSelf,pszSetupString))
  255. #endif
  256. #define ColorPaletteParent_wpSetup parent_wpSetup
  257.  
  258. /*
  259.  * Temporary class data structure used only in class creation
  260.  */
  261. static somClassDataStructure ColorPalettetempClassData;
  262.  
  263. /*
  264.  * Initialize the class data structure
  265.  */
  266. struct ColorPaletteClassDataStructure ColorPaletteClassData = {(SOMAny *) NULL};
  267.  
  268. /*
  269.  * Define the C class data structure
  270.  */
  271. struct ColorPaletteCClassDataStructure ColorPaletteCClassData = {(somMethodTab *) NULL};
  272.  
  273. /*
  274.  * New Method: SetEditDlgHandle
  275.  */
  276. #pragma linkage(clrp_SetEditDlgHandle, system)
  277. SOM_Scope BOOL   SOMLINK clrp_SetEditDlgHandle(ColorPalette *somSelf,
  278.         HWND hwndEditDlg);
  279. static char *somMN_SetEditDlgHandle = "SetEditDlgHandle";
  280. static somId somId_SetEditDlgHandle = &somMN_SetEditDlgHandle;
  281. static char *somDS_SetEditDlgHandle = somMD_ColorPalette_SetEditDlgHandle;
  282. static somId somDI_SetEditDlgHandle = &somDS_SetEditDlgHandle;
  283. #pragma linkage(somRD_SetEditDlgHandle, system)
  284. static BOOL   SOMLINK somRD_SetEditDlgHandle(ColorPalette *somSelf,
  285.         HWND hwndEditDlg)
  286. {
  287.     return ((BOOL) va_somDispatchL(somSelf, somId_SetEditDlgHandle,
  288.         _somGetMethodDescriptor(SOM_GetClass(somSelf),somId_SetEditDlgHandle),hwndEditDlg));
  289. }
  290.  
  291. /*
  292.  * New Method: QueryEditDlgHandle
  293.  */
  294. #pragma linkage(clrp_QueryEditDlgHandle, system)
  295. SOM_Scope HWND   SOMLINK clrp_QueryEditDlgHandle(ColorPalette *somSelf);
  296. static char *somMN_QueryEditDlgHandle = "QueryEditDlgHandle";
  297. static somId somId_QueryEditDlgHandle = &somMN_QueryEditDlgHandle;
  298. static char *somDS_QueryEditDlgHandle = somMD_ColorPalette_QueryEditDlgHandle;
  299. static somId somDI_QueryEditDlgHandle = &somDS_QueryEditDlgHandle;
  300. #pragma linkage(somRD_QueryEditDlgHandle, system)
  301. static HWND   SOMLINK somRD_QueryEditDlgHandle(ColorPalette *somSelf)
  302. {
  303.     return ((HWND) va_somDispatchL(somSelf, somId_QueryEditDlgHandle,
  304.         _somGetMethodDescriptor(SOM_GetClass(somSelf),somId_QueryEditDlgHandle)));
  305. }
  306.  
  307. /*
  308.  * New Method: QuerySampleShape
  309.  */
  310. #pragma linkage(clrp_QuerySampleShape, system)
  311. SOM_Scope BOOL   SOMLINK clrp_QuerySampleShape(ColorPalette *somSelf,
  312.         PPOINTL pPoints,
  313.         PULONG pcPoints);
  314. static char *somMN_QuerySampleShape = "QuerySampleShape";
  315. static somId somId_QuerySampleShape = &somMN_QuerySampleShape;
  316. static char *somDS_QuerySampleShape = somMD_ColorPalette_QuerySampleShape;
  317. static somId somDI_QuerySampleShape = &somDS_QuerySampleShape;
  318. #pragma linkage(somRD_QuerySampleShape, system)
  319. static BOOL   SOMLINK somRD_QuerySampleShape(ColorPalette *somSelf,
  320.         PPOINTL pPoints,
  321.         PULONG pcPoints)
  322. {
  323.     return ((BOOL) va_somDispatchL(somSelf, somId_QuerySampleShape,
  324.         _somGetMethodDescriptor(SOM_GetClass(somSelf),somId_QuerySampleShape),pPoints,pcPoints));
  325. }
  326.  
  327. /*
  328.  * Routines to create the class object
  329.  */
  330.  
  331. /*
  332.  * Declare the Static Methods table.
  333.  */
  334. static somStaticMethod_t ColorPaletteSM[] = {
  335.     {    &ColorPaletteClassData.SetEditDlgHandle,
  336.          &somId_SetEditDlgHandle,
  337.          &somDI_SetEditDlgHandle,
  338.          (somMethodProc *) clrp_SetEditDlgHandle,
  339.          (somMethodProc *) somRD_SetEditDlgHandle,
  340.          (somMethodProc *) somAP_SetEditDlgHandle    },
  341.     {    &ColorPaletteClassData.QueryEditDlgHandle,
  342.          &somId_QueryEditDlgHandle,
  343.          &somDI_QueryEditDlgHandle,
  344.          (somMethodProc *) clrp_QueryEditDlgHandle,
  345.          (somMethodProc *) somRD_QueryEditDlgHandle,
  346.          (somMethodProc *) somAP_QueryEditDlgHandle    },
  347.     {    &ColorPaletteClassData.QuerySampleShape,
  348.          &somId_QuerySampleShape,
  349.          &somDI_QuerySampleShape,
  350.          (somMethodProc *) clrp_QuerySampleShape,
  351.          (somMethodProc *) somRD_QuerySampleShape,
  352.          (somMethodProc *) somAP_QuerySampleShape    },
  353. };
  354.  
  355.  
  356. /*
  357.  * Declare the Override Methods table.
  358.  */
  359. static somOverrideMethod_t ColorPaletteOM[] = {
  360.     {    &somId_wpPaintCell,
  361.          (somMethodProc *) clrp_wpPaintCell    },
  362.     {    &somId_wpEditCell,
  363.          (somMethodProc *) clrp_wpEditCell    },
  364.     {    &somId_wpRedrawCell,
  365.          (somMethodProc *) clrp_wpRedrawCell    },
  366.     {    &somId_wpSetup,
  367.          (somMethodProc *) clrp_wpSetup    },
  368. };
  369.  
  370. static void ColorPalettesomInitializeClass ()
  371. {
  372.     int i;
  373.     somStaticMethod_t *smp;
  374.     somOverrideMethod_t *omp;
  375.  
  376. /*
  377.  * Add the Static Methods.
  378.  */
  379.     for (smp = ColorPaletteSM, i = 0; i < 3; smp++, i++)
  380.         *(smp->classData) =
  381.             _somAddStaticMethod (ColorPalettetempClassData.classObject,
  382.                 *(smp->methodId), *(smp->methodDescriptor),
  383.                 smp->method, smp->redispatchStub,
  384.                 smp->applyStub);
  385.  
  386.  
  387. /*
  388.  * Override methods.
  389.  */
  390.     for (omp = ColorPaletteOM, i = 0; i < 4; omp++, i++)
  391.         _somOverrideSMethod (ColorPalettetempClassData.classObject,
  392.             *(omp->methodId), omp->method);
  393.  
  394. }
  395.  
  396. #pragma linkage(ColorPalettesomCreateClass, system)
  397. static void SOMLINK ColorPalettesomCreateClass(SOMClass *pClsObj,
  398.                            SOMClass *mClsObj)
  399. {
  400.     ColorPalettetempClassData.classObject = _somNew (mClsObj);
  401.     _somInitClass (ColorPalettetempClassData.classObject,
  402.         "ColorPalette",
  403.         pClsObj,
  404.         sizeof(ColorPaletteData),
  405.         ColorPalette_MaxNoMethods,
  406.         ColorPalette_MajorVersion,
  407.         ColorPalette_MinorVersion);
  408.     ColorPaletteCClassData.instanceDataToken = 
  409.     _somGetInstanceToken(ColorPalettetempClassData.classObject);
  410.     ColorPalettesomInitializeClass();
  411.     ColorPaletteCClassData.parentMtab =
  412.     _somGetPClsMtab(ColorPalettetempClassData.classObject);
  413.     _somSetClassData(ColorPalettetempClassData.classObject, (somClassDataStructure *)&ColorPaletteClassData);
  414.     _somClassReady(ColorPalettetempClassData.classObject);
  415.     /* make newly created class object visible */
  416.     ColorPaletteClassData.classObject = ColorPalettetempClassData.classObject;
  417. }
  418.  
  419. ColorPalette * SOMLINK ColorPaletteNewClass (integer4 scemajorVersion,
  420.         integer4 sceminorVersion)
  421. {
  422.     SOMClass *pClsObj;
  423.     SOMClass *mClsObj;
  424.  
  425.     /* Check the version numbers */
  426.     if (((scemajorVersion != 0) && 
  427.          (scemajorVersion != ColorPalette_MajorVersion)) ||
  428.         ((sceminorVersion != 0) && 
  429.          (sceminorVersion > ColorPalette_MinorVersion))) {
  430.     somPrintf("ColorPaletteNewClass: Error, bad version numbers.\n");
  431.     SOM_Error(SOMERROR_BadVersion);
  432.     }
  433.     /* Don't do anything if class object is already created. */
  434.     if (ColorPaletteClassData.classObject != (SOMAny *) NULL)
  435.     return(ColorPaletteClassData.classObject);
  436.  
  437.     /* Make sure the environment is initialized. */
  438.     if (SOMClassMgrObject == (SOMAny *) NULL) somEnvironmentNew();
  439.     if (SOMClassMgrObject == (SOMAny *) NULL)
  440.     SOM_Error(SOMERROR_CouldNotStartup);
  441.  
  442.     /* Get the parent class object. */
  443.     WPColorPaletteNewClass(1,2);    /* static reference */
  444.     pClsObj = _somFindClass(SOMClassMgrObject,
  445.         SOM_IdFromString("WPColorPalette"), 1, 2);
  446.     if (pClsObj == (SOMClass *) NULL)
  447.     SOM_Error(SOMERROR_NoParentClass);
  448.  
  449.     /* Explicit metaclass, so get it */ 
  450.     M_ColorPaletteNewClass(0,0);    /* static reference */
  451.     mClsObj = _somFindClass(SOMClassMgrObject,
  452.         SOM_IdFromString("M_ColorPalette"), 0, 0);
  453.     if (mClsObj == (SOMClass *) NULL)
  454.     SOM_Error(SOMERROR_NoMetaClass);
  455.  
  456.     somConstructClass(ColorPalettesomCreateClass, pClsObj, mClsObj,
  457.              &ColorPalettetempClassData);
  458.     return (ColorPaletteClassData.classObject);
  459. }
  460.  
  461. #endif                   /* ColorPalette_Class_Source */
  462.  
  463. #endif       /* clrpalet_ih */
  464.  
  465. /*
  466.  * This file was generated by the SOM Compiler.
  467.  * FileName: clrpalet.ih.
  468.  * Generated using:
  469.  *     SOM Precompiler spc: 1.22
  470.  *     SOM Emitter emitih: 1.59
  471.  */
  472.  
  473. #ifndef clrpalet_mih
  474. #define clrpalet_mih
  475.  
  476.  
  477. /*
  478.  * Set the scope of methods functions
  479.  */
  480. #ifndef SOM_Scope
  481. #ifdef __cplusplus
  482. #define SOM_Scope extern "C"
  483. #else
  484. #define SOM_Scope extern
  485. #endif
  486. #endif
  487.  
  488. #ifndef SOM_CurrentClass
  489. #define SOM_CurrentClass M_ColorPaletteCClassData.parentMtab
  490. #endif
  491.  
  492. #define M_ColorPalette_MaxNoMethods 0
  493.  
  494. /*
  495.  * Instance data
  496.  */
  497. typedef void M_ColorPaletteData;
  498.  
  499. /*
  500.  * Trace/Debug macro
  501.  */
  502. #ifndef M_ColorPaletteMethodDebug
  503. #define M_ColorPaletteMethodDebug(c,m) SOMMethodDebug(c,m)
  504. #endif
  505.  
  506. /*
  507.  * Begin stuff that only goes in the primary file
  508.  */
  509. #ifdef M_ColorPalette_Class_Source
  510.  
  511. /*
  512.  * Current class macros for Instance and Meta classes.
  513.  */
  514.  
  515. /*
  516.  * Generate the Apply Stubs.
  517.  */
  518.  
  519. /*
  520.  * Overridden method: wpclsInitData
  521.  */
  522. #pragma linkage(clrpM_wpclsInitData, system)
  523. SOM_Scope void   SOMLINK clrpM_wpclsInitData(M_ColorPalette *somSelf);
  524. #ifndef parent_wpclsInitData
  525. static char *somMN_wpclsInitData = "wpclsInitData";
  526. static somId somId_wpclsInitData = &somMN_wpclsInitData;
  527. #define parent_wpclsInitData(somSelf) \
  528.     ((SOM_ParentResolveE(M_WPObject, SOM_CurrentClass, wpclsInitData)) \
  529.      (somSelf))
  530. #endif
  531. #define M_ColorPaletteParent_wpclsInitData parent_wpclsInitData
  532.  
  533. /*
  534.  * Overridden method: wpclsQueryIconData
  535.  */
  536. #pragma linkage(clrpM_wpclsQueryIconData, system)
  537. SOM_Scope ULONG   SOMLINK clrpM_wpclsQueryIconData(M_ColorPalette *somSelf,
  538.         PICONINFO pIconInfo);
  539. #ifndef parent_wpclsQueryIconData
  540. static char *somMN_wpclsQueryIconData = "wpclsQueryIconData";
  541. static somId somId_wpclsQueryIconData = &somMN_wpclsQueryIconData;
  542. #define parent_wpclsQueryIconData(somSelf,pIconInfo) \
  543.     ((SOM_ParentResolveE(M_WPObject, SOM_CurrentClass, wpclsQueryIconData)) \
  544.      (somSelf,pIconInfo))
  545. #endif
  546. #define M_ColorPaletteParent_wpclsQueryIconData parent_wpclsQueryIconData
  547.  
  548. /*
  549.  * Overridden method: wpclsQueryStyle
  550.  */
  551. #pragma linkage(clrpM_wpclsQueryStyle, system)
  552. SOM_Scope ULONG   SOMLINK clrpM_wpclsQueryStyle(M_ColorPalette *somSelf);
  553. #ifndef parent_wpclsQueryStyle
  554. static char *somMN_wpclsQueryStyle = "wpclsQueryStyle";
  555. static somId somId_wpclsQueryStyle = &somMN_wpclsQueryStyle;
  556. #define parent_wpclsQueryStyle(somSelf) \
  557.     ((SOM_ParentResolveE(M_WPObject, SOM_CurrentClass, wpclsQueryStyle)) \
  558.      (somSelf))
  559. #endif
  560. #define M_ColorPaletteParent_wpclsQueryStyle parent_wpclsQueryStyle
  561.  
  562. /*
  563.  * Temporary class data structure used only in class creation
  564.  */
  565. static somClassDataStructure M_ColorPalettetempClassData;
  566.  
  567. /*
  568.  * Initialize the class data structure
  569.  */
  570. struct M_ColorPaletteClassDataStructure M_ColorPaletteClassData = {(SOMAny *) NULL};
  571.  
  572. /*
  573.  * Define the C class data structure
  574.  */
  575. struct M_ColorPaletteCClassDataStructure M_ColorPaletteCClassData = {(somMethodTab *) NULL};
  576.  
  577. /*
  578.  * Routines to create the class object
  579.  */
  580.  
  581. /*
  582.  * Declare the Override Methods table.
  583.  */
  584. static somOverrideMethod_t M_ColorPaletteOM[] = {
  585.     {    &somId_wpclsInitData,
  586.          (somMethodProc *) clrpM_wpclsInitData    },
  587.     {    &somId_wpclsQueryIconData,
  588.          (somMethodProc *) clrpM_wpclsQueryIconData    },
  589.     {    &somId_wpclsQueryStyle,
  590.          (somMethodProc *) clrpM_wpclsQueryStyle    },
  591. };
  592.  
  593. static void M_ColorPalettesomInitializeClass ()
  594. {
  595.     int i;
  596.     somOverrideMethod_t *omp;
  597.  
  598. /*
  599.  * Override methods.
  600.  */
  601.     for (omp = M_ColorPaletteOM, i = 0; i < 3; omp++, i++)
  602.         _somOverrideSMethod (M_ColorPalettetempClassData.classObject,
  603.             *(omp->methodId), omp->method);
  604.  
  605. }
  606.  
  607. #pragma linkage(M_ColorPalettesomCreateClass, system)
  608. static void SOMLINK M_ColorPalettesomCreateClass(SOMClass *pClsObj,
  609.                            SOMClass *mClsObj)
  610. {
  611.     M_ColorPalettetempClassData.classObject = _somNew (mClsObj);
  612.     _somInitClass (M_ColorPalettetempClassData.classObject,
  613.         "M_ColorPalette",
  614.         pClsObj,
  615.         0,
  616.         M_ColorPalette_MaxNoMethods,
  617.         M_ColorPalette_MajorVersion,
  618.         M_ColorPalette_MinorVersion);
  619.     M_ColorPaletteCClassData.instanceDataToken = 
  620.     _somGetInstanceToken(M_ColorPalettetempClassData.classObject);
  621.     M_ColorPalettesomInitializeClass();
  622.     M_ColorPaletteCClassData.parentMtab =
  623.     _somGetPClsMtab(M_ColorPalettetempClassData.classObject);
  624.     _somSetClassData(M_ColorPalettetempClassData.classObject, (somClassDataStructure *)&M_ColorPaletteClassData);
  625.     _somClassReady(M_ColorPalettetempClassData.classObject);
  626.     /* make newly created class object visible */
  627.     M_ColorPaletteClassData.classObject = M_ColorPalettetempClassData.classObject;
  628. }
  629.  
  630. M_ColorPalette * SOMLINK M_ColorPaletteNewClass (integer4 scemajorVersion,
  631.         integer4 sceminorVersion)
  632. {
  633.     SOMClass *pClsObj;
  634.     SOMClass *mClsObj;
  635.  
  636.     /* Check the version numbers */
  637.     if (((scemajorVersion != 0) && 
  638.          (scemajorVersion != M_ColorPalette_MajorVersion)) ||
  639.         ((sceminorVersion != 0) && 
  640.          (sceminorVersion > M_ColorPalette_MinorVersion))) {
  641.     somPrintf("M_ColorPaletteNewClass: Error, bad version numbers.\n");
  642.     SOM_Error(SOMERROR_BadVersion);
  643.     }
  644.     /* Don't do anything if class object is already created. */
  645.     if (M_ColorPaletteClassData.classObject != (SOMAny *) NULL)
  646.     return(M_ColorPaletteClassData.classObject);
  647.  
  648.     /* Make sure the environment is initialized. */
  649.     if (SOMClassMgrObject == (SOMAny *) NULL) somEnvironmentNew();
  650.     if (SOMClassMgrObject == (SOMAny *) NULL)
  651.     SOM_Error(SOMERROR_CouldNotStartup);
  652.  
  653.     /* Get the parent class object. */
  654.     M_WPColorPaletteNewClass(1,2);    /* static reference */
  655.     pClsObj = _somFindClass(SOMClassMgrObject,
  656.         SOM_IdFromString("M_WPColorPalette"), 1, 2);
  657.     if (pClsObj == (SOMClass *) NULL)
  658.     SOM_Error(SOMERROR_NoParentClass);
  659.  
  660.     /* Use parent's metaclass */ 
  661.     mClsObj = SOM_GetClass(pClsObj);
  662.  
  663.     somConstructClass(M_ColorPalettesomCreateClass, pClsObj, mClsObj,
  664.              &M_ColorPalettetempClassData);
  665.     return (M_ColorPaletteClassData.classObject);
  666. }
  667.  
  668. #endif                   /* M_ColorPalette_Class_Source */
  669.  
  670. #endif       /* clrpalet_ih */
  671.