home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWViews / FWListBx.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  36.9 KB  |  1,291 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWListBx.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWLISTBX_H
  13. #include "FWListBx.h"
  14. #endif
  15.  
  16. #ifndef FWFRAME_H
  17. #include "FWFrame.h"
  18. #endif
  19.  
  20. #ifndef FWCONTXT_H
  21. #include "FWContxt.h"
  22. #endif
  23.  
  24. #ifndef FWWINDOW_H
  25. #include "FWWindow.h"
  26. #endif
  27.  
  28. #ifndef FWEVENT_H
  29. #include "FWEvent.h"
  30. #endif
  31.  
  32. #ifndef FWNOTDEF_H
  33. #include "FWNotDef.h"
  34. #endif
  35.  
  36. #ifndef FWEVEDEF_H
  37. #include "FWEveDef.h"
  38. #endif
  39.  
  40. #ifndef FWITERS_H
  41. #include "FWIters.h"
  42. #endif
  43.  
  44. #ifndef FWRECSHP_H
  45. #include "FWRecShp.h"
  46. #endif
  47.  
  48. #ifndef FWCURSOR_H
  49. #include "FWCursor.h"
  50. #endif
  51.  
  52. #ifndef FWSOMENV_H
  53. #include "FWSOMEnv.h"
  54. #endif
  55.  
  56. #ifndef SLREGION_H
  57. #include "SLRegion.h"
  58. #endif
  59.  
  60. #ifndef SOM_ODFacet_xh
  61. #include <Facet.xh>
  62. #endif
  63.  
  64. //========================================================================================
  65. // File scope definitions
  66. //========================================================================================
  67.  
  68. #ifdef FW_BUILD_MAC
  69. #pragma segment fwgadgts
  70. #endif
  71.  
  72. //========================================================================================
  73. // CLASS FW_CListBox
  74. //========================================================================================
  75.  
  76. FW_DEFINE_AUTO(FW_CListBox)
  77. FW_DEFINE_CLASS_M2(FW_CListBox, FW_CView, FW_MNotifier)
  78.  
  79. // This class is archivable, but we provide the archiving implementation in a separate
  80. // translation unit in order to enable deadstripping of the archiving-related code
  81. // in parts that do not use archiving with this class.
  82.  
  83. //----------------------------------------------------------------------------------------
  84. // FW_CListBox::FW_CListBox
  85. //----------------------------------------------------------------------------------------
  86.  
  87. FW_CListBox::FW_CListBox (Environment* ev, 
  88.                         FW_CSuperView* container,
  89.                         const FW_CRect& bounds,
  90.                         ODID id,
  91.                         int    numRows,
  92.                         FW_Boolean scrollVert,
  93.                         const FW_CFont&    font,
  94.                         FW_Message doubleClick,
  95.                         FW_Boolean singleSelection,
  96.                         FW_Boolean useFocusFrame,
  97.                         FW_Boolean useClientData) :
  98.     FW_CView(ev, container, bounds, id),
  99. #ifdef FW_BUILD_MAC
  100.     fPlatformList(NULL),
  101.     fMacFocusFrame(useFocusFrame),
  102.     fMacFocusFrameOn(FALSE),
  103.     fMacFontID(1),
  104.     fMacFontStyle(0),
  105.     fMacFontSize(12),
  106. #endif
  107.     fDoubleClickMsg(doubleClick),
  108.     fSingleSelection(singleSelection),
  109.     fUseClientData(useClientData)
  110. {
  111. #ifdef FW_BUILD_MAC
  112.     InitMacListBox(ev, bounds, numRows, scrollVert, font);
  113. #endif    
  114.     FW_END_CONSTRUCTOR
  115. }
  116.                 
  117. //----------------------------------------------------------------------------------------
  118. // FW_CListBox::FW_CListBox
  119. //----------------------------------------------------------------------------------------
  120.  
  121. FW_CListBox::FW_CListBox (Environment* ev) :
  122.     FW_CView(ev),
  123. #ifdef FW_BUILD_MAC
  124.     fPlatformList(NULL),
  125.     fMacFocusFrame(FALSE),
  126.     fMacFocusFrameOn(FALSE),
  127.     fMacFontID(1),
  128.     fMacFontStyle(0),
  129.     fMacFontSize(12),
  130. #endif
  131.     fDoubleClickMsg(0),
  132.     fSingleSelection(TRUE),
  133.     fDrawingMode(FALSE),
  134.     fUseClientData(FALSE)
  135. {
  136.     FW_END_CONSTRUCTOR
  137. }
  138.                 
  139. //----------------------------------------------------------------------------------------
  140. // FW_CListBox::~FW_CListBox
  141. //----------------------------------------------------------------------------------------
  142.  
  143. FW_CListBox::~FW_CListBox()
  144. {
  145.     FW_START_DESTRUCTOR
  146. }
  147.  
  148. //----------------------------------------------------------------------------------------
  149. //    FW_CListBox::AdjustCursor
  150. //----------------------------------------------------------------------------------------
  151.  
  152. FW_Handled FW_CListBox::AdjustCursor(Environment *ev, ODFacet* odFacet, const FW_CPoint& theMousePoint, ODEventInfo* eventInfo)
  153. {
  154. FW_UNUSED(ev);
  155. FW_UNUSED(odFacet);
  156. FW_UNUSED(theMousePoint);
  157. FW_UNUSED(eventInfo);
  158.  
  159.     FW_gArrowCursor.Select();
  160.     return FW_kHandled;
  161. }
  162.  
  163. //----------------------------------------------------------------------------------------
  164. // FW_CListBox::DoMouseDown
  165. //----------------------------------------------------------------------------------------
  166.  
  167. FW_Handled FW_CListBox::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
  168. {
  169.  
  170. #ifdef FW_BUILD_MAC
  171.     // Need a view context to set the correct origin before using the list Manager
  172.     ODFacet* odFacet = theMouseEvent.GetFacet(ev);
  173.     FW_CViewContext gc(ev, this, odFacet);
  174.     
  175.     FW_CPoint canvasWhere = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kWindow);
  176.     FW_CPlatformPoint qdWhere    = canvasWhere.AsPlatformPoint();
  177.  
  178.     SetupListBox(gc, TRUE, &qdWhere);
  179.  
  180.     if (::LClick(qdWhere, theMouseEvent.GetPlatformModifiers(ev), fPlatformList)) 
  181.     {
  182.         if (fDoubleClickMsg != 0)
  183.             Notify(ev, FW_CListBoxNotification(this));        
  184.     }    
  185.  
  186. #endif
  187.     return FW_kHandled;
  188. }
  189.  
  190. //----------------------------------------------------------------------------------------
  191. // FW_CListBox::DoActivateEvent
  192. //----------------------------------------------------------------------------------------
  193.  
  194. void FW_CListBox::DoActivateEvent(Environment *ev, const FW_CActivateEvent& theActivateEvent)
  195. {
  196. #ifdef FW_BUILD_MAC
  197.     // Need a view context to set the correct origin before using the list Manager
  198.     FW_CViewContext gc(ev, this, theActivateEvent.GetFacet(ev), NULL);
  199.     SetupListBox(gc);
  200.  
  201.     ::LActivate(theActivateEvent.IsActivating(ev), fPlatformList);
  202. #endif
  203. }
  204.  
  205. //----------------------------------------------------------------------------------------
  206. // FW_CListBox::WantsToBeTarget
  207. //----------------------------------------------------------------------------------------
  208.  
  209. FW_Boolean FW_CListBox::WantsToBeTarget(Environment* ev)
  210. {
  211. FW_UNUSED(ev);
  212.     // Let visible list views process keys and menu commands
  213.     if (IsVisible(ev))
  214.         return TRUE;
  215.     else
  216.         return FALSE;
  217. }
  218.  
  219. //----------------------------------------------------------------------------------------
  220. // FW_CListBox::ActivateTarget
  221. //----------------------------------------------------------------------------------------
  222.  
  223. void FW_CListBox::ActivateTarget (Environment * ev, FW_Boolean tabSelection)
  224. {
  225. FW_UNUSED(tabSelection);
  226.  
  227. #ifdef FW_BUILD_MAC
  228.     if (fMacFocusFrame) 
  229.     {
  230.         fMacFocusFrameOn = TRUE;
  231.         
  232.         FW_CViewContext gc(ev, this, GetFrame(ev)->GetActiveFacet(ev), NULL);
  233.         FW_CRect viewRect(FW_kZeroPoint, GetSize(ev));
  234.         FW_CRectShape::RenderRect( gc, viewRect, FW_kFrame,
  235.                                     FW_kNormalInk, FW_CStyle(FW_IntToFixed(2)));
  236.     }
  237. #endif
  238. }
  239.  
  240. //----------------------------------------------------------------------------------------
  241. // FW_CListBox::DeactivateTarget
  242. //----------------------------------------------------------------------------------------
  243.  
  244. void FW_CListBox::DeactivateTarget (Environment * ev)
  245. {
  246. #ifdef FW_BUILD_MAC
  247.     if (fMacFocusFrameOn) 
  248.     {
  249.         fMacFocusFrameOn = FALSE;
  250.         
  251.         ODFacet* facet = GetFrame(ev)->GetActiveFacet(ev);
  252.         if (facet)
  253.         {
  254.             FW_CViewContext gc(ev, this, facet, NULL);
  255.             FW_CRect viewRect(FW_kZeroPoint, GetSize(ev));
  256.             // [LSD] FW_kWhiteEraseInk won't always be good
  257.             FW_CRectShape::RenderRect( gc, viewRect, FW_kFrame,
  258.                                         FW_kWhiteEraseInk, FW_CStyle(FW_IntToFixed(2)));
  259.         }
  260.     }
  261. #endif
  262. }
  263.  
  264. //----------------------------------------------------------------------------------------
  265. // FW_CListBox::SetVisible
  266. //----------------------------------------------------------------------------------------
  267.  
  268. void FW_CListBox::SetVisible(Environment* ev, FW_Boolean visible, FW_Boolean propagate)
  269. {
  270.     FW_CView::SetVisible(ev, visible, propagate);
  271.     
  272.     if (visible)
  273.     {
  274. #ifdef FW_BUILD_MAC
  275.         MacSetVisible(ev, TRUE);
  276. #endif
  277.     }
  278.     else
  279.     {
  280.         SetDrawingMode(ev, FALSE);
  281.         ResignTarget(ev);
  282.     }
  283. }
  284.  
  285. //----------------------------------------------------------------------------------------
  286. // FW_CListBox::SetDrawingMode
  287. //----------------------------------------------------------------------------------------
  288.  
  289. FW_Boolean FW_CListBox::SetDrawingMode(Environment* ev, FW_Boolean draw)
  290. {
  291. FW_UNUSED(ev);
  292.     FW_Boolean oldMode = fDrawingMode;
  293.     
  294.     if (oldMode != draw)
  295.     {
  296.         fDrawingMode = draw;
  297. #ifdef FW_BUILD_MAC
  298.         ::LSetDrawingMode(draw, fPlatformList);
  299. #endif
  300.     }
  301.     
  302.     return oldMode;
  303. }
  304.  
  305. //----------------------------------------------------------------------------------------
  306. // FW_CListBox::Draw
  307. //----------------------------------------------------------------------------------------
  308. void FW_CListBox::Draw (Environment* ev, ODFacet* facet, ODShape* invalidShape)
  309. {
  310. #ifdef FW_BUILD_MAC
  311.     FW_CViewContext gc(ev, this, facet, invalidShape);
  312.  
  313.     // Use the current port set by FW_CViewContext to allow printing
  314.     GrafPtr savedPort = (*fPlatformList)->port;
  315.     ::GetPort(&((*fPlatformList)->port));
  316.     
  317.     // Convert to grafport coordinates
  318.     FW_CPlatformPoint qdPoint = gc.LogicalToDevice(FW_kZeroPoint);
  319.     
  320.     SetupListBox(gc);
  321.         
  322.     // Compute update region 
  323.     FW_CRect invalidRect;
  324.     gc.GetClipRect(invalidRect);
  325.     Rect rgnRect;
  326.     rgnRect.top = FW_FixedToInt(invalidRect.top) + qdPoint.v;
  327.     rgnRect.left = FW_FixedToInt(invalidRect.left) + qdPoint.h;
  328.     rgnRect.bottom = FW_FixedToInt(invalidRect.bottom) + qdPoint.v;
  329.     rgnRect.right = FW_FixedToInt(invalidRect.right) + qdPoint.h;    
  330.     RgnHandle    updateRgn = ::FW_NewRegion();
  331.     ::RectRgn(updateRgn, &rgnRect);
  332.     
  333.     // Redraw the list box
  334.     ::LUpdate(updateRgn, fPlatformList);
  335.     
  336.     (*fPlatformList)->port = savedPort;
  337.     ::FW_DisposeRegion(updateRgn);
  338.     
  339.     // Draw the frame
  340.     FW_CRect viewRect(FW_kZeroPoint, GetSize(ev));
  341.     FW_CRect listRect(viewRect);
  342.     
  343.     if (fMacFocusFrame)
  344.     {
  345.         listRect.Inset(FW_IntToFixed(3), FW_IntToFixed(3));
  346.         
  347.         if (fMacFocusFrameOn)
  348.         {
  349.             FW_CRectShape::RenderRect( gc, viewRect, FW_kFrame,
  350.                                     FW_kNormalInk, FW_CStyle(FW_IntToFixed(2)));
  351.         }    
  352.     }
  353.     FW_CRectShape::RenderRect(gc, listRect, FW_kFrame, FW_kNormalInk);
  354.         
  355. #endif
  356. }
  357.  
  358. //----------------------------------------------------------------------------------------
  359. //    FW_CListBox::DoVirtualKey
  360. //----------------------------------------------------------------------------------------
  361.  
  362. FW_Handled FW_CListBox::DoVirtualKey(Environment* ev, const FW_CVirtualKeyEvent& event)
  363. {
  364. #ifdef FW_BUILD_MAC
  365.     // Need a view context to set the correct origin before using the list Manager
  366.     FW_CViewContext gc(ev, this, GetFrame(ev)->GetActiveFacet(ev), NULL);
  367.  
  368.     SetupListBox(gc);
  369.  
  370.     short    keyCode = event.GetKeyCode(ev);
  371.     FW_Boolean    commandKey = event.IsItemModifier(ev);
  372.     FW_Boolean    extendSelection = event.IsExtendModifier(ev) &&
  373.                               (((**fPlatformList).selFlags & lOnlyOne) == 0);
  374.     Cell    selectCell = {0, 0};
  375.     short    viewItem = 1;
  376.  
  377.     switch (keyCode) 
  378.     {
  379.     case FW_kVKUp:
  380.         if (::LGetSelect(true, &selectCell, fPlatformList)) 
  381.         {
  382.             if (commandKey && extendSelection) 
  383.             {
  384.                 // Select all items above
  385.                 while (--selectCell.v >= 0) 
  386.                     ::LSetSelect(true, selectCell, fPlatformList);
  387.             } 
  388.             else if (commandKey) 
  389.             {
  390.                 // Select top item
  391.                 PrivSelectOneItem(ev, 1, TRUE);
  392.             } 
  393.             else if (extendSelection) 
  394.             {
  395.                 // Extend selection above
  396.                 if (selectCell.v > 0) 
  397.                 {
  398.                     viewItem = selectCell.v;
  399.                     selectCell.v -= 1;
  400.                     ::LSetSelect(true, selectCell, fPlatformList);
  401.                 }
  402.             } 
  403.             else 
  404.             {    
  405.                 // Select 1 item above current one
  406.                 if(selectCell.v > 0) 
  407.                     selectCell.v -= 1;
  408.                 viewItem = selectCell.v + 1;
  409.                 PrivSelectOneItem(ev, viewItem, TRUE);
  410.             }
  411.             PrivScrollIntoView(viewItem);
  412.         }
  413.         break;
  414.  
  415.     case FW_kVKDown:
  416.         short count;
  417.         short lastItem = PrivGetSelectedItems(&count);
  418.         if (lastItem > 0) 
  419.         {
  420.             selectCell.v = lastItem - 1;
  421.             short    lastRow = (**fPlatformList).dataBounds.bottom - 1;
  422.             
  423.             if (commandKey && extendSelection) 
  424.             {
  425.                 while (++selectCell.v <= lastRow) 
  426.                     ::LSetSelect(true, selectCell, fPlatformList);
  427.                 viewItem = lastRow + 1;                                    
  428.             } 
  429.             else if (commandKey) 
  430.             {
  431.                 selectCell.v = lastRow + 1;
  432.                 PrivSelectOneItem(ev, selectCell.v, TRUE);                                    
  433.                 viewItem = selectCell.v;                                    
  434.             } 
  435.             else if (extendSelection) {
  436.                 viewItem = lastRow + 1;    
  437.                 if(selectCell.v < lastRow) 
  438.                 {
  439.                     selectCell.v += 1;
  440.                     ::LSetSelect(true, selectCell, fPlatformList);
  441.                     viewItem = selectCell.v + 1;                                    
  442.                 }
  443.             } else {    
  444.                 if(selectCell.v < lastRow) 
  445.                     selectCell.v += 1;
  446.                 viewItem = selectCell.v + 1;                                    
  447.                 PrivSelectOneItem(ev, viewItem, TRUE);
  448.             }
  449.             PrivScrollIntoView(viewItem);
  450.         }
  451.         break;
  452.         
  453.     case FW_kVKHome:
  454.         ::LScroll(-16000, -16000, fPlatformList);
  455.         break;
  456.  
  457.     case FW_kVKEnd:
  458.         ::LScroll(16000, 16000, fPlatformList);
  459.         break;
  460.         
  461.     case FW_kVKPageUp:
  462.     case FW_kVKPageDown: 
  463.         short    dRows = (**fPlatformList).visible.bottom - (**fPlatformList).visible.top - 1;
  464.         if (keyCode == FW_kVKPageUp) 
  465.             dRows = -dRows;
  466.         ::LScroll(0, dRows, fPlatformList);
  467.         break;
  468.     
  469.     default:
  470.         return FW_kNotHandled;
  471.     }
  472.     
  473.     return FW_kHandled;
  474. #endif
  475. }
  476.  
  477. //----------------------------------------------------------------------------------------
  478. //    FW_CListBox::Flatten
  479. //----------------------------------------------------------------------------------------
  480.  
  481. void FW_CListBox::Flatten(Environment* ev, FW_CWritableStream& stream) const
  482. {
  483.     FW_CView::Flatten(ev, stream);
  484.     
  485.     short numRows = GetCountItems(ev);
  486.     FW_Boolean scrollVert = ((**fPlatformList).vScroll != 0);
  487.     
  488.     stream << numRows;
  489.     stream << scrollVert;
  490.     stream << fSingleSelection;
  491.     stream << fMacFocusFrame;
  492.     stream << fUseClientData;
  493.     stream << fDoubleClickMsg;
  494.     stream << FW_CFont(FW_kNormalFont);    // [LSD] use default value for now
  495.  
  496.     stream << numRows;
  497.     FW_CString str;
  498.     for (int i = 1; i <= numRows; i++)
  499.     {
  500.         GetStringItem(ev, i, str);
  501.         stream << str;
  502.     } 
  503. }
  504.  
  505. //----------------------------------------------------------------------------------------
  506. //    FW_CListBox::InitializeFromStream
  507. //----------------------------------------------------------------------------------------
  508.  
  509. void FW_CListBox::InitializeFromStream(Environment* ev, FW_CReadableStream& stream)
  510. {
  511.     FW_CView::InitializeFromStream(ev, stream);
  512.     
  513.     short numRows;
  514.     FW_Boolean scrollVert;    
  515.     FW_CFont font;
  516.  
  517.     stream >> numRows;
  518.     stream >> scrollVert;
  519.     stream >> fSingleSelection;
  520.     stream >> fMacFocusFrame;
  521.     stream >> fUseClientData;
  522.     stream >> fDoubleClickMsg;
  523.     stream >> font;
  524.     
  525.     InitMacListBox(ev, GetBounds(ev), numRows, scrollVert, font);
  526.     
  527.     // ----- Read string items
  528.     SetDrawingMode(ev, FALSE);
  529.  
  530.     short numStrings;
  531.     stream >> numStrings;
  532.     
  533.     if (numStrings > numRows)
  534.         numStrings = numRows;
  535.     
  536.     FW_CString str;
  537.     for (int i = 1; i <= numStrings; i++)
  538.     {
  539.         stream >> str;
  540.         SetStringItem(ev, i, str);
  541.     } 
  542.     
  543.     SetDrawingMode(ev, TRUE);
  544. }
  545.  
  546. //----------------------------------------------------------------------------------------
  547. //    FW_CListBox::SizeChanged
  548. //----------------------------------------------------------------------------------------
  549.  
  550. void FW_CListBox::SizeChanged(Environment* ev, const FW_CPoint& oldSize)
  551. {
  552.     FW_CView::SizeChanged(ev, oldSize);
  553.  
  554. #ifdef FW_BUILD_MAC        
  555.     // The list manager redraws and validates list scrollbars when a list
  556.     // is resized whether or not drawing is on. It also validates the
  557.     // space where a horizontal scrollbar would be whether or not there is a
  558.     // horizontal scrollbar. To prevent redraw and validation while resizing,
  559.     // we set the clip region of the grafport that contains the list to NULL
  560.     // while we are sizing. This also lets us postpone the manipulations we
  561.     // do to align lists on 8 byte boundaries until a time when we have
  562.     // a view context.
  563.     
  564.     RgnHandle savedClip = (*fPlatformList)->port->clipRgn;
  565.     (*fPlatformList)->port->clipRgn = NewRgn();
  566.  
  567.     FW_CPoint size = GetSize(ev);
  568.     FW_Fixed vInset = FW_IntToFixed(2 * (fMacFocusFrame ? 4 : 1));
  569.     FW_Fixed hInset(vInset);
  570.     
  571.     if ((*fPlatformList)->vScroll != NULL)
  572.         hInset += FW_IntToFixed(15);
  573.  
  574.     size -= FW_CPoint(hInset, vInset);
  575.     
  576.     LSize(size.IntX(), size.IntY(), fPlatformList);
  577.     
  578.     // Adjust the cell width. The cell height will already be correct for the
  579.     // font, and shouldn't be adjusted.
  580.     FW_PlatformPoint cellSize = (*fPlatformList)->cellSize;
  581.     cellSize.h = size.IntX();
  582.     LCellSize(cellSize, fPlatformList);
  583.     
  584.     DisposeRgn((*fPlatformList)->port->clipRgn);
  585.     (*fPlatformList)->port->clipRgn = savedClip;
  586. #endif
  587. }
  588.  
  589. //----------------------------------------------------------------------------------------
  590. //    FW_CListBox::GetCountItems
  591. //----------------------------------------------------------------------------------------
  592.  
  593. short FW_CListBox::GetCountItems(Environment* ev) const
  594. {
  595. FW_UNUSED(ev);
  596.     // return number of rows
  597. #ifdef FW_BUILD_MAC
  598.     return (**fPlatformList).dataBounds.bottom;
  599. #endif
  600. }
  601.  
  602. //----------------------------------------------------------------------------------------
  603. //    FW_CListBox::GetSelectionCount
  604. //----------------------------------------------------------------------------------------
  605.  
  606. short FW_CListBox::GetSelectionCount(Environment* ev) const
  607. {
  608. FW_UNUSED(ev);
  609. #ifdef FW_BUILD_MAC
  610.     short count;
  611.     PrivGetSelectedItems(&count);
  612.     return count;
  613. #endif
  614. }
  615.  
  616. //----------------------------------------------------------------------------------------
  617. //    FW_CListBox::GetSelectedState
  618. //----------------------------------------------------------------------------------------
  619. // return if an item is selected
  620.  
  621. FW_Boolean     FW_CListBox::GetSelectedState(Environment* ev, short index) const
  622. {
  623.     if (!CheckIndex(ev, index)) return FALSE;
  624.  
  625. #ifdef FW_BUILD_MAC
  626.     Cell    curSel = {index - 1, 0};
  627.  
  628.     if (::LGetSelect(false, &curSel, fPlatformList)) 
  629.         return TRUE;
  630.     else
  631.         return FALSE;    
  632. #endif
  633. }
  634.  
  635. //----------------------------------------------------------------------------------------
  636. //    FW_CListBox::GetSelectedItem
  637. //----------------------------------------------------------------------------------------
  638. // find the first selected item
  639.  
  640. short     FW_CListBox::GetSelectedItem(Environment* ev) const
  641. {
  642. FW_UNUSED(ev);
  643. #ifdef FW_BUILD_MAC
  644.     Cell    curSel = {0, 0};
  645.     if (::LGetSelect(true, &curSel, fPlatformList)) 
  646.         return curSel.v + 1;
  647.     else
  648.         return 0;    // no item selected
  649. #endif
  650. }
  651.  
  652. //----------------------------------------------------------------------------------------
  653. //    FW_CListBox::GetSelectedItems
  654. //----------------------------------------------------------------------------------------
  655. // build an array of selected items, return the number of items read
  656.  
  657. short     FW_CListBox::GetSelectedItems(Environment* ev, short maxItems, short* indexArray) const
  658. {
  659. FW_UNUSED(ev);
  660.     FW_ASSERT(!fSingleSelection);    // only multi-selection list boxes allowed
  661.  
  662. #ifdef FW_BUILD_MAC
  663.     short count;
  664.     PrivGetSelectedItems(&count, maxItems, indexArray);
  665.     return count;
  666. #endif
  667. }
  668.  
  669. //----------------------------------------------------------------------------------------
  670. //    FW_CListBox::GetStringItem
  671. //----------------------------------------------------------------------------------------
  672. // read the 255 chars value of an item. Return FALSE if no data was read
  673.  
  674. FW_Boolean FW_CListBox::GetStringItem(Environment* ev, short index, FW_CString& str) const
  675. {
  676.     if (!CheckIndex(ev, index)) return FALSE;
  677.  
  678. #ifdef FW_BUILD_MAC
  679.     Cell  itemCell = {index - 1, 0};
  680.     char pStr[255];
  681.     short dataLen = 255;
  682.     
  683.     ::LGetCell(pStr, &dataLen, itemCell, fPlatformList);
  684.  
  685.     if (dataLen > 0) 
  686.         str.ReplaceAll(pStr, (FW_ByteCount)dataLen);
  687.     
  688.     return (dataLen > 0);
  689. #endif
  690. }
  691.  
  692. //----------------------------------------------------------------------------------------
  693. //    FW_CListBox::GetStringItem
  694. //----------------------------------------------------------------------------------------
  695. // read the 255 chars value of an item + the 4 bytes value associated.
  696. // return FALSE if the 4 bytes data was not found.
  697.  
  698. FW_Boolean FW_CListBox::GetStringItem(Environment* ev, short index, FW_CString& str,
  699.                                                 void** clientData) const
  700. {
  701.     FW_ASSERT(fUseClientData);
  702.     if (!CheckIndex(ev, index)) return FALSE;
  703.  
  704.     GetStringItem(ev, index, str);
  705.     
  706. #ifdef FW_BUILD_MAC
  707.     Cell  itemCell = {index - 1, 1};
  708.     short dataLen = 4;
  709.     
  710.     ::LGetCell(clientData, &dataLen, itemCell, fPlatformList);
  711.  
  712.     return (dataLen == 4);
  713. #endif
  714. }
  715.  
  716. //----------------------------------------------------------------------------------------
  717. //    FW_CListBox::GetClientDataItem
  718. //----------------------------------------------------------------------------------------
  719. // read the 4 bytes value stored in 2nd column. Return FALSE if couldn't read 4 bytes
  720.  
  721. FW_Boolean FW_CListBox::GetClientDataItem(Environment* ev, short index, void** clientData) const
  722. {
  723.     FW_ASSERT(fUseClientData);
  724.     if (!CheckIndex(ev, index)) return FALSE;
  725.  
  726. #ifdef FW_BUILD_MAC
  727.     Cell  itemCell = {index - 1, 1};
  728.     short dataLen = 4;
  729.     
  730.     ::LGetCell(clientData, &dataLen, itemCell, fPlatformList);
  731.  
  732.     return (dataLen == 4);
  733. #endif
  734. }
  735.  
  736. //----------------------------------------------------------------------------------------
  737. //    FW_CListBox::SetStringItem
  738. //----------------------------------------------------------------------------------------
  739. // Set the string value of an existing item
  740.  
  741. void FW_CListBox::SetStringItem(Environment* ev, short index, const FW_CString& str)
  742. {
  743.     if (!CheckIndex(ev, index)) return;  // index out of range (item doesn't exist)
  744.         
  745.     if (fDrawingMode)
  746.     {
  747.         // Must setup the listbox to be sure it's drawn correctly
  748.         // Must also loop on all facets for this frame
  749.         FW_CFrameFacetIterator ite(ev, GetFrame(ev));
  750.         for  (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  751.         {
  752.             FW_CViewContext vc(ev, this, facet);
  753.             SetupListBox(vc);
  754.  
  755.             MacSetItem(index, str);
  756.         }
  757.     }
  758.     else
  759.         MacSetItem(index, str);
  760. }
  761.  
  762. //----------------------------------------------------------------------------------------
  763. //    FW_CListBox::SetStringItem
  764. //----------------------------------------------------------------------------------------
  765. // Set the string value of an existing item + set its 4 bytes clientData
  766.  
  767. void FW_CListBox::SetStringItem(Environment* ev, short index, const FW_CString& str,
  768.                                                 void* clientData)
  769. {
  770.     FW_ASSERT(fUseClientData);
  771.     if (!CheckIndex(ev, index)) return; // index out of range (item doesn't exist)
  772.  
  773.     if (fDrawingMode)
  774.     {
  775.         // Must setup the listbox to be sure it's drawn correctly
  776.         // Must also loop on all facets for this frame
  777.         FW_CFrameFacetIterator ite(ev, GetFrame(ev));
  778.         for  (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  779.         {
  780.             FW_CViewContext vc(ev, this, facet);
  781.             SetupListBox(vc);
  782.  
  783.             MacSetItem(index, str, TRUE, clientData);
  784.         }
  785.     }
  786.     else 
  787.         MacSetItem(index, str, TRUE, clientData);
  788. }
  789.  
  790. //----------------------------------------------------------------------------------------
  791. //    FW_CListBox::AddStringItem
  792. //----------------------------------------------------------------------------------------
  793. // Add a new item to the list and sets its string value
  794. // if index = 0, item is added at the end of the list
  795.  
  796. void FW_CListBox::AddStringItem(Environment* ev, const FW_CString& str, short index)
  797. {
  798.     FW_ASSERT(index >= 0);
  799.     
  800.     short count = GetCountItems(ev);
  801.     if (index == 0 || index  > count)
  802.         index = count + 1;        
  803.         
  804.     if (fDrawingMode)
  805.     {
  806.         // Must setup the listbox to be sure it's drawn correctly
  807.         // Must also loop on all facets for this frame
  808.         FW_CFrameFacetIterator ite(ev, GetFrame(ev));
  809.         for  (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  810.         {
  811.             FW_CViewContext vc(ev, this, facet);
  812.             SetupListBox(vc);
  813.  
  814. #ifdef FW_BUILD_MAC
  815.             ::LAddRow(1, index-1, fPlatformList);        
  816.             MacSetItem(index, str);
  817. #endif    
  818.         }
  819.     }
  820.     else 
  821.     {
  822. #ifdef FW_BUILD_MAC
  823.         ::LAddRow(1, index-1, fPlatformList);        
  824.         MacSetItem(index, str);
  825. #endif    
  826.     }
  827. }
  828.  
  829. //----------------------------------------------------------------------------------------
  830. //    FW_CListBox::AddStringItem
  831. //----------------------------------------------------------------------------------------
  832. // Add a new item to the list and sets its string value
  833. // if index = 0, item is added at the end of the list
  834.  
  835. void FW_CListBox::AddStringItem(Environment* ev, const FW_CString& str, void* clientData,
  836.                                 short index)
  837. {
  838.     FW_ASSERT(index >= 0);
  839.     FW_ASSERT(fUseClientData);
  840.     if (index < 0 || index > 16000) return;
  841.     
  842.     short count = GetCountItems(ev);
  843.     if (index == 0 || index  > count)
  844.         index = count + 1;        
  845.         
  846.     if (fDrawingMode)
  847.     {
  848.         // Must setup the listbox to be sure it's drawn correctly
  849.         // Must also loop on all facets for this frame
  850.         FW_CFrameFacetIterator ite(ev, GetFrame(ev));
  851.         for  (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  852.         {
  853.             FW_CViewContext vc(ev, this, facet);
  854.             SetupListBox(vc);
  855.  
  856. #ifdef FW_BUILD_MAC
  857.             ::LAddRow(1, index-1, fPlatformList);        
  858.             MacSetItem(index, str, TRUE, clientData);
  859. #endif    
  860.         }
  861.     }
  862.     else 
  863.     {
  864. #ifdef FW_BUILD_MAC
  865.         ::LAddRow(1, index-1, fPlatformList);        
  866.         MacSetItem(index, str, TRUE, clientData);
  867. #endif    
  868.     }
  869. }
  870.  
  871. //----------------------------------------------------------------------------------------
  872. //    FW_CListBox::DeleteItems
  873. //----------------------------------------------------------------------------------------
  874. // Delete "count" rows starting at "index"
  875.  
  876. void FW_CListBox::DeleteItems(Environment* ev, short index, short count)
  877. {
  878.     if (count <= 0 || !CheckIndex(ev, index)) return; 
  879.     
  880. #ifdef FW_BUILD_MAC
  881.     if (fDrawingMode)
  882.     {
  883.         // Must setup the listbox to be sure it's drawn correctly
  884.         // Must also loop on all facets for this frame
  885.         FW_CFrameFacetIterator ite(ev, GetFrame(ev));
  886.         for  (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  887.         {
  888.             FW_CViewContext vc(ev, this, facet);
  889.             SetupListBox(vc);
  890.  
  891.             ::LDelRow(count, index-1, fPlatformList);
  892.         }
  893.     }
  894.     else 
  895.     {
  896.         ::LDelRow(count, index-1, fPlatformList);
  897.     }
  898. #endif
  899. }
  900.  
  901. //----------------------------------------------------------------------------------------
  902. //    FW_CListBox::PrivSelectOneItem
  903. //----------------------------------------------------------------------------------------
  904. // Internal use only.  ViewContext must be setup already.
  905.  
  906. void FW_CListBox::PrivSelectOneItem(Environment* ev, short index, FW_Boolean selected)
  907. {
  908. FW_UNUSED(ev);
  909. #ifdef FW_BUILD_MAC
  910.     Cell    curCell = {0, 0};
  911.     Cell    itemCell = {index - 1, 0};
  912.     
  913.     // Follows recipe from Inside Mac "More ToolBox" page 4-36 to select without
  914.     // flashing
  915.     if (selected && fDrawingMode) 
  916.     {
  917.         while (::LGetSelect(TRUE, &curCell, fPlatformList)) 
  918.         {
  919.             if (*(long*)&curCell == *(long*)&itemCell) 
  920.                 ::LNextCell(FALSE, TRUE, &curCell, fPlatformList);            
  921.             else
  922.                 ::LSetSelect(FALSE, curCell, fPlatformList);
  923.         }
  924.     }
  925.         
  926.     ::LSetSelect(selected ? TRUE : FALSE, itemCell, fPlatformList);
  927. #endif
  928.  
  929. }
  930.  
  931. //----------------------------------------------------------------------------------------
  932. //    FW_CListBox::SelectOneItem
  933. //----------------------------------------------------------------------------------------
  934. // Set the selection state of 1 item, On or Off
  935.  
  936. void FW_CListBox::SelectOneItem(Environment* ev, short index, FW_Boolean selected)
  937. {
  938.     if (!CheckIndex(ev, index)) return; 
  939.  
  940.     if (fDrawingMode)
  941.     {
  942.         // Must setup the listbox to be sure it's drawn correctly
  943.         // Must also loop on all facets for this frame
  944.         FW_CFrameFacetIterator ite(ev, GetFrame(ev));
  945.         for  (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  946.         {
  947.             FW_CViewContext vc(ev, this, facet);
  948.             SetupListBox(vc);
  949.             
  950.             PrivSelectOneItem(ev, index, selected);
  951.         }
  952.     }
  953.     else 
  954.     {
  955.         PrivSelectOneItem(ev, index, selected);
  956.     }
  957. }
  958.  
  959. //----------------------------------------------------------------------------------------
  960. //    FW_CListBox::PrivScrollIntoView
  961. //----------------------------------------------------------------------------------------
  962.  
  963. void FW_CListBox::PrivScrollIntoView(short index)
  964. {
  965.  
  966. #ifdef FW_BUILD_MAC
  967.     Rect    visibleCells = (**fPlatformList).visible;
  968.     Cell    itemCell = {index - 1, 0};
  969.     
  970.     // recipe from Inside Mac "More ToolBox" page 4-37
  971.     if (::PtInRect(itemCell, &visibleCells) == FALSE) 
  972.     {
  973.         short    dRows = 0;            
  974.         if (itemCell.v > visibleCells.bottom - 1) 
  975.             dRows = itemCell.v - visibleCells.bottom + 1;
  976.         else if (itemCell.v < visibleCells.top) 
  977.             dRows = itemCell.v - visibleCells.top;
  978.         
  979.         ::LScroll(0, dRows, fPlatformList);
  980.         visibleCells = (**fPlatformList).visible;
  981.     }
  982.     
  983.     // if item is at the bottom check that it is entirely visible
  984.     short numVisibleCells = visibleCells.bottom - visibleCells.top;
  985.     if (itemCell.v == visibleCells.bottom - 1 && numVisibleCells > 1)
  986.     {
  987.         short visibleHeight = numVisibleCells * (**fPlatformList).cellSize.v;
  988.         Rect listRect = (**fPlatformList).rView;
  989.  
  990.         if (visibleHeight > (listRect.bottom - listRect.top))
  991.             ::LScroll(0, 1, fPlatformList);
  992.     }
  993. #endif
  994. }
  995.  
  996. //----------------------------------------------------------------------------------------
  997. //    FW_CListBox::ScrollIntoView
  998. //----------------------------------------------------------------------------------------
  999.  
  1000. void FW_CListBox::ScrollIntoView(Environment* ev, short index)
  1001. {
  1002.     short count = GetCountItems(ev);
  1003.     if (index <= 0 || index  > count)
  1004.         index = count + 1;        
  1005.  
  1006.     // Must setup the listbox to be sure it's drawn correctly
  1007.     // Must also loop on all facets for this frame
  1008.     FW_CFrameFacetIterator ite(ev, GetFrame(ev));
  1009.     for  (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  1010.     {
  1011.         FW_CViewContext vc(ev, this, facet);
  1012.         SetupListBox(vc);
  1013.         
  1014.         PrivScrollIntoView(index);
  1015.     }
  1016. }
  1017.  
  1018. //----------------------------------------------------------------------------------------
  1019. //    FW_CListBox::CheckIndex
  1020. //----------------------------------------------------------------------------------------
  1021.  
  1022. FW_Boolean FW_CListBox::CheckIndex(Environment* ev, short index) const    
  1023. {
  1024.     if (index <= 0 || index > GetCountItems(ev)) 
  1025.     {                                                    
  1026.         FW_DEBUG_MESSAGE("Wrong index for FW_CListBox");
  1027.         return FALSE;                                            
  1028.     }
  1029.     return TRUE;
  1030. }
  1031.         
  1032.  
  1033. //========================================================================================
  1034. // Macintosh specific code below
  1035. #ifdef FW_BUILD_MAC
  1036.  
  1037. //----------------------------------------------------------------------------------------
  1038. //    FW_CListBox::PrivGetSelectedItems
  1039. //----------------------------------------------------------------------------------------
  1040. // If maxItems = 0, count the number of selected items and return the index of the last one
  1041. // If maxItems > 0, store indexes in an array and count only the number found (<= maxItems)
  1042.  
  1043. short FW_CListBox::PrivGetSelectedItems(short* count, short maxItems, short* indexArray) const
  1044. {
  1045.     Cell    curItem = {0, 0};
  1046.     short    i = 0;
  1047.     short    index = 0;
  1048.     
  1049.     // Follows recipe from Inside Mac "More ToolBox" page 4-35
  1050.     if (::LGetSelect(TRUE, &curItem, fPlatformList)) 
  1051.     {
  1052.         do 
  1053.         {
  1054.             index = curItem.v + 1;
  1055.             i++;
  1056.             if (maxItems > 0)    
  1057.             {
  1058.                 if (indexArray)
  1059.                     indexArray[i-1] = index;
  1060.                 if (i == maxItems)    
  1061.                     break;
  1062.             }
  1063.         } while (::LNextCell(FALSE, TRUE, &curItem, fPlatformList) &&
  1064.                  ::LGetSelect(TRUE, &curItem, fPlatformList));
  1065.     }    
  1066.     *count = i;
  1067.     return index;
  1068. }
  1069.  
  1070. //----------------------------------------------------------------------------------------
  1071. //    FW_CListBox::InitMacListBox
  1072. //----------------------------------------------------------------------------------------
  1073.  
  1074. void FW_CListBox::InitMacListBox(Environment* ev, 
  1075.                                 const FW_CRect& bounds, 
  1076.                                 int numRows, 
  1077.                                 FW_Boolean scrollVert, 
  1078.                                 const FW_CFont& font)
  1079. {
  1080.     Rect    listRect;
  1081.     
  1082.     // list box rect doesn't contain border and scroll-bars 
  1083.     int border = fMacFocusFrame ? 4 : 1;
  1084.     
  1085.     listRect.left = FW_FixedToInt(bounds.left) + border;
  1086.     listRect.top = FW_FixedToInt(bounds.top) + border;
  1087.     listRect.right = FW_FixedToInt(bounds.right) - border;
  1088.     listRect.bottom = FW_FixedToInt(bounds.bottom) - border;
  1089.     
  1090.     if (scrollVert)        
  1091.         listRect.right -= 15;
  1092.     
  1093.     // Set the font to be used to draw cells in this window
  1094.     FW_CAcquiredODWindow aqODWindow = GetFrame(ev)->GetWindow(ev)->AcquireODWindow(ev);
  1095.     GrafPtr macPort = aqODWindow->GetPlatformWindow(ev);
  1096.     GrafPtr oldPort;
  1097.     ::GetPort(&oldPort);
  1098.     ::SetPort(macPort);
  1099.     
  1100.     fMacFontID = font.MacGetFontID();
  1101.     fMacFontStyle = font.MacGetFontStyle();
  1102.     fMacFontSize = FW_FixedToInt(font.GetFontSize());
  1103.     ::TextFont(fMacFontID);
  1104.     ::TextFace(fMacFontStyle);
  1105.     ::TextSize(fMacFontSize);
  1106.     ::TextMode(srcOr);
  1107.     
  1108.     // Use 2 columns for storing clientdata items
  1109.     Rect    dataBounds = {0, 0, numRows,  (fUseClientData ? 2 : 1)};
  1110.     
  1111.     // Adjust cell width.  Cell height will be set according to the font
  1112.     Point    cellSize = { 0,  listRect.right - listRect.left};        
  1113.     
  1114.     // Create the Mac list box handle
  1115.     fPlatformList = ::LNew(&listRect, &dataBounds, cellSize, 
  1116.                                     0,             // use default LDEF
  1117.                                     macPort,     // port window
  1118.                                     false,         // don't draw it
  1119.                                     false,        // no Grow box space
  1120.                                     false,        // no Horizontal scrollbar
  1121.                                     scrollVert);
  1122.                                 
  1123.     if (fSingleSelection)
  1124.         (**fPlatformList).selFlags |= lOnlyOne;
  1125.         
  1126.     MacSetVisible(ev, true);
  1127.         
  1128.     if (oldPort != macPort)    
  1129.         ::SetPort(oldPort);
  1130. }
  1131.  
  1132. //----------------------------------------------------------------------------------------
  1133. //    FW_CListBox::MacSetVisible
  1134. //----------------------------------------------------------------------------------------
  1135.  
  1136. void FW_CListBox::MacSetVisible(Environment* ev, FW_Boolean activate)
  1137. {
  1138.     // Turn on drawing mode & set activation 
  1139.     // but avoid immediate redraw by clipping to empty rect
  1140.     GrafPtr oldPort;
  1141.     ::GetPort(&oldPort);
  1142.     ::SetPort((**fPlatformList).port);
  1143.     RgnHandle clipRgn = ::FW_NewRegion();
  1144.     if (clipRgn)
  1145.     {
  1146.         ::GetClip(clipRgn);
  1147.         Rect emptyRect = {0, 0, 0, 0};
  1148.         ::ClipRect(&emptyRect);
  1149.     }
  1150.     
  1151.     SetDrawingMode(ev, TRUE);
  1152.     
  1153.     ::LActivate(activate, fPlatformList);
  1154.  
  1155.     if (clipRgn)
  1156.     {
  1157.         ::SetClip(clipRgn);
  1158.         ::FW_DisposeRegion(clipRgn);
  1159.     }
  1160.     ::SetPort(oldPort);
  1161. }
  1162.  
  1163. //----------------------------------------------------------------------------------------
  1164. //    FW_CListBox::MacSetItem
  1165. //----------------------------------------------------------------------------------------
  1166.  
  1167. void FW_CListBox::MacSetItem(short index, const FW_CString& str, FW_Boolean hasClientData,
  1168.                                     void* clientData)
  1169. {
  1170.     Cell  itemCell = {index - 1, 0};
  1171.  
  1172.     FW_PascalChar    pStr[255];
  1173.     str.ExportPascal(pStr);
  1174.  
  1175.     ::LSetCell(pStr+1, pStr[0], itemCell, fPlatformList);        
  1176.     
  1177.     if (hasClientData && fUseClientData)
  1178.     {
  1179.         // Set clientdata value in second (invisible) column
  1180.         itemCell.h = 1;        
  1181.         ::LSetCell(&clientData, 4, itemCell, fPlatformList);
  1182.     }
  1183. }
  1184.  
  1185. //----------------------------------------------------------------------------------------
  1186. //    FW_CListBox::SetupListBox
  1187. //----------------------------------------------------------------------------------------
  1188. // SetupListBox must be called before any List Manager call that may redraw the list box
  1189. // (and after creating a View Context which will set the correct port) in order to
  1190. // adjust the listbox and scrollbars rects and set the fonts.
  1191.  
  1192. void FW_CListBox::SetupListBox(FW_CViewContext& vc,  
  1193.                                 FW_Boolean mouseDownEvent,
  1194.                                 FW_CPlatformPoint* qdWhere)
  1195. {
  1196.     Rect     curRect = (**fPlatformList).rView;
  1197.  
  1198.     FW_CPlatformPoint qdPoint = vc.LogicalToDevice(FW_kZeroPoint);
  1199.     
  1200.     short     border = fMacFocusFrame ? 4 : 1;
  1201.     short    hDelta = qdPoint.h - curRect.left + border;
  1202.     short    vDelta = qdPoint.v - curRect.top + border;
  1203.     if (hDelta != 0 || vDelta != 0)
  1204.     {
  1205.         ::OffsetRect(&(**fPlatformList).rView, hDelta, vDelta);
  1206.         if ((**fPlatformList).vScroll) 
  1207.             ::OffsetRect(&(**((**fPlatformList).vScroll)).contrlRect, hDelta, vDelta);
  1208.         if ((**fPlatformList).hScroll) 
  1209.             ::OffsetRect(&(**((**fPlatformList).hScroll)).contrlRect, hDelta, vDelta);
  1210.     }
  1211.     
  1212.     if (mouseDownEvent)
  1213.     {
  1214.         // We must adjust the mouse position by the offset created by the view
  1215.         // context (to handle pattern alignment).  See also FW_CControl::DoMouseDown
  1216.         ODPlatformCanvas plfmCanvas = vc.GetPlatformCanvas();
  1217.         qdWhere->h += plfmCanvas->portRect.left;
  1218.         qdWhere->v += plfmCanvas->portRect.top;
  1219.     }
  1220.     
  1221.     // Setup the correct font (port has been set by the ViewContext)
  1222.     ::TextFont(fMacFontID);
  1223.     ::TextFace(fMacFontStyle);
  1224.     ::TextSize(fMacFontSize);    
  1225. }        
  1226.  
  1227. //========================================================================================
  1228. //    CLASS FW_CListBoxNotification
  1229. //========================================================================================
  1230.  
  1231. FW_DEFINE_CLASS_M1(FW_CListBoxNotification, FW_CNotification)
  1232.  
  1233. //----------------------------------------------------------------------------------------
  1234. // FW_CListBoxNotification::FW_CListBoxNotification
  1235. //----------------------------------------------------------------------------------------
  1236.  
  1237. FW_CListBoxNotification::FW_CListBoxNotification(FW_CListBox* listbox) :
  1238.     FW_CNotification(),
  1239.     fListBox(listbox)
  1240. {
  1241.     FW_SOMEnvironment ev;
  1242.     FW_Message msg = listbox->GetDoubleClickedMsg(ev);
  1243.     SetInterest(FW_CInterest((FW_MNotifier*)listbox, msg));
  1244. }
  1245.  
  1246. //----------------------------------------------------------------------------------------
  1247. // FW_CListBoxNotification::FW_CListBoxNotification
  1248. //----------------------------------------------------------------------------------------
  1249.  
  1250. FW_CListBoxNotification::FW_CListBoxNotification(const FW_CListBoxNotification& other) :
  1251.     FW_CNotification(other),
  1252.     fListBox(other.fListBox)
  1253. {
  1254. }
  1255.  
  1256. //----------------------------------------------------------------------------------------
  1257. // FW_CListBoxNotification::~FW_CListBoxNotification
  1258. //----------------------------------------------------------------------------------------
  1259.  
  1260. FW_CListBoxNotification::~FW_CListBoxNotification()
  1261. {
  1262. }
  1263.  
  1264. //----------------------------------------------------------------------------------------
  1265. // FW_CListBoxNotification::operator=
  1266. //----------------------------------------------------------------------------------------
  1267.  
  1268. FW_CListBoxNotification& FW_CListBoxNotification::operator=(const FW_CListBoxNotification& other)
  1269. {
  1270.     if (this != &other)
  1271.     {
  1272.         FW_CNotification::operator=(other);
  1273.         fListBox = other.fListBox;
  1274.     }
  1275.     
  1276.     return *this;
  1277. }
  1278.  
  1279. //----------------------------------------------------------------------------------------
  1280. // FW_CListBoxNotification::operator==
  1281. //----------------------------------------------------------------------------------------
  1282.  
  1283. FW_Boolean FW_CListBoxNotification::operator==(const FW_CListBoxNotification& other) const
  1284. {
  1285.     return FW_CNotification::operator==(other) && fListBox == other.fListBox;
  1286. }
  1287.  
  1288. #endif
  1289.  
  1290.  
  1291.