home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / CFGED1B.ZIP / PMVIEWS.ZIP / CONTROLS.CC next >
C/C++ Source or Header  |  1992-08-12  |  7KB  |  266 lines

  1. // this might look like 'C', but it's really  -*-c++-*-
  2. /* controls.cc
  3.  *
  4.  * Realisierung der Control-Window-Klassen
  5.  *
  6.  * Die Klassen ermoeglichen die einfachere Handhabung
  7.  * von PM-Dialogboxen und -Controls fuer eine
  8.  * eine PM Applikation
  9.  *
  10.  *┌────────────────────────────────────────────┐
  11.  *│Language        : C++                       │
  12.  *│Operating System: OS/2 V2.0 and higher      │
  13.  *│Compiler        : GNU GCC V2.1 and higher   │
  14.  *└────────────────────────────────────────────┘
  15.  *
  16.  * $Id: controls.cc,v 1.1 1992/07/19 02:01:16 gruen Exp $
  17.  * $Log: controls.cc,v $
  18. // Revision 1.1  1992/07/19  02:01:16  gruen
  19. // Initial revision
  20. //
  21. // Revision 1.2  1992/06/24  23:17:00  gruen
  22. // changed the contructor from HWND to Dialog*
  23. //
  24. // Revision 1.1  1992/06/24  19:51:38  gruen
  25. // Initial revision
  26. //
  27.  *
  28.  * Copyright (c) 1992 Lutz Grueneberg
  29.  *
  30.  * This library is free software; you can redistribute it and/or modify
  31.  * it under the terms of the GNU Library General Public License as
  32.  * published by the Free Software Foundation; either version 2 of the
  33.  * License, or (at your option) any later version.  This library is
  34.  * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  35.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  36.  * A PARTICULAR PURPOSE.  See the GNU Library General Public License for
  37.  * more details. You should have received a copy of the GNU Library
  38.  * General Public License along with this library; if not, write to the
  39.  * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  40.  */
  41.  
  42. #define INCL_WIN 
  43. #include <os2.h>
  44.  
  45. #include "session.h"
  46. #include "window.h"
  47. #include "dialog.h"
  48. #include "controls.h"
  49.  
  50. /*
  51.  * methods of class CntrlWindow
  52.  */
  53. CntrlWindow::CntrlWindow( Dialog* pOwnerNew, USHORT idResNew)
  54. {
  55.   pOwner = pOwnerNew;
  56.   idRes  = idResNew;
  57. }
  58.  
  59. HWND CntrlWindow::queryHwnd( VOID)
  60. {
  61.   return pOwner->queryHwnd();
  62. }
  63.  
  64. USHORT CntrlWindow::queryId( VOID)
  65. {
  66.   return idRes;
  67. }
  68.  
  69. BOOL   CntrlWindow::show( BOOL fShow)              /* TRUE signals success */
  70. {
  71.   return WinShowWindow( WinWindowFromID( queryHwnd(), queryId()), fShow);
  72. }
  73.  
  74. BOOL   CntrlWindow::enable( BOOL fEnable)          /* TRUE signals success */
  75. {
  76.   return WinEnableWindow( WinWindowFromID( queryHwnd(), queryId()), fEnable);
  77. }
  78.  
  79. BOOL   CntrlWindow::enableUpdate( BOOL fEnable)    /* TRUE signals success */
  80. {
  81.   return WinEnableWindowUpdate( WinWindowFromID( queryHwnd(), 
  82.                         queryId()), fEnable);
  83. }
  84.  
  85.  
  86.  
  87. /*
  88.  * Methoden der Klasse StaticText
  89.  */
  90.  
  91. StaticText::StaticText( Dialog* pOwnerNew, USHORT idResNew)
  92.      :(pOwnerNew,idResNew){}
  93.  
  94. BOOL StaticText::setText( CHAR* szBuf)
  95. {
  96.   return WinSetDlgItemText( queryHwnd(), queryId(), (PSZ)szBuf);
  97. }
  98.  
  99. SHORT StaticText::queryText( CHAR* szBuf, SHORT sSize)
  100. {
  101.   return (SHORT) WinQueryDlgItemText( queryHwnd(), queryId(), 
  102.                      sSize, (PSZ)szBuf); 
  103. }
  104.  
  105. BOOL StaticText::setShort( SHORT sVal)
  106. {
  107.   return WinSetDlgItemShort( queryHwnd(), queryId(), sVal, TRUE);
  108. }
  109.  
  110. BOOL StaticText::queryShort( SHORT *psVal)
  111. {
  112.   return WinQueryDlgItemShort( queryHwnd(), queryId(), psVal, TRUE);
  113. }
  114.  
  115. BOOL StaticText::setUShort( USHORT usVal)
  116. {
  117.   return WinSetDlgItemShort( queryHwnd(), queryId(), usVal, FALSE);
  118. }
  119.  
  120. BOOL StaticText::queryUShort( USHORT *pusVal)
  121. {
  122.   return WinQueryDlgItemShort( queryHwnd(), queryId(), (SHORT*)pusVal, FALSE);
  123. }
  124.  
  125. SHORT StaticText::queryTextLength( VOID)
  126. {
  127.   return WinQueryDlgItemTextLength( queryHwnd(), queryId());
  128. }
  129.  
  130.  
  131. /*
  132.  * Methoden der Klasse EntryField
  133.  */
  134.  
  135. EntryField::EntryField( Dialog* pOwnerNew, USHORT idResNew)
  136.      :(pOwnerNew,idResNew){}
  137.  
  138. BOOL EntryField::setTextLimit( SHORT sMax)
  139. {
  140.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  141.                     EM_SETTEXTLIMIT,
  142.                     MPFROMSHORT( sMax), 0L));
  143. }
  144.  
  145. /*
  146.  * methods of class ListBox
  147.  */
  148.  
  149. ListBox::ListBox( Dialog* pOwnerNew, USHORT idResNew)
  150.      :(pOwnerNew,idResNew){}
  151.  
  152. BOOL ListBox::deleteAll(VOID)
  153. {
  154.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  155.                     LM_DELETEALL,
  156.                     0L, 0L));
  157. }
  158.   
  159. SHORT ListBox::deleteItem(SHORT iItem)
  160. {
  161.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  162.                     LM_DELETEITEM,
  163.                     MPFROMSHORT( iItem), 0L));
  164. }
  165.  
  166. SHORT ListBox::insertItem(SHORT iItem, CHAR* pszText)
  167. {
  168.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  169.                     LM_INSERTITEM,
  170.                     MPFROMSHORT( iItem), 
  171.                     MPFROMP( pszText)));
  172. }
  173.  
  174. SHORT ListBox::queryItemCount(VOID)
  175. {
  176.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  177.                     LM_QUERYITEMCOUNT,
  178.                     0L, 0L));
  179. }
  180.  
  181. SHORT ListBox::queryItemHandle(SHORT iItem)
  182. {
  183.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  184.                     LM_QUERYITEMCOUNT,
  185.                     MPFROMSHORT(iItem), 0L));
  186. }
  187.  
  188. SHORT ListBox::queryItemText(SHORT iItem, CHAR* pszText, SHORT cch)
  189. {
  190.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  191.                     LM_QUERYITEMTEXT,
  192.                     MPFROM2SHORT(iItem, cch), 
  193.                     MPFROMP(pszText)));
  194. }
  195.  
  196. SHORT ListBox::queryItemTextLength(SHORT iItem)
  197. {
  198.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  199.                     LM_QUERYITEMTEXTLENGTH,
  200.                     MPFROMSHORT(iItem), 0L));
  201. }
  202.  
  203. SHORT ListBox::querySelection(SHORT iItemPrev)
  204. {
  205.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  206.                     LM_QUERYSELECTION,
  207.                     MPFROMSHORT(iItemPrev), 0L));
  208. }
  209.  
  210. SHORT ListBox::queryTopIndex(VOID)
  211. {
  212.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  213.                     LM_QUERYTOPINDEX,
  214.                     0L, 0L));
  215. }
  216.  
  217. SHORT ListBox::searchString(USHORT usCmd, SHORT iItem, CHAR* pszSearch)
  218. {
  219.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  220.                     LM_SEARCHSTRING,
  221.                     MPFROM2SHORT(usCmd, iItem),
  222.                     MPFROMP(pszSearch)));
  223. }
  224.  
  225. BOOL  ListBox::selectItem( SHORT iItem, BOOL fSelect)
  226. {
  227.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  228.                     LM_SELECTITEM,
  229.                     MPFROMSHORT(iItem),
  230.                     MPFROMSHORT(fSelect)));
  231. }
  232.  
  233. BOOL  ListBox::setItemHandle(SHORT iItem, ULONG ulHandle)
  234. {
  235.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  236.                     LM_SETITEMHANDLE,
  237.                     MPFROMSHORT(iItem),
  238.                     MPFROMLONG(ulHandle)));
  239. }
  240.  
  241. BOOL  ListBox::setItemHeight(SHORT sHeight)
  242. {
  243.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  244.                     LM_SETITEMHEIGHT,
  245.                     MPFROMSHORT(sHeight), 0L));
  246. }
  247.  
  248. BOOL  ListBox::setItemText(SHORT iItem, CHAR* pszText)
  249. {
  250.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  251.                     LM_SETITEMTEXT,
  252.                     MPFROMSHORT(iItem),
  253.                     MPFROMLONG(pszText)));
  254. }
  255.  
  256. BOOL  ListBox::setTopIndex(SHORT iItem)
  257. {
  258.   return SHORT1FROMMR(WinSendDlgItemMsg(queryHwnd(), queryId(), 
  259.                     LM_SETTOPINDEX,
  260.                     MPFROMSHORT(iItem), 0L));
  261. }
  262.  
  263. /* E O F */
  264.  
  265.  
  266.