home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ctrl1.zip / TEXT3D.C < prev    next >
C/C++ Source or Header  |  1996-04-29  |  55KB  |  1,129 lines

  1. #pragma title("3D Text Control  --  Version 1.0 -- (Text3D.C)")
  2. #pragma subtitle("  3D Text Control Control DLL - Interface Definitions")
  3.  
  4. #pragma info(noext)
  5.  
  6. #define INCL_DOS                   /* Include OS/2 DOS Kernal           */
  7. #define INCL_GPI                   /* Include OS/2 PM GPI Interface     */
  8. #define INCL_WIN                   /* Include OS/2 PM Windows Interface */
  9.  
  10. static char *MODID = "@(#)text3d.c:2.03";
  11.  
  12. #include <malloc.h>
  13. #include <os2.h>
  14. #include <string.h>
  15.  
  16. #include <pmcx.h>
  17.  
  18. #include "text3d.h"
  19.  
  20. /* This module contains an example installable control that can be used */
  21. /* within applications where additional facilities are provided that    */
  22. /* are not found within the default controls of OS/2 PM.                */
  23. /*                                                                      */
  24. /* For complete details regarding the PM Control Extensions (PMCX)      */
  25. /* consult the User's Guide.                                            */
  26. /*                                                                      */
  27. /* The DLL is created using the following command line invocation:      */
  28. /*                                                                      */
  29. /*     Icc -G3e- -O+ -Rn -W3 -C Text3D.C                                */
  30.  
  31. /* Filename:   Text3D.C                                                 */
  32.  
  33. /*  Version:   1.0                                                      */
  34. /*  Created:   1993-12-21                                               */
  35. /*  Revised:   1995-11-16                                               */
  36.  
  37. /* Routines:   BOOL EXPENTRY Text3DRegister(HAB hAB);                   */
  38. /*             BOOL EXPENTRY Text3DQuery(PUSERINFO pControlInfo);       */
  39. /*             MRESULT EXPENTRY Text3DWndProc(HWND hWnd, ULONG msg,     */
  40. /*                                            MPARAM mp1, MPARAM mp2);  */
  41. /*             MRESULT EXPENTRY Text3DStyles(HWND hWnd, ULONG msg,      */
  42. /*                                           MPARAM mp1, MPARAM mp2);   */
  43.  
  44.  
  45. /* Copyright ╕ 1989-1996  Prominare Inc.  All Rights Reserved.          */
  46.  
  47. /* -------------------------------------------------------------------- */
  48.  
  49. /************************************************************************/
  50. /************************************************************************/
  51. /*                     DISCLAIMER OF WARRANTIES.                        */
  52. /************************************************************************/
  53. /************************************************************************/
  54. /*     The following [enclosed] code is library code created by         */
  55. /*     Prominare Inc.  This library code is  provided to you solely     */
  56. /*     for the purpose of assisting you in the development of your      */
  57. /*     applications.  The code is provided "AS IS", without             */
  58. /*     warranty of any kind.  Prominare Inc. shall not be liable        */
  59. /*     for any damages arising out of your use of the library code,     */
  60. /*     even if they have been advised of the possibility of such        */
  61. /*     damages.                                                         */
  62. /************************************************************************/
  63. /************************************************************************/
  64.  
  65. /* --- Control Data Structures ---------------------------------------- */
  66.  
  67.  
  68. typedef struct _TEXTFIELD          /* tf */
  69.    {
  70.    POINTL aptl[4];                 /* Entry Field Outline Points        */
  71.    RECTL  rcl;                     /* Frame Rectangle                   */
  72.    LONG   lClrLeftTop;             /* Left and Top Edge Colour          */
  73.    LONG   lClrBottomRight;         /* Right and Bottom Edge Colour      */
  74.    BOOL   fRaised;                 /* Raised Field Flag                 */
  75.    LONG   lClrText;                /* Text Colour                       */
  76.    LONG   lClrBackground;          /* Background Colour                 */
  77.    LONG   lClrBorder;              /* Border Colour                     */
  78.    LONG   cText;                   /* Text Length Holder                */
  79.    PSZ    pszText;                 /* Text Holder                       */
  80.    ULONG  flFormat;                /* Formatting Flags                  */
  81.    ULONG  flStyle;                 /* Style Flags                       */
  82.    BOOL   fDraw;                   /* Draw Flag                         */
  83.    POINTL ptlDraw;                 /* Text Drawing Point                */
  84.    } TEXTFIELD ;
  85.  
  86. typedef TEXTFIELD *PTEXTFIELD;
  87.  
  88. /* --- Module Prototype Definitions ----------------------------------- */
  89.  
  90. static VOID CalcSize(HWND hWnd, PRECTL prcl, PTEXTFIELD ptf);
  91. static VOID SetDefaultColours(HWND hWnd, PTEXTFIELD ptf);
  92. static LONG lGetPresParam(HWND hWnd, ULONG ulID1, ULONG ulID2, LONG lDefault);
  93.  
  94. #define CLENpszClassname 13
  95. static PSZ pszClassname = "Depressed.3D";
  96.  
  97. #define DT_MASK (DT_LEFT | DT_CENTER | DT_RIGHT | DT_TOP | DT_VCENTER | DT_BOTTOM | DT_HALFTONE | DT_MNEMONIC | DT_WORDBREAK)
  98.  
  99. BOOL    EXPENTRY Text3DRegister(HAB hAB);
  100. BOOL    EXPENTRY Text3DQuery(PUSERINFO pControlInfo);
  101. MRESULT EXPENTRY Text3DWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  102. MRESULT EXPENTRY Text3DStyles(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  103.  
  104. #pragma subtitle("   3D Text Control DLL - Control Initialization Function")
  105. #pragma page ( )
  106.  
  107. /* --- Text3DRegister ---------------------------------- [ Public ] --- */
  108. /*                                                                      */
  109. /*     This function is used to register the installable control class  */
  110. /*     with OS/2 Presentation Manager.  The registration must use the   */
  111. /*     USER_CWINDOWWORDS to reserve memory for the control to allow for */
  112. /*     proper usage by Resource Editor and for use by the control       */
  113. /*     dialog and window procedures.  The information for the control   */
  114. /*     containing the style, presentation parameters and control data   */
  115. /*     is pointed to by a pointer that can be referenced by the         */
  116. /*     control's dialog and window procedure as required.  The memory   */
  117. /*     for the structure is allocated and controlled through Resource   */
  118. /*     Editor.   The control can reserve more memory for its use        */
  119. /*     by adding the memory required to that of the USER_CWINDOWWORDS   */
  120. /*     constant.                                                        */
  121. /*                                                                      */
  122. /*     Upon Entry:                                                      */
  123. /*                                                                      */
  124. /*     HAB hAB; = Application Anchor Block Handle                       */
  125. /*                                                                      */
  126. /*     Upon Exit:                                                       */
  127. /*                                                                      */
  128. /*     Text3DRegister =  TRUE : Class Registration Successful           */
  129. /*                    = FALSE : Class Registration Failed               */
  130. /*                                                                      */
  131. /* -------------------------------------------------------------------- */
  132.  
  133. BOOL EXPENTRY Text3DRegister(HAB hAB)
  134.  
  135. {
  136.                        /* Register the control class with OS/2          */
  137.                        /* Presentation Manager and return registration  */
  138.                        /* result                                        */
  139.  
  140. return(WinRegisterClass(hAB, pszClassname, Text3DWndProc, CS_SYNCPAINT | CS_SIZEREDRAW, USER_CWINDOWWORDS));
  141.  
  142. }
  143. #pragma subtitle("   3D Text Control DLL - Query Control Information Function")
  144. #pragma page ( )
  145.  
  146. /* --- Text3DQuery ------------------------------------- [ Public ] --- */
  147. /*                                                                      */
  148. /*     This function is used to return to the caller information        */
  149. /*     regarding the installable control and its capabilities.  The     */
  150. /*     function should return a true value otherwise Resource           */
  151. /*     Editor will not register the control as being usable.            */
  152. /*                                                                      */
  153. /*     Upon Entry:                                                      */
  154. /*                                                                      */
  155. /*     PUSERINFO pUserInfo; = User Information Pointer                  */
  156. /*                                                                      */
  157. /*     Upon Exit:                                                       */
  158. /*                                                                      */
  159. /*     Text3DQuery =  TRUE : User Information Being Returned            */
  160. /*                 = FALSE : No User Information Available              */
  161. /*                                                                      */
  162. /* -------------------------------------------------------------------- */
  163.  
  164. BOOL EXPENTRY Text3DQuery(PUSERINFO pUserInfo)
  165.  
  166. {
  167.                        /* Complete the User Information structure       */
  168.                        /* passed to the function by Resource Editor  */
  169.  
  170.                        /* Complete the version and number of control    */
  171.                        /* types.  In Version 1.00 of PMCX, only one     */
  172.                        /* control type is used.                         */
  173. pUserInfo->ulMajor = 3UL;
  174. pUserInfo->ulMinor = 0UL;
  175.                        /* Complete the author and control classname     */
  176.  
  177. memcpy(pUserInfo->szAuthor,    "Prominare Inc.", 15);
  178. memcpy(pUserInfo->szClassname, pszClassname, CLENpszClassname);
  179. memcpy(pUserInfo->szName,      "Text3D", 7);
  180.  
  181.                        /* Complete the default size and style of the    */
  182.                        /* first user control type                       */
  183.  
  184. pUserInfo->utDefined[0].cx           = 25L;
  185. pUserInfo->utDefined[0].cy           = 10L;
  186. pUserInfo->utDefined[0].flStyle      = WS_VISIBLE | SS_TEXT | DT_LEFT | DT_VCENTER;
  187.  
  188.                        /* Set the maximum amount of text control can    */
  189.                        /* accept including NULL termination byte        */
  190.  
  191. pUserInfo->utDefined[0].cMaxText     = CCHTEXTMAX;
  192.  
  193.                        /* Save the style's dialogue ID, type, control   */
  194.                        /* data size and count of style masks            */
  195.  
  196. pUserInfo->utDefined[0].idDlg        = DLG_CTRLUSER;
  197. pUserInfo->utDefined[0].flOptions    = PMCXOPT_REFRESH;
  198. pUserInfo->utDefined[0].ulType       = UTYPE_PRIVATE;
  199. pUserInfo->utDefined[0].cCtlData     = 0UL;
  200. pUserInfo->utDefined[0].cMasks       = 12UL;
  201. pUserInfo->utDefined[0].flStyleType  = STYLETYPE_BITFLAGS;
  202. pUserInfo->utDefined[0].stMasks[0].flStyleMask = SS_TEXT;
  203. pUserInfo->utDefined[0].stMasks[0].idStyle     = IDS_SS_TEXT;
  204. pUserInfo->utDefined[0].stMasks[1].flStyleMask = DT_LEFT;
  205. pUserInfo->utDefined[0].stMasks[1].idStyle     = IDS_DT_LEFT;
  206. pUserInfo->utDefined[0].stMasks[2].flStyleMask = DT_CENTER;
  207. pUserInfo->utDefined[0].stMasks[2].idStyle     = IDS_DT_CENTER;
  208. pUserInfo->utDefined[0].stMasks[3].flStyleMask = DT_RIGHT;
  209. pUserInfo->utDefined[0].stMasks[3].idStyle     = IDS_DT_RIGHT;
  210. pUserInfo->utDefined[0].stMasks[4].flStyleMask = DT_TOP;
  211. pUserInfo->utDefined[0].stMasks[4].idStyle     = IDS_DT_TOP;
  212. pUserInfo->utDefined[0].stMasks[5].flStyleMask = DT_VCENTER;
  213. pUserInfo->utDefined[0].stMasks[5].idStyle     = IDS_DT_VCENTER;
  214. pUserInfo->utDefined[0].stMasks[6].flStyleMask = DT_BOTTOM;
  215. pUserInfo->utDefined[0].stMasks[6].idStyle     = IDS_DT_BOTTOM;
  216. pUserInfo->utDefined[0].stMasks[7].flStyleMask = DT_HALFTONE;
  217. pUserInfo->utDefined[0].stMasks[7].idStyle     = IDS_DT_HALFTONE;
  218. pUserInfo->utDefined[0].stMasks[8].flStyleMask = DT_MNEMONIC;
  219. pUserInfo->utDefined[0].stMasks[8].idStyle     = IDS_DT_MNEMONIC;
  220. pUserInfo->utDefined[0].stMasks[9].flStyleMask = DT_WORDBREAK;
  221. pUserInfo->utDefined[0].stMasks[9].idStyle     = IDS_DT_WORDBREAK;
  222. pUserInfo->utDefined[0].stMasks[10].flStyleMask = DS_DEPRESSED;
  223. pUserInfo->utDefined[0].stMasks[10].idStyle     = IDS_DS_DEPRESSED;
  224. pUserInfo->utDefined[0].stMasks[11].flStyleMask = DS_RAISED;
  225. pUserInfo->utDefined[0].stMasks[11].idStyle     = IDS_DS_RAISED;
  226.  
  227.                        /* Save the description of the control           */
  228.  
  229. memcpy(pUserInfo->utDefined[0].szDescription, "3D Text", 8);
  230.  
  231.                        /* Return the success flag back to Resource      */
  232.                        /* Editor                                        */
  233. return(TRUE);
  234. }
  235. #pragma subtitle("   3D Text Control DLL - Control Window Procedure")
  236. #pragma page( )
  237.  
  238. /* --- lGetPresParam ---------------------------------- [ Private } --- */
  239. /*                                                                      */
  240. /*     This function is used to retrieve a presentation parameter       */
  241. /*     that may be present.  If the presentation parameter is not,      */
  242. /*     the default colour passed to the function will be used.          */
  243. /*                                                                      */
  244. /*     Upon Entry:                                                      */
  245. /*                                                                      */
  246. /*     HWND  hWnd;     = Window Handle                                  */
  247. /*     ULONG ulID1;    = Presentation Parameter 1 ID                    */
  248. /*     ULONG ulID2;    = Presentation Parameter 2 ID                    */
  249. /*     LONG  lDefault; = Default Colour                                 */
  250. /*                                                                      */
  251. /*     Upon Exit:                                                       */
  252. /*                                                                      */
  253. /*     lGetPresParam = Colour to Use                                    */
  254. /*                                                                      */
  255. /* -------------------------------------------------------------------- */
  256.  
  257. LONG lGetPresParam(HWND hWnd, ULONG ulID1, ULONG ulID2, LONG lDefault)
  258.  
  259. {
  260. HPS   hPS;                         /* Presentation Space Handle         */
  261. LONG  lClr;                        /* Presentation Parameter Colour     */
  262. ULONG ulID;                        /* Presentation Parameter ID         */
  263.  
  264. if ( WinQueryPresParam(hWnd, ulID1, ulID2, &ulID, 4UL, (PVOID)&lClr,
  265.                        QPF_NOINHERIT | QPF_ID2COLORINDEX | QPF_PURERGBCOLOR) )
  266.    return(lClr);
  267. else
  268.    if ( (lDefault >= SYSCLR_SHADOWHILITEBGND) && (lDefault <= SYSCLR_HELPHILITE) )
  269.        return(WinQuerySysColor(HWND_DESKTOP, lDefault, 0L));
  270.    else
  271.        if ( (lClr = GpiQueryRGBColor(hPS = WinGetPS(hWnd), LCOLOPT_REALIZED, lDefault)) == GPI_ALTERROR )
  272.            {
  273.            WinReleasePS(hPS);
  274.            return(lDefault);
  275.            }
  276.        else
  277.            {
  278.            WinReleasePS(hPS);
  279.            return(lClr);
  280.            }
  281. }
  282. #pragma subtitle("   Shadowed Text DLL - Control Window Sizing Procedure")
  283. #pragma page ( )
  284.  
  285. /* --- SizeText --------------------------------------- [ Private ] --- */
  286. /*                                                                      */
  287. /*     This function is used to calculate the size and position         */
  288. /*     of the text.                                                     */
  289. /*                                                                      */
  290. /*     Upon Entry:                                                      */
  291. /*                                                                      */
  292. /*     HWND       hWnd; = Control Window Handle                         */
  293. /*     PTEXTFIELD ptf;  = Text Information Pointer                      */
  294. /*                                                                      */
  295. /*     Upon Exit:                                                       */
  296. /*                                                                      */
  297. /*     Nothing                                                          */
  298. /*                                                                      */
  299. /* -------------------------------------------------------------------- */
  300.  
  301. static VOID SizeText(HWND hWnd, PTEXTFIELD ptf)
  302.  
  303. {
  304. FONTMETRICS fm;                    /* Font Metrics                      */
  305. HPS         hPS;                   /* Presentation Space Handle         */
  306. POINTL      rgptl[TXTBOX_COUNT];   /* Text Box Point Array              */
  307.  
  308. GpiQueryFontMetrics(hPS = WinGetPS(hWnd), sizeof(FONTMETRICS), &fm);
  309. GpiQueryTextBox(hPS, (LONG)ptf->cText, ptf->pszText, 5L, rgptl);
  310. WinReleasePS(hPS);
  311.  
  312. if ( ptf->flStyle & DT_RIGHT )
  313.    ptf->ptlDraw.x = ptf->rcl.xRight - rgptl[TXTBOX_CONCAT].x;
  314. else
  315.    if ( ptf->flStyle & DT_CENTER )
  316.        ptf->ptlDraw.x = (ptf->rcl.xRight - ptf->rcl.xLeft) / 2L - rgptl[TXTBOX_CONCAT].x / 2L + ptf->rcl.xLeft;
  317.    else
  318.        ptf->ptlDraw.x = ptf->rcl.xLeft;
  319.  
  320. if ( ptf->flStyle & DT_TOP )
  321.    ptf->ptlDraw.y = ptf->rcl.yTop - (rgptl[TXTBOX_TOPRIGHT].y - rgptl[TXTBOX_BOTTOMRIGHT].y) + fm.lMaxDescender;
  322. else
  323.    if ( ptf->flStyle & DT_VCENTER )
  324.        ptf->ptlDraw.y = (ptf->rcl.yTop - ptf->rcl.yBottom) / 2L - (rgptl[TXTBOX_TOPRIGHT].y - rgptl[TXTBOX_BOTTOMRIGHT].y) / 2L +
  325.                         fm.lMaxDescender + ptf->rcl.yBottom;
  326.    else
  327.        ptf->ptlDraw.y = ptf->rcl.yBottom + fm.lMaxDescender;
  328. }
  329. #pragma subtitle("   Shadowed Text DLL - Control Window Sizing Procedure")
  330. #pragma page ( )
  331.  
  332. /* --- CalcSize --------------------------------------- [ Private ] --- */
  333. /*                                                                      */
  334. /*     This function is used to calculate the sizes and positions       */
  335. /*     of the various elements that are used to make up a shadowed      */
  336. /*     text field.                                                      */
  337. /*                                                                      */
  338. /*     Upon Entry:                                                      */
  339. /*                                                                      */
  340. /*     PRECTL     prcl; = Control Rectangle Pointer                     */
  341. /*     PTEXTFIELD ptf;  = Group Box Information Pointer                 */
  342. /*                                                                      */
  343. /*     Upon Exit:                                                       */
  344. /*                                                                      */
  345. /*     Nothing                                                          */
  346. /*                                                                      */
  347. /* -------------------------------------------------------------------- */
  348.  
  349. static VOID CalcSize(HWND hWnd, PRECTL prcl, PTEXTFIELD ptf)
  350.  
  351. {
  352.  
  353. if ( (prcl->yTop <= prcl->yBottom) || (prcl->xRight <= prcl->xLeft) )
  354.    ptf->fDraw = FALSE;
  355. else
  356.    {
  357.    ptf->fDraw = TRUE;
  358.                        /* Save the rectangle for the control            */
  359.    ptf->rcl = *prcl;
  360.                        /* Adjust the rectangle size for the text which  */
  361.                        /* resides inside the 3D frame                   */
  362.    ++ptf->rcl.xLeft;
  363.    ++ptf->rcl.yBottom;
  364.    ptf->rcl.yTop -= 2L;
  365.    ptf->rcl.xRight -= 2L;
  366.  
  367.    if ( !(ptf->flStyle & DT_WORDBREAK) && ptf->cText )
  368.        SizeText(hWnd, ptf);
  369.  
  370.                /*  Text display points                                  */
  371.                /*                                                       */
  372.                /*         1                           2                 */
  373.                /*          +-------------------------+                  */
  374.                /*          |                         |                  */
  375.                /*          |                         |                  */
  376.                /*          |                         |                  */
  377.                /*          |                         |                  */
  378.                /*          +-------------------------+                  */
  379.                /*         0 4                         3                 */
  380.  
  381.    ptf->aptl[0].x = prcl->xLeft;
  382.    ptf->aptl[0].y = prcl->yTop   - 1L;
  383.    ptf->aptl[1].x = prcl->xRight - 1L;
  384.    ptf->aptl[1].y = prcl->yTop   - 1L;
  385.    ptf->aptl[2].x = prcl->xRight - 1L;
  386.    ptf->aptl[2].y = prcl->yBottom;
  387.    ptf->aptl[3].x = prcl->xLeft;
  388.    ptf->aptl[3].y = prcl->yBottom;
  389.  
  390.    ptf->flFormat = (ptf->flStyle & DT_MASK) | DT_ERASERECT;
  391.    }
  392. }
  393. #pragma subtitle("   Shadowed Text DLL - Default Colours Procedure")
  394. #pragma page( )
  395.  
  396. /* --- SetDefaultColours ------------------------------ [ Private ] --- */
  397. /*                                                                      */
  398. /*     This function is used to set the default colours that the        */
  399. /*     image button should use within the internal paint routines.      */
  400. /*     The colour can either be a presentation parameter that has       */
  401. /*     been set or it can be the default colour as defined within       */
  402. /*     control.                                                         */
  403. /*                                                                      */
  404. /*     Upon Entry:                                                      */
  405. /*                                                                      */
  406. /*     HWND       hWnd; = Window Handle                                 */
  407. /*     PTEXTFIELD ptf;  = Text Field Structure Pointer                  */
  408. /*                                                                      */
  409. /*     Upon Exit:                                                       */
  410. /*                                                                      */
  411. /*     Nothing                                                          */
  412. /*                                                                      */
  413. /* -------------------------------------------------------------------- */
  414.  
  415. static VOID SetDefaultColours(HWND hWnd, PTEXTFIELD ptf)
  416.  
  417. {
  418.                        /* Set up the colours that will be used within   */
  419.                        /* the painting of the control.                  */
  420.  
  421. ptf->lClrText       = lGetPresParam(hWnd, PP_FOREGROUNDCOLOR, PP_FOREGROUNDCOLORINDEX, SYSCLR_OUTPUTTEXT);
  422. ptf->lClrBackground = lGetPresParam(hWnd, PP_BACKGROUNDCOLOR, PP_BACKGROUNDCOLORINDEX, SYSCLR_DIALOGBACKGROUND);
  423. ptf->lClrBorder     = lGetPresParam(hWnd, PP_BORDERCOLOR,     PP_BORDERCOLORINDEX,     SYSCLR_BUTTONDARK);
  424. }
  425. #pragma subtitle("   Shadowed Text DLL - 3D Text Window Procedure")
  426. #pragma page ( )
  427.  
  428. /* --- hpsDrawText ------------------------------------ [ Private ] --- */
  429. /*                                                                      */
  430. /*     This function is used to draw the text and 3D outline.           */
  431. /*                                                                      */
  432. /*     Upon Entry:                                                      */
  433. /*                                                                      */
  434. /*     HPS        hPS; = Window Presentation Space Handle               */
  435. /*     PTEXTFIELD ptf; = Text Field Pointer                             */
  436. /*                                                                      */
  437. /*     Upon Exit:                                                       */
  438. /*                                                                      */
  439. /*     hpsDrawText = Window Presentation Space Handle                   */
  440. /*                                                                      */
  441. /* -------------------------------------------------------------------- */
  442.  
  443. static HPS hpsDrawText(HPS hPS, PTEXTFIELD ptf)
  444.  
  445. {
  446. FONTMETRICS fm;                    /* Font Metrics Holder               */
  447. RECTL       rcl;                   /* Rectangle Holder                  */
  448. register LONG i, k, n;             /* String Length Counter             */
  449.  
  450.                        /* Get the presentation space for the control    */
  451.                        /* and set the colour table to RGB mode          */
  452.  
  453. GpiCreateLogColorTable(hPS, 0L, LCOLF_RGB, 0L, 0L, (PLONG)NULL);
  454.  
  455.                        /* Check to see if any text present and if the   */
  456.                        /* case, draw it within the rectangle            */
  457. if ( ptf->cText )
  458.                        /* Check to see if the text is to be broken over */
  459.                        /* more than one line if the length of the text  */
  460.                        /* is greater than the width of the control      */
  461.  
  462.    if ( ptf->flStyle & DT_WORDBREAK )
  463.        {
  464.                        /* Word break style specified, set the drawing   */
  465.                        /* of the text within a loop such that it can    */
  466.                        /* be drawn on successive lines                  */
  467.        n = ptf->cText;
  468.        GpiQueryFontMetrics(hPS, sizeof(FONTMETRICS), &fm);
  469.        rcl = ptf->rcl;
  470.        i = 0;
  471.        do
  472.            {
  473.            n -= (k = WinDrawText(hPS, n, &ptf->pszText[i], &rcl, ptf->lClrText, ptf->lClrBackground, ptf->flFormat));
  474.            i += k;
  475.            if ( (rcl.yTop -= fm.lMaxBaselineExt) < rcl.yBottom )
  476.                break;
  477.            } while ( n > 0 );
  478.        }
  479.    else
  480.        {
  481.        GpiSetColor(hPS, ptf->lClrText);
  482.        GpiSetBackColor(hPS, ptf->lClrBackground);
  483.        GpiCharStringPosAt(hPS, &ptf->ptlDraw, &ptf->rcl, CHS_OPAQUE | CHS_CLIP, ptf->cText, ptf->pszText, NULL);
  484.        }
  485. else
  486.    WinFillRect(hPS, &ptf->rcl, ptf->lClrBackground);
  487.  
  488. GpiSetColor(hPS, ptf->lClrLeftTop);
  489.  
  490. GpiMove(hPS, &ptf->aptl[3]);
  491. GpiPolyLine(hPS, 2L, ptf->aptl);
  492.  
  493. GpiSetColor(hPS, ptf->lClrBottomRight);
  494. GpiPolyLine(hPS, 2L, &ptf->aptl[2]);
  495.  
  496. return(hPS);
  497. }
  498. #pragma subtitle("   Shadowed Text DLL - 3D Text Window Procedure")
  499. #pragma page ( )
  500.  
  501. /* --- Text3DWndProc ---------------------------------- [ Private ] --- */
  502. /*                                                                      */
  503. /*     This function is used to handle the messages sent to the         */
  504. /*     installed control.  The window procedure is designed to          */
  505. /*     allow for multiple instances and to be totally re-entrant.       */
  506. /*                                                                      */
  507. /*     Upon Entry:                                                      */
  508. /*                                                                      */
  509. /*     HWND   hWnd; = Window Handle                                     */
  510. /*     ULONG  msg;  = PM Message                                        */
  511. /*     MPARAM mp1;  = Message Parameter 1                               */
  512. /*     MPARAM mp2;  = Message Parameter 2                               */
  513. /*                                                                      */
  514. /*     Upon Exit:                                                       */
  515. /*                                                                      */
  516. /*     Text3DWndProc = Message Handling Result                          */
  517. /*                                                                      */
  518. /* -------------------------------------------------------------------- */
  519.  
  520. MRESULT EXPENTRY Text3DWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  521.  
  522. {
  523. LONG           lClr;               /* Presentation Parameter Colour     */
  524. PCREATESTRUCT  pcrst;              /* Create Structure Pointer          */
  525. PSWP           pswp;               /* Size/Window Position Pointer      */
  526. PTEXTFIELD     ptf;                /* Text Field Structure Pointer      */
  527. PWNDPARAMS     pwprm;              /* Window Parameters Pointer         */
  528. RECTL          rcl;                /* Rectangle Holder                  */
  529. ULONG          flStyle;            /* Control Style                     */
  530. ULONG          ulID;               /* Presentation Parameter ID         */
  531.  
  532. switch ( msg )
  533.    {
  534.                        /* Perform control initialization when the       */
  535.                        /* control is created                            */
  536.    case WM_CREATE :
  537.                        /* Save the address of the text string pointer   */
  538.                        /* in the control's reserved memory to allow it  */
  539.                        /* to be referenced as required by the control   */
  540.  
  541.        WinSetWindowPtr(hWnd, QWW_CDATA, (PVOID)(ptf = (PTEXTFIELD)malloc(sizeof(TEXTFIELD))));
  542.        memset(ptf, 0, sizeof(TEXTFIELD));
  543.  
  544.                        /* Get the control's creation structure address  */
  545.                        /* to copy the default text of the control to    */
  546.                        /* the memory in the heap                        */
  547.  
  548.        pcrst = (PCREATESTRUCT)PVOIDFROMMP(mp2);
  549.  
  550.        if ( pcrst->pszText )
  551.            {
  552.            ptf->pszText = (PSZ)malloc((ULONG)(ptf->cText = (LONG)strlen(pcrst->pszText)) + 1UL);
  553.            memcpy(ptf->pszText, pcrst->pszText, (UINT)ptf->cText);
  554.            }
  555.                        /* Set up the colours that will be used within   */
  556.                        /* the painting of the control.                  */
  557.  
  558.        SetDefaultColours(hWnd, ptf);
  559.  
  560.                        /* Check to see if the user provided font that   */
  561.                        /* should override the default font that would   */
  562.                        /* be set                                        */
  563.  
  564.        if ( !WinQueryPresParam(hWnd, PP_FONTNAMESIZE, 0L, &ulID, 4L, (PVOID)&lClr, QPF_NOINHERIT) )
  565.  
  566.                        /* System indicates not set since not data was   */
  567.                        /* returned, therefore set default font for the  */
  568.                        /* control                                       */
  569.  
  570.            WinSetPresParam(hWnd, PP_FONTNAMESIZE, 8L, (PVOID)"10.Helv");
  571.  
  572.        if ( (ptf->flStyle = pcrst->flStyle) & DS_RAISED )
  573.            {
  574.            ptf->fRaised = TRUE;
  575.            ptf->lClrLeftTop     = RGB_WHITE;
  576.            ptf->lClrBottomRight = ptf->lClrBorder;
  577.            }
  578.        else
  579.            {
  580.            ptf->fRaised = FALSE;
  581.            ptf->lClrLeftTop     = ptf->lClrBorder;
  582.            ptf->lClrBottomRight = RGB_WHITE;
  583.            }
  584.  
  585.        if ( ((rcl.xRight = pcrst->cx) > 0L) && ((rcl.yTop = pcrst->cy) > 0L) )
  586.            {
  587.            rcl.xLeft = rcl.yBottom = 0L;
  588.            CalcSize(hWnd, &rcl, ptf);
  589.            }
  590.        break;
  591.  
  592.    case WM_ADJUSTWINDOWPOS :
  593.        pswp = (PSWP)PVOIDFROMMP(mp1);
  594.        if ( (pswp->fl & SWP_SIZE) && (pswp->cx > 0) && (pswp->cy > 0) )
  595.  
  596.                        /* Get the address of the control info from the  */
  597.                        /* control's reserved memory and save the new    */
  598.                        /* size of the control                           */
  599.            {
  600.            rcl.xLeft = rcl.yBottom = 0L;
  601.            rcl.xRight = pswp->cx;
  602.            rcl.yTop   = pswp->cy;
  603.            CalcSize(hWnd, &rcl, (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA));
  604.            }
  605.        break;
  606.  
  607.    /*********************************************************************/
  608.    /*  Convert position query                                           */
  609.    /*********************************************************************/
  610.  
  611.    case WM_QUERYCONVERTPOS :
  612.        return(MRFROMLONG(QCP_NOCONVERT));
  613.  
  614.                        /* Control size changing, update the rectangle   */
  615.                        /* points for the 3D text control                */
  616.    case WM_SIZE :
  617.        if ( ((LONG)(SHORT)SHORT1FROMMP(mp2) > 0L) && ((LONG)(SHORT)SHORT2FROMMP(mp2) > 0L) )
  618.            {
  619.            rcl.xLeft = rcl.yBottom = 0L;
  620.            rcl.xRight = (LONG)(SHORT)SHORT1FROMMP(mp2);
  621.            rcl.yTop   = (LONG)(SHORT)SHORT2FROMMP(mp2);
  622.            CalcSize(hWnd, &rcl, (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA));
  623.            }
  624.        else
  625.            {
  626.            ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  627.            ptf->fDraw = FALSE;
  628.            }
  629.        break;
  630.                        /* Process window parameters setting             */
  631.  
  632.    case WM_SETWINDOWPARAMS :
  633.  
  634.                        /* Get the address for the windows parameters    */
  635.                        /* structure                                     */
  636.  
  637.        pwprm = (PWNDPARAMS)PVOIDFROMMP(mp1);
  638.  
  639.                        /* Check to see if the text for the control is   */
  640.                        /* being set                                     */
  641.  
  642.        if ( pwprm->fsStatus & WPM_TEXT )
  643.            {
  644.                        /* Text being set, get the address of the text   */
  645.                        /* string stored in the heap                     */
  646.  
  647.            ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  648.  
  649.                        /* Check to see if any text is being set         */
  650.  
  651.            if ( pwprm->cchText )
  652.                {
  653.                if ( ptf->cText )
  654.                    ptf->pszText = (PSZ)realloc(ptf->pszText, (ULONG)(ptf->cText = (LONG)pwprm->cchText) + 1UL);
  655.                else
  656.                    ptf->pszText = (PSZ)malloc((ULONG)(ptf->cText = (LONG)pwprm->cchText) + 1UL);
  657.  
  658.                        /* Check to make sure that the text that is to   */
  659.                        /* be set is not greater than the memory         */
  660.                        /* allocated                                     */
  661.  
  662.                memcpy(ptf->pszText, pwprm->pszText, (UINT)pwprm->cchText);
  663.                ptf->pszText[ptf->cText] = (CHAR)0;
  664.                }
  665.            else
  666.                {
  667.                if ( ptf->cText )
  668.                    free(ptf->pszText);
  669.  
  670.                        /* No text is being set, clear any existing text */
  671.  
  672.                ptf->cText = 0L;
  673.                }
  674.  
  675.            if ( ptf->fDraw )
  676.                {
  677.                if ( !(ptf->flStyle & DT_WORDBREAK) && ptf->cText )
  678.                   SizeText(hWnd, ptf);
  679.                WinReleasePS(hpsDrawText(WinGetPS(hWnd), ptf));
  680.                }
  681.            }
  682.        return(MRFROMLONG(TRUE));
  683.  
  684.                        /* Process window parameters query               */
  685.  
  686.    case WM_QUERYWINDOWPARAMS :
  687.  
  688.                        /* Get the address for the windows parameters    */
  689.                        /* structure                                     */
  690.  
  691.        pwprm = (PWNDPARAMS)PVOIDFROMMP(mp1);
  692.  
  693.        if ( (pwprm->fsStatus & (WPM_TEXT | WPM_CCHTEXT)) == (WPM_TEXT | WPM_CCHTEXT) )
  694.            {
  695.                        /* Text being asked for, get the address of the  */
  696.                        /* text string stored in the heap                */
  697.  
  698.            ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  699.  
  700.                        /* Copy the text from the string to the          */
  701.                        /* structure                                     */
  702.  
  703.            memcpy(pwprm->pszText, ptf->pszText, (UINT)(ptf->cText + 1));
  704.            pwprm->cchText = (ULONG)ptf->cText;
  705.            }
  706.        else
  707.            {
  708.            ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  709.            if ( pwprm->fsStatus & WPM_TEXT )
  710.  
  711.                        /* Copy the text from the string to the          */
  712.                        /* structure                                     */
  713.  
  714.                memcpy(pwprm->pszText, ptf->pszText, (UINT)(ptf->cText + 1));
  715.  
  716.            if ( pwprm->fsStatus & WPM_CCHTEXT )
  717.                pwprm->cchText = (ULONG)ptf->cText;
  718.            }
  719.                        /* Query type:  get control data length          */
  720.  
  721.        if ( pwprm->fsStatus & WPM_CBCTLDATA )
  722.  
  723.                        /* Set the control data length to zero           */
  724.  
  725.            pwprm->cbCtlData = 0;
  726.        return(MRFROMLONG(TRUE));
  727.  
  728.                        /* Presentation parameters changed, record the   */
  729.                        /* change internally                             */
  730.  
  731.    case WM_PRESPARAMCHANGED :
  732.  
  733.                        /* Get the address of the control info from the  */
  734.                        /* control's reserved memory                     */
  735.  
  736.        ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  737.  
  738.                        /* Get the new presentation parameter colour for */
  739.                        /* the presentation parameter that has changed.  */
  740.                        /* Get the colour as a RGB value so as to be     */
  741.                        /* able to get an exact value and not an         */
  742.                        /* approximation which could happen if the       */
  743.                        /* presentation parameter was set as a RGB but   */
  744.                        /* queried as an index.  When WinQueryPresParam  */
  745.                        /* returns a 0, it indicates that no             */
  746.                        /* presentation parameter set and the default    */
  747.                        /* colours should be used.                       */
  748.  
  749.        switch ( LONGFROMMP(mp1) )
  750.            {
  751.            case 0 :
  752.                SetDefaultColours(hWnd, ptf);
  753.                break;
  754.  
  755.            case PP_FOREGROUNDCOLOR :
  756.            case PP_FOREGROUNDCOLORINDEX :
  757.                ptf->lClrText = lGetPresParam(hWnd, PP_FOREGROUNDCOLOR, PP_FOREGROUNDCOLORINDEX, SYSCLR_OUTPUTTEXT);
  758.                break;
  759.  
  760.            case PP_BACKGROUNDCOLOR :
  761.            case PP_BACKGROUNDCOLORINDEX :
  762.                ptf->lClrBackground = lGetPresParam(hWnd, PP_BACKGROUNDCOLOR, PP_BACKGROUNDCOLORINDEX, SYSCLR_DIALOGBACKGROUND);
  763.                break;
  764.  
  765.            case PP_BORDERCOLOR :
  766.            case PP_BORDERCOLORINDEX :
  767.                ptf->lClrBorder = lGetPresParam(hWnd, PP_BORDERCOLOR, PP_BORDERCOLORINDEX, SYSCLR_BUTTONDARK);
  768.                if ( ptf->fRaised )
  769.                    ptf->lClrBottomRight = ptf->lClrBorder;
  770.                else
  771.                    ptf->lClrLeftTop     = ptf->lClrBorder;
  772.                break;
  773.  
  774.            default :
  775.                return(0L);
  776.            }
  777.                    /* Invalidate the button to force to use the     */
  778.                    /* new colours just set or removed               */
  779.  
  780.        if ( ptf->fDraw )
  781.            WinReleasePS(hpsDrawText(WinGetPS(hWnd), ptf));
  782.        break;
  783.                        /* Mouse being passed over the control, imply    */
  784.                        /* that the control is transparent to the        */
  785.                        /* system                                        */
  786.    case WM_HITTEST :
  787.        return(MRFROMLONG(HT_TRANSPARENT));
  788.  
  789.                        /* Erase control background                      */
  790.  
  791.    case WM_ERASEBACKGROUND :
  792.        return(MRFROMLONG(TRUE));
  793.  
  794.                        /* Paint the Control                             */
  795.    case WM_PAINT :
  796.                        /* Get the address of the text from the          */
  797.                        /* control's reserved memory                     */
  798.  
  799.        ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  800.  
  801.                        /* Before painting, check to see if the style of */
  802.                        /* the control has changed.  When it has changed */
  803.                        /* make sure that the control internal values    */
  804.                        /* are updated to reflect any changes made.      */
  805.  
  806.        if ( ((flStyle = WinQueryWindowULong(hWnd, QWL_STYLE)) & (DT_MASK | SS_TEXT)) != (ptf->flStyle & (DT_MASK | SS_TEXT)) )
  807.            {
  808.            if ( (ptf->flStyle = flStyle) & DS_RAISED )
  809.                {
  810.                ptf->fRaised = TRUE;
  811.                ptf->lClrLeftTop     = RGB_WHITE;
  812.                ptf->lClrBottomRight = ptf->lClrBorder;
  813.                }
  814.            else
  815.                {
  816.                ptf->fRaised = FALSE;
  817.                ptf->lClrLeftTop     = ptf->lClrBorder;
  818.                ptf->lClrBottomRight = RGB_WHITE;
  819.                }
  820.  
  821.            WinQueryWindowRect(hWnd, &rcl);
  822.            CalcSize(hWnd, &rcl, ptf);
  823.            }
  824.                        /* Get the presentation space for the control    */
  825.                        /* and set the colour table to RGB mode          */
  826.        if ( ptf->fDraw )
  827.            WinEndPaint(hpsDrawText(WinBeginPaint(hWnd, (HPS)NULL, (PRECTL)NULL), ptf));
  828.        break;
  829.                        /* Control being destroyed                       */
  830.    case WM_DESTROY :
  831.                        /* Release the heap allocated for use by the     */
  832.                        /* control                                       */
  833.  
  834.        ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  835.        if ( ptf->cText )
  836.            free(ptf->pszText);
  837.        free(ptf);
  838.        break;
  839.                        /* Default message processing                    */
  840.    default :
  841.        return(WinDefWindowProc(hWnd, msg, mp1, mp2));
  842.    }
  843.  
  844. return(0L);
  845. }
  846. #pragma subtitle("   3D Text Control DLL - Control Styles Dialogue Procedure")
  847. #pragma page ( )
  848.  
  849. /* --- Text3DStyles ------------------------------------ [ Public ] --- */
  850. /*                                                                      */
  851. /*     This function is used for the custom control's styles dialogue   */
  852. /*     box procedure.                                                   */
  853. /*                                                                      */
  854. /*     When the dialogue is invoked from Resource Editor, the           */
  855. /*     address of the user style information is contained in message    */
  856. /*     parameter 2.  The dialogue is responsible for saving the         */
  857. /*     address.  The best method to do this is to save the pointer      */
  858. /*     in the dialogue's reserved memory where it can be retrieved as   */
  859. /*     needed.                                                          */
  860. /*                                                                      */
  861. /*     Upon Entry:                                                      */
  862. /*                                                                      */
  863. /*     HWND   hWnd; = Dialog Window Handle                              */
  864. /*     ULONG  msg;  = PM Message                                        */
  865. /*     MPARAM mp1;  = Message Parameter 1                               */
  866. /*     MPARAM mp2;  = Message Parameter 2                               */
  867. /*                                                                      */
  868. /*     Upon Exit:                                                       */
  869. /*                                                                      */
  870. /*     Text3DStyles = Message Handling Result                           */
  871. /*                                                                      */
  872. /* -------------------------------------------------------------------- */
  873.  
  874. MRESULT EXPENTRY Text3DStyles(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  875.  
  876. {
  877. PUSERSTYLE   pust;                 /* User Style Pointer                */
  878. SWP          swp;                  /* Screen Window Position Holder     */
  879.  
  880. switch ( msg )
  881.    {
  882.                        /* Perform dialogue initialization               */
  883.    case WM_INITDLG :
  884.                        /* Save the pointer to user style information    */
  885.                        /* within the dialog's reserved memory           */
  886.  
  887.        WinSetWindowPtr(hWnd, QWL_USER, (PVOID)mp2);
  888.  
  889.                        /* Get the pointer to the user style information */
  890.  
  891.        if ( (pust = (PUSERSTYLE)mp2) != NULL )
  892.            {
  893.                        /* Set the text, ID symbol and value for the     */
  894.                        /* control                                       */
  895.  
  896.            WinSetDlgItemText(hWnd, EF_TEXT, pust->pszText);
  897.            pust->pfnSetSymbolID(hWnd, IDBX_SYMBOLVALUE, pust);
  898.  
  899.            if ( pust->flStyle & DS_RAISED )
  900.                WinSendDlgItemMsg(hWnd, RB_RAISED, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  901.            else
  902.                WinSendDlgItemMsg(hWnd, RB_DEPRESSED, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  903.  
  904.                        /* Set Auto Scroll check box if selected         */
  905.  
  906.            if ( pust->flStyle & DT_RIGHT )
  907.                WinSendDlgItemMsg(hWnd, RB_RIGHTALIGNED, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  908.            else
  909.                if ( pust->flStyle & DT_CENTER )
  910.                    WinSendDlgItemMsg(hWnd, RB_HORZALIGNED, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  911.                else
  912.                    WinSendDlgItemMsg(hWnd, RB_LEFTALIGNED, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  913.  
  914.                        /* Set vertical alignment style radio button     */
  915.  
  916.            if ( pust->flStyle & DT_BOTTOM )
  917.                WinSendDlgItemMsg(hWnd, RB_BOTALIGNED, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  918.            else
  919.                if ( pust->flStyle & DT_VCENTER )
  920.                    WinSendDlgItemMsg(hWnd, RB_VERTCENTERED, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  921.                else
  922.                    WinSendDlgItemMsg(hWnd, RB_TOPALIGNED, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  923.  
  924.                        /* Set Word Break check box if style selected    */
  925.  
  926.            if ( pust->flStyle & DT_WORDBREAK )
  927.                WinSendDlgItemMsg(hWnd, CB_WORDWRAP, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  928.  
  929.                        /* Set Half Tone check box if style selected     */
  930.  
  931.            if ( pust->flStyle & DT_HALFTONE )
  932.                WinSendDlgItemMsg(hWnd, CB_HALFTONE, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  933.  
  934.                        /* Set Mnemonic check box if style selected      */
  935.  
  936.            if ( pust->flStyle & DT_MNEMONIC )
  937.                WinSendDlgItemMsg(hWnd, CB_MNEMONIC, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  938.  
  939.            if ( pust->flStyle & WS_VISIBLE )
  940.                WinSendDlgItemMsg(hWnd, CB_VISIBLE, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  941.  
  942.            if ( pust->flStyle & WS_GROUP )
  943.                WinSendDlgItemMsg(hWnd, CB_GROUP, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  944.  
  945.            if ( pust->flStyle & WS_DISABLED )
  946.                WinSendDlgItemMsg(hWnd, CB_DISABLED, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  947.  
  948.            if ( pust->flStyle & WS_TABSTOP )
  949.                WinSendDlgItemMsg(hWnd, CB_TABSTOP, BM_SETCHECK, MPFROMSHORT(TRUE), 0L);
  950.            }
  951.                        /* Centre dialog on the screen                   */
  952.  
  953.        WinQueryWindowPos(hWnd, (PSWP)&swp);
  954.        WinSetWindowPos(hWnd, HWND_TOP,
  955.                        (WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN) - swp.cx) / 2L,
  956.                        (WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - swp.cy) / 2L,
  957.                        0L, 0L, SWP_MOVE);
  958.        break;
  959.                        /* Process push button selections                */
  960.    case WM_COMMAND :
  961.        switch ( SHORT1FROMMP(mp1) )
  962.            {
  963.                        /* Presentation push button selected             */
  964.  
  965.            case DID_FONTCLR :
  966.  
  967.                        /* Get the pointer to the user style information */
  968.  
  969.                if ( (pust = PDATAFROMDLG(hWnd)) != NULL )
  970.  
  971.                        /* Get the address of the look up function from  */
  972.                        /* user style information structure and display  */
  973.                        /* the dialog.  The value selected within the    */
  974.                        /* dialog will be automatically placed within    */
  975.                        /* the required entry fields                     */
  976.  
  977.                    pust->pfnGetFontClr(hWnd);
  978.                break;
  979.                        /* Enter pushbutton selected get the definitions */
  980.                        /* for the control                               */
  981.            case DID_OK :
  982.  
  983.                        /* Get the pointer to the user style information */
  984.  
  985.                if ( (pust = PDATAFROMDLG(hWnd)) != NULL )
  986.                    {
  987.                        /* Get the address of the CUA compliance         */
  988.                        /* function from the user style information      */
  989.                        /* structure.  The function will check the text  */
  990.                        /* for CUA compliance according to index value   */
  991.                        /* selected.  A return value of TRUE from the    */
  992.                        /* compliance function indicates that the text   */
  993.                        /* entered is acceptable.  Conversely, a FALSE   */
  994.                        /* return value indicates that text is non-      */
  995.                        /* compliant.  In this case, the dialog should   */
  996.                        /* not be exited from and the values within the  */
  997.                        /* the entry fields should not be saved.         */
  998.  
  999.                    if ( !pust->pfnCUACheck(hWnd, EF_TEXT, CUACHK_CAPS) )
  1000.                        break;
  1001.  
  1002.                        /* Get the address of the symbol validation      */
  1003.                        /* function from the user style information      */
  1004.                        /* structure.  The function will validate the    */
  1005.                        /* symbol and will check for duplications of     */
  1006.                        /* values.  A return value of TRUE from the      */
  1007.                        /* validation function indicates that the symbol */
  1008.                        /* and value are acceptable.  Conversely, a      */
  1009.                        /* FALSE return value indicates that symbol or   */
  1010.                        /* value was not acceptable.  In this case,      */
  1011.                        /* the dialog should not be exited from and the  */
  1012.                        /* values within the entry fields should not be  */
  1013.                        /* saved.                                        */
  1014.  
  1015.                    if ( !pust->pfnGetSymbolID(hWnd, IDBX_SYMBOLVALUE, pust) )
  1016.                        break;
  1017.                    else
  1018.                        {
  1019.                        /* Symbol and value validated, get the text of   */
  1020.                        /* the control and save within the user style    */
  1021.                        /* information structure for use by Resource     */
  1022.                        /* Editor                                        */
  1023.  
  1024.                        pust->cText = WinQueryDlgItemText(hWnd, EF_TEXT, CCHTEXTMAX, pust->pszText);
  1025.  
  1026.                        /* Mask out current edit field styles clearing   */
  1027.                        /* selectable styles and save new style          */
  1028.  
  1029.                        pust->flStyle = SS_TEXT;
  1030.  
  1031.                        /* Get raised/depressed style                    */
  1032.  
  1033.                        if ( SHORT1FROMMR(WinSendDlgItemMsg(hWnd, RB_RAISED, BM_QUERYCHECK, 0L, 0L)) )
  1034.                            pust->flStyle |= DS_RAISED;
  1035.                        else
  1036.                            pust->flStyle |= DS_DEPRESSED;
  1037.  
  1038.                        /* Get horizontal alignment type                 */
  1039.  
  1040.                        switch ( (ULONG)SHORT1FROMMR(WinSendDlgItemMsg(hWnd, RB_LEFTALIGNED, BM_QUERYCHECKINDEX,
  1041.                                                                       0L, 0L)) + RB_LEFTALIGNED )
  1042.                            {
  1043.                            case RB_LEFTALIGNED :
  1044.                                pust->flStyle |= DT_LEFT;
  1045.                                break;
  1046.  
  1047.                            case RB_HORZALIGNED :
  1048.                                pust->flStyle |= DT_CENTER;
  1049.                                break;
  1050.  
  1051.                            case RB_RIGHTALIGNED :
  1052.                                pust->flStyle |= DT_RIGHT;
  1053.                                break;
  1054.                            }
  1055.  
  1056.                        /* Get vertical alignment style                  */
  1057.  
  1058.                        switch ( (ULONG)SHORT1FROMMR(WinSendDlgItemMsg(hWnd, RB_TOPALIGNED,
  1059.                                                                       BM_QUERYCHECKINDEX,
  1060.                                                                       0L, 0L)) + RB_TOPALIGNED )
  1061.                            {
  1062.                            case RB_TOPALIGNED :
  1063.                                pust->flStyle |= DT_TOP;
  1064.                                break;
  1065.  
  1066.                            case RB_VERTCENTERED :
  1067.                                pust->flStyle |= DT_VCENTER;
  1068.                                break;
  1069.  
  1070.                            case RB_BOTALIGNED :
  1071.                                pust->flStyle |= DT_BOTTOM;
  1072.                                break;
  1073.                            }
  1074.  
  1075.                        /* Set Half Tone style if selected               */
  1076.  
  1077.                        if ( WinSendDlgItemMsg(hWnd, CB_HALFTONE, BM_QUERYCHECK, 0L, 0L) )
  1078.                            pust->flStyle |= DT_HALFTONE;
  1079.  
  1080.                        /* Set Word Break style if selected              */
  1081.  
  1082.                        if ( WinSendDlgItemMsg(hWnd, CB_WORDWRAP, BM_QUERYCHECK, 0L, 0L) )
  1083.                            pust->flStyle |= DT_WORDBREAK;
  1084.  
  1085.                        /* Set Mnemonic style if selected                */
  1086.  
  1087.                        if ( WinSendDlgItemMsg(hWnd, CB_MNEMONIC, BM_QUERYCHECK, 0L, 0L) )
  1088.                            pust->flStyle |= DT_MNEMONIC;
  1089.  
  1090.                        /* Save completed edit field style in internal   */
  1091.                        /* window information                            */
  1092.  
  1093.                        if ( WinSendDlgItemMsg(hWnd, CB_VISIBLE, BM_QUERYCHECK, 0L, 0L) )
  1094.                            pust->flStyle |= WS_VISIBLE;
  1095.  
  1096.                        if ( WinSendDlgItemMsg(hWnd, CB_GROUP, BM_QUERYCHECK, 0L, 0L) )
  1097.                            pust->flStyle |= WS_GROUP;
  1098.  
  1099.                        if ( WinSendDlgItemMsg(hWnd, CB_DISABLED, BM_QUERYCHECK, 0L, 0L) )
  1100.                            pust->flStyle |= WS_DISABLED;
  1101.  
  1102.                        if ( WinSendDlgItemMsg(hWnd, CB_TABSTOP, BM_QUERYCHECK, 0L, 0L) )
  1103.                            pust->flStyle |= WS_TABSTOP;
  1104.                        }
  1105.                    }
  1106.                        /* Exit the dialogue indicating changes made     */
  1107.  
  1108.                WinDismissDlg(hWnd, TRUE);
  1109.                break;
  1110.                        /* Cancel selected, exit the dialogue without    */
  1111.                        /* changing anything                             */
  1112.  
  1113.            case DID_CANCEL :
  1114.                WinDismissDlg(hWnd, FALSE);
  1115.                break;
  1116.            }
  1117.        break;
  1118.                        /* Close received, exit dialog                   */
  1119.    case WM_CLOSE :
  1120.        WinDismissDlg(hWnd, FALSE);
  1121.        break;
  1122.                        /* Pass through unhandled messages               */
  1123.    default :
  1124.        return(WinDefDlgProc(hWnd, msg, mp1, mp2));
  1125.    }
  1126. return(0L);
  1127.  
  1128. }
  1129.