home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool.zip / OOL / source / xvaluset.cpp < prev    next >
C/C++ Source or Header  |  1997-04-05  |  9KB  |  285 lines

  1. #include "xvaluset.h"
  2. #include "xstring.h"
  3. #include "xcolor.h"
  4. #include "xicon.h"
  5. #include "xbitmap.h"
  6.  
  7.  
  8. /*@ 
  9. @class XValueSet
  10. @parent XControl
  11. @type overview
  12. @symbol _
  13. */
  14.  
  15. /*@ XValueSet :: XValueSet(const XWindow * owner, const XRect * rec, const USHORT id, const ULONG style, const char *font)
  16. @group constructors/destructors
  17. @remarks Construct a value-set
  18. @parameters <t '°' c=2>
  19.                 °XWindow * owner         °owner of the value-set
  20.             °XRect * rect            °position and size
  21.             °USHORT id               °control-id
  22.             °ULONG style             °style, possible values are:
  23.                                                 <t '°' c=1>
  24.                                        °VA_ICON
  25.                                        °VA_BITMAP
  26.                                        °VA_COLOR
  27.                                        °VA_TEXT
  28.                                        °VA_BORDER
  29.                                        °VA_ITEMBORDER
  30.                                                 </t>
  31.                                     (can be or-ed)
  32.                 °char * font                    °font to use, e.g. "8.Helv"
  33.                 </t>
  34. */
  35. XValueSet :: XValueSet(const XWindow * owner, const XRect * rec, const USHORT id, const ULONG style, const char *font):XControl(rec, style, owner, "", WC_VALUESET, id, font)
  36. {
  37. }
  38.  
  39.  
  40. /*@ XValueSet::SetDimensions(const SHORT rows, const SHORT cols)
  41. @group misc
  42. @remarks Set the number of colums and rows.
  43. @parameters SHORT rows<BR>
  44.             SHORT cols
  45. */
  46. void XValueSet::SetDimensions(const SHORT rows, const SHORT cols)
  47. {
  48.     VSCDATA data;
  49.  
  50.     data.cbSize = sizeof(data);
  51.     data.usRowCount = rows;
  52.     data.usColumnCount = cols;
  53.  
  54.     WNDPARAMS params;
  55.  
  56.     params.fsStatus = WPM_CTLDATA;
  57.     params.cbCtlData = sizeof(data);
  58.     params.pCtlData = &data;
  59.  
  60.     WinSendMsg(winhandle, WM_SETWINDOWPARAMS, MPFROMP(¶ms), 0);
  61. }
  62.  
  63.  
  64. /*@ XValueSet::SetItem(const SHORT row, const SHORT col, const XColor * color) 
  65. @group item contents
  66. @remarks Set the items color (if VA_COLOR is set)
  67. @parameters <t '°' c=2>
  68.                 °SHORT row    °row of the item
  69.             °SHORT col    °colum of the item
  70.             °XColor * col °the new color
  71.                 </t>
  72. */
  73. void XValueSet::SetItem(const SHORT row, const SHORT col, const XColor * color) const
  74. {
  75.     WinSendMsg(winhandle, VM_SETITEM, MPFROM2SHORT(row + 1, col + 1), (MPARAM) color->GetColor());
  76. }
  77.  
  78.  
  79. /*@ XValueSet::SetItem(const SHORT row, const SHORT col, const char *text) 
  80. @group item contents
  81. @remarks Set the items text (if it is in text-mode)
  82. @parameters <t '°' c=2>
  83.                 °SHORT row   °row of the item
  84.             °SHORT col   °colum of the item
  85.             °char * text °the new text
  86.                 </t>
  87. */
  88. void XValueSet::SetItem(const SHORT row, const SHORT col, const char *text) const
  89. {
  90.     WinSendMsg(winhandle, VM_SETITEM, MPFROM2SHORT(row + 1, col + 1), MPFROMP(text));
  91. }
  92.  
  93.  
  94. /*@ XValueSet::SetItem(const SHORT row, const SHORT col, const XIcon * icon) 
  95. @group item contents
  96. @remarks Set the items content
  97. @parameters <t '°' c=2>
  98.                 °SHORT row    °row of the item
  99.             °SHORT col    °colum of the item
  100.             °XIcon *      °icon
  101.                 </t>
  102. */
  103. void XValueSet::SetItem(const SHORT row, const SHORT col, const XIcon * icon) const
  104. {
  105.     WinSendMsg(winhandle, VM_SETITEM, MPFROM2SHORT(row + 1, col + 1), (MPARAM) icon->GetHandle());
  106. }
  107.  
  108.  
  109. /*@ XValueSet::SetItem(const SHORT row, const SHORT col, const XBitmap * bitmap) 
  110. @group item contents
  111. @remarks Set the items content
  112. @parameters <t '°' c=2>
  113.                 °SHORT row    °row of the item
  114.             °SHORT col    °colum of the item
  115.             °XBitmap *    °bitmap
  116.                 </t>
  117. */
  118. void XValueSet::SetItem(const SHORT row, const SHORT col, const XBitmap * bitmap) const
  119. {
  120.     WinSendMsg(winhandle, VM_SETITEM, MPFROM2SHORT(row + 1, col + 1), (MPARAM) bitmap->GetHandle());
  121. }
  122.  
  123.  
  124. /*@ XValueSet::SetItemAttribute(const SHORT row, const SHORT col, const SHORT attr, const BOOL enable) 
  125. @group item attributes
  126. @remarks Set the items attributes
  127. @parameters <t '°' c=2>
  128.                 °SHORT row    °row of the item
  129.             °SHORT col    °colum of the item
  130.             °SHORT attr   °the attribute:
  131.                                     <t '°' c=1>
  132.                             °VA_ICON
  133.                             °VA_BITMAP
  134.                             °VA_COLOR
  135.                             °VA_TEXT
  136.                             °VA_ITEMBORDER
  137.                                     </t>
  138.             °BOOL enable  enabe/disable attribute
  139.                 </t>
  140. */
  141. void XValueSet::SetItemAttribute(const SHORT row, const SHORT col, const SHORT attr, const BOOL enable) const
  142. {
  143.     WinSendMsg(winhandle, VM_SETITEMATTR, MPFROM2SHORT(row + 1, col + 1), MPFROM2SHORT(attr, enable));
  144. }
  145.  
  146.  
  147. /*@ XValueSet::SelectItem(const SHORT row, const SHORT col) 
  148. @group selection
  149. @remarks Select an item
  150. @parameters SHORT row    row of the item<BR>
  151.             SHORT col    colum of the item
  152. */
  153. void XValueSet::SelectItem(const SHORT row, const SHORT col) const
  154. {
  155.     WinSendMsg(winhandle, VM_SELECTITEM, MPFROM2SHORT(row + 1, col + 1), 0);
  156. }
  157.  
  158.  
  159. /*@ XValueSet::SetItemSpacing(const XSize * s)
  160. @group size
  161. @remarks Set the spacing between the items.
  162. @parameters XSize * size
  163. */
  164. void XValueSet::SetItemSpacing(const XSize * s) const
  165. {
  166.     WinSendMsg(winhandle, VM_SETMETRICS, MPFROMSHORT(VMA_ITEMSPACING), MPFROM2SHORT( s->GetWidth(), s->GetHeight()));
  167. }
  168.  
  169.  
  170. /*@ XValueSet::SetItemSize(const XSize * s)
  171. @group size
  172. @remarks Set the size of the items.
  173. @parameters XSize * size
  174. */
  175. void XValueSet::SetItemSize(const XSize * s) const
  176. {
  177.     WinSendMsg(winhandle, VM_SETMETRICS, MPFROMSHORT(VMA_ITEMSIZE), MPFROM2SHORT(s->GetWidth(), s->GetHeight()));
  178. }
  179.  
  180.  
  181. /*@ XValueSet::GetSelection(SHORT & row, SHORT & col)
  182. @group selection
  183. @remarks Returns column/row of the selected item.
  184. @parameters SHORT& row    row of the item<BR>
  185.             SHORT& col    colum of the item
  186. */
  187. void XValueSet::GetSelection(SHORT & row, SHORT & col)
  188. {
  189.     MRESULT mr = WinSendMsg(winhandle, VM_QUERYSELECTEDITEM, 0, 0);
  190.  
  191.     row = SHORT1FROMMR(mr) - 1;
  192.     col = SHORT2FROMMR(mr) - 1;
  193. }
  194.  
  195.  
  196. /*@ XValueSet::GetItem(const SHORT row, const SHORT col, XString * s)
  197. @group item contents
  198. @remarks Get the items text (if it is in text-mode)
  199. @parameters <t '°' c=2>
  200.                 °SHORT row        °row of the item
  201.             °SHORT col        °colum of the item
  202.             °XString * °buffer buffer to hold the text
  203.                 </t>
  204. */
  205. void XValueSet::GetItem(const SHORT row, const SHORT col, XString * s)
  206. {
  207.     VSTEXT text;
  208.  
  209.     text.pszItemText = (PSZ) s->GetBuffer(512);
  210.     text.ulBufLen = 512;
  211.     WinSendMsg(winhandle, VM_QUERYITEM, MPFROM2SHORT(row + 1, col + 1), MPFROMP(&text));
  212.     s->ReleaseBuffer();
  213. }
  214.  
  215.  
  216. /*@ XValueSet::GetItem(const SHORT row, const SHORT col, XColor * color)
  217. @group item contents
  218. @remarks Get the items color
  219. @parameters <t '°' c=2>
  220.                 °SHORT row        °row of the item
  221.             °SHORT col        °colum of the item
  222.             °XColor * col     °buffer to hold the color
  223.                 </t>
  224. */
  225. void XValueSet::GetItem(const SHORT row, const SHORT col, XColor * color)
  226. {
  227.     color->SetColor((LONG) WinSendMsg(winhandle, VM_QUERYITEM, MPFROM2SHORT(row + 1, col + 1), 0));
  228. }
  229.  
  230.  
  231. /*@ XValueSet::GetItem(const SHORT row, const SHORT col, LONG & val)
  232. @group item contents
  233. @remarks Get the items icon/bitmap-handle
  234. @parameters <t '°' c=2>
  235.                 °SHORT row        °row of the item
  236.             °SHORT col        °colum of the item
  237.             °LONG& value      °icon/bitmap-handle from the item
  238.                 </t>
  239. */
  240. void XValueSet::GetItem(const SHORT row, const SHORT col, LONG & val)
  241. {
  242.     val = (LONG) WinSendMsg(winhandle, VM_QUERYITEM, MPFROM2SHORT(row + 1, col + 1), 0);
  243. }
  244.  
  245.  
  246. /*@ XValueSet::GetItem(const SHORT row, const SHORT col, LONG & val)
  247. @group item attributes
  248. @remarks Get the items attributes
  249. @parameters SHORT row    row of the item<BR>
  250.             SHORT col    colum of the item
  251. @returns  SHORT theAttribute
  252. */
  253. LONG XValueSet::GetItemAttribute(const SHORT row, const SHORT col) const
  254. {
  255.     return (LONG) WinSendMsg(winhandle, VM_QUERYITEMATTR, MPFROM2SHORT(row + 1, col + 1), 0);
  256. }
  257.  
  258.  
  259. /*@ XValueSet::GetItemSpacing(XSize*)
  260. @group size
  261. @remarks Returns the spacing between the items
  262. @parameters XSize * buffer to hold horizontal(vertical spacing
  263. */
  264. void XValueSet::GetItemSpacing( XSize * s)
  265. {
  266.     MRESULT mr = WinSendMsg(winhandle, VM_QUERYMETRICS, MPFROMSHORT(VMA_ITEMSPACING), 0);
  267.  
  268.     s->SetWidth( SHORT1FROMMR(mr));
  269.     s->SetHeight( SHORT2FROMMR(mr));
  270. }
  271.  
  272.  
  273. /*@ XValueSet::GetItemSize(XSize *)
  274. @group size
  275. @remarks Returns the size of the items
  276. @parameters XSize * size     bufer to hold the size
  277. */
  278. void XValueSet::GetItemSize(XSize * size)
  279. {
  280.     MRESULT mr = WinSendMsg(winhandle, VM_QUERYMETRICS, MPFROMSHORT(VMA_ITEMSIZE), 0);
  281.  
  282.     size->SetWidth( SHORT1FROMMR(mr));
  283.     size->SetHeight( SHORT2FROMMR(mr));
  284. }
  285.