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

  1. /* $Id: kNotebookPageBase.cpp,v 1.1 2000/04/29 19:06:35 stknut Exp $
  2.  *
  3.  * kNotebookPageBase (kClassLib) - Notebook page base class.
  4.  *
  5.  * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
  6.  *
  7.  */
  8.  
  9.  
  10. /*******************************************************************************
  11. *   Defined Constants And Macros                                               *
  12. *******************************************************************************/
  13. #define INCL_WIN
  14. #define INCL_DOS
  15.  
  16.  
  17. /*******************************************************************************
  18. *   Internal Functions                                                         *
  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.  
  31. #include "kError.h"
  32. #include "kBase.h"
  33. #include "kDlgBase.h"
  34. #include "kNotebookPageBase.h"
  35. #include "kNotebookBase.h"
  36.  
  37.  
  38. /**
  39.  * Default command.
  40.  * prevent from being dismissed by DID_OK and DID_CANCEL.
  41.  * @param     usCmd     Control id which send/posted the message.
  42.  * @param     usSource  Source id.
  43.  * @param     fPointer  Mouse pointer flag.
  44.  */
  45. VOID  kNotebookPageBase::command(USHORT usCmd, USHORT usSource, BOOL fPointer)
  46. {
  47.     switch (usCmd)
  48.     {
  49.         case DID_OK:
  50.         case DID_CANCEL:
  51.             break;
  52.     }
  53.  
  54.     /* unreferenced */
  55.     usSource = usSource;
  56.     fPointer = fPointer;
  57. }
  58.  
  59.  
  60. /**
  61.  * Constructor. Creates a page in a notebook.
  62.  * Note! You'll have to add it to the notebook afterwards.
  63.  * @param     usResId  Dialog resource id.
  64.  * @param     hmodRes  Handle to resource module.
  65.  * @param     pNtbk    Pointer to the notebook these pages are to be a part of.
  66.  * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
  67.  * @remark
  68.  */
  69. kNotebookPageBase::kNotebookPageBase(ULONG ulResId, HMODULE hmodRes, kNotebookBase *pNtbk) throw (kError)
  70.     : kDlgBase(ulResId, hmodRes, pNtbk->getHwnd(), pNtbk->getHwnd()),
  71.     pNtbk(NULL)
  72. {
  73.  
  74. }
  75.  
  76.  
  77. /**
  78.  * Destructor.
  79.  */
  80. kNotebookPageBase::~kNotebookPageBase()
  81. {
  82.     pNtbk = NULL;
  83. }
  84.  
  85.  
  86.  
  87. /**
  88.  * Help is requested for this page...
  89.  */
  90. VOID  kNotebookPageBase::ntfyHelp()
  91. {
  92. }
  93.  
  94.  
  95. /**
  96.  * This method is called to notify the page that is has been selected and
  97.  * is now on top.
  98.  */
  99. VOID  kNotebookPageBase::ntfySelected()
  100. {
  101. }
  102.  
  103.  
  104. /**
  105.  * This method is called to notify the page that it is about to selected (switched to).
  106.  * This selection is aborted if you return FALSE.
  107.  * This stub does simply return TRUE.
  108.  * @returns   TRUE: selecting me is ok with me!
  109.  *            FALSE: selecting me is _not_ ok. Abort the process.
  110.  */
  111. BOOL  kNotebookPageBase::ntfySelectedPending()
  112. {
  113.     return TRUE;
  114. }
  115.  
  116.  
  117. /**
  118.  * This method is called to notify the page that it has been deselected
  119.  * and is not longer on top.
  120.  */
  121. VOID  kNotebookPageBase::ntfyDeselected()
  122. {
  123. }
  124.  
  125.  
  126. /**
  127.  * This method is called to notify the page that it is about to deselected (switched from).
  128.  * This deselection is aborted if you return FALSE.
  129.  * This stub does simply return TRUE.
  130.  * @returns   TRUE: deselecting me is ok with me!
  131.  *            FALSE: deselecting me is _not_ ok. Abort the process.
  132.  */
  133. BOOL  kNotebookPageBase::ntfyDeselectedPending()
  134. {
  135.     return TRUE;
  136. }
  137.  
  138.  
  139. /**
  140.  * This method is called to notify the page that the size of the notebook has changed.
  141.  * It is called by the Notobook class.
  142.  * @param     cx  New width.
  143.  * @param     cy  New height.
  144.  */
  145. VOID  kNotebookPageBase::ntfySized(LONG cx, LONG cy)
  146. {
  147.     resize(cx, cy);
  148. }
  149.  
  150.  
  151. /**
  152.  * Notify the page that it has been inserted into the notebook.
  153.  * Stub.
  154.  */
  155. VOID  kNotebookPageBase::ntfyInserted()
  156. {
  157. }
  158.  
  159.  
  160. /**
  161.  * Gets the tab text for this page.
  162.  * This stub returns the dialog title (if template exists).
  163.  * @returns   pszBuffer on success. NULL on error.
  164.  * @param     pszBuffer  Pointer to string buffer.
  165.  * @param     cchBuffer  Size of the buffer.
  166.  */
  167. PSZ  kNotebookPageBase::queryTabText(PSZ pszBuffer, ULONG cchBuffer)
  168. {
  169.     /*
  170.      * We'll have to get the text from the dialog template.
  171.      * (WinQueryWindowText don't work.)
  172.      */
  173.     if (pDlgTemplate != NULL
  174.         && pDlgTemplate->adlgti[0].cchText != 0
  175.         && pDlgTemplate->adlgti[0].offText != 0xFFFF
  176.         && pDlgTemplate->adlgti[0].offText != 0)
  177.     {
  178.         *pszBuffer = '\0';
  179.         strncat(pszBuffer,
  180.                 (char*)((unsigned)(pDlgTemplate) + pDlgTemplate->adlgti[0].offText),
  181.                 (size_t)cchBuffer);
  182.         return pszBuffer;
  183.     }
  184.     return NULL;
  185. }
  186.