home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 December / PCO_1298.ISO / filesbbs / os2 / bubpd102.arj / BUBPD102.ZIP / Source / bubblepd.cpp next >
Encoding:
C/C++ Source or Header  |  1998-09-19  |  55.3 KB  |  1,361 lines

  1. /***********************************************************************/
  2. /* BubblePad - Replacement class for the launchpad of Warp 3/4         */
  3. /* (C) Chris Wohlgemuth                                                */
  4. /*                                                                     */
  5. /* E-Mail: chris.wohlgemuth@cityweb.de                                 */
  6. /*     or  christopher.wohlgemuth@bch.siemens.de                       */
  7. /*                                                                     */
  8. /* Released under the GNU Public Licence                               */
  9. /* See file COPYING for further information                            */
  10. /*                                                                     */
  11. /* 20.06.98 V1.00:  First public version                               */
  12. /* 16.08.98 V1.00a: Corrected bug: fly over help window on some        */
  13. /*                  systems remains visible. Workaround: When help     */
  14. /*                  stucks on the desktop move pointer over another    */
  15. /*                  button                                             */
  16. /*                                                                     */
  17. /* 18.08.98 V1.00b: Corrected positioning of drawers. Drawers below    */
  18. /*                  or on the left of the launchpad were placed        */
  19. /*                  with some distance to the launchpad                */
  20. /*                  Timer routines rewritten.                          */
  21. /*                                                                     */
  22. /* 18.08.98 V1.01: Stucking window problem for drawers with autoclose  */
  23. /*                  feature corrected                                  */
  24. /*                                                                     */
  25. /* 19.09.98 V1.02: Positioning of help windows for launchpad at the    */
  26. /*                 top of the desktop corrected.                       */
  27. /*                 Drawer button hide feature added.                   */
  28. /*                 Individual settings for BubblePads added.           */
  29. /*                 Bug with broken references causing drawers to       */
  30. /*                 disapear fixed                                      */
  31. /*                 Added saving of drawer state. Drawers are reopened  */
  32. /*                 on next reboot. Doesn't work with normal open/close */
  33. /*                 Moved button reordering from wpRefreshDrawer()      */
  34. /*                 to wpSetDrawerHWND(). This eliminates the flickering*/
  35. /*                 when opening drawers.                               */
  36. /*                                                                     */
  37. /***********************************************************************/
  38.  
  39. #define INCL_WINWORKPLACE
  40. #define INCL_WPCLASS
  41. #define INCL_GPILCIDS
  42. #define INCL_GPIPRIMITIVES
  43. #define INCL_GPIBITMAPS
  44.  
  45. #include "BUBBLEPD.hh"
  46. #include <somcls.hh>
  47. #include <wpobject.hh>
  48. #include <pmwp.h>
  49. #include <os2.h>
  50.  
  51.  
  52. // for sprintf
  53. #include <stdio.h>
  54. #include <string.h>  //for strchr()
  55.  
  56. #define xVal  12      //x-distance of Bubble
  57. #define yVal  12      //y-distance of Bubble
  58. #define delta 0       //use this if you want to reduce the button size
  59.  
  60. //#define debug      //uncomment for debuging
  61.  
  62. static PFNWP  oldButtonProc2;  //place for original button-procedure
  63. static HWND hwndBubbleWindow=NULLHANDLE;// The handle of the help window
  64.  
  65. M_WPObject  M_ob;  //We need a class object to get an object pointer from HOBJECT
  66.  
  67. #ifdef debug
  68. /* Display a PM-Messagebox with an Errortext if debug is defined */
  69. void showMessage(HWND hwnd,PSZ msgText)
  70. {
  71.     WinMessageBox(HWND_DESKTOP,hwnd ,msgText ,"Debug Launchpad",0,MB_OK);
  72. }
  73. #endif
  74.  
  75. /* This function returns the module handle of our class-dll */
  76. HMODULE QueryModuleHandle(void)
  77. {
  78.     static HMODULE hmod=0;
  79.     
  80.     if(!hmod) {
  81.         PSZ pathname=SOMClassMgrObject  //Query Pathname of class file
  82.             ->somLocateClassFile(somIdFromString("WPLnchCW"),1,2);
  83.         DosQueryModuleHandle(pathname,&hmod);  //Query module handle
  84.     }
  85.     return hmod;
  86. }
  87.  
  88. /*************************************************************/
  89. /* This dialog procedure handles the Bubblehelp enable page  */
  90. /*************************************************************/
  91. MRESULT EXPENTRY BubblehelpDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {    
  92.         ULONG spinValue;
  93.  
  94.      switch(msg) {
  95.      case WM_INITDLG :    
  96.         //thisPtr
  97.         WinSetWindowULong(hwnd,QWL_USER,LONGFROMMP(mp2));
  98.         /* We have to initialize the dialog controls with the approbiate values */
  99.  
  100.         // Set the focus on the enable checkbox
  101.         WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, CWDLG_ENABLEBUBBLE));
  102.         // Set the linits for the delay spin button
  103.         WinSendMsg(WinWindowFromID(hwnd, CWDLG_DELAYSPIN),
  104.                              SPBM_SETLIMITS,(MPARAM)9999,(MPARAM)0);
  105.         // Set the current value for delay
  106.         WinSendMsg(WinWindowFromID(hwnd, CWDLG_DELAYSPIN),
  107.                              SPBM_SETCURRENTVALUE,
  108.                              (MPARAM)((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->delayValue,
  109.                              (MPARAM)NULL);
  110.         // Enable or disable the spin button according to the value of bubbleEnabled
  111.         WinEnableWindow(WinWindowFromID(hwnd, CWDLG_DELAYSPIN),((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->bubbleEnabled);
  112.         // Set the state of the enable checkbox
  113.         WinSendMsg(WinWindowFromID(hwnd, CWDLG_ENABLEBUBBLE),
  114.                              BM_SETCHECK,MPFROMSHORT(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->bubbleEnabled),(MPARAM)NULL);
  115.         return (MRESULT) TRUE;  //Initialisation done
  116.  
  117.      case WM_DESTROY:
  118.         /* The notebook closes and gets destroyed */
  119.         // Query the value of the delay spin button
  120.         WinSendMsg(WinWindowFromID(hwnd, CWDLG_DELAYSPIN),
  121.                              SPBM_QUERYVALUE,(MPARAM)&spinValue,
  122.                              MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE));                
  123.         ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->delayValue=spinValue;
  124.             // Write the new  values to the instance permanent data
  125.         ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->wpSaveDeferred();
  126.         break;
  127.     case WM_CONTROL:
  128.         /* The window controls send WM_CONTROL messages */
  129.         switch(SHORT1FROMMP(mp1)) {
  130.         case CWDLG_ENABLEBUBBLE:
  131.             // We only have one checkbox, so we do not really need this switch statement
  132.             // but with it you can expand the dialog easily 
  133.             if(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->bubbleEnabled)// switch the bubbleEnabled state
  134.                 ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->bubbleEnabled=0;                        
  135.             else 
  136.                 ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->bubbleEnabled=1;                
  137.             // Enable or disable the spin button according to the value of bubbleEnabled
  138.             WinEnableWindow(WinWindowFromID(hwnd, CWDLG_DELAYSPIN),((WPLnchCW*)WinQueryWindowULong(hwnd,QWL_USER))->bubbleEnabled);            
  139.             // Set the state of the enable checkbox    
  140.             WinSendMsg(WinWindowFromID(hwnd, CWDLG_ENABLEBUBBLE),
  141.                                  BM_SETCHECK,MPFROMSHORT(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->bubbleEnabled),(MPARAM)NULL);
  142.  
  143.             WinPostMsg(WinWindowFromID(((WPLnchCW*)WinQueryWindowULong(hwnd,QWL_USER))->wpQueryDrawerHWND(0),300),
  144.                                  BM_CLICK,FALSE,0);
  145.             break;
  146.         case CWDLG_DELAYSPIN:
  147.             switch (SHORT2FROMMP(mp1)) {
  148.             case SPBN_UPARROW:
  149.             case SPBN_DOWNARROW:
  150.             case SPBN_ENDSPIN:
  151.                 // Query the value of the delay spin button
  152.                 WinSendMsg(WinWindowFromID(hwnd, CWDLG_DELAYSPIN),
  153.                                      SPBM_QUERYVALUE,(MPARAM)&spinValue,
  154.                                      MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE));                
  155.                 ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->delayValue=spinValue;            
  156.                 break;
  157.             default:
  158.                 break;
  159.             }
  160.         } // end switch(SHORT1FROMMP(mp1))
  161.         break;            
  162.         //} // end switch(SHORT2FROMMP(mp1))
  163.         return (MRESULT) TRUE;
  164.     }
  165.     // The WinDefDlgProc() handles the rest of the messages
  166.     return WinDefDlgProc(hwnd, msg, mp1, mp2);
  167. }
  168.  
  169. /*************************************************************/
  170. /* This dialog procedure handles the colour and font page    */
  171. /*************************************************************/            
  172. MRESULT EXPENTRY ColorchangeDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
  173.     HINI hini;
  174.     HOBJECT  hObject;
  175.     ULONG  attrFound;
  176.     ULONG  len;
  177.     static RGB b;
  178.     static RGB f;
  179.     static     font[FONTNAMELENGTH];
  180.     char msgText[250];
  181.     
  182.      switch(msg) {
  183.      case WM_INITDLG :    
  184.         WinSetWindowULong(hwnd,QWL_USER,LONGFROMMP(mp2));
  185.     
  186.         /* We have to initialize the dialog controls with the approbiate values */
  187.  
  188.         // Set the focus on the demo area
  189.         WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD));
  190.         // Set the background colour of the demo area
  191.         WinSetPresParam(WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD),
  192.                                         PP_BACKGROUNDCOLOR,(ULONG)sizeof(RGB) ,&((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->background );
  193.         // Set the foreground colour of the demo area
  194.         WinSetPresParam(WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD),
  195.                                         PP_FOREGROUNDCOLOR,(ULONG)sizeof(RGB) ,&((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->foreground );
  196.         // Set the font of the demo area
  197.         WinSetPresParam(WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD),
  198.                                         PP_FONTNAMESIZE,(ULONG)sizeof(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->fontName),
  199.                                         &((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->fontName );
  200.         b=((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->background;  // Save value for undo 
  201.         f=((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->foreground;  //Save value for undo
  202.         memcpy(&font,&((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->fontName,
  203.                      sizeof(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->fontName));
  204.         return (MRESULT) TRUE;
  205.     case WM_DESTROY:
  206.         /* The notebook closes and gets destroyed */
  207.         // Query the current background colour
  208.         len=WinQueryPresParam(WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD),
  209.                                                     PP_BACKGROUNDCOLOR,0,&attrFound,sizeof(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->background),
  210.                                                     &((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->background,QPF_NOINHERIT);
  211.         // Query the current font
  212.         len=WinQueryPresParam(WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD),
  213.                                                     PP_FONTNAMESIZE,0,&attrFound,sizeof(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->fontName),
  214.                                                     &((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->fontName,QPF_NOINHERIT);
  215.         // Query the current foreground colour
  216.         len=WinQueryPresParam(WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD),
  217.                                                     PP_FOREGROUNDCOLOR,0,&attrFound,sizeof(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->foreground),
  218.                                                     &((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->foreground,QPF_NOINHERIT);
  219.         // Save font to instance permanent data
  220.         ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->wpSaveDeferred();
  221.         break;
  222.     case WM_COMMAND :
  223.         switch (SHORT1FROMMP(mp1)) {
  224.             // Process commands here //
  225.         case CWDLG_COLORUNDO:
  226.             /* The undo button was clicked */
  227.             ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->background=b;  // Restore the previous background colour
  228.             ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->foreground=f;  // Restore the previous background colour
  229.             // Set the background colour of the demo area
  230.             WinSetPresParam(WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD),
  231.                                             PP_BACKGROUNDCOLOR,(ULONG)sizeof(RGB) ,&((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->background );
  232.             // Set the foreground colour of the demo area
  233.             WinSetPresParam(WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD),
  234.                                             PP_FOREGROUNDCOLOR,(ULONG)sizeof(RGB) ,&((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->foreground );            
  235.             // Set the font of the demo area
  236.             WinSetPresParam(WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD),
  237.                                             PP_FONTNAMESIZE,(ULONG)sizeof(font) ,&font);
  238.             break;
  239.         case CWDLG_COLORSTANDARD:
  240.             /* The default button was clicked */
  241.             ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->background.bBlue=180;  // Set the default colours
  242.             ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->background.bGreen=255; 
  243.             ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->background.bRed=255;
  244.             ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->foreground.bBlue=0;
  245.             ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->foreground.bGreen=0;            
  246.             ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->foreground.bRed=0;
  247.             // Set the default font
  248.             memcpy(&((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->fontName,"8.Helv",sizeof("8.Helv"));
  249.             // Set the background colour of the demo area
  250.             WinSetPresParam(WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD),
  251.                                             PP_BACKGROUNDCOLOR,(ULONG)sizeof(RGB) ,&((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->background );
  252.             // Set the foreground colour of the demo area
  253.             WinSetPresParam(WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD),
  254.                                             PP_FOREGROUNDCOLOR,(ULONG)sizeof(RGB) ,&((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->foreground );
  255.             // Set the font of the demo area
  256.             WinSetPresParam(WinWindowFromID(hwnd, CWDLG_TEXTDEMOFIELD),
  257.                                             PP_FONTNAMESIZE,(ULONG)sizeof(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->fontName),
  258.                                             &((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->fontName );
  259.             break;
  260.         case CWDLG_COLORPALETTE:
  261.             /* Colour... button was clicked */
  262.             // Open the colorpalette 
  263.             if((hObject=WinQueryObject("<WP_HIRESCLRPAL>"))!=NULL) {
  264.                 WinOpenObject(hObject,OPEN_DEFAULT,TRUE);
  265.             }
  266.             else {//Error, can't open the palette
  267.                 /*  Show an error msg.                           */
  268.                 WinLoadString(WinQueryAnchorBlock(hwnd),QueryModuleHandle(),ID_NOCOLORPALETTESTRING,
  269.                                             sizeof(msgText), msgText);
  270.                 WinMessageBox(HWND_DESKTOP,
  271.                                             hwnd,         
  272.                                             msgText,          
  273.                                             (PSZ) NULL,                      
  274.                                             ID_COLORPALETTEMSGBOX,            /* Window ID */
  275.                                             MB_OK |
  276.                                             MB_MOVEABLE |
  277.                                             MB_ICONEXCLAMATION |
  278.                                             MB_DEFBUTTON1);                  /* Style     */
  279.                 
  280.             }
  281.             break;
  282.         case CWDLG_FONTPALETTE:
  283.             /* Font... button was clicked */
  284.             // Open the fontpalette 
  285.             if((hObject=WinQueryObject("<WP_FNTPAL>"))!=NULL) {
  286.                 WinOpenObject(hObject,OPEN_DEFAULT,TRUE);
  287.             }
  288.             else {//Error, can't open the palette
  289.                 /*  Show an error msg.                           */
  290.                 WinLoadString(WinQueryAnchorBlock(hwnd),QueryModuleHandle(),ID_NOFONTPALETTESTRING,
  291.                                             sizeof(msgText), msgText);
  292.                 WinMessageBox(HWND_DESKTOP,
  293.                                             hwnd,         
  294.                                             msgText,          
  295.                                             (PSZ) NULL,                      
  296.                                             ID_COLORPALETTEMSGBOX,                   /* Window ID */
  297.                                             MB_OK |
  298.                                             MB_MOVEABLE |
  299.                                             MB_ICONEXCLAMATION |
  300.                                             MB_DEFBUTTON1);                  /* Style     */
  301.             }
  302.             break;
  303.         }
  304.         /* Don't call WinDefDlgProc here, or the dialog gets closed */
  305.         return (MRESULT) TRUE;
  306.     }
  307.     // The WinDefDlgProc() handles the rest of the messages
  308.     return WinDefDlgProc(hwnd, msg, mp1, mp2);
  309. }
  310.  
  311.  
  312. /*************************************************************/
  313. /* This dialog procedure handles the third option page       */
  314. /*************************************************************/
  315. MRESULT EXPENTRY OptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
  316.     
  317.      switch(msg) {
  318.      case WM_INITDLG :    
  319.         /* We have to initialize the dialog controls with the approbiate values */
  320.         WinSetWindowULong(hwnd,QWL_USER,LONGFROMMP(mp2));
  321.         // Set the focus on the smallsize checkbox
  322.         WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, CWDLG_SMALLSIZE));
  323.         // Set limits of the distance spinbutton
  324.         WinSendMsg(WinWindowFromID(hwnd, CWDLG_DISTANCESPIN),
  325.                              SPBM_SETLIMITS,(MPARAM)18,(MPARAM)4);
  326.         // Set distance spinbutton to the current value of icondistance
  327.         WinSendMsg(WinWindowFromID(hwnd, CWDLG_DISTANCESPIN),
  328.                              SPBM_SETCURRENTVALUE,
  329.                              (MPARAM)((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->icondistance,
  330.                              (MPARAM)NULL);
  331.         // Enable or disable the spin button according to the value of smallSizeEnabled
  332.         WinEnableWindow(WinWindowFromID(hwnd, CWDLG_DISTANCESPIN),((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->smallSizeEnabled);
  333.         // Set the state of the smallSizeEnabled checkbox
  334.         WinSendMsg(WinWindowFromID(hwnd, CWDLG_SMALLSIZE),
  335.                              BM_SETCHECK,MPFROMSHORT(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->smallSizeEnabled),(MPARAM)NULL);
  336.         // Enable or disable the noDrawers checkbox according to the value of smallSizeEnabled
  337.         WinEnableWindow(WinWindowFromID(hwnd, CWDLG_NODRAWERS),((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->smallSizeEnabled);
  338.         // Set the state of the noDrawers checkbox
  339.         WinSendMsg(WinWindowFromID(hwnd, CWDLG_NODRAWERS),
  340.                              BM_SETCHECK,MPFROMSHORT(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->noDrawers),(MPARAM)NULL);
  341.         return (MRESULT) TRUE;
  342.     case WM_DESTROY:
  343.         /* The notebook closes and gets destroyed */
  344.         // Save the value to the instance data
  345.         ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->wpSaveDeferred();
  346.         break;                
  347.     case WM_CONTROL:
  348.         switch (SHORT2FROMMP(mp1)) {
  349.         case SPBN_ENDSPIN:
  350.             /* The value of the spinbutton has changed */
  351.             ULONG spinValue;
  352.             // Query the new spinbutton value
  353.             WinSendMsg(WinWindowFromID(hwnd, CWDLG_DISTANCESPIN),
  354.                                  SPBM_QUERYVALUE,(MPARAM)&spinValue,
  355.                                  MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE));                                     
  356.             ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->icondistance=spinValue;
  357.             // Refresh the size of the launchpad
  358.             ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->wpRefreshDrawer(0);//0: LaunchPad
  359.             break;
  360.         case BN_CLICKED:
  361.             switch(SHORT1FROMMP(mp1)) {
  362.             case CWDLG_SMALLSIZE:
  363.                 /* checkbox was clicked */
  364.                 if(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->smallSizeEnabled)  // Change the value of smallSizeEnabled
  365.                     ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->smallSizeEnabled=0;
  366.                 else 
  367.                     ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->smallSizeEnabled=1;                
  368.                 // Set the checkbox state
  369.                 WinSendMsg(WinWindowFromID(hwnd, CWDLG_SMALLSIZE),
  370.                                      BM_SETCHECK,MPFROMSHORT(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->smallSizeEnabled),(MPARAM)NULL);
  371.                 // Enable/disable the spinbutton
  372.                 WinEnableWindow(WinWindowFromID(hwnd, CWDLG_DISTANCESPIN),((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->smallSizeEnabled);
  373.                 // Enable/disable the noDrawers checkbox
  374.                 WinEnableWindow(WinWindowFromID(hwnd, CWDLG_NODRAWERS),((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->smallSizeEnabled);
  375.                 // Refresh the size of the launchpad
  376.                 ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->wpRefreshDrawer(0);//0: LaunchPad
  377.                 break;
  378.             case CWDLG_NODRAWERS:
  379.                 if(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->wpQueryHideDrawers())  // Change the value of smallSizeEnabled
  380.                     ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->wpSetHideDrawers(0);
  381.                 else 
  382.                     ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->wpSetHideDrawers(1);
  383.                 // Set the checkbox state
  384.                  WinSendMsg(WinWindowFromID(hwnd, CWDLG_NODRAWERS),
  385.                                      BM_SETCHECK,MPFROMSHORT(((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->wpQueryHideDrawers()),(MPARAM)NULL);
  386.                 // Refresh the size of the launchpad
  387.                 ((WPLnchCW*) WinQueryWindowULong(hwnd,QWL_USER))->wpRefreshDrawer(0);//0: LaunchPad
  388.                 break;
  389.             } // end switch(SHORT1FROMMP(mp1))
  390.             break;
  391.         }// end switch SHORT2FROMMP(mp1)
  392.         return (MRESULT) TRUE;
  393.     }
  394.     // The WinDefDlgProc() handles the rest of the messages
  395.     return WinDefDlgProc(hwnd, msg, mp1, mp2);
  396. }
  397.  
  398. /*****************************************************************************/
  399. /*  New launchpad button procedure with fly over help                                                */
  400. /*****************************************************************************/
  401. static MRESULT EXPENTRY newButtonProc(HWND hwnd, ULONG msg,MPARAM mp1,MPARAM mp2 )
  402. {
  403.     static BOOL bBubbleOn=TRUE;
  404.     POINTL ptl;
  405.     HPS  hps;
  406.     FONTMETRICS   fm;
  407.     LONG  ulWinTextLen;
  408.     POINTL aptlPoints[TXTBOX_COUNT];
  409.     RECTL   rcl;
  410.     LONG   deltaX,deltaY;
  411.     RGB    rgb= {200,200,0};
  412.     static USHORT id=0;//Initialisation new in V1.00a 
  413.     RECTL  rclWork;
  414.     ULONG bubbleEnabled;
  415.     HWND hwndStore;
  416.     
  417.     switch (msg)
  418.         {
  419.         case WM_DESTROY:
  420.             WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,1);//Stop timer if running
  421.             if(hwndBubbleWindow) WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
  422.             hwndBubbleWindow=0;
  423.             /* Stop delay timer if running */
  424.             WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,WinQueryWindowUShort(hwnd,QWS_ID));            
  425.             break;
  426.         case WM_NEWBUBBLE:
  427.             ULONG bubbleEnabled;
  428.             HWND hwndStore;
  429.             bubbleEnabled=1;
  430.             hwndStore=WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),ID_STOREWINDOW);
  431.             if(hwndStore)bubbleEnabled=((WPLnchCW*) WinQueryWindowULong(hwndStore,QWL_USER) )->bubbleEnabled;
  432.             /*  we have to build a new information window                                                                   */
  433.             if(hwndBubbleWindow){// if(){...} new in V1.00a 
  434.                 WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
  435.                 hwndBubbleWindow=0;
  436.             }
  437.             // Query the pointer position
  438.             WinQueryPointerPos(HWND_DESKTOP,&ptl);
  439.             WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
  440.             WinQueryWindowRect(hwnd,&rclWork);                
  441.             if(!hwndBubbleWindow 
  442.                  && WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl)
  443.                  && bubbleEnabled) {
  444.                 static HWND hwndBubbleClient;
  445.                 ULONG style=FCF_BORDER;
  446.                 char winText[255];
  447.  
  448.                 /* Get window text (It's the object title) for size calculating */
  449.                 WinQueryWindowText(hwnd,sizeof(winText),winText);
  450.                 ulWinTextLen=(LONG)strlen(winText); // Query text length
  451.  
  452.                 /* Delete 'Returns' in object title */
  453.                 char *pBuchst;
  454.                 pBuchst=strchr(winText,10);
  455.                 if(pBuchst)    winText[pBuchst-winText]=' ';
  456.                 pBuchst=strchr(winText,13);
  457.                 if(pBuchst)    winText[pBuchst-winText]=' ';
  458.                 
  459.                 /* Create help window */
  460.                 hwndBubbleWindow=WinCreateStdWindow(HWND_DESKTOP,
  461.                                                                                         0,
  462.                                                                                         &style,
  463.                                                                                         WC_STATIC,
  464.                                                                                         "",
  465.                                                                                         SS_TEXT|DT_CENTER|DT_VCENTER,
  466.                                                                                         NULLHANDLE,
  467.                                                                                         400,
  468.                                                                                         &hwndBubbleClient);
  469.                          
  470.                 // Set the font for the help
  471.                 WinSetPresParam(hwndBubbleClient,PP_FONTNAMESIZE,sizeof(((WPLnchCW*) WinQueryWindowULong(hwndStore,QWL_USER) )->fontName),
  472.                                                 &((WPLnchCW*) WinQueryWindowULong(hwndStore,QWL_USER) )->fontName);
  473.                 /* Calculate text size in pixel */
  474.                 hps=WinBeginPaint(hwndBubbleClient,(HPS)NULL,(PRECTL)NULL);
  475.                 GpiQueryTextBox(hps,ulWinTextLen,winText,TXTBOX_COUNT,aptlPoints);
  476.                 WinEndPaint(hps);
  477.                 
  478.                 /* Set colors */
  479.                 WinSetPresParam(hwndBubbleClient,
  480.                                                 PP_BACKGROUNDCOLOR,sizeof(RGB) ,&((WPLnchCW*) WinQueryWindowULong(hwndStore,QWL_USER) )->background );
  481.                 WinSetPresParam(hwndBubbleClient,
  482.                                                 PP_FOREGROUNDCOLOR,sizeof(RGB) ,&((WPLnchCW*) WinQueryWindowULong(hwndStore,QWL_USER) )->foreground );                
  483.  
  484.                 /* Calculate bubble positon and show bubble */
  485.                 WinQueryPointerPos(HWND_DESKTOP,&ptl);//Query pointer position in the desktop window
  486.                 WinQueryWindowRect(HWND_DESKTOP,&rcl);//Query desktop size
  487.                 aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+7+xVal+ptl.x 
  488.                     > rcl.xRight 
  489.                     ? deltaX=-aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x-xVal-xVal-7 
  490.                     : deltaX=0 ;
  491.                 /*
  492.                 aptlPoints[TXTBOX_TOPLEFT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+2+yVal+ptl.x 
  493.                     > rcl.yTop 
  494.                     ? deltaY=-aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x-yVal
  495.                     : deltaY=0 ;    */            
  496.                 aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2+yVal+ptl.y 
  497.                     > rcl.yTop 
  498.                     ? deltaY=-aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y-2*yVal-7
  499.                     : deltaY=0 ;                
  500.                 WinSetWindowPos(hwndBubbleWindow,
  501.                                                 HWND_DESKTOP,
  502.                                                 ptl.x+xVal+deltaX,ptl.y+yVal+deltaY,  //deltaY value not used yet
  503.                                                 aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
  504.                                                 aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
  505.                                                 SWP_SIZE|SWP_MOVE|SWP_SHOW);
  506.                 /* Set bubble text */
  507.                 WinSetWindowText(hwndBubbleClient,winText);
  508.                 WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,1,35); 
  509.             } // end if(!hwndBubbleWindow)
  510.             break;
  511.         case WM_MOUSEMOVE:
  512.             USHORT  tempID;
  513.             ULONG delayValue;
  514.             delayValue=250;
  515.             hwndStore=WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),ID_STOREWINDOW);
  516.             if(hwndStore)delayValue=((WPLnchCW*) WinQueryWindowULong(hwndStore,QWL_USER) )->delayValue;
  517.             tempID=WinQueryWindowUShort(hwnd,QWS_ID);/*  get the id of the window under the pointer  */              
  518.             if(id!=tempID) {    // New Button?    
  519.                 WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)delayValue); // New timer for delay
  520.                 id=tempID;  // Save ID 
  521.             }
  522.             else {
  523.                 if(!hwndBubbleWindow)WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)delayValue); // New timer for delay    
  524.             }            
  525.             break;
  526.         case WM_TIMER:            
  527.             switch (SHORT1FROMMP(mp1))
  528.                 {
  529.                 case 1: //Intervall timer
  530.                     /* Test pointer position */
  531.                     WinQueryPointerPos(HWND_DESKTOP,&ptl);
  532.                     WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
  533.                     WinQueryWindowRect(hwnd,&rclWork);
  534.                     if(!WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
  535.                         {    // Button has changed                 
  536.                             WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,1);  // stop the running timer
  537.                             if(hwndBubbleWindow) WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
  538.                             hwndBubbleWindow=0;
  539.                             id=0;
  540.                         }                         
  541.                     break;
  542.                 default:// delay over
  543.                     //                    if (SHORT1FROMMP(mp1)==id) {
  544.                     if (SHORT1FROMMP(mp1)==WinQueryWindowUShort(hwnd,QWS_ID)) {//our own timer. It has got the window id
  545.                         WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,SHORT1FROMMP(mp1));//Stop the delay timer
  546.                         /* Check the pointer position */
  547.                         WinQueryPointerPos(HWND_DESKTOP,&ptl);
  548.                         WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
  549.                         WinQueryWindowRect(hwnd,&rclWork);
  550.                         if(WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
  551.                             WinPostMsg(hwnd,WM_NEWBUBBLE,NULL,NULL);//Request a help window
  552.                     }
  553.                     break;
  554.                 }
  555.             break;            
  556.         }
  557.     // call the original button procedure to handle the rest of the messages
  558.     return (*oldButtonProc2)(hwnd,msg,mp1,mp2);    
  559. };
  560.  
  561. /* This class function returns the name of our class */
  562. PSZ M_WPLnchCW::wpclsQueryTitle()
  563. {
  564.     return "Ext-LaunchPad";
  565. }
  566.  
  567. /************************************************************/
  568. /* We have to override wpRefreshDrawer() cause we must know */
  569. /* if there're new objects on the launchpad. Every object   */
  570. /* has got a button and we have to change the window        */
  571. /* procedure of the button                                  */
  572. /************************************************************/ 
  573. void WPLnchCW::wpRefreshDrawer(ULONG ulDrawer)
  574. {
  575.     
  576.     // Call parent so it can update its private structures and build the
  577.     // buttons
  578.     // We will change the button procedures later on to provide the 
  579.     // bubble help 
  580.     ((somTD_WPLaunchPad_wpRefreshDrawer)
  581.      somParentNumResolve(__ClassObject->somGetPClsMtabs(),
  582.                                              1,
  583.                                              __ClassObject->
  584.                                              somGetMethodToken(somIdFromString
  585.                                                                                  ("wpRefreshDrawer")))
  586.      )(this,ulDrawer);        
  587.     // This piece of code looks strange, because we're doing no additional processing. Only if we're doing that
  588.     // wpSetDrawerHWND(ULONG ulDrawer,HWND hwnd) is called with the new hwnd. Might be a bug.
  589.     // Docs say wpSetDrawer() is called every time a drawer is build. I realized it is only called when the drawer
  590.     // closes. 
  591.     return;
  592. }
  593.  
  594. void WPLnchCW::wpSetDrawerHWND(ULONG ulDrawer,HWND hwndDrawer)
  595. {
  596.     SWP  swp;
  597.     SWP  lpSWP;
  598.     SWP  desktopSWP;
  599.     
  600.     HWND hwnd;
  601.     HWND hwndNext;
  602.     HWND hwndStore;
  603.     
  604.     HENUM henum;
  605.     BOOL  succ;
  606.     USHORT  id;
  607.     PFNWP  tempProc;
  608.     ULONG  num;
  609.     int maxcy,maxcy1,maxcy3,maxcy2,maxcx,maxcx1,maxcx2,maxcx3;
  610.     ULONG xpos,ypos;
  611.     ULONG res;
  612.     ULONG tempBit;    
  613.     int titlebarSize;
  614.     int actionButtonsText;
  615.  
  616.     int textDelta2;
  617.     int textDelta;
  618.     PSZ  objectTitle;
  619.     HOBJECT *hobject;
  620.     BOOL  isVertical;
  621.     WPObject *wpObject;
  622.     int hasActionButtons;
  623.  
  624. #ifdef debug
  625.                                 char buf2[260];
  626.                                 sprintf(buf2,"wpSetDrawerHWND() beginning    ulDrawer: %x hwndDrawer: %x ",ulDrawer,hwndDrawer);
  627.                                 showMessage(HWND_DESKTOP,buf2);
  628. #endif                                
  629.                         
  630.     actionButtonsText=0;    
  631.     hasActionButtons=1;
  632.  
  633.     if(!hwndDrawer){//Drawer closes, no reordering of buttons necessary
  634.         if(ulDrawer)
  635.             {//We have a drawer. Mark it as closed
  636.                 ULONG tempBit;
  637.                 tempBit=1;
  638.                 tempBit=tempBit<<(ulDrawer-1);
  639.                 ulOpenDrawers&=~tempBit;
  640.             }
  641.     ((somTD_WPLaunchPad_wpSetDrawerHWND)
  642.      somParentNumResolve(__ClassObject->somGetPClsMtabs(),
  643.                                              1,
  644.                                              __ClassObject->
  645.                                              somGetMethodToken(somIdFromString
  646.                                                                                  ("wpSetDrawerHWND")))
  647.      )(this,ulDrawer,hwndDrawer);                
  648.         return;
  649.     }    
  650.  
  651.     if(!WinWindowFromID(hwndDrawer,200)){//That's the first Button. If we have it, the launchpad is built.
  652.         // No the pad isn't ready. Call parent and wait for next call
  653.         ((somTD_WPLaunchPad_wpSetDrawerHWND)
  654.          somParentNumResolve(__ClassObject->somGetPClsMtabs(),
  655.                                                  1,
  656.                                                  __ClassObject->
  657.                                                  somGetMethodToken(somIdFromString
  658.                                                                                      ("wpSetDrawerHWND")))
  659.          )(this,ulDrawer,hwndDrawer);            
  660.         return;
  661.     }
  662.     
  663.  
  664.     // The original Launchpad has built the buttons. We can now reorder them. The Launchpad isn't visible yet.
  665.     // When calling wpSetDrawerHWND() of the parent the launchpad will be displayed
  666.  
  667.     if(ulDrawer)
  668.         {//We have a drawer. Mark it as opened, so we can save the open state on shutdown and reopen it on IPL
  669.             ULONG tempBit;
  670.             tempBit=1;
  671.             tempBit=tempBit << (ulDrawer-1);
  672.             ulOpenDrawers|=tempBit;        
  673. #ifdef debug
  674.                                 char buf2[260];
  675.                                 sprintf(buf2,"ulDrawer: %x ulOpenDrawers:  %x  tempBit: %x",ulDrawer,ulOpenDrawers,tempBit);                                
  676.                                 //    showMessage(HWND_DESKTOP,buf2);
  677. #endif
  678.                                                 
  679.                                 wpSaveDeferred();//Save open state
  680.         }
  681.              
  682.     //Query state of ActionButtons?
  683.     res=wpQueryActionButtonStyle();    
  684.     if(res==ACTION_BUTTONS_OFF)hasActionButtons=0;
  685.     if(res==ACTION_BUTTONS_TEXT)actionButtonsText=1;
  686.  
  687.     //The Warpcenter is a Child of WPLaunchPad, so it inherits all the features.
  688.     // We substitute WPLaunchPad with WPLnchCW, so the Warpcenter inherits the 
  689.     // bubblehelp but it doesn't need it cause it has its own. So if it's the WarpCenter
  690.     // do nothing.
  691.     if(strcmp(somGetClassName(),"SmartCenter")) {// 0 if equal
  692.         // It's not the Warpcenter
  693.         
  694.         // Query the window handle of the drawer
  695.         //It may be the launchpad itself or a drawer
  696.         //hwnd=wpQueryDrawerHWND(ulDrawer);
  697.         hwnd=hwndDrawer;
  698.         
  699.         if(!WinWindowFromID(hwnd,ID_STOREWINDOW))//We use this window to store our object ptr
  700.             WinCreateWindow(hwnd,WC_BUTTON,"StoreWindow",0,0,0,0,0,NULL,HWND_TOP,ID_STOREWINDOW,NULL,NULL);
  701.         hwndStore=WinWindowFromID(hwnd,ID_STOREWINDOW);
  702.         if(hwndStore)WinSetWindowULong(hwndStore,QWL_USER,(ULONG)this);
  703.         isVertical=wpQueryDisplayVertical();//true if vertical 
  704.         if(hwnd) {  // Just to catch errors
  705. #ifdef debug
  706.             //    showMessage(hwnd,"Main window");
  707. #endif
  708.             // Query the list of objects living on this drawer
  709.             hobject=wpQueryObjectList(ulDrawer,&num);
  710.             xpos=0;
  711.             maxcx=0;
  712.             maxcy=0;                        
  713.             maxcx1=-1;
  714.             maxcy1=-1;
  715.  
  716.             henum=WinBeginEnumWindows(hwnd);// We will query all child windows
  717.             while((hwndNext=WinGetNextWindow(henum))!=NULLHANDLE) {
  718.                 // Get windowsize and position
  719.                 WinQueryWindowPos(hwndNext,(PSWP)&swp);
  720.                 
  721.                 // Query window ID
  722.                 // The small drawer buttons have got ID 3XX
  723.                 // The object buttons have got ID 2XX
  724.                 // The action buttons (e.g. shutdown) have got ID 1XX
  725.                 id=WinQueryWindowUShort(hwndNext,QWS_ID);    
  726.                 if(id<400) {
  727.                     if(id>=300) //ID 3XX Drawer-Buttons
  728.                         {
  729.                             maxcy3=swp.cy;//Vert. size of Drawer-Buttons. We need it later
  730.                             maxcx3=swp.cx;//Horz. size of Drawer-Buttons
  731.                             if(noDrawers){
  732.                                 maxcx3=-(int)(icondistance/2);
  733.                                 maxcy3=-(int)(icondistance/2);
  734. #ifdef debug
  735.                                 char buf[260];
  736.                                 sprintf(buf,"maxcx3: %d,     maxcy3:   %d,    icondistance: %d",maxcx3,maxcy3,icondistance);
  737.                                 //                    showMessage(HWND_DESKTOP,buf);
  738. #endif                                    
  739.                             }
  740.                         }
  741.                     else{
  742.                         if(id>=200){   //ID 2XX object Buttons on the launchpad
  743.                             maxcy2=swp.cy;//Vert. sizeize of Prog-Buttons
  744.                             maxcx2=swp.cx;//Horz. size of Prog-Buttons
  745.                             maxcx+=swp.cx+icondistance;  // We need this for sizechanging of the launchpad
  746.                             maxcy+=swp.cy+icondistance;
  747.  
  748.                             //        maxcx+=swp.cx+icondistance/2;  // We need this for sizechanging of the launchpad
  749.                             //        maxcy+=swp.cy+icondistance/2;// When using delta
  750.                         }
  751.                         else{
  752.                             if(id==100){ //ID 1XX System-Buttons auf der Klickstart
  753.                                 xpos=swp.x;//x-pos of leftmost button
  754.                                 ypos=swp.y;
  755.                                 maxcx1=swp.cx;
  756.                                 maxcy1=swp.cy;
  757.                                 maxcx+=((swp.cx+1)*4);// There're 4 system buttons (normaly)
  758.                                 maxcy+=((swp.cy+1)*4);                            
  759.                             }
  760.                         }
  761.                     }                
  762.                 }//end id<400
  763.                 else {//id>400. One of these windows must be the Titlebar
  764.                     char classname[4];
  765.                     //Check if it's the titlebar
  766.                     if(WinQueryClassName(hwndNext,sizeof(classname),classname)==2) {
  767.                         if(*(classname+1)==0x39) {//WC_TITLEBAR
  768.                             // We can't use the system defined value for the titlebar size
  769.                             // because the user may use a custom font for the titlebar so
  770.                             // the size is unknown.
  771.                             WinQueryWindowPos(hwndNext,(PSWP)&swp);//Titlebardimensions
  772.                             // We have to take care of the titlebar size if we resize the launchpad
  773.                             // so save the value
  774.                             titlebarSize=swp.cy;//y-size=0 if titlebar isn't visible
  775.                         }
  776.                     }                    
  777.                 }
  778.             }
  779.             succ=WinEndEnumWindows(henum);
  780.             /****************************************
  781.              *                     
  782.              * Size Launchpad 
  783.              *
  784.              ****************************************/
  785. #ifdef debug
  786.             //    showMessage(hwnd,"Size Launchpad");
  787. #endif
  788.             WinQueryWindowPos(HWND_DESKTOP,(PSWP)&desktopSWP);//Get desktop size
  789.             WinQueryWindowPos(hwnd,(PSWP)&swp);//Get launchpadsize or drawersize
  790.             // Only resize launchpad if user enabled this feature
  791.             if(smallSizeEnabled) {
  792.                 // Hide the launchpad (or drawer) so the user can't see the resizing
  793.                 //    WinShowWindow(hwnd,FALSE);                
  794.                 HWND lpHWND=wpQueryDrawerHWND(0);//Query HWND of launchpad
  795.                 
  796.                 //*************** Launchpad is horizontal                
  797.                 if(!isVertical) {
  798.                     if(!ulDrawer){//Launchpad
  799.                         WinSetWindowPos(hwnd,NULL,0,0,
  800.                                                         maxcx+(1+hasActionButtons)*icondistance-actionButtonsText*maxcx1*2,
  801.                                                         maxcy3+maxcy2+icondistance/2+2*icondistance+titlebarSize,
  802.                                                         SWP_SIZE|SWP_HIDE);
  803.                         /*WinSetWindowPos(hwnd,NULL,0,0,
  804.                             maxcx+(1+hasActionButtons)*icondistance-actionButtonsText*maxcx1*2+icondistance/2,
  805.                             maxcy3+maxcy2+icondistance/2+2*icondistance+titlebarSize-delta,
  806.                             SWP_SIZE|SWP_HIDE);
  807.                             */
  808.                     }
  809.                     else {  //Drawer
  810.                         if(WinQueryWindowPos(lpHWND,(PSWP)&lpSWP)&&swp.y<lpSWP.y){//got launchpad size and drawer is below launchpad
  811.                             //Check if small drawer fits above launchpad
  812.                             if((icondistance+maxcy+titlebarSize)<(desktopSWP.cy-(lpSWP.y+lpSWP.cy+titlebarSize)))
  813.                                 {// yes, place it above
  814.                                     WinSetWindowPos(hwnd,NULL,swp.x+(swp.cx-maxcx2-icondistance)/2,
  815.                                                                     lpSWP.y+lpSWP.cy+titlebarSize,
  816.                                                                     maxcx2+icondistance,
  817.                                                                     icondistance+maxcy+titlebarSize,
  818.                                                                     SWP_SIZE|SWP_MOVE);
  819.                                 }
  820.                             else
  821.                                 {//No, no place for drawer
  822.                                     WinSetWindowPos(hwnd,NULL,swp.x+(swp.cx-maxcx2-icondistance)/2,
  823.                                                                     lpSWP.y-(icondistance+maxcy+titlebarSize),
  824.                                                                     maxcx2+icondistance,
  825.                                                                     icondistance+maxcy+titlebarSize,
  826.                                                                     SWP_SIZE|SWP_MOVE);                        
  827.                                 }
  828.                         }
  829.                         else {//couldn't get launchpad size, using default positions
  830.                             WinSetWindowPos(hwnd,NULL,swp.x+(swp.cx-maxcx2-icondistance)/2,
  831.                                                             swp.y,
  832.                                                             maxcx2+icondistance,
  833.                                                             icondistance+maxcy+titlebarSize,
  834.                                                             SWP_SIZE|SWP_MOVE);
  835.                         }
  836.                     }
  837.                 }
  838.                 // ************** Launchpad is vertical **************
  839.                 else {
  840.                     if(!ulDrawer){//Launchpad
  841.                         WinSetWindowPos(hwnd,NULL,0,0,maxcx3+maxcx2+icondistance/2+2*icondistance,
  842.                                                         maxcy+titlebarSize+(1+hasActionButtons)*icondistance,SWP_SIZE);
  843.                         //WinSetWindowPos(hwnd,NULL,0,0,maxcx3+maxcx2+icondistance/2+2*icondistance-delta,
  844.                         //                                maxcy+titlebarSize+(1+hasActionButtons)*icondistance+icondistance/2,SWP_SIZE);
  845.                     }
  846.                     else {  //Drawer needs some position tweaking
  847.                         if(WinQueryWindowPos(lpHWND,(PSWP)&lpSWP)&&swp.x<lpSWP.x){//got launchpad size and drawer is left of launchpad
  848.                             //Check if small drawer fits to the right of launchpad
  849.                             if((icondistance+maxcx)<(desktopSWP.cx-(lpSWP.x+lpSWP.cx)))
  850.                                 {// yes, place it on the right side
  851.                                     WinSetWindowPos(hwnd,NULL,lpSWP.x+lpSWP.cx,
  852.                                                                     swp.y+(swp.cy-maxcy2-icondistance)/2,
  853.                                                                     maxcx+icondistance,
  854.                                                                     icondistance+maxcy2+titlebarSize,
  855.                                                                     SWP_SIZE|SWP_MOVE);
  856.                                 }
  857.                             else
  858.                                 {//No, no place for drawer
  859.                                     WinSetWindowPos(hwnd,NULL,lpSWP.x-(maxcx+icondistance),
  860.                                                                     swp.y+(swp.cy-maxcy2-icondistance)/2,
  861.                                                                     maxcx+icondistance,
  862.                                                                     icondistance+maxcy2+titlebarSize,
  863.                                                                     SWP_SIZE|SWP_MOVE);                        
  864.                                 }
  865.                         }
  866.                         else {//couldn't get launchpad size, using default positions
  867.                             WinSetWindowPos(hwnd,NULL,
  868.                                                             swp.x,
  869.                                                             swp.y+(swp.cy-maxcy2-icondistance)/2,
  870.                                                             icondistance+maxcx,
  871.                                                             maxcy2+icondistance+titlebarSize,SWP_SIZE|SWP_MOVE);
  872.                         }
  873.                     }    
  874.                 }
  875.             }            
  876.             /****************************************
  877.              *                     
  878.              * Size the buttons and change the window procedure
  879.              *
  880.              ****************************************/
  881. #ifdef debug
  882.             //    showMessage(hwnd,"Size buttons and change window procedures");
  883. #endif
  884.             henum=WinBeginEnumWindows(hwnd);// We will query all child windows
  885.             while((hwndNext=WinGetNextWindow(henum))!=NULLHANDLE) {
  886.                 // Query the current position of the buttons
  887.                 WinQueryWindowPos(hwndNext,(PSWP)&swp);
  888.                 // Query the window ID
  889.                 id=WinQueryWindowUShort(hwndNext,QWS_ID);
  890.                 if(id>=300)//ID 3XX Drawer-Icons
  891.                     {
  892.                         if(smallSizeEnabled) {
  893.                             if(id<400) {
  894.                                 if(!noDrawers) {
  895.                                     //**************** Launchpad is horizontal *************    
  896.                                     if(!isVertical) {
  897.                                         // Set new position and size of the icons
  898.                                         WinSetWindowPos(hwndNext,NULL,
  899.                                                                         4*(maxcx1+1)+(id-300)*(maxcx2+icondistance)
  900.                                                                         -actionButtonsText*maxcx1*2
  901.                                                                         +(1+hasActionButtons)*icondistance,
  902.                                                                         maxcy2+icondistance/2+icondistance,
  903.                                                                         swp.cx-delta,swp.cy-delta,SWP_MOVE|SWP_SIZE);
  904.                                         /*        WinSetWindowPos(hwndNext,NULL,
  905.                                                     4*(maxcx1+1)+(id-300)*(maxcx2+icondistance/2)
  906.                                                     -actionButtonsText*maxcx1*2
  907.                                                     +(1+hasActionButtons)*icondistance,
  908.                                                     maxcy2+icondistance/2+icondistance,
  909.                                                     swp.cx-delta,swp.cy-delta,SWP_MOVE|SWP_SIZE);*/
  910.                                     }
  911.                                 //*************** Launchpad is vertical *****************
  912.                                 else{
  913.                                     //  Set new position and size of the icons
  914.                                     WinSetWindowPos(hwndNext,NULL,maxcx2+icondistance/2+icondistance,
  915.                                         4*(maxcy1+1)+(id-300)*(icondistance+maxcy2)
  916.                                         +(1+hasActionButtons)*icondistance,
  917.                                         swp.cx,swp.cy-delta,SWP_MOVE|SWP_SIZE);
  918.                                     /*                                    WinSetWindowPos(hwndNext,NULL,maxcx2+icondistance/2+icondistance,
  919.                                                                             4*(maxcy1+1)+(id-300)*(icondistance/2+maxcy2)
  920.                                                                             +(1+hasActionButtons)*icondistance,
  921.                                                                             swp.cx,swp.cy-delta,SWP_MOVE|SWP_SIZE);*/
  922.                                 }    // else
  923.                                 } //if(!NODRAWERS)
  924.                             else {
  925.                                 WinSetWindowPos(hwndNext,NULL,0,0,0,0,SWP_HIDE);
  926.                                 
  927.                             } // else if(!NODRAWERS)
  928.                             }// endif(id<400)
  929.                         }// endif(smallSizeEnabled)
  930.                     }
  931.             else //id>=300
  932.                 {
  933.                     if(id>=200)//ID 2XX Progicons auf der Klickstartleiste
  934.                         {
  935.                             // We subclass the window so we can track mouse movements
  936.                             // over the buttons and can build a bubble help if the mouse
  937.                             // resides over a button.
  938.                             // WinSubclassWindow() returns the old procedure and sets our procedure
  939.                             // as the default.
  940.                             // If the returned procedure is the same as our own we have already subclassed
  941.                             // the window otherwise we save the original procedure pointer.
  942.                             tempProc=WinSubclassWindow(hwndNext,newButtonProc);                        
  943.                             if(tempProc!=(*newButtonProc)){
  944.                                 oldButtonProc2=tempProc; 
  945.                             }
  946.                             // Now we need the class object to get a WPObject* from the HOBJECT
  947.                             
  948. #ifdef debug
  949.                             //        showMessage(hwnd,"Inside enumeration loop...ProgIcons");
  950. #endif
  951.                             wpObject=M_ob.wpclsQueryObject(hobject[id-200]);
  952.                             if(wpObject)
  953.                                 objectTitle=wpObject->wpQueryTitle();
  954.                             else
  955.                                 objectTitle="";
  956. #ifdef debug
  957.                             //        showMessage(hwnd,"Inside enumeration loop...ProgIcons after wpQueryTitle()");
  958. #endif
  959.                             
  960.                             // Set the object title as the window title. In our button proc we
  961.                             // take this window title and display it in the help window.
  962.                             // The original launchpad only sets the window title in this way if
  963.                             // you've switched on text on the launchpad.
  964.                             WinSetWindowText(hwndNext,objectTitle);
  965.                             
  966. #ifdef debug
  967.                             //        showMessage(hwnd,"ID >=200, Program-Icons");
  968. #endif
  969.                             if(smallSizeEnabled)
  970.                                 WinSetWindowBits(hwndNext,QWL_STYLE,BS_NOPOINTERFOCUS,BS_NOPOINTERFOCUS);
  971.                             if(!ulDrawer)//Launchpad
  972.                                 {
  973.                                     if(smallSizeEnabled) {
  974.                                         //************ Horizontal
  975.                                         if(!isVertical) 
  976.                                             // Set new position and size of the icons
  977.                                             WinSetWindowPos(hwndNext,NULL,
  978.                                                                             4*(maxcx1+1)+(id-200)*(maxcx2+icondistance)
  979.                                                                             +(1+hasActionButtons)*icondistance
  980.                                                                             -actionButtonsText*maxcx1*2,
  981.                                                                             icondistance,swp.cx-delta,swp.cy-delta,
  982.                                                                             SWP_MOVE|SWP_SIZE);
  983.                                         /* WinSetWindowPos(hwndNext,NULL,
  984.                                              4*(maxcx1+1)+(id-200)*(maxcx2+icondistance/2)
  985.                                              +(1+hasActionButtons)*icondistance
  986.                                              -actionButtonsText*maxcx1*2,
  987.                                              icondistance,swp.cx-delta,swp.cy-delta,
  988.                                              SWP_MOVE|SWP_SIZE);*/
  989.                                                 
  990.                                                 
  991.                                                 //************ Vertikal
  992.                                                 else  
  993.                                                     // Set new position and size of the icons
  994.                                                     WinSetWindowPos(hwndNext,NULL,icondistance,
  995.                                                                                     4*(maxcy1+1)+(id-200)*(icondistance+maxcy2)
  996.                                                                                     +(1+hasActionButtons)*icondistance,                                
  997.                                                                                     swp.cx-delta,swp.cy-delta,SWP_MOVE|SWP_SIZE);
  998.                                         /*                WinSetWindowPos(hwndNext,NULL,icondistance,
  999.                                                             4*(maxcy1+1)+(id-200)*(icondistance/2+maxcy2)
  1000.                                                             +(1+hasActionButtons)*icondistance,                                
  1001.                                                             swp.cx-delta,swp.cy-delta,SWP_MOVE|SWP_SIZE);*/
  1002.                                                 }//endif(smallSizeEnabled)
  1003.                                 }// endif(!ulDrawer)
  1004.                             else//Launchpad-drawer
  1005.                                 {
  1006.                                     if(smallSizeEnabled) {
  1007.                                         //************ Horizontal
  1008.                                         if(!isVertical)WinSetWindowPos(hwndNext,NULL,icondistance/2,
  1009.                                                                                                      icondistance+(id-200)*(maxcy2+icondistance),
  1010.                                                                                                      swp.cx-delta,swp.cy-delta,SWP_MOVE|SWP_SIZE);
  1011.                                         //************ Vertikal
  1012.                                         else    WinSetWindowPos(hwndNext,NULL,//swp.x,
  1013.                                                                                     icondistance+(id-200)*(maxcx2+icondistance),
  1014.                                                                                     icondistance/2,swp.cx-delta,
  1015.                                                                                     swp.cy-delta,SWP_MOVE|SWP_SIZE);    
  1016.                                     }
  1017.                                 }//#endelse    Launchpad-drawer                        
  1018.                         }
  1019.                     else  //ID 1XX; shutdown, window list etc.
  1020.                         {    
  1021.                             tempProc=WinSubclassWindow(hwndNext,newButtonProc);                        
  1022.                             if(tempProc!=(*newButtonProc)){
  1023.                                 oldButtonProc2=tempProc;
  1024.                             }
  1025.                             if(smallSizeEnabled) {
  1026.                                 WinSetWindowBits(hwndNext,QWL_STYLE,BS_NOPOINTERFOCUS,BS_NOPOINTERFOCUS);
  1027.                                 //********** Launchpad is horizontal    
  1028.                                 if(!isVertical)
  1029.                                     if(actionButtonsText) {//ActionButtons with Text
  1030.                                         textDelta=id-100;
  1031.                                         textDelta2=textDelta;
  1032.                                         textDelta2/=2;
  1033.                                         textDelta&=1;
  1034.                                         WinSetWindowPos(hwndNext,NULL,
  1035.                                                                         icondistance+textDelta2*(1+maxcx1),
  1036.                                                                         //    icondistance+((icondistance/2)+maxcy1)*textDelta,
  1037.                                                                         icondistance+((icondistance/2)+maxcy1-icondistance*noDrawers*2)*textDelta,
  1038.                                                                         swp.cx,(maxcy2+maxcy3)/2,SWP_MOVE|SWP_SIZE);
  1039.                                     }
  1040.                                     else {
  1041.                                         WinSetWindowPos(hwndNext,NULL,
  1042.                                                                         icondistance+(id-100)*(1+maxcx1),
  1043.                                                                         icondistance,
  1044.                                                                         swp.cx-delta,maxcy2+maxcy3+icondistance/2-delta,SWP_MOVE|SWP_SIZE);
  1045.                                     }
  1046.                                 //******** Verikal
  1047.                                 else WinSetWindowPos(hwndNext,NULL,icondistance,
  1048.                                                                          icondistance+(id-100)*(1+swp.cy),
  1049.                                                                          maxcx2+maxcx3+icondistance/2-delta,swp.cy-delta,SWP_MOVE|SWP_SIZE);
  1050.                             }// endif(smallSizeEnabled)
  1051.                         };
  1052.                 };
  1053.             };
  1054.     succ=WinEndEnumWindows(henum);
  1055.     WinSetWindowPos(hwnd,NULL,0,0,0,0,SWP_SHOW);  // Show the launchpad
  1056.         };        
  1057.     }; // endif strcmp()
  1058. //Make Launchpad visible
  1059.     ((somTD_WPLaunchPad_wpSetDrawerHWND)
  1060.      somParentNumResolve(__ClassObject->somGetPClsMtabs(),
  1061.                                              1,
  1062.                                              __ClassObject->
  1063.                                              somGetMethodToken(somIdFromString
  1064.                                                                                  ("wpSetDrawerHWND")))
  1065.      )(this,ulDrawer,hwndDrawer);            
  1066.     return;
  1067. }
  1068.  
  1069. /********************************************************/
  1070. /* New class function which inserts the bubblehelp page */
  1071. /* into the settings notebook                           */
  1072. /********************************************************/
  1073. ULONG WPLnchCW::AddBubblehelpPage(HWND hwndNotebook)
  1074. {
  1075.     PAGEINFO pageinfo;
  1076.     char pageName[50];
  1077.     
  1078.     //Clear the pageinfo structure
  1079.     memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
  1080.     //Fill the pageinfo structure
  1081.     pageinfo.cb = sizeof(PAGEINFO);
  1082.     pageinfo.hwndPage = NULLHANDLE;
  1083.     //The page has got a major tab and status text
  1084.     pageinfo.usPageStyleFlags = BKA_MAJOR|BKA_STATUSTEXTON;
  1085.     pageinfo.usPageInsertFlags = BKA_FIRST;
  1086.     //We want page numbers
  1087.     pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
  1088.     //The dialog procedure for this page
  1089.     pageinfo.pfnwp = BubblehelpDlgProc;
  1090.     //The resource is in the class file
  1091.     pageinfo.resid = QueryModuleHandle();
  1092.     pageinfo.dlgid = ID_BUBBLEENABLE;
  1093.     pageinfo.pszName = pageName;        
  1094.     //We need a pointer to our WPS-object in the dialog procedure
  1095.     //to call class functions
  1096.     pageinfo.pCreateParams = this;
  1097.     //The ID of the help panel for this page
  1098.     pageinfo.idDefaultHelpPanel = 001;
  1099.     //Tell the WPS the help library name
  1100.     pageinfo.pszHelpLibraryName = "bubblepd.hlp";
  1101.     //Load the name for the notebookpage
  1102.     WinLoadString(WinQueryAnchorBlock(hwndNotebook),QueryModuleHandle(),
  1103.                                 ID_BUBBLESTRING,sizeof(pageName),pageName);
  1104.     
  1105.     //Insert the page into the settings notebook
  1106.     return wpInsertSettingsPage(hwndNotebook,&pageinfo);
  1107. }
  1108.  
  1109. /********************************************************/
  1110. /* New class function which inserts the colour and font */
  1111. /* page into the settings notebook                      */
  1112. /********************************************************/
  1113. ULONG WPLnchCW::AddColorchangePage(HWND hwndNotebook)
  1114. {
  1115.     PAGEINFO pageinfo;
  1116.     
  1117.     //Clear the pageinfo structure
  1118.     memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
  1119.     //Fill the pageinfo structure
  1120.     pageinfo.cb = sizeof(PAGEINFO);
  1121.     pageinfo.hwndPage = NULLHANDLE;
  1122.     pageinfo.usPageStyleFlags = BKA_STATUSTEXTON;
  1123.     pageinfo.usPageInsertFlags = BKA_FIRST;
  1124.     //We want page numbers
  1125.     pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;    
  1126.     //The dialog procedure for this page
  1127.     pageinfo.pfnwp = ColorchangeDlgProc;
  1128.     //The resource is in the class file
  1129.     pageinfo.resid = QueryModuleHandle();
  1130.     pageinfo.dlgid = ID_COLORCHANGE;
  1131.     //We need a pointer to our WPS-object in the dialog procedure
  1132.     //to call class functions
  1133.     pageinfo.pCreateParams = this;
  1134.     //The ID of the help panel for this page
  1135.     pageinfo.idDefaultHelpPanel = 202;
  1136.     //Tell the WPS the help library name
  1137.     pageinfo.pszHelpLibraryName = "bubblepd.hlp";
  1138.     //We have no major tab so we need no name
  1139.     
  1140.     //Insert the page into the settings notebook
  1141.     return wpInsertSettingsPage(hwndNotebook,&pageinfo);
  1142. }
  1143.  
  1144. /********************************************************/
  1145. /* New class function which inserts the size option     */
  1146. /* page into the settings notebook                      */
  1147. /********************************************************/
  1148. ULONG WPLnchCW::AddOptionPage(HWND hwndNotebook)
  1149. {
  1150.     PAGEINFO pageinfo;
  1151.     
  1152.     //Clear the pageinfo structure
  1153.     memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
  1154.     //Fill the pageinfo structure
  1155.     pageinfo.cb = sizeof(PAGEINFO);
  1156.     pageinfo.hwndPage = NULLHANDLE;
  1157.     pageinfo.usPageStyleFlags = BKA_STATUSTEXTON;
  1158.     pageinfo.usPageInsertFlags = BKA_FIRST;
  1159.     //We want page numbers
  1160.     pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
  1161.     //The dialog procedure for this page
  1162.     pageinfo.pfnwp = OptionDlgProc;
  1163.     //The resource is in the class file
  1164.     pageinfo.resid = QueryModuleHandle();
  1165.     pageinfo.dlgid = ID_OPTIONPAGE;
  1166.     //We need a pointer to our WPS-object in the dialog procedure
  1167.     //to call class functions
  1168.     pageinfo.pCreateParams = this;
  1169.     //The ID of the help panel for this page
  1170.     pageinfo.idDefaultHelpPanel = 200;
  1171.     //Tell the WPS the help library name
  1172.     pageinfo.pszHelpLibraryName = "bubblepd.hlp";
  1173.     //We have no major tab so we need no name
  1174.  
  1175.     //Insert the page into the settings notebook
  1176.     return wpInsertSettingsPage(hwndNotebook,&pageinfo);
  1177. }
  1178.  
  1179. BOOL WPLnchCW::wpAddLaunchPadPage2(HWND hwndNotebook)
  1180. {
  1181.     return(AddOptionPage(hwndNotebook)&&
  1182.                  ((somTD_WPLaunchPad_wpAddLaunchPadPage2)
  1183.                     somParentNumResolve(__ClassObject->somGetPClsMtabs(),
  1184.                                                             1,
  1185.                                                             __ClassObject->
  1186.                                                             somGetMethodToken(somIdFromString
  1187.                                                                                                 ("wpAddLaunchPadPage2")))
  1188.                     )(this,hwndNotebook));        
  1189. }
  1190.  
  1191.  
  1192. BOOL WPLnchCW::wpAddSettingsPages(HWND hwndNotebook)
  1193. {
  1194.     ULONG   ulPageIdColor;
  1195.     ULONG   ulPageIdBubble;
  1196.     ULONG   ulPageIdUninstall;
  1197.  
  1198.     //The Warpcenter is a Child of WPLaunchPad, so it inherits all the features.
  1199.     // We substitute WPLaunchPad with WPLnchCW, so the Warpcenter inherits the 
  1200.     // Bubblehelp pages but it doesn't need them cause it has its own bubblehelp.
  1201.     
  1202.     // Check if it's the Warpcenter (classname is 'SmartCenter')
  1203.     // somGetClassName() returns our class name
  1204.     if(strcmp(somGetClassName(),"SmartCenter")) {// 0 if equal
  1205.         //Insert our settings pages
  1206.         ulPageIdColor=AddColorchangePage(hwndNotebook);
  1207.         ulPageIdBubble=AddBubblehelpPage(hwndNotebook);
  1208.         return(ulPageIdColor 
  1209.                      && ulPageIdBubble
  1210.                      //call parent
  1211.                      &&((somTD_WPObject_wpAddSettingsPages)
  1212.                             somParentNumResolve(__ClassObject->somGetPClsMtabs(),
  1213.                                                                     1,
  1214.                                                                     __ClassObject->
  1215.                                                                     somGetMethodToken(somIdFromString
  1216.                                                                                                         ("wpAddSettingsPages")))
  1217.                             )(this,hwndNotebook));
  1218.         
  1219.     }
  1220.     else // If SmartCenter only call parent
  1221.     return    ((somTD_WPObject_wpAddSettingsPages)
  1222.                      somParentNumResolve(__ClassObject->somGetPClsMtabs(),
  1223.                                                              1,
  1224.                                                              __ClassObject->
  1225.                                                              somGetMethodToken(somIdFromString
  1226.                                                                                                  ("wpAddSettingsPages")))
  1227.                      )(this,hwndNotebook);
  1228.                      
  1229.     // Durch obige Konstruktion wird die Elternmethode des direkten Vorgängers aufgerufen,
  1230.     // und nicht die ursprüngliche von WPLaunchPad, falls WPLaunchPad replaced wurde.
  1231.     // Durch diesen Aufruf gehen eventuelle Erweiterungen durch Vererbung verloren:
  1232.     //            < return WPLaunchPad::wpMenuItemSelected(hwndFrame, ulMenuId); >
  1233.     // Dieser Aufruf macht Ergänzungen in wpobject.hh erforderlich!!! Wird durch ein VAC-Fixpack vielleicht später
  1234.     //erledigt
  1235. }
  1236. BOOL WPLnchCW::wpSaveState()
  1237. {
  1238. #ifdef debug
  1239.                                 char buf[260];
  1240.                                 sprintf(buf,"wpSaveState()  ulOpenDrawers: %x",ulOpenDrawers);
  1241.                                 showMessage(HWND_DESKTOP,buf);
  1242. #endif
  1243.     wpSaveLong("WPLnchCW",ID_NODRAWERS,noDrawers);
  1244.     wpSaveLong("WPLnchCW",ID_SMALLSIZEENABLED,smallSizeEnabled);
  1245.     wpSaveLong("WPLnchCW",ID_DELAYVALUE,delayValue);
  1246.     wpSaveLong("WPLnchCW",ID_ICONDISTANCE,icondistance);
  1247.     wpSaveLong("WPLnchCW",ID_BUBBLEENABLED,bubbleEnabled);
  1248.     wpSaveLong("WPLnchCW",ID_OPENDRAWERBITS,ulOpenDrawers);
  1249.     wpSaveData("WPLnchCW",ID_BACKGROUND,(PBYTE)&background,sizeof(RGB));
  1250.     wpSaveData("WPLnchCW",ID_FOREGROUND,(PBYTE)&foreground,sizeof(RGB));
  1251.     wpSaveString("WPLnchCW",ID_FONT,(PBYTE)&fontName);
  1252.  
  1253.     return((somTD_WPObject_wpSaveState)
  1254.                  somParentNumResolve(__ClassObject->somGetPClsMtabs(),
  1255.                                                          1,
  1256.                                                          __ClassObject->
  1257.                                                          somGetMethodToken(somIdFromString
  1258.                                                                                              ("wpSaveState")))                     
  1259.                  )(this);
  1260. }
  1261.  
  1262.  
  1263. BOOL WPLnchCW::wpRestoreState(ULONG ulReserved)
  1264. {
  1265.     BOOL  rc;
  1266.     ULONG dataSize=sizeof(USHORT);
  1267.     
  1268.     /* Read values from instance data                                         */
  1269.     /* If we start the BubblePad for the first time there're no values in the */
  1270.     /* instance data. In this case use defaults.                              */
  1271.  
  1272.     if(!wpRestoreLong("WPLnchCW",ID_NODRAWERS,&noDrawers))
  1273.         noDrawers=0;
  1274.     if(!wpRestoreLong("WPLnchCW",ID_SMALLSIZEENABLED,&smallSizeEnabled))
  1275.         smallSizeEnabled=1;
  1276.     if(!wpRestoreLong("WPLnchCW",ID_DELAYVALUE,&delayValue))
  1277.         delayValue=250;
  1278.     if(!wpRestoreLong("WPLnchCW",ID_ICONDISTANCE,&icondistance))
  1279.         icondistance=4;
  1280.     if(!wpRestoreLong("WPLnchCW",ID_BUBBLEENABLED,&bubbleEnabled))
  1281.         bubbleEnabled=1;
  1282.     if(!wpRestoreLong("WPLnchCW",ID_OPENDRAWERBITS,&ulOpenDrawers))
  1283.         ulOpenDrawers=(ULONG)0;
  1284.     dataSize=sizeof(RGB);
  1285.     if(!wpRestoreData("WPLnchCW",ID_BACKGROUND,(PBYTE)&background,&dataSize)) {
  1286.         background.bBlue=180;
  1287.         background.bGreen=255;
  1288.         background.bRed=255;
  1289.     }
  1290.     dataSize=sizeof(RGB);
  1291.     if(!wpRestoreData("WPLnchCW",ID_FOREGROUND,(PBYTE)&foreground,&dataSize)) {
  1292.         foreground.bRed=0;
  1293.         foreground.bGreen=0;
  1294.         foreground.bBlue=0;
  1295.     }
  1296.     memset(fontName,0,sizeof(fontName));    
  1297.     dataSize=sizeof(fontName);
  1298.     if(!wpRestoreString("WPLnchCW",ID_FONT,(PBYTE)&fontName,&dataSize))
  1299.         memcpy(&fontName,"8.Helv",sizeof("8.Helv"));
  1300.     
  1301.     return((somTD_WPObject_wpRestoreState)
  1302.                  somParentNumResolve(__ClassObject->somGetPClsMtabs(),
  1303.                                                          1,
  1304.                                                          __ClassObject->
  1305.                                                          somGetMethodToken(somIdFromString
  1306.                                                                                              ("wpRestoreState")))                     
  1307.                  )(this,ulReserved);
  1308.     
  1309.     // Durch obige Konstruktion wird die direkte Elternmethode aufgerufen,
  1310.     // und nicht die ursprüngliche von WPLaunchPad, falls WPLaunchPad replaced wurde.
  1311.     // Durch diesen Aufruf gehen eventuelle Erweiterungen durch Vererbung verloren:
  1312.     //    
  1313. }
  1314.  
  1315. HWND  WPLnchCW::wpOpen(HWND hwndCnr,ULONG ulView,ULONG ulParam)
  1316. {
  1317.     HWND rcHWND;
  1318.     HWND hwndDrawerButton;
  1319.     ULONG ulTemp;
  1320.     int a;
  1321.     
  1322.     rcHWND=((somTD_WPObject_wpOpen)
  1323.                  somParentNumResolve(__ClassObject->somGetPClsMtabs(),
  1324.                                                          1,
  1325.                                                          __ClassObject->
  1326.                                                          somGetMethodToken(somIdFromString
  1327.                                                                                              ("wpOpen")))                     
  1328.                  )(this,hwndCnr, ulView, ulParam);        
  1329.  
  1330.     if(ulView==OPEN_SETTINGS)    return rcHWND;
  1331.  
  1332.     // The parent function opened the launchpad. We look which drawers were open on last shutdown and
  1333.     // reopen them now.
  1334.     ulTemp=ulOpenDrawers;
  1335. #ifdef debug
  1336.                                 char buf[260];
  1337.                                 sprintf(buf,"ulOpenDrawers:  %x",ulTemp);                                
  1338.                                 showMessage(HWND_DESKTOP,buf);
  1339. #endif
  1340.  
  1341.         for(a=0;a<32;a++) {
  1342.         if(ulTemp&1) {
  1343.             hwndDrawerButton=WinWindowFromID(rcHWND,300+a);
  1344.             if(hwndDrawerButton)
  1345.                 WinPostMsg(hwndDrawerButton,BM_CLICK,MPFROMSHORT(FALSE),MPFROMSHORT(0));
  1346.         }
  1347.         ulTemp=ulTemp>>1;
  1348.     }
  1349.     return rcHWND;
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.