home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Tools & Goodies / IntlTest / Sources / Select.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  4.7 KB  |  168 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Select.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "IntlTest.hpp"
  11.  
  12. #ifndef SELECT_H
  13. #include "Select.h"
  14. #endif
  15.  
  16. #ifndef CONTENT_H
  17. #include "Content.h"
  18. #endif
  19.  
  20. #ifndef PART_H
  21. #include "Part.h"
  22. #endif
  23.  
  24. #ifndef DEFINES_K
  25. #include "Defines.k"
  26. #endif
  27.  
  28. // ----- Framework Includes -----
  29.  
  30. #ifndef FWPRESEN_H
  31. #include "FWPresen.h"
  32. #endif
  33.  
  34. #ifndef FWUTIL_H
  35. #include "FWUtil.h"
  36. #endif
  37.  
  38. // ----- OS Includes -----
  39.  
  40. #ifndef FWBARRAY_H
  41. #include "FWBArray.h"
  42. #endif
  43.  
  44. // ----- Foundation Layer -----
  45.  
  46. #ifndef FWSUSINK_H
  47. #include "FWSUSink.h"
  48. #endif
  49.  
  50. #ifndef FWSTREAM_H
  51. #include "FWStream.h"
  52. #endif
  53.  
  54. #ifndef FWSTRING_H
  55. #include "FWString.h"
  56. #endif
  57.  
  58. // ----- OpenDoc Includes -----
  59.  
  60. #ifndef SOM_Module_OpenDoc_StdProps_defined
  61. #include <StdProps.xh>
  62. #endif
  63.  
  64. // ----- Macintosh Includes -----
  65.  
  66. #if defined(FW_BUILD_MAC) && !defined(__DRAG__)
  67. #include <Drag.h>
  68. #endif
  69.  
  70. //========================================================================================
  71. //    Runtime information
  72. //========================================================================================
  73.  
  74. #ifdef FW_BUILD_MAC
  75. #pragma segment odfIntlTest
  76. #endif
  77.  
  78. //========================================================================================
  79. //    Constants
  80. //========================================================================================
  81.  
  82. const ODPropertyName kIntlTestPropText = "IntlTest:Property:Text";
  83.  
  84. //========================================================================================
  85. //    CLASS CIntlTestSelection
  86. //========================================================================================
  87.  
  88. FW_DEFINE_AUTO(CIntlTestSelection)
  89.  
  90. //---------------------------------------------------------------------------------------
  91. //    CIntlTestSelection constructor
  92. //---------------------------------------------------------------------------------------
  93.  
  94. CIntlTestSelection::CIntlTestSelection(Environment* ev, CIntlTestPart* testPart) :
  95.     FW_CSelection(ev, false, false),
  96.     fTestPart(testPart),
  97.     fSelectedContent(NULL)
  98. {
  99.     fSelectedContent = FW_NEW(CIntlTestSelectedContent, (ev, testPart));
  100. }
  101.  
  102. //---------------------------------------------------------------------------------------
  103. //    CIntlTestSelection destructor
  104. //---------------------------------------------------------------------------------------
  105.  
  106. CIntlTestSelection::~CIntlTestSelection()
  107. {
  108. }
  109.  
  110. //---------------------------------------------------------------------------------------
  111. //    CIntlTestSelection::GetSelectedContent
  112. //---------------------------------------------------------------------------------------
  113. //    The whole content is always selected
  114.  
  115. FW_CContent* CIntlTestSelection::GetSelectedContent(Environment* ev)
  116. {
  117.     return fSelectedContent;
  118. }
  119.  
  120. //---------------------------------------------------------------------------------------
  121. //    CIntlTestSelection::ClearSelection
  122. //---------------------------------------------------------------------------------------
  123.  
  124. void CIntlTestSelection::ClearSelection(Environment* ev)
  125. {
  126.     fSelectedContent->ClearSelectedText(ev); 
  127. }
  128.  
  129. //---------------------------------------------------------------------------------------
  130. //    CIntlTestSelection::CloseSelection
  131. //---------------------------------------------------------------------------------------
  132.  
  133. void CIntlTestSelection::CloseSelection(Environment* ev)
  134. {
  135.     // Unselect text in the current EditView
  136.     fSelectedContent->SetSelectionRange(ev, 0, 0);
  137. }
  138.  
  139. //---------------------------------------------------------------------------------------
  140. //    CIntlTestSelection::IsEmpty
  141. //---------------------------------------------------------------------------------------
  142.  
  143. FW_Boolean CIntlTestSelection::IsEmpty(Environment* ev) const
  144. {
  145.     // Is the current string empty?
  146.     FW_CString selection;
  147.     fSelectedContent->GetSelectedText(ev, selection);
  148.     return (selection.GetByteLength() == 0);
  149. }
  150.  
  151. //---------------------------------------------------------------------------------------
  152. //    CIntlTestSelection::SelectAll
  153. //---------------------------------------------------------------------------------------
  154.  
  155. void CIntlTestSelection::SelectAll(Environment* ev)
  156. {
  157.     // This function is handled by the current EditView
  158. }
  159.  
  160. //---------------------------------------------------------------------------------------
  161. //    CIntlTestSelection::SetContentEditView
  162. //---------------------------------------------------------------------------------------
  163. void CIntlTestSelection::SetContentEditView(FW_CEditView* editView)
  164. {
  165.     fSelectedContent->SetEditView(editView);
  166. }
  167.  
  168.