home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ocl150a.zip / OCL / Source / OSpinBtn.cpp < prev    next >
C/C++ Source or Header  |  1996-08-12  |  5KB  |  189 lines

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // (c) 1994 Matthias Stübner
  5. // All Rights Reserved
  6. // OSpinBtn.cpp
  7.  
  8.  
  9. /*
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions
  12.  * are met:
  13.  * 1. Redistributions of source code must retain the above copyright
  14.  *    notice, this list of conditions and the following disclaimer.
  15.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  16.  *    endorse or promote products derived from this software
  17.  *    without specific prior written permission.
  18.  * 3. See OCL.INF for a detailed copyright notice.
  19.  *
  20.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  21.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  24.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30.  * SUCH DAMAGE.
  31.  */
  32.  
  33. // $Header: W:/Projects/OCL/Source/rcs/OSpinBtn.cpp 1.50 1996/08/11 23:49:31 B.STEIN Release $
  34.  
  35. #define __OCL_SOURCE__
  36.  
  37. #define OINCL_OSTRING
  38. #define OINCL_BASE
  39.  
  40. #include <ocl.hpp>
  41. #include <OSpinBtn.hpp>
  42.  
  43.  
  44. OSpinBtn::OSpinBtn(const ULONG id,
  45.                    const HWND  Parent,  // becomes parent and owner of the slider
  46.                    const ULONG Style)
  47.   : OWindow(id, 0, 0)
  48. {
  49.  style  = Style;
  50.  parent = Parent;
  51.  owner  = Parent;
  52. }
  53.  
  54.  
  55. OSpinBtn::OSpinBtn(const ULONG id,
  56.                    const OFrame& Parent,
  57.                    const ULONG Style)
  58.   : OWindow(id, 0, 0)
  59. {
  60.  style  = Style;
  61.  parent = Parent.hwnd;
  62.  owner  = Parent.hwnd;
  63. }
  64.  
  65.  
  66. OSpinBtn::OSpinBtn(const ULONG id,
  67.                    const pOFrame Parent,
  68.                    const ULONG Style)
  69.  : OWindow(id, 0, 0)
  70. {
  71.  style  = Style;
  72.  parent = Parent->hwnd;
  73.  owner  = Parent->hwnd;
  74. }
  75.  
  76. // dtor
  77.  
  78. OSpinBtn::~OSpinBtn()
  79.   {}
  80.  
  81.  
  82. PSZ OSpinBtn::isOfType() const
  83.  return("OSpinBtn"); 
  84. }
  85.  
  86.  
  87. BOOL OSpinBtn::createSpinBtn(const SHORT x, const SHORT y, 
  88.                              const SHORT cx, const SHORT cy)
  89. {
  90.  hwnd = WinCreateWindow(parent, WC_SPINBUTTON, NULL, style | WS_VISIBLE,
  91.                         x, y, cx, cy,
  92.                         owner, HWND_TOP, 0, NULL, NULL);
  93.  
  94.  return(hwnd != NULLHANDLE);
  95. }
  96.  
  97.  
  98. BOOL OSpinBtn::setArray(PSZ array, ULONG num)
  99. {
  100.   return((BOOL)WinSendMsg (hwnd, SPBM_SETARRAY,
  101.                      MPFROMP (array),
  102.                      MPFROMLONG (num)));
  103. }
  104.  
  105. BOOL OSpinBtn::setCurrent(LONG index)
  106. {
  107.   return((BOOL)WinSendMsg (hwnd, SPBM_SETCURRENTVALUE,
  108.                      MPFROMLONG(index),0));
  109. }
  110.  
  111. BOOL OSpinBtn::setLimits(LONG upper, LONG lower)
  112. {
  113.   return((BOOL)WinSendMsg (hwnd, SPBM_SETLIMITS,
  114.                      MPFROMLONG(upper),
  115.                      MPFROMLONG(lower)));
  116. }
  117.  
  118. BOOL OSpinBtn::setMaster(HWND master)
  119. {
  120.   return((BOOL)WinSendMsg (hwnd, SPBM_SETMASTER,
  121.                      MPFROMP(master),0));
  122. }
  123.  
  124. BOOL OSpinBtn::setTextLimit(USHORT length)
  125. {
  126.   return((BOOL)WinSendMsg (hwnd, SPBM_SETTEXTLIMIT,
  127.                      MPFROMSHORT(length),0));
  128. }
  129.  
  130. BOOL OSpinBtn::overrideLimits(LONG upper, LONG lower)
  131. {
  132.   return((BOOL)WinSendMsg (hwnd, SPBM_OVERRIDESETLIMITS,
  133.                      MPFROMLONG(upper),
  134.                      MPFROMLONG(lower)));
  135. }
  136.  
  137. BOOL OSpinBtn::incSpin(ULONG delta)
  138. {
  139.   return((BOOL)WinSendMsg (hwnd, SPBM_SPINUP,
  140.                      MPFROMLONG(delta),0));
  141. }
  142.  
  143. BOOL OSpinBtn::decSpin(ULONG delta)
  144. {
  145.   return((BOOL)WinSendMsg (hwnd, SPBM_SPINDOWN,
  146.                      MPFROMLONG(delta),0));
  147. }
  148.  
  149. BOOL OSpinBtn::getLimits(LONG *upper, LONG *lower)
  150. {
  151.   return((BOOL)WinSendMsg(hwnd,SPBM_QUERYLIMITS,
  152.                      MPFROMP(upper),MPFROMP(lower)));
  153. }
  154.  
  155. BOOL OSpinBtn::getCurrent(PVOID addr, USHORT size, USHORT control)
  156. {
  157.   return((BOOL)WinSendMsg (hwnd, SPBM_QUERYVALUE,
  158.                      MPFROMP(addr),
  159.                      MPFROM2SHORT(size,control)));
  160. }
  161.  
  162. BOOL OSpinBtn::jumptoEnd()
  163. {
  164.   while(WinSendMsg(hwnd,SPBM_SPINUP,MPFROMLONG(1),0)) {}
  165.   return(TRUE);
  166. }
  167.  
  168. BOOL OSpinBtn::jumptoStart()
  169. {
  170.   while(WinSendMsg(hwnd,SPBM_SPINDOWN,MPFROMLONG(1),0)) {}
  171.   return(TRUE);
  172. }
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.