home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool_main.zip / ool / source / xevent.cpp < prev    next >
C/C++ Source or Header  |  1998-04-05  |  31KB  |  1,071 lines

  1. #include "XCntrevn.h"
  2. #include "XDragEvn.h"
  3. #include "XWindow.h"
  4. #include "XPoint.h"
  5. #include "XBitmap.h"
  6. #include "XDragItm.h"
  7. #include "XMousevn.h"
  8. #include "XCntEvnt.h"
  9. #include "XKeyEvnt.h"
  10. #include "XContObj.h"
  11. #include "XcnDrEvn.h"
  12. #include "XCnEdEvn.h"
  13. #include "xString.h"
  14. #include "XContCol.h"
  15. #include "XItmDEvn.h"
  16. #include "XBackEvn.h "
  17. #include "xnbevent.h"
  18.  
  19.  
  20. #include <stdlib.h>
  21.  
  22. #ifdef OOL_FOR_OS2_X86
  23. #define GBN_BUTTONUP      0x0524
  24. #define GBN_BUTTONDOWN    0x0525
  25. #endif
  26.  
  27.  
  28. /*@
  29. @class XEvent
  30. @parent XObject
  31. @type overview
  32. @symbol _
  33. */
  34.  
  35.  
  36. /*@ XContainerEvent::GetObject(void)
  37. @remarks Returns the object which posted the event
  38. @returns       XContainerObject * the Object (can be NULL)
  39. */
  40. XContainerObject * XContainerEvent::GetObject(void)
  41. {
  42.    if (core)
  43.    {
  44.       RECORDCORE *pr = (RECORDCORE *) ((PBYTE) core + sizeof(RECORDCORE));
  45.       XContainerObject *obj;
  46.  
  47.       memcpy(&obj, pr, 4);
  48.       return obj;
  49.    }
  50.    else
  51.       return NULL;
  52. }
  53.  
  54.  
  55. /*@
  56. @class XNoteBookEvent
  57. @parent XEvent
  58. @type overview
  59. @symbol _
  60. @remarks XNoteBookEvent is posted for event in a XNoteBook. Possible event-id∩s are:
  61. <UL>
  62. <LI>XNOTEBOOK_PAGESELECTED
  63. <LI>XNOTEBOOK_PAGESELECTEDPENDING
  64. <LI>XNOTEBOOK_HELP
  65. <LI>XNOTEBOOK_PAGEDELETED
  66. <LI>XNOTEBOOK_NEWPAGESIZE
  67. </UL>
  68. Except of the case XNOTEBOOK_NEWPAGESIZE you can retrieve the depending notebook-page
  69. by calling XNoteBookPage::GetPage().
  70. @new
  71. */
  72.  
  73. /*@ XNoteBookEvent::GetPage()
  74. @remarks Retrive the related page
  75. @returns XNoteBookPage* pointer to the page (can be NULL)
  76. */
  77.  
  78. XNoteBookEvent :: XNoteBookEvent( const XWindow * w, const void * mp1, const void * mp2):XControlEvent( (XWindow*) w, mp1, mp2)
  79. {
  80.    eventID = SHORT2FROMMP(mp1);
  81.    HWND page = 0;
  82.    switch( eventID )
  83.    {
  84.       case XNOTEBOOK_PAGESELECTED:
  85.       case XNOTEBOOK_PAGESELECTEDPENDING:
  86.          {
  87.             PAGESELECTNOTIFY * notify = (PAGESELECTNOTIFY *) mp2;
  88.             ULONG pageID = (ULONG) notify->ulPageIdNew;
  89.             page = (HWND) WinSendMsg( window->GetHandle(), BKM_QUERYPAGEWINDOWHWND, (MPARAM) pageID, 0);
  90.          }
  91.          break;
  92.       case XNOTEBOOK_HELP:
  93.          page = (HWND) WinSendMsg( window->GetHandle(), BKM_QUERYPAGEWINDOWHWND, (MPARAM) mp2, 0);
  94.          break;
  95.       case XNOTEBOOK_PAGEDELETED:
  96.          {
  97.             DELETENOTIFY * notify = (DELETENOTIFY*) mp2;
  98.             page = notify->hwndPage;
  99.          }
  100.          break;
  101.       case XNOTEBOOK_NEWPAGESIZE:
  102.          break;
  103.    }
  104.    bookPage = (XNoteBookPage*) WinQueryWindowULong( page, QWL_USER);
  105. }
  106.  
  107.  
  108. XContainerEvent :: XContainerEvent(const XContainerControl * w, const MPARAM mp1, const MPARAM mp2):XControlEvent(SHORT2FROMMP(mp1))
  109. {
  110.    core = NULL;
  111.  
  112.    if (mp1)
  113.    {
  114.       windowID = SHORT1FROMMP(mp1);
  115.       window = (XWindow *) w;
  116.    }
  117.  
  118.    if (!window)
  119.       return;
  120.  
  121.    eventID = SHORT2FROMMP(mp1);
  122.  
  123.    switch (eventID)
  124.    {
  125.    case CN_EMPHASIS:
  126.       core = ((PNOTIFYRECORDEMPHASIS) mp2)->pRecord;
  127.       break;
  128.    case CN_ENTER:
  129.       core = ((NOTIFYRECORDENTER *) mp2)->pRecord;
  130.       break;
  131.    case CN_INITDRAG:
  132.       core = ((CNRDRAGINIT *) mp2)->pRecord;
  133.       break;
  134.    default:
  135.       core = (PRECORDCORE) mp2;
  136.    }
  137. }
  138.  
  139.  
  140. XContainerEditEvent :: XContainerEditEvent(const XWindow * w, const MPARAM mp1, const MPARAM mp2):XContainerEvent((XContainerControl *) w, mp1, mp2)
  141. {
  142.    cnEdit = (CNREDITDATA *) mp2;
  143.    core = cnEdit->pRecord;
  144. }
  145.  
  146.  
  147.  
  148. /*@ XContainerEditEvent::GetObject(void)
  149. @remarks Returns a pointer to the object which is edited;
  150. @returns XContainerObject * theObject
  151. */
  152. XContainerObject * XContainerEditEvent::GetObject(void)
  153. {
  154.    RECORDCORE *pr = (RECORDCORE *) ((PBYTE) cnEdit->pRecord + sizeof(RECORDCORE));
  155.    XContainerObject *obj;
  156.  
  157.    memcpy(&obj, pr, 4);
  158.    return obj;
  159. }
  160.  
  161.  
  162. XContainerDragEvent :: XContainerDragEvent(const XWindow * w, const MPARAM mp1, const MPARAM mp2):XContainerEvent((XContainerControl *) w, mp1, mp2)
  163. {
  164.    printer = NULL;
  165.    if (mp2)
  166.    {
  167.       core = ((CNRDRAGINFO *) mp2)->pRecord;
  168.       dragInfo = ((CNRDRAGINFO *) mp2)->pDragInfo;
  169.    }
  170. }
  171.  
  172.  
  173. BOOL XContainerDragEvent::GetDropPos(XPoint * p)
  174. {
  175.    if ((!(dragInfo)) || eventID != DRG_DROP)
  176.       return FALSE;
  177.    p->Set(dragInfo->xDrop, dragInfo->yDrop);
  178.    return TRUE;
  179. }
  180.  
  181.  
  182. XContainerDragEvent :: ~XContainerDragEvent()
  183. {
  184.    if (dragInfo)
  185.       DrgFreeDraginfo(dragInfo);
  186.    dragInfo = NULL;
  187. }
  188.  
  189.  
  190. BOOL XContainerDragEvent::GetDragItem(XDragItem * itm, const SHORT index)
  191. {
  192.    if (!(dragInfo))
  193.       return FALSE;
  194.    if (index > dragInfo->cditem)
  195.       return FALSE;
  196.  
  197.    DRAGITEM *pItem = DrgQueryDragitemPtr(dragInfo, index);
  198.  
  199.    itm->item = pItem;
  200.    return TRUE;
  201. }
  202.  
  203.  
  204. XControlEvent :: XControlEvent(XWindow * w, const void *mp1, const void *mp2)
  205. {
  206.    windowID = SHORT1FROMMP(mp1);
  207.    window = w->GetWindow(windowID);
  208.    if (!window)
  209.       return;
  210.  
  211.    char str[5];
  212.  
  213.    WinQueryClassName(window->GetHandle(), 5, (PCH) str);
  214.    str[0] = ' ';
  215.    SHORT type = atol(str);
  216.  
  217.    switch (type)
  218.    {
  219.    case 2:               // Combo
  220.       switch (SHORT2FROMMP(mp1))
  221.       {
  222.       case CBN_LBSELECT:
  223.          eventID = WIN_SELECTED;
  224.          break;
  225.       case CBN_ENTER:
  226.          eventID = WIN_ENTER;
  227.          break;
  228.       case CBN_LBSCROLL:
  229.          eventID = WIN_VSCROLL;
  230.          break;
  231.       case CBN_EFSCROLL:
  232.          eventID = WIN_HSCROLL;
  233.          break;
  234.       case CBN_SHOWLIST:
  235.          eventID = WIN_SHOWLIST;
  236.          break;
  237.       case CBN_EFCHANGE:
  238.          eventID = WIN_CHANGED;
  239.          break;
  240.       }
  241.       break;
  242.    case 3:               // Button
  243.       if (SHORT2FROMMP(mp1) == BN_CLICKED)
  244.          eventID = WIN_CHANGED;
  245.       break;
  246.    case 6:               // Entry
  247.       switch (SHORT2FROMMP(mp1))
  248.       {
  249.       case EN_CHANGE:
  250.          eventID = WIN_CHANGED;
  251.          break;
  252.       case EN_SCROLL:
  253.          eventID = WIN_HSCROLL;
  254.          break;
  255.       case EN_SETFOCUS:
  256.          eventID = WIN_SETFOCUS;
  257.          break;
  258.       case EN_KILLFOCUS:
  259.          eventID = WIN_KILLFOCUS;
  260.          break;
  261.       }
  262.       break;
  263.    case 7:               // Listbox
  264.       switch (SHORT2FROMMP(mp1))
  265.       {
  266.       case LN_SELECT:
  267.          eventID = WIN_SELECTED;
  268.          break;
  269.       case LN_ENTER:
  270.          eventID = WIN_ENTER;
  271.          break;
  272.       case LN_SCROLL:
  273.          eventID = WIN_HSCROLL;
  274.          break;
  275.       case LN_SETFOCUS:
  276.          eventID = WIN_SETFOCUS;
  277.          break;
  278.       case LN_KILLFOCUS:
  279.          eventID = WIN_KILLFOCUS;
  280.          break;
  281.       }
  282.       break;
  283.    case 10:               // MLE
  284.       switch (SHORT2FROMMP(mp1))
  285.       {
  286.       case MLN_CHANGE:
  287.          eventID = WIN_CHANGED;
  288.          break;
  289.       case MLN_VSCROLL:
  290.          eventID = WIN_VSCROLL;
  291.          break;
  292.       case MLN_HSCROLL:
  293.          eventID = WIN_HSCROLL;
  294.          break;
  295.       case MLN_SETFOCUS:
  296.          eventID = WIN_SETFOCUS;
  297.          break;
  298.       case MLN_KILLFOCUS:
  299.          eventID = WIN_KILLFOCUS;
  300.          break;
  301.       }
  302.       break;
  303.    case 32:               // SpinButton
  304.       switch (SHORT2FROMMP(mp1))
  305.       {
  306.       case SPBN_CHANGE:
  307.          eventID = WIN_CHANGED;
  308.          break;
  309.       case SPBN_SETFOCUS:
  310.          eventID = WIN_SETFOCUS;
  311.          break;
  312.       case SPBN_KILLFOCUS:
  313.          eventID = WIN_KILLFOCUS;
  314.          break;
  315.       case SPBN_UPARROW:
  316.          eventID = WIN_UPARROW;
  317.          break;
  318.       case SPBN_DOWNARROW:
  319.          eventID = WIN_DOWNARROW;
  320.          break;
  321.       case SPBN_ENDSPIN:
  322.          eventID = WIN_ENDTRACK;
  323.          break;
  324.       }
  325.       break;
  326.    case 37:
  327.       switch (SHORT2FROMMP(mp1))
  328.       {
  329.       case CN_KILLFOCUS:
  330.          eventID = WIN_KILLFOCUS;
  331.          break;
  332.       case CN_SETFOCUS:
  333.          eventID = WIN_SETFOCUS;
  334.          break;
  335.       }
  336.       break;
  337.    case 38:               // Slider
  338.       switch (SHORT2FROMMP(mp1))
  339.       {
  340.       case SLN_CHANGE:
  341.          eventID = WIN_CHANGED;
  342.          break;
  343.       case SLN_SETFOCUS:
  344.          eventID = WIN_SETFOCUS;
  345.          break;
  346.       case SLN_KILLFOCUS:
  347.          eventID = WIN_KILLFOCUS;
  348.          break;
  349.       case SLN_SLIDERTRACK:
  350.          eventID = WIN_TRACK;
  351.          break;
  352.       }
  353.       break;
  354.    case 39:               // Valueset
  355.       switch (SHORT2FROMMP(mp1))
  356.       {
  357.       case VN_SELECT:
  358.          eventID = WIN_SELECTED;
  359.          break;
  360.       case VN_ENTER:
  361.          eventID = WIN_ENTER;
  362.          break;
  363.       case VN_SETFOCUS:
  364.          eventID = WIN_SETFOCUS;
  365.          break;
  366.       case VN_KILLFOCUS:
  367.          eventID = WIN_KILLFOCUS;
  368.          break;
  369.       }
  370.       break;
  371.    case 64:               // GraphicButton
  372.       switch (SHORT2FROMMP(mp1))
  373.       {
  374.       case GBN_BUTTONDOWN:
  375.       case GBN_BUTTONUP:
  376.          eventID = WIN_CHANGED;
  377.          break;
  378.       }
  379.       break;
  380.    case 65:               // CircularSlider
  381.       switch (SHORT2FROMMP(mp1))
  382.       {
  383.       case CSN_CHANGED:
  384.          eventID = WIN_CHANGED;
  385.          break;
  386.       case CSN_SETFOCUS:
  387.          {
  388.             BOOL e = (BOOL) mp2;
  389.  
  390.             if (e)
  391.                eventID = WIN_SETFOCUS;
  392.             else
  393.                eventID = WIN_KILLFOCUS;
  394.          }
  395.          break;
  396.       case CSN_TRACKING:
  397.          eventID = WIN_TRACK;
  398.          break;
  399.       }
  400.    }
  401.    window->DoControl(this);
  402. }
  403.  
  404.  
  405. /*@
  406. @class XDragEvent
  407. @parent XEvent
  408. @type overview
  409. @symbol _
  410. @remarks Drag/drop events generate a XDragEvent, you catch them with XDragHandler.
  411. If drag-events should be cought in a container-control use XContainerDragEvent / XContainerHandler.
  412. */
  413.  
  414.  
  415. /*@ XDragEvent::SetAcceptMode()
  416. @remarks Set the operation supported by the application which receives
  417. the drag-event
  418. @parameters    SHORT accept              the opperation, possible values are
  419.                                           <t '°' c=2>
  420.                                              °DRG_DROP       °accept the items
  421.                                              °DRG_NODROP     °dont accept the items in this case
  422.                                              °DRG_NEVERDROP  °never accept the items
  423.                                           </t>
  424. */
  425.  
  426.  
  427. /*@ XDragEvent::SetOperation()
  428. @remarks Set the operation supported by the application which generates
  429. the drag-event
  430. @parameters    SHORT operation           the opperation, possible values are
  431.                                           <t '°' c=2>
  432.                                              °DRG_COPY   °copy the items
  433.                                              °DRG_MOVE   °move the items
  434.                                              °DRG_LINK   °link the items
  435.                                           </t>
  436. */
  437.  
  438.  
  439. XDragEvent :: ~XDragEvent()
  440. {
  441.    if (dragInfo)
  442.       DrgFreeDraginfo(dragInfo);
  443.    dragInfo = NULL;
  444. }
  445.  
  446.  
  447. XDragEvent :: XDragEvent(const LONG event, const void *v)
  448. {
  449.    printer = NULL;
  450.    switch (event)
  451.    {
  452.    case DM_DROP:
  453.       eventID = DRG_DROPPED;
  454.       break;
  455.    case DM_DRAGOVER:
  456.       eventID = DRG_DRAGOVER;
  457.       break;
  458.    case DM_DISCARDOBJECT:
  459.       eventID = DRG_DISCARDOBJECT;
  460.       break;
  461.    case DM_ENDCONVERSATION:
  462.       eventID = DRG_ENDCONVERSATION;
  463.       break;
  464.    }
  465.  
  466.    dragInfo = NULL;
  467.    DRAGINFO *info = (DRAGINFO *) v;
  468.  
  469.    if (DrgAccessDraginfo(info))
  470.       dragInfo = info;
  471.    accept = DRG_NODROP;
  472.    operation = 0;
  473. }
  474.  
  475.  
  476. /*@ XDragEvent::GetDropPos()
  477. @remarks Query the position where the objects were dropped
  478. @parameters    XPoint * position         buffer which will get the position
  479. */
  480. BOOL XDragEvent::GetDropPos(XPoint * p) const
  481. {
  482.    if ((!(dragInfo)) || eventID != DRG_DROP)
  483.       return FALSE;
  484.    p->Set(dragInfo->xDrop, dragInfo->yDrop);
  485.    return TRUE;
  486. }
  487.  
  488.  
  489. /*@ XDragEvent::GetDragItem()
  490. @remarks Query a dragitem.
  491. @parameters    XDragItem * buffer        buffer which will get the item-information<br>
  492.                SHORT index               zero-based index of item to query
  493. */
  494. BOOL XDragEvent::GetDragItem(XDragItem * itm, const SHORT index)
  495. {
  496.    if (!(dragInfo))
  497.       return FALSE;
  498.    if (index > dragInfo->cditem)
  499.       return FALSE;
  500.  
  501.    itm->item = DrgQueryDragitemPtr(dragInfo, index);
  502.    return TRUE;
  503. }
  504.  
  505.  
  506. XMouseEvent :: XMouseEvent(const LONG e, const void *v1, const void *v2)
  507. {
  508.    switch (e)
  509.    {
  510.       case WM_BUTTON1DOWN:
  511.          eventID = MOU_BTN1DOWN;
  512.          break;
  513.       case WM_BUTTON1DBLCLK:
  514.          eventID = MOU_BTN1DBLCLICK;
  515.          break;
  516.       case WM_BUTTON1CLICK:
  517.          eventID = MOU_BTN1CLICK;
  518.          break;
  519.       case WM_BUTTON1UP:
  520.          eventID = MOU_BTN1UP;
  521.          break;
  522.       case WM_BUTTON2DOWN:
  523.          eventID = MOU_BTN2DOWN;
  524.          break;
  525.       case WM_BUTTON2DBLCLK:
  526.          eventID = MOU_BTN2DBLCLICK;
  527.          break;
  528.       case WM_BUTTON2CLICK:
  529.          eventID = MOU_BTN2CLICK;
  530.          break;
  531.       case WM_BUTTON2UP:
  532.          eventID = MOU_BTN2UP;
  533.          break;
  534.       case WM_BUTTON3DOWN:
  535.          eventID = MOU_BTN3DOWN;
  536.          break;
  537.       case WM_BUTTON3DBLCLK:
  538.          eventID = MOU_BTN3DBLCLICK;
  539.          break;
  540.       case WM_BUTTON3CLICK:
  541.          eventID = MOU_BTN3CLICK;
  542.          break;
  543.       case WM_BUTTON3UP:
  544.          eventID = MOU_BTN3UP;
  545.          break;
  546.       default:
  547.          eventID = e;
  548.          break;
  549.    }
  550.  
  551. //   p.Set( (LONG) SHORT1FROMMP(v1), (LONG) SHORT2FROMMP(v1));
  552. SHORT x = SHORT1FROMMP(v1);
  553. SHORT y = SHORT2FROMMP(v1);
  554. p.Set( x, y);
  555.    keyboardState = SHORT2FROMMP((MPARAM) v2);
  556. }
  557.  
  558.  
  559. XItemDrawEvent :: XItemDrawEvent(const LONG msg, const void *mp1, const void *mp2, const SHORT t)
  560. {
  561.    type = t;
  562.    eventID = msg;
  563.    windowID = SHORT1FROMMP(mp1);
  564.    item = (POWNERITEM) mp2;
  565.    bColor = color = 0;
  566.    textStyle = DT_VCENTER | DT_LEFT;
  567. }
  568.  
  569.  
  570. /*@ XItemDrawEvent::GetObject(void)
  571. @group comtainer-related functions
  572. @remarks Returns the object from which an item must be drawn. Only use
  573. this function in container-controls!
  574. @returns    XContainerObject *   the object
  575. */
  576. XContainerObject * XItemDrawEvent::GetObject(void)
  577. {
  578.    CNRDRAWITEMINFO *info = (CNRDRAWITEMINFO *) item->hItem;
  579.  
  580.    if (!(info->pRecord))
  581.       return NULL;
  582.    RECORDCORE *pr = (RECORDCORE *) ((PBYTE) info->pRecord + sizeof(RECORDCORE));
  583.    XContainerObject *obj;
  584.  
  585.    memcpy(&obj, pr, 4);
  586.    return obj;
  587. }
  588.  
  589.  
  590. /*@ XItemDrawEvent::GetColumn(void)
  591. @group comtainer-related functions
  592. @remarks Returns the column from which an item must be drawn. Only use
  593. this function in container-controls!
  594. @returns    XContainerColumn *   the column
  595. */
  596. XContainerColumn * XItemDrawEvent::GetColumn(void) const
  597. {
  598.    CNRDRAWITEMINFO *info = (CNRDRAWITEMINFO *) item->hItem;
  599.  
  600.    if (info->pFieldInfo)
  601.       return (XContainerColumn *) info->pFieldInfo->pUserData;
  602.    else
  603.       return NULL;
  604. }
  605.  
  606.  
  607. /*@ XItemDrawEvent::DrawItem(const XBitmap * bitmap, const char *title, const BOOL drawOver)
  608. @group drawing
  609. @remarks Draws an item using a bitmap and/or text in
  610. XListBox, XContainerControl and XMenuBar
  611. @parameters <t '°' c=2>
  612.             °XBitmap * bitmap     °A bitmap to display (can be NULL)
  613.             °char * text          °Text to display (can be NULL)
  614.             °BOOL drawOver        °If FALSE (default) first the bitmap is drawn and the text is drawn right from the bitmap.
  615.                                  If TRUE, the text is drawn over the bitmap.
  616.             </t>
  617. */
  618. void XItemDrawEvent::DrawItem(const XBitmap * bitmap, const char *title, const BOOL drawOver)
  619. {
  620.    POINTL p;
  621.  
  622.    GpiCreateLogColorTable(item->hps, LCOL_RESET, LCOLF_RGB, 0L, 0L, NULL);
  623.  
  624.    if(bColor == 0)
  625.    {
  626.       if (type == 4)
  627.          WinFillRect(item->hps, &item->rclItem, SYSCLR_MENU);
  628.       else if (type == 37)
  629.       {
  630.          if (item->fsAttribute & CRA_SELECTED)
  631.             WinFillRect(item->hps, &item->rclItem, SYSCLR_HILITEBACKGROUND);
  632.       }
  633.       else
  634.          WinFillRect(item->hps, &item->rclItem, (item->fsState == 1 ? SYSCLR_HILITEBACKGROUND : SYSCLR_ENTRYFIELD));
  635.  
  636.       if (item->fsAttribute & MIA_HILITED && type == 4)
  637.       {
  638.          GpiSetColor(item->hps, SYSCLR_BUTTONDARK);
  639.          p.x = item->rclItem.xLeft + 2;
  640.          p.y = item->rclItem.yBottom;
  641.          GpiMove(item->hps, &p);
  642.          p.y = item->rclItem.yTop - 1;
  643.          GpiLine(item->hps, &p);
  644.          p.x = item->rclItem.xRight - item->rclItem.xLeft - 1;
  645.          GpiLine(item->hps, &p);
  646.          GpiSetColor(item->hps, SYSCLR_BUTTONLIGHT);
  647.          p.y = item->rclItem.yBottom;
  648.          GpiLine(item->hps, &p);
  649.          p.x = item->rclItem.xLeft + 2;
  650.          GpiLine(item->hps, &p);
  651.  
  652.          item->rclItem.xLeft += 3;
  653.       }
  654.    }
  655.    else
  656.       WinFillRect(item->hps, &item->rclItem, bColor);
  657.  
  658.    if ((item->fsAttributeOld & MIA_CHECKED || item->fsAttribute & MIA_CHECKED) && type == 4)
  659.    {
  660.       p.y = (item->rclItem.yTop - item->rclItem.yBottom - bitmap->cy) / 2 + item->rclItem.yBottom - (item->fsAttribute & MIA_HILITED ? 2 : 0) + 1;
  661.       p.x = item->rclItem.xLeft;
  662.  
  663.       HBITMAP hb = WinGetSysBitmap(HWND_DESKTOP, SBMP_MENUCHECK);
  664.  
  665.       WinDrawBitmap(item->hps, hb, NULL, (PPOINTL) & p, (item->fsAttribute & MIA_DISABLED ? SYSCLR_MENUDISABLEDTEXT : SYSCLR_OUTPUTTEXT), SYSCLR_MENU, DBM_NORMAL);   // /XColor(COL_PALEGRAY).
  666.                                                                                                                               // GetColor()
  667.       item->fsAttributeOld = (item->fsAttribute &= ~MIA_CHECKED);
  668.       GpiDeleteBitmap(hb);
  669.    }
  670.  
  671.    if (type == 4)
  672.       item->rclItem.xLeft += 14;
  673.  
  674.    if (type == 37)
  675.    {
  676.       if (GetObject() && drawOver == FALSE)
  677.          item->rclItem.xLeft += 12;
  678.    }
  679.    else if (drawOver == FALSE)
  680.       item->rclItem.xLeft += 3;
  681.  
  682.    if (bitmap)
  683.    {
  684.       RECTL rect;
  685.  
  686.       rect.yBottom = (item->rclItem.yTop - item->rclItem.yBottom - bitmap->cy) / 2 + item->rclItem.yBottom - (item->fsAttribute & MIA_HILITED ? 2 : 0) + 1;
  687.       rect.xLeft = item->rclItem.xLeft;
  688.       if (type == 4)
  689.          rect.yBottom += 1;
  690.       rect.xRight = rect.xLeft + bitmap->width;
  691.       rect.yTop = rect.yBottom + bitmap->height;
  692.       WinDrawBitmap(item->hps, bitmap->hbm, NULL, (PPOINTL) &rect, 0, 0, DBM_NORMAL | DBM_STRETCH );
  693.    }
  694.  
  695.    if (title)
  696.    {
  697.       if (bitmap && drawOver == FALSE)
  698.          item->rclItem.xLeft += bitmap->cx + 3;
  699.       if (item->fsAttribute & MIA_HILITED && type == 4)
  700.       {
  701.          item->rclItem.yBottom -= 2;
  702.          item->rclItem.yTop -= 2;
  703.       }
  704.       LONG backCol, frontCol;
  705.  
  706.       switch (type)
  707.       {
  708.       case 4:
  709.          frontCol = (item->fsAttribute & MIA_DISABLED ? SYSCLR_MENUDISABLEDTEXT : color);
  710.          backCol = SYSCLR_MENU;
  711.          break;
  712.       case 37:
  713.          frontCol = (item->fsAttribute & CRA_SELECTED ? SYSCLR_HILITEFOREGROUND : color);
  714.          backCol = (item->fsAttribute & CRA_SELECTED ? SYSCLR_HILITEBACKGROUND : SYSCLR_WINDOW);
  715.          break;
  716.       default:
  717.          frontCol = (item->fsState == 1 ? SYSCLR_HILITEFOREGROUND : color);
  718.          backCol = (item->fsState == 1 ? SYSCLR_HILITEBACKGROUND : SYSCLR_ENTRYFIELD);
  719.          break;
  720.       }
  721.  
  722.       if( bColor )
  723.          backCol = bColor;
  724.         if( color )
  725.             frontCol = color;
  726.  
  727.       if (textStyle & DT_WORDBREAK)
  728.       {
  729.          int drawn = 0, totalDrawn, length = strlen(title);
  730.          int fontSize = 12;
  731.  
  732.          for (totalDrawn = 0; totalDrawn < length; item->rclItem.yTop -= (LONG) (fontSize * 1.3))
  733.          {
  734.             drawn = WinDrawText(item->hps, length - totalDrawn, (PSZ) title + totalDrawn, &item->rclItem, frontCol, backCol, textStyle);
  735.             if (drawn)
  736.                totalDrawn += drawn;
  737.             else
  738.                break;
  739.          }
  740.       }
  741.       else
  742.          WinDrawText(item->hps, strlen(title), (PCH) title, &item->rclItem, frontCol, backCol, textStyle);
  743.    }
  744.  
  745.    if (type != 4)
  746.       item->fsState = item->fsStateOld = 0;
  747.    else
  748.    {
  749.       if (item->fsAttribute & MIA_HILITED)
  750.          item->fsAttribute ^= MIA_HILITED;
  751.       if (item->fsAttributeOld & MIA_HILITED)
  752.          item->fsAttributeOld ^= MIA_HILITED;
  753.    }
  754. }
  755.  
  756.  
  757. /*@
  758. @class XBackgroundDrawEvent
  759. @parent XEvent
  760. @type overview
  761. @symbol _
  762. */
  763.  
  764.  
  765. /*@ XBackgroundDrawEvent::Draw(const XBitmap * bitmap)
  766. @group drawing
  767. @remarks Draws a bitmap
  768. @parameters XBitmap * bitmap     bitmap to draw
  769. */
  770. void XBackgroundDrawEvent::Draw(const XBitmap * bitmap)
  771. {
  772.    WinDrawBitmap(back->hps, bitmap->GetHandle(), (PRECTL) & back->rclBackground, (PPOINTL) & back->rclBackground, 0, 0, DBM_NORMAL);
  773. }
  774.  
  775.  
  776. ////////////////////////docs only
  777. /*@ XEvent::GetEventID()
  778. @remarks GetEventID return the ID of the event which ocures. Valid
  779. ID∩s are specified by the classes derived from XEvent
  780. @returns      ULONG theEventID
  781. */
  782.  
  783.  
  784.  
  785. /*@ XControlEvent::GetEventID()
  786. @remarks Returns a pointer to the window which has send the event
  787. @returns     LONG id                     the id of the event, see XControlEvent.
  788. */
  789.  
  790.  
  791.  
  792. /*@ XControlEvent::GetWindow()
  793. @remarks Returns a pointer to the window which has send the event
  794. @returns     XWindow * thePointer    the pointer of the sending window, if you
  795.                                      know the window type, you can typecast to
  796.                                      the needed class
  797. */
  798.  
  799.  
  800. /*@ XControlEvent::GetWindowID()
  801. @remarks Returns the ID of the window which has send the event
  802. @returns     LONG theWindowID        the ID of the sending window
  803. */
  804.  
  805.  
  806. /*@ XMouseEvent::GetEventID()
  807. @remarks Returns the ID of the mouse-event. To get a mouse-event you must
  808. register a XMouseHandler!
  809. @returns     LONG theID              the ID of the mouse-event, see XMouseEvent.
  810. */
  811.  
  812.  
  813. /*@ XMouseEvent::GetKeyInfo()
  814. @remarks Returns the state of the keyboard
  815. @returns     SHORT keyInfo           information of the keyboard
  816. */
  817.  
  818.  
  819. /*@
  820. @class XContainerEditEvent
  821. @parent XContainerEvent
  822. @type overview
  823. @symbol _
  824. @remarks An XContainerEditEvent is catched with a XContainerHandler. This event occures
  825. if the user edit the text of a container-item.
  826. */
  827.  
  828.  
  829. /*@ XContainerEditEvent :: GetText( XString * s)
  830. @remarks Returns the text of an edited item. On CON_REALLOC
  831. the old text is returned, on CON_ENDEDIT the new text is avaible.
  832. @parameters XString * buffer     buffer to hold the data
  833. */
  834.  
  835.  
  836.  
  837.  
  838. /*@ XContainerEditEvent::GetColumn()
  839. @remarks Returns a pointer to that column in which
  840. an item is edited;
  841. @returns XContainerColumn * theColumn
  842. */
  843.  
  844.  
  845. /*@
  846. @class XItemDrawEvent
  847. @parent XEvent
  848. @type overview
  849. @symbol _
  850. @remarks An XItemDrawEvent is catched with a XItemDrawHandler. This event occures
  851. if a listbox, menu or container is set with the style OWNERDRAW. In this case the
  852. items must be drwan by the application.
  853. */
  854.  
  855.  
  856. /*@ XItemDrawEvent::GetItemHandle()
  857. @group item-related
  858. @remarks Returns a handle to the item which must redrawn. Only use
  859. this function in listbox-controls! (There you can set the handle
  860. with XListBox::SetItemhandle() )
  861. @returns    ULONG theHandle
  862. */
  863.  
  864.  
  865. /*@ XItemDrawEvent::GetWindowID()
  866. @group misc
  867. @remarks Returns the ID of the window.
  868. @returns    LONG theID
  869. */
  870.  
  871.  
  872. /*@ XItemDrawEvent::GetItemID()
  873. @group item-related
  874. @remarks Returns the ID of the item to draw. Don∩t use
  875. this function in container-controls! (use XItemDrawEvent::GetObject() and XItemDrawEvent::GetColumn()
  876. to find out what you have to draw )
  877. @returns    LONG theID
  878. */
  879.  
  880.  
  881. /*@ XItemDrawEvent::GetWindowHandle()
  882. @remarks Returns the sytem-define window handle.
  883. @returns    OOL_WINDOWHANDLE handle
  884. */
  885.  
  886.  
  887. /*@ XItemDrawEvent::SetTextColor()
  888. @group colors
  889. @remarks Set the text color for non-selected items
  890. @parameters XColor * color    new color
  891. */
  892.  
  893.  
  894. /*@ XDragEvent::GetDragItemCount()
  895. @remarks Return the count of drag-items of this dragevent
  896. @returns       SHORT                     count of items
  897. */
  898.  
  899.  
  900. /*@ XDragEvent::GetSourceWindow()
  901. @remarks Query the system-define handle of the window where the objects
  902. were dropped.
  903. @returns:       OOL_WINDOWHANDLE          The system-defined window handle.
  904. */
  905.  
  906.  
  907. /*@
  908. @class XContainerDragEvent
  909. @parent XContainerEvent
  910. @type overview
  911. @symbol _
  912. @remarks Drag/drop events in a container generate a XContainerDragEvent which is derived
  913. from XContainerEvent and has the same functionality like XDragEvent (see there for
  914. further information).
  915. */
  916.  
  917.  
  918. /*@ XContainerEvent::GetObject()
  919. @remarks Query the object which belongs to the event.
  920. @returns XContainerObject * theObject
  921. */
  922.  
  923.  
  924. /*@
  925. @class XContainerEvent
  926. @parent XControlEvent
  927. @type overview
  928. @symbol _
  929. @remarks Events in a container generate a XContainerEvent, if you want to catch these
  930. events you must generate a XContainerHandler. Possible event-IDs are:
  931. <t '°' 2>
  932.    °CON_BEGINEDIT         °the user start to edit a field
  933.    °CON_COLLAPSTREE       °in tree-view the tree or a part of it is collapsed
  934.    °CON_CONTEXTMENU       °a context-menu is requested
  935.    °CON_DRAGOVER          °one or more objects fly over the container
  936.    °CON_DROP              °one or more objects are dropped
  937.    °CON_EMPHASIS          °the emphasis of an item has changed
  938.    °CON_ENTER             °ENTER was pressed or a double-click with the mouse occured
  939.    °CON_EXPANDTREE        °in tree-view the tree or a part of it is expanded
  940.    °CON_INITDRAG          °a drag-operation is requested
  941.    °CON_PAINTBACKGOUND    °the background of the container must be redrawn
  942. </t>
  943. which you can get with XEvent::GetEventID(). In the cases of CON_BEGINEDIT, CON_ENDEDIT and CON_REALLOC
  944. a event of the Type XContainerEditEvent is posted, in the case od CON_DROP and CON_DRAGOVER a XContainerDragEvent is posted, you can simple typecast to them.
  945. */
  946.  
  947.  
  948. /*@
  949. @class XControlEvent
  950. @parent XEvent
  951. @type overview
  952. @symbol _
  953. @remarks The XControlEvent is send to a XFrameWindow when the user has performed
  954. some interaction with a client window of the frame window. If you have caught the XControlEvent
  955. by overriding XFrameWindow::DoControl you can get information about the sending window
  956. and the type (ID) of the event. Valid event-ID∩s are:
  957. <t '°' 2>
  958.    °WIN_CHANGED          °the content of the client has changed
  959.    °WIN_DBLCLICK         °the user double-clicked on the window
  960.    °WIN_PAINT            °the window will be redrawn
  961.    °WIN_ENTER            °the user pressed ENTER
  962.    °WIN_SELECTED         °an item of the window was selected
  963.    °WIN_VSCROLL          °the window scrolls it contents
  964.    °WIN_HSCROLL          °the window scrolls it contents
  965.    °WIN_SETFOCUS         °the window recieves the focus
  966.    °WIN_KILLFOCUS        °the window lost the focus
  967.    °WIN_SHOWLIST         °the list of a XComboBox will be displayed
  968.    °WIN_TRACK            °the user tracks the window (in XSlider)
  969.    °WIN_ENDTRACK         °the user stopped tracking (in XSlider)
  970.    °WIN_UPARROW          °the user pressed the arrow "up" (in XSpinButton)
  971.    °WIN_DOWNARROW        °the user pressed the arrow "down" (in XSpinButton)
  972.    °MEDIA_PLAYED         °a media-window has completed playing a file
  973.    °MEDIA_PAUSED         °a media-window paused playing a file
  974.    °MEDIA_REWINDED       °a media-window completed rewinding a file
  975.    °MEDIA_STOPED         °a media-window stoped playing a file
  976. </t>
  977. */
  978.  
  979.  
  980. /*@
  981. @class XDragEvent
  982. @parent XEvent
  983. @type overview
  984. @symbol _
  985. @remarks For drag-events a XDragEvent is generated, to catch them you need to install
  986. a XDragHandler. Possible event-IDs are:
  987. <t '°' 2>
  988.    °DRG_DROPPED          °An item was dropped.
  989.    °DRG_DRAGOVER         °An item fly over the window.
  990.    °DRG_ENDCONVERSATION  °The converation ends. No informations about dragitems avaible!
  991.    °DRG_DISCARDOBJECT    °Delete the items(s).
  992.    °DRG_PRINTOBJECT      °Print the item(s). Use QueryPrinterInfo() to get information about the requested printer.
  993. </t>
  994. For drag-events in a container see:
  995. <UL>
  996. <LI>XContainerDragEvent
  997. <LI>XContainerEvent
  998. <LI>XContainerHandler
  999. </UL>
  1000. */
  1001.  
  1002.  
  1003. /*@
  1004. @class XMouseEvent
  1005. @parent XEvent
  1006. @type overview
  1007. @symbol _
  1008. @remarks To catch events from the mouse like moving using mouse-buttons etc you must
  1009. install a XMouseHandler. If you use this handler you recieve XMouseEvents
  1010. which contains information about the mouse-state. For drag/drop you don∩t
  1011. need a XMousehandler but a XDragHandler. Possible event-IDs are
  1012. <t '°' c=2>
  1013.    °MOU_BTN1CLICK      °button 1 clicked
  1014.    °MOU_BTN1DBLCLICK   °button 1 double-click
  1015.    °MOU_BTN1DOWN       °button 1 down
  1016.    °MOU_BTN1UP         °button 1 up
  1017.    °MOU_BTN2CLICK      °button 2 clicked
  1018.    °MOU_BTN2DBLCLICK   °button 2 double-click
  1019.    °MOU_BTN2DOWN       °button 2 down
  1020.    °MOU_BTN2UP         °button 2 up
  1021.    °MOU_BTN3CLICK      °button 3 clicked
  1022.    °MOU_BTN3DBLCLICK   °button 3 double-click
  1023.    °MOU_BTN3DOWN       °button 3 down
  1024.    °MOU_BTN3UP         °button 3 up
  1025.    °MOU_INITDRAG       °the user requested a drag-operation
  1026.    °MOU_MOVE           °mouse moved
  1027.    °MOU_ENTER           °mouse entered the window (Warp 4)
  1028.    °MOU_EXIT           °mouse leaves the window (Warp 4)
  1029. </t>
  1030. */
  1031.  
  1032.  
  1033. /*@
  1034. @class XKeyboardEvent
  1035. @parent XEvent
  1036. @type overview
  1037. @symbol _
  1038. @remarks A XKeyboardEvent represents a user input to the keyboard, to catch these
  1039. events install a XKeyboardHandler.<P>
  1040. XKeyboardEvent::GetEventID() returns the ASCII-code of the key which was pressed, with XKeyboardEvent::GetVirtualKey()
  1041. and XKeyboardEvent::GetScanCode() you receivemore information.
  1042. */
  1043.  
  1044.  
  1045. /*@ XKeyboardEvent::GetVirtualKey()
  1046. @remarks Use this function to get the virtual key defined by the OS
  1047. @returns
  1048. SHORT key   virtual key, see OS/2-information
  1049. */
  1050.  
  1051.  
  1052. /*@ XKeyboardEvent::GetScanCode()
  1053. @remarks Use this function to get the scancode
  1054. @returns SHORT code
  1055. */
  1056.  
  1057. /*@ XKeyboardEvent::GetFlags()
  1058. @remarks Use this function to get the flags
  1059. @returns SHORT flags:
  1060.          <t '°' c=2>
  1061.             °XKC_KEYUP    °The event is a key-up transition
  1062.             °XKC_PREVDOWN           °The key has been previously down
  1063.              °XKC_LONEKEY           °Indicates if the key is pressed and released without any other keys
  1064.              °XKC_SHIFT             °The SHIFT state is active
  1065.              °XKC_ALT           °The ALT state is active
  1066.              °XKC_CTRL           °The CTRL state was active
  1067.             </t>
  1068.             This values can be or-ed.
  1069. </t>
  1070. */
  1071.