home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / taman002.zip / TASKMANA.ZIP / src / kObjectContainer.cpp < prev    next >
C/C++ Source or Header  |  2000-04-29  |  5KB  |  196 lines

  1. /* $Id: kObjectContainer.cpp,v 1.1 2000/04/29 19:06:35 stknut Exp $
  2.  *
  3.  * kObjectContainer - generic object container.
  4.  *
  5.  * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
  6.  *
  7.  */
  8.  
  9. /*******************************************************************************
  10. *   Defined Constants And Macros                                               *
  11. *******************************************************************************/
  12. #define INCL_WIN
  13. #define INCL_GPI
  14. #define INCL_BASE
  15.  
  16.  
  17. /*******************************************************************************
  18. *   Header Files                                                               *
  19. *******************************************************************************/
  20. #include <os2.h>
  21. #ifdef USE_KLIB
  22.     #include <kAssert.h>
  23.     #include <kLog.h>
  24.     #include <kHeap.h>
  25. #else
  26.     #include <malloc.h>
  27. #endif
  28. #include <memory.h>
  29. #include <string.h>
  30. #include <stddef.h>
  31. #include <stdio.h>
  32.  
  33. #include "kBase.h"
  34. #include "kError.h"
  35. #include "kDlgBase.h"
  36. #include "kMenuBase.h"
  37. #include "kClickDlg.h"
  38. #include "kContainer.h"
  39. #include "kQuerySysState.h"
  40. #include "kNotebookBase.h"
  41. #include "kNotebookPageBase.h"
  42. #include "kObjectRecord.h"
  43. #include "kObjectContainer.h"
  44. #include "kTaskMgr.h"
  45. #include "kTaskMgr_defs.h"
  46.  
  47.  
  48. /**
  49.  * Updates the content of the container.
  50.  * @returns   success indicator.
  51.  * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
  52.  */
  53. BOOL   kObjectContainer::insertObjects()
  54. {
  55.     qsLrec_t *      pMteData;
  56.     int             c;
  57.  
  58.     /*
  59.      * Get data for this MTE and get the object count.
  60.      */
  61.     pMteData = QSGetMteData(hMTE);
  62.     if (pMteData == NULL)
  63.         return FALSE;
  64.  
  65.     c = (int)pMteData->ctObj;
  66.  
  67.     if (c > 0 && pMteData->pObjInfo != NULL)
  68.     {
  69.         int i;
  70.         kObjectRecord  *pCurCnrRec, *pCnrRec;
  71.  
  72.         /*
  73.          * Allocate container records for all the objects.
  74.          */
  75.         pCurCnrRec = pCnrRec = (kObjectRecord*)allocMiniRec(sizeof(kObjectRecord), c);
  76.         if (pCurCnrRec == NULL)
  77.             return FALSE;               /* FIXME: complain about this! */
  78.  
  79.         /*
  80.          * Loop thru the list of processes and update the container.
  81.          */
  82.         for (i = 0; i < c; i++, pCurCnrRec = (kObjectRecord*)pCurCnrRec->getNext())
  83.         {
  84.             /*
  85.              * Init and set the record.
  86.              */
  87.             pCurCnrRec->init();
  88.             pCurCnrRec->set(&pMteData->pObjInfo[i], i);
  89.         }
  90.  
  91.         /*
  92.          * Insert the record at bottom of the container.
  93.          */
  94.         return insertAtTop(pCnrRec, c);
  95.     }
  96.  
  97.     return FALSE;
  98. }
  99.  
  100.  
  101.  
  102. /**
  103.  * Menu is closing. Remove emphasis.
  104.  * @param     usMenuId  Menu id.
  105.  * @param     hwndMnu   Handle to menu window.
  106.  */
  107. VOID kObjectContainer::menuEnd(USHORT usMenuId, HWND hwndMnu)
  108. {
  109.     setRecordEmphasis(pCurRecord, FALSE, CRA_SOURCE);
  110.     hwndMnu = hwndMnu;
  111.     usMenuId = usMenuId;
  112. }
  113.  
  114.  
  115. /**
  116.  * Command events - none yet.
  117.  * @param     usCmd     Control id which send/posted the message.
  118.  * @param     usSource  Source id.
  119.  * @param     fPointer  Mouse pointer flag.
  120.  */
  121. VOID  kObjectContainer::command(USHORT usCmd, USHORT usSource, BOOL fPointer)
  122. {
  123.     usCmd = usCmd;
  124.     usSource = usSource;
  125.     fPointer = fPointer;
  126. }
  127.  
  128.  
  129.  
  130. /**
  131.  * Constructor.
  132.  * @param     hwndDlg   Handle to dialog window.
  133.  * @param     ulCnrId   ID of the container dialog item in hwndDlg.
  134.  * @param     usMTE     Module handle.
  135.  * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
  136.  */
  137. kObjectContainer::kObjectContainer(HWND hwndDlg, ULONG ulCnrId, USHORT hMTE) throw(kError)
  138.     : kDetailCnr(WinWindowFromID(hwndDlg, ulCnrId),
  139.                  0,
  140.                  "Object Overview",
  141.                  kObjectRecord::cFieldInfo,
  142.                  (PFIELDINFO)&kObjectRecord::aFieldInfo[0]),
  143.     hMTE(hMTE), pCurRecord(NULL)
  144. {
  145. }
  146.  
  147.  
  148. /**
  149.  * Destructor.
  150.  */
  151. kObjectContainer::~kObjectContainer()
  152. {
  153. }
  154.  
  155.  
  156. /**
  157.  * Displays the popup menu for the container.
  158.  * @param     usId     Container id.
  159.  * @param     pRecord  Pointer to the record which is selected by either the key
  160.  */
  161. VOID kObjectContainer::cnrContextMenu(USHORT usId, PRECORDCORE pRecord)
  162. {
  163.     pRecord = pRecord;
  164.     usId = usId;
  165. }
  166.  
  167.  
  168. /**
  169.  * Enter or double click on record in the container.
  170.  * This action will bring up the detail dialog for the record.
  171.  */
  172. VOID kObjectContainer::cnrEnter(USHORT usId, HWND hwndCnr, PRECORDCORE pRecord, ULONG fKey)
  173. {
  174.     if (pRecord != NULL)
  175.     {
  176.         pCurRecord = (kObjectRecord*)pRecord;
  177.         /* command(IDM_CNR_MOD_DETAILS, 0, 0); */
  178.     }
  179.     usId = usId;
  180.     fKey = fKey;
  181.     hwndCnr = hwndCnr;
  182. }
  183.  
  184.  
  185.  
  186. /**
  187.  * Updates the contents of the container - Note that this kind of info doesn't normally change!
  188.  * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
  189.  */
  190. VOID  kObjectContainer::update()
  191. {
  192.     this->insertObjects();
  193. }
  194.  
  195.  
  196.