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.

214 lines
5.7 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. Modified by Salvador E. Tropea for Unicode Copyright (c) 2003.
  9. *
  10. *
  11. */
  12. #if defined( Uses_TView ) && !defined( __TView )
  13. #define __TView
  14. struct write_args
  15. {
  16. void *self;
  17. void *target;
  18. void *buf;
  19. ushort offset;
  20. };
  21. class TRect;
  22. struct TEvent;
  23. class TGroup;
  24. class TPalette;
  25. class TCommandSet;
  26. class TView : public TObject
  27. #if !defined ( NO_STREAM )
  28. , public TStreamable
  29. #endif // NO_STREAM
  30. {
  31. public:
  32. friend void genRefs();
  33. enum phaseType { phFocused, phPreProcess, phPostProcess };
  34. enum selectMode{ normalSelect, enterSelect, leaveSelect };
  35. TView( const TRect& bounds );
  36. ~TView();
  37. virtual void sizeLimits( TPoint& min, TPoint& max );
  38. TRect getBounds();
  39. TRect getExtent();
  40. TRect getClipRect();
  41. Boolean mouseInView( TPoint mouse );
  42. Boolean containsMouse( TEvent& event );
  43. void locate( TRect& bounds );
  44. virtual void dragView( TEvent& event, uchar mode, // temporary fix
  45. TRect& limits, TPoint minSize, TPoint maxSize ); // for Miller's stuff
  46. virtual void calcBounds( TRect& bounds, TPoint delta );
  47. virtual void changeBounds( const TRect& bounds );
  48. void growTo( int x, int y );
  49. void moveTo( int x, int y );
  50. void setBounds( const TRect& bounds );
  51. virtual ushort getHelpCtx();
  52. virtual Boolean valid( ushort command );
  53. void hide();
  54. void show();
  55. virtual void draw();
  56. void drawView();
  57. Boolean exposed();
  58. void hideCursor();
  59. void drawHide( TView *lastView );
  60. void drawShow( TView *lastView );
  61. void drawUnderRect( TRect& r, TView *lastView );
  62. void drawUnderView( Boolean doShadow, TView *lastView );
  63. virtual uint32 dataSize();
  64. virtual void getData( void *rec );
  65. virtual void setData( void *rec );
  66. void blockCursor();
  67. void normalCursor();
  68. virtual void resetCursor();
  69. void setCursor( int x, int y );
  70. void showCursor();
  71. void drawCursor();
  72. void clearEvent( TEvent& event );
  73. Boolean eventAvail();
  74. virtual void getEvent( TEvent& event );
  75. virtual void handleEvent( TEvent& event );
  76. virtual void putEvent( TEvent& event );
  77. static Boolean commandEnabled( ushort command );
  78. static void disableCommands( TCommandSet& commands );
  79. static void enableCommands( TCommandSet& commands );
  80. static void disableCommand( ushort command );
  81. static void enableCommand( ushort command );
  82. static void getCommands( TCommandSet& commands );
  83. static void setCommands( TCommandSet& commands );
  84. virtual void endModal( ushort command );
  85. virtual ushort execute();
  86. ushort getColor( ushort color );
  87. virtual TPalette& getPalette() const;
  88. uchar mapColor( uchar );
  89. Boolean getState( ushort aState );
  90. void select();
  91. virtual void setState( ushort aState, Boolean enable );
  92. void keyEvent( TEvent& event );
  93. Boolean mouseEvent( TEvent& event, ushort mask );
  94. TPoint makeGlobal( TPoint source );
  95. TPoint makeLocal( TPoint source );
  96. TView *nextView();
  97. TView *prevView();
  98. TView *prev();
  99. TView *next;
  100. void makeFirst();
  101. void putInFrontOf( TView *Target );
  102. TView *TopView();
  103. // For old code bypassing TDrawBuffer and encoding using 8 bit chars
  104. void writeBuf(int x, int y, int w, int h, const void *b);
  105. // Best choice because the TDrawBuffer says which format is used
  106. void writeBuf(int x, int y, int w, int h, TDrawBufferBase& b);
  107. // For new code that want to bypass TDrawBuffer and knows the screen format
  108. void writeNativeBuf(int x, int y, int w, int h, const void *Buffer);
  109. void writeLine(int x, int y, int w, int h, const void *b);
  110. void writeLine(int x, int y, int w, int h, TDrawBufferBase& b);
  111. void writeNativeLine(int x, int y, int w, int h, const void *b);
  112. void writeChar(int x, int y, char c, uchar color, int count);
  113. void writeCharU16(int x, int y, unsigned c, unsigned color, int count);
  114. void writeStr(int x, int y, const char *str, uchar color);
  115. void writeStrU16(int x, int y, const uint16 *str, unsigned color);
  116. TPoint size;
  117. ushort options;
  118. ushort eventMask;
  119. ushort state;
  120. TPoint origin;
  121. TPoint cursor;
  122. uchar growMode;
  123. uchar dragMode;
  124. ushort helpCtx;
  125. static Boolean commandSetChanged;
  126. static TCommandSet curCommandSet;
  127. TGroup *owner;
  128. static Boolean showMarkers;
  129. static uchar errorAttr;
  130. virtual void shutDown();
  131. // SET: These are shared by various TView members.
  132. // I moved it to a class because I think is better to enclose them.
  133. static uchar specialChars[];
  134. static uchar ospecialChars[];
  135. private:
  136. void moveGrow( TPoint p,
  137. TPoint s,
  138. TRect& limits,
  139. TPoint minSize,
  140. TPoint maxSize,
  141. uchar mode
  142. );
  143. void change( uchar, TPoint delta, TPoint& p, TPoint& s, int grow=0 );
  144. static void writeView( write_args );
  145. #if !defined( NO_STREAM )
  146. virtual const char *streamableName() const
  147. { return name; }
  148. protected:
  149. TView( StreamableInit );
  150. public:
  151. static const char * const name;
  152. static TStreamable *build();
  153. protected:
  154. virtual void write( opstream& );
  155. virtual void *read( ipstream& );
  156. #endif // NO_STREAM
  157. };
  158. inline ipstream& operator >> ( ipstream& is, TView& cl )
  159. { return is >> (TStreamable&)cl; }
  160. inline ipstream& operator >> ( ipstream& is, TView*& cl )
  161. { return is >> (void *&)cl; }
  162. inline opstream& operator << ( opstream& os, TView& cl )
  163. { return os << (TStreamable&)cl; }
  164. inline opstream& operator << ( opstream& os, TView* cl )
  165. { return os << (TStreamable *)cl; }
  166. #endif // Uses_TView