home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ocl150a.zip / OCL / Source / OContainerBase.cpp < prev    next >
C/C++ Source or Header  |  1996-09-23  |  10KB  |  385 lines

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // OContainerBase.cpp
  5.  
  6. /*
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  13.  *    endorse or promote products derived from this software
  14.  *    without specific prior written permission.
  15.  * 3. See OCL.INF for a detailed copyright notice.
  16.  *
  17.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  18.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  21.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27.  * SUCH DAMAGE.
  28.  */
  29.  
  30.  
  31. // $Header: W:/Projects/OCL/Source/rcs/OContainerBase.cpp 1.50 1996/08/11 23:49:12 B.STEIN Release $
  32.  
  33. #define __OCL_SOURCE__
  34.  
  35. #define OINCL_OSTRING
  36. #define OINCL_BASE
  37.  
  38. #include <ocl.hpp>
  39. #include <OContainer.hpp>
  40.  
  41.  
  42. OContainerBase::OContainerBase(const ULONG id,
  43.                                const HWND Parent,
  44.                                const ULONG cnrStyle, 
  45.                                const ULONG initViewStyle)
  46.   : OWindow(id, cnrStyle, 0)
  47. {
  48.  parent = owner = Parent;
  49.  cnri.flWindowAttr = initViewStyle;
  50.  hwnd = NULLHANDLE;
  51. }
  52.  
  53.  
  54. OContainerBase::OContainerBase(const ULONG id,
  55.                                const pOFrame Parent, 
  56.                                const ULONG cnrStyle, 
  57.                                const ULONG initViewStyle)
  58.   : OWindow(id, cnrStyle, 0)
  59. {
  60.  parent = Parent->client;
  61.  owner  = Parent->frame;
  62.  cnri.flWindowAttr = initViewStyle;
  63.  hwnd = NULLHANDLE;
  64. }
  65.  
  66.  
  67. OContainerBase::OContainerBase(const ULONG id,
  68.                                const OFrame& Parent, 
  69.                                const ULONG cnrStyle, 
  70.                                const ULONG initViewStyle)
  71.   : OWindow(id, cnrStyle, 0)
  72.  parent = Parent.client;
  73.  owner  = Parent.frame;
  74.  cnri.flWindowAttr = initViewStyle;
  75.  hwnd = NULLHANDLE;
  76.  
  77.  
  78.  
  79. OContainerBase::~OContainerBase() 
  80.   {}
  81.  
  82.  
  83. PSZ OContainerBase::isOfType() const
  84.  return("OContainerBase"); 
  85. }
  86.  
  87.  
  88. OContainerBase& OContainerBase::createContainer()
  89. {
  90.  if (!hwnd)
  91.   {
  92.    if ((hwnd = WinCreateWindow(parent, WC_CONTAINER, "",
  93.                                style, 0, 0, 0, 0,
  94.                                owner, HWND_TOP,
  95.                                res, this, NULL)) == NULLHANDLE)
  96.      throw OPMException(OCL::error(165), 0);
  97.   }
  98.  
  99.  if ((!setupDetails()) || (!setupItems()))
  100.    throw OPMException(OCL::error(166), 0);
  101.  
  102.  if (cnri.flWindowAttr & CA_CONTAINERTITLE)
  103.    setTitle(winText);
  104.  else
  105.    setView(cnri.flWindowAttr);
  106.  
  107.  show();
  108.  
  109.  return(*this);
  110. }
  111.  
  112.  
  113. OWindow& OContainerBase::inherit(const HWND hwndDlg)
  114. {
  115.  OWindow::inherit(hwndDlg);
  116.  createContainer();
  117.  return(*this);
  118. }
  119.  
  120.  
  121. BOOL OContainerBase::freeDetails()
  122. {
  123.  if (!hwnd) return(FALSE);
  124.  
  125.  WinSendMsg(hwnd, CM_REMOVEDETAILFIELDINFO, NULL,
  126.             MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE));
  127.  return(TRUE);
  128. }
  129.  
  130.  
  131. BOOL OContainerBase::freeItems()
  132. {
  133.  if (!hwnd) return(FALSE);
  134.  
  135.  WinSendMsg(hwnd, CM_REMOVERECORD, NULL,
  136.             MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE));
  137.  return(TRUE);
  138. }
  139.  
  140.  
  141.  
  142. BOOL OContainerBase::freeContainer()
  143. {
  144.  return(freeItems() && freeDetails());
  145. }
  146.  
  147.  
  148. BOOL OContainerBase::setTitle(PSZ title)
  149. {
  150.  if (title) {
  151.    winText << title;
  152.    cnri.pszCnrTitle = winText;
  153.    return(setCnrInfo(CMA_FLWINDOWATTR | CMA_CNRTITLE) && invalidateDetails()); }
  154.  return(FALSE);
  155. }
  156.  
  157.  
  158. BOOL OContainerBase::setView(ULONG viewStyle)
  159. {
  160.  cnri.flWindowAttr = viewStyle;
  161.  return(setCnrInfo(CMA_FLWINDOWATTR) && invalidateDetails()); 
  162. }
  163.  
  164.  
  165. /***********************************************************************************************************/
  166. /* Services                                                                                                */
  167. /***********************************************************************************************************/
  168.  
  169.  
  170. PFIELDINFO  OContainerBase::allocDetailFields(ULONG fields) const
  171. {
  172.  return((PFIELDINFO)WinSendMsg(hwnd, 
  173.                                CM_ALLOCDETAILFIELDINFO, 
  174.                                MPFROMSHORT(fields), 
  175.                                NULL));
  176. }
  177.  
  178.  
  179. PRECORDCORE OContainerBase::_allocRecords(ULONG additional, ULONG records) const
  180. {
  181.  return((PRECORDCORE)WinSendMsg(hwnd, 
  182.                                 CM_ALLOCRECORD, 
  183.                                 MPFROMSHORT(additional), 
  184.                                 MPFROMSHORT(records)));
  185. }
  186.  
  187.  
  188. BOOL OContainerBase::arrangeRecords() const
  189. {
  190.  return((BOOL)WinSendMsg(hwnd, 
  191.                          CM_ARRANGE, 
  192.                          NULL, 
  193.                          NULL));
  194. }
  195.  
  196.  
  197.  
  198. BOOL OContainerBase::collapseTree(PVOID rootRecord) const
  199. {
  200.  return((BOOL)WinSendMsg(hwnd, 
  201.                          CM_COLLAPSETREE, 
  202.                          MPFROMP(rootRecord), 
  203.                          NULL));
  204. }
  205.  
  206.  
  207.  
  208. BOOL OContainerBase::expandTree(PVOID rootRecord) const
  209. {
  210.  return((BOOL)WinSendMsg(hwnd, 
  211.                          CM_EXPANDTREE, 
  212.                          MPFROMP(rootRecord), 
  213.                          NULL));
  214. }
  215.  
  216.  
  217.  
  218. BOOL OContainerBase::openEdit(PCNREDITDATA editData) const
  219. {
  220.  return((BOOL)WinSendMsg(hwnd, 
  221.                          CM_OPENEDIT, 
  222.                          MPFROMP(editData), 
  223.                          NULL));
  224. }
  225.  
  226.  
  227.  
  228. BOOL OContainerBase::closeEdit() const
  229. {
  230.  return((BOOL)WinSendMsg(hwnd, 
  231.                          CM_CLOSEEDIT, 
  232.                          NULL, 
  233.                          NULL));
  234. }
  235.  
  236.  
  237.  
  238. BOOL OContainerBase::eraseRecord(PVOID record) const
  239. {
  240.  return((BOOL)WinSendMsg(hwnd, 
  241.                          CM_ERASERECORD, 
  242.                          MPFROMP(record), 
  243.                          NULL));
  244. }
  245.  
  246.  
  247. BOOL OContainerBase::freeDetailInfo(PFIELDINFO rootRecord, ULONG count) const
  248. {
  249.  return((BOOL)WinSendMsg(hwnd, 
  250.                          CM_FREEDETAILFIELDINFO, 
  251.                          MPFROMP(rootRecord), 
  252.                          MPFROMSHORT(count)));
  253. }
  254.  
  255.  
  256. BOOL OContainerBase::freeRecord(PVOID rootRecord, ULONG count) const
  257. {
  258.  return((BOOL)WinSendMsg(hwnd, 
  259.                          CM_FREERECORD, 
  260.                          MPFROMP(rootRecord), 
  261.                          MPFROMSHORT(count)));
  262. }
  263.  
  264.  
  265. BOOL OContainerBase::removeDetailInfo(PFIELDINFO rootRecord, ULONG count, ULONG flag) const
  266. {
  267.  return((BOOL)WinSendMsg(hwnd,
  268.                          CM_REMOVEDETAILFIELDINFO,
  269.                          MPFROMP(rootRecord),
  270.                          MPFROM2SHORT(count, flag)));
  271. }
  272.  
  273.  
  274. BOOL OContainerBase::removeRecord(PVOID rootRecord, ULONG count, ULONG flag) const
  275. {
  276.  return((BOOL)WinSendMsg(hwnd,
  277.                          CM_REMOVERECORD,
  278.                          MPFROMP(rootRecord),
  279.                          MPFROM2SHORT(count, flag)));
  280. }
  281.  
  282.  
  283. BOOL OContainerBase::filter(PFN function, PVOID storage) const
  284. {
  285.  return(FALSE);
  286. }
  287.  
  288.  
  289. BOOL OContainerBase::insertDetailInfo(PFIELDINFO info, PFIELDINFOINSERT insert) const
  290. {
  291.  return((BOOL)WinSendMsg(hwnd, 
  292.                          CM_INSERTDETAILFIELDINFO, 
  293.                          MPFROMP(info), 
  294.                          MPFROMP(insert)));
  295. }
  296.  
  297.  
  298. BOOL OContainerBase::insertRecord(PVOID rootRecord, PRECORDINSERT insert) const
  299. {
  300.  return((BOOL)WinSendMsg(hwnd, 
  301.                          CM_INSERTRECORD, 
  302.                          MPFROMP(rootRecord), 
  303.                          MPFROMP(insert)));
  304. }
  305.  
  306.  
  307.  
  308. BOOL OContainerBase::invalidateDetails() const
  309. {
  310.  return((BOOL)WinSendMsg(hwnd, 
  311.                          CM_INVALIDATEDETAILFIELDINFO, 
  312.                          NULL, NULL));
  313. }
  314.  
  315.  
  316. BOOL OContainerBase::invalidateRecord(PVOID rootRecord, ULONG flag, ULONG count) const
  317. {
  318.  return((BOOL)WinSendMsg(hwnd, 
  319.                          CM_INVALIDATERECORD, 
  320.                          MPFROMP(rootRecord), 
  321.                          MPFROM2SHORT(count, flag)));
  322. }
  323.  
  324.  
  325. ULONG OContainerBase::queryCnrInfo() const
  326. {
  327.  return((ULONG)WinSendMsg(hwnd, 
  328.                           CM_QUERYCNRINFO, 
  329.                           MPFROMP(&cnri), 
  330.                           MPFROMSHORT(sizeof(CNRINFO))));
  331. }
  332.  
  333.  
  334. PFIELDINFO OContainerBase::queryDetailInfo(PFIELDINFO rootRecord, ULONG flag) const
  335. {
  336.  return((PFIELDINFO)WinSendMsg(hwnd, 
  337.                                CM_QUERYDETAILFIELDINFO, 
  338.                                MPFROMP(rootRecord),
  339.                                MPFROMSHORT(flag)));
  340. }
  341.  
  342.  
  343. PRECORDCORE OContainerBase::_queryRecord(PVOID rootRecord, ULONG flag, ULONG order) const
  344. {
  345.  return((PRECORDCORE)WinSendMsg(hwnd, 
  346.                                 CM_QUERYRECORD, 
  347.                                 MPFROMP(rootRecord), 
  348.                                 MPFROM2SHORT(flag, order)));
  349. }
  350.  
  351.  
  352. PRECORDCORE OContainerBase::_queryEmphasis(PVOID record, ULONG flag) const
  353. {
  354.  return((PRECORDCORE)WinSendMsg(hwnd, 
  355.                                 CM_QUERYRECORDEMPHASIS, 
  356.                                 MPFROMP(record), 
  357.                                 MPFROMSHORT(flag)));
  358. }
  359.  
  360.  
  361.  
  362. BOOL OContainerBase::setCnrInfo(ULONG attributeFlag) const
  363. {
  364.  return((BOOL)WinSendMsg(hwnd, 
  365.                          CM_SETCNRINFO, 
  366.                          MPFROMP(&cnri), 
  367.                          MPFROMSHORT(attributeFlag)));
  368. }
  369.  
  370.  
  371.  
  372. BOOL OContainerBase::setEmphasis(PVOID record, ULONG emphasis, BOOL set) const
  373. {
  374.  return((BOOL)WinSendMsg(hwnd, 
  375.                          CM_SETRECORDEMPHASIS, 
  376.                          MPFROMP(record),
  377.                          MPFROM2SHORT(set, emphasis)));
  378. }
  379.  
  380.  
  381. // end of source
  382.