home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / celltk7b.zip / cell07b.zip / samples / entry.cpp < prev    next >
C/C++ Source or Header  |  1999-02-06  |  5KB  |  253 lines

  1. /*
  2. ** Module   :SIMPLE.C
  3. ** Abstract :
  4. **
  5. ** Copyright (C) Sergey I. Yevtushenko
  6. ** Log: Sun  14/02/1998     Created
  7. **
  8. */
  9.  
  10. #define INCL_WIN
  11. #define INCL_NLS
  12. #define INCL_DOS
  13. #define INCL_GPI
  14.  
  15. #include <os2.h>
  16. #include <multibar.h>
  17. #include <cell.h>
  18. #include <string.h>
  19.  
  20. /* Local procedures */
  21.  
  22. MRESULT EXPENTRY MainClientProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  23. MRESULT EXPENTRY LEProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  24.  
  25. /* Static Variables */
  26. #define ID_FINDEF   1060
  27. #define ID_FINDPB   1061
  28. #define ID_PRXCELL  1062
  29. #define ID_MLE2     1063
  30.  
  31.  
  32. CellDef cdLeftPane =
  33. {
  34.     CELL_WINDOW,
  35.     WC_MLE,
  36.     "SampleText",
  37.     MLS_BORDER | WS_VISIBLE,
  38.     ID_MLE2
  39. };
  40.  
  41. CellDef findEf =
  42. {
  43.     CELL_WINDOW,
  44.     WC_ENTRYFIELD,
  45.     NULL,
  46.     WS_VISIBLE | ES_ANY | ES_MARGIN,
  47.     ID_FINDEF,
  48.     0,0,
  49.     LEProc,
  50.     0,0
  51. };
  52.  
  53. CellDef findPb =
  54. {
  55.     CELL_WINDOW,
  56.     WC_BUTTON,
  57.     "Find",
  58.     WS_VISIBLE,
  59.     ID_FINDPB
  60. };
  61.  
  62. CellDef cdRightPane =
  63. {
  64.     CELL_VSPLIT | CELL_SIZE2 | CELL_SPLITBAR | CELL_FIXED,
  65.     0,
  66.     NULL,
  67.     WS_VISIBLE,
  68.     ID_PRXCELL,
  69.     &findEf,
  70.     &findPb,
  71.     NULL, NULL,
  72.     60
  73. };
  74.  
  75. CellDef mainClient =
  76. {
  77.     CELL_HSPLIT | CELL_SIZE2 | CELL_FIXED,
  78.     0,
  79.     "Simple",
  80.     FCF_TITLEBAR | FCF_SYSMENU  | FCF_MENU |
  81.     FCF_MINMAX   | FCF_TASKLIST | FCF_SIZEBORDER |
  82.     0,
  83.     MAIN_FRAME,
  84.     &cdLeftPane,
  85.     &cdRightPane,
  86.     0,
  87.     MainClientProc,
  88.     20
  89. };
  90.  
  91. ULONG mainItems[]=
  92. {
  93.     IDB_FILENEW ,
  94.     IDB_FILEOPEN,
  95.     IDB_FILESAVE,
  96.     IDB_FILSAVAS,
  97.     TB_SEPARATOR,
  98.     IDB_EXIT    ,
  99.     TB_SEPARATOR,
  100.     IDB_EDITCOPY,
  101.     IDB_EDITCUT ,
  102.     IDB_EDITPAST,
  103.     IDB_EDITUNDO,
  104.     TB_SEPARATOR,
  105.     IDB_EDITFIND,
  106.     IDB_EDITFNNX,
  107.     IDB_EDITREPL,
  108.     TB_SEPARATOR,
  109.     IDB_HELP    ,
  110.     IDB_ABOUT   ,
  111.     0
  112. };
  113.  
  114. TbDef mainTb =
  115. {
  116.     TB_ATTACHED_TP /*| TB_BUBBLE*/,
  117.     ID_TOOLBAR,
  118.     mainItems
  119. };
  120.  
  121. MRESULT EXPENTRY LEProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  122. {
  123.     WindowCellCtlData *pWCtlData = 0;
  124.  
  125.     pWCtlData = (WindowCellCtlData *)WinQueryWindowULong(hwnd, QWL_USER);
  126.  
  127.     switch(msg)
  128.     {
  129.         case WM_BUTTON1DOWN:
  130.             {
  131.                 WinPostMsg(hwnd, WM_BUTTON1DBLCLK, mp1, mp2);
  132.             }
  133.             break;
  134.     }
  135.     if(pWCtlData)
  136.         return pWCtlData->pOldProc(hwnd, msg, mp1, mp2);
  137.  
  138.     return WinDefWindowProc(hwnd, msg, mp1, mp2);
  139. }
  140.  
  141. MRESULT EXPENTRY MainClientProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  142. {
  143.     WindowCellCtlData *pWCtlData = 0;
  144.     static iTimerStarted = 0;
  145. /*
  146.     if(!iTimerStarted)
  147.     {
  148.         APIRET rc = WinStartTimer(0, hwnd, 1, 1000);
  149.         iTimerStarted = 0;
  150.     }
  151. */
  152.     pWCtlData = (WindowCellCtlData *)WinQueryWindowULong(hwnd, QWL_USER);
  153.  
  154.     switch(msg)
  155.     {
  156.         case WM_TIMER:
  157.             WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT),
  158.                             HWND_TOP, 0,0,0,0, SWP_ZORDER);
  159.             break;
  160.  
  161.         case WM_COMMAND:
  162.             switch(SHORT1FROMMP(mp1))
  163.             {
  164.                 case IDB_EXIT:
  165.                     WinPostMsg(hwnd, WM_QUIT, 0L, 0L);
  166.                     return ((MRESULT) NULL);
  167.             }
  168.             break;
  169.  
  170.         case WM_CLOSE:
  171.             WinPostMsg(hwnd, WM_QUIT, 0L, 0L);
  172.             return ((MRESULT) NULL);
  173.     }
  174.     if(pWCtlData)
  175.         return pWCtlData->pOldProc(hwnd, msg, mp1, mp2);
  176.  
  177.     return WinDefWindowProc(hwnd, msg, mp1, mp2);
  178. }
  179.  
  180. INT main(VOID)
  181. {
  182.     HAB hab;
  183.     HMQ hmq;
  184.     QMSG qmsg;
  185.     HWND hwndFrame;
  186.     HWND hwndTb;
  187.     HWND hwndTmp;
  188.     LONG lColor = CLR_PALEGRAY;
  189.     static char cFontMy[]="8.Helv";
  190.     SWP swp;
  191.  
  192.     hab = WinInitialize(0);
  193.  
  194.     if(!hab)
  195.     {
  196.         return -1;
  197.     }
  198.  
  199.     hmq = WinCreateMsgQueue(hab, 0);
  200.  
  201.     if(!hmq)
  202.     {
  203.         WinTerminate(hab);
  204.         return -2;
  205.     }
  206.  
  207.     ToolkitInit(hab);
  208.  
  209.     WinQueryWindowPos(HWND_DESKTOP, &swp);
  210.  
  211.     hwndFrame = CreateCell(&mainClient, HWND_DESKTOP, 0);
  212.     if(hwndFrame)
  213.     {
  214.         WinSetWindowPos(hwndFrame, NULLHANDLE,
  215.                         swp.x + swp.cx / 8,
  216.                         swp.y + swp.cy / 8,
  217.                         (swp.cx / 4) * 3,
  218.                         (swp.cy / 4) * 3,
  219.                         SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW);
  220.  
  221.  
  222.         CreateToolbar(hwndFrame, &mainTb);
  223.  
  224.         /* Set MLE color */
  225.  
  226.         hwndTmp = CellWindowFromID(hwndFrame, ID_MLE2);
  227.  
  228.         WinSetPresParam(hwndTmp,
  229.                         PP_BACKGROUNDCOLORINDEX,
  230.                         sizeof(lColor),
  231.                         &lColor);
  232.  
  233.         WinSetPresParam(hwndFrame,
  234.                         PP_FONTNAMESIZE,
  235.                         sizeof(cFontMy),
  236.                         cFontMy);
  237.  
  238.         WinStartTimer(0, WinWindowFromID(hwndFrame, FID_CLIENT), 1, 1000);
  239.  
  240.         while (WinGetMsg(hab, &qmsg, 0, 0, 0))
  241.             WinDispatchMsg(hab, &qmsg);
  242.  
  243.         WinDestroyWindow(hwndFrame);
  244.     }
  245.  
  246.     WinDestroyMsgQueue(hmq);
  247.     WinTerminate(hab);
  248.  
  249.     return 0;
  250. }
  251.  
  252.  
  253.