You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
2.6 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Turbo Vision - Version 2.0
  3. *
  4. * Copyright (c) 1994 by Borland International
  5. * All Rights Reserved.
  6. *
  7. Modified by Robert H�hne to be used for RHIDE.
  8. *
  9. *
  10. */
  11. #if defined( Uses_TFileViewer ) && !defined( __TFileViewer )
  12. #define __TFileViewer
  13. #include <tv.h>
  14. const ushort hlChangeDir = cmChangeDir;
  15. const ushort
  16. hcFileViewer = 599,
  17. cmSaveFile = 598,
  18. cmFileViewAnswer = 599; // I hope this conflicts with
  19. // nothing else
  20. class TLineCollection : public TCollection
  21. {
  22. public:
  23. TLineCollection(ccIndex lim, ccIndex delta) : TCollection(lim, delta) {}
  24. virtual void freeItem(void *p) { delete (char *)p; }
  25. #if !defined( NO_STREAM )
  26. private:
  27. virtual void *readItem( ipstream& ) { return 0; }
  28. virtual void writeItem( void *, opstream& ) {}
  29. #endif // NO_STREAM
  30. friend class TFileViewer;
  31. };
  32. class TFileViewer : public TScroller
  33. {
  34. public:
  35. char *fileName;
  36. Boolean isValid;
  37. TFileViewer( const TRect& bounds,
  38. TScrollBar *aHScrollBar,
  39. TScrollBar *aVScrollBar,
  40. const char *aFileName
  41. );
  42. ~TFileViewer();
  43. #if !defined( NO_STREAM )
  44. TFileViewer( StreamableInit ) : TScroller(streamableInit) { };
  45. #endif // NO_STREAM
  46. void draw();
  47. void readFile( const char *fName );
  48. virtual void saveFile(const char *fName);
  49. virtual void handleEvent(TEvent &);
  50. void setState( ushort aState, Boolean enable );
  51. void scrollDraw();
  52. virtual void changeBounds(const TRect &);
  53. Boolean valid( ushort command );
  54. void insertLine(const char *line);
  55. const char * const operator [] (int index);
  56. int Count() { return count; }
  57. private:
  58. /* I have moved the fileLines in the private section, because
  59. I'm using now a faster way for the FileViewer in which the user
  60. is not allowed to insert or delete a line from the fileLines.
  61. For inserting a line use the TFileViewer::insertLine.
  62. For accessing the lines use TFileViewer::operator []
  63. */
  64. TLineCollection *fileLines;
  65. char *buffer;
  66. int real_bufsize;
  67. protected:
  68. const char * const getBuffer() { return buffer; }
  69. int getBufsize() { return real_bufsize; }
  70. int width;
  71. int count;
  72. #if !defined( NO_STREAM )
  73. private:
  74. virtual const char *streamableName() const
  75. { return name; }
  76. protected:
  77. virtual void write( opstream& );
  78. virtual void *read( ipstream& );
  79. public:
  80. static const char * const name;
  81. static TStreamable *build();
  82. #endif // NO_STREAM
  83. };
  84. class TFileWindow : public TWindow
  85. {
  86. public:
  87. TFileWindow( const char *fileName );
  88. };
  89. #endif