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.

125 lines
3.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. Added callback, code page stuff and various details by Salvador Eduardo Tropea.
  9. Added new class TButtonRef by Salvador Eduardo Tropea.
  10. Added i18n support by Salvador Eduardo Tropea.
  11. *
  12. *
  13. */
  14. /* ---------------------------------------------------------------------- */
  15. /* TButton object */
  16. /* */
  17. /* Palette layout */
  18. /* 1 = Normal text */
  19. /* 2 = Default text */
  20. /* 3 = Selected text */
  21. /* 4 = Disabled text */
  22. /* 5 = Normal shortcut */
  23. /* 6 = Default shortcut */
  24. /* 7 = Selected shortcut */
  25. /* 8 = Shadow */
  26. /* ---------------------------------------------------------------------- */
  27. #if defined( Uses_TButton ) && !defined( __TButton )
  28. #define __TButton
  29. class TRect;
  30. struct TEvent;
  31. class TDrawBuffer;
  32. // SET: callback function and return values
  33. typedef int (*TButtonCallBack)(unsigned command);
  34. const int btcbGoOn=0, btcbEndModal=1;
  35. class TButton : public TView
  36. {
  37. public:
  38. TButton( const TRect& bounds,
  39. const char *aTitle,
  40. ushort aCommand,
  41. ushort aFlags
  42. );
  43. ~TButton();
  44. virtual void draw();
  45. void drawState( Boolean down );
  46. virtual TPalette& getPalette() const;
  47. virtual void handleEvent( TEvent& event );
  48. void makeDefault( Boolean enable );
  49. virtual void press();
  50. virtual void setState( ushort aState, Boolean enable );
  51. void setCallBack(TButtonCallBack cb) { callBack=cb; };
  52. const char *getText() { return TVIntl::getText(title,intlTitle); };
  53. const char *title;
  54. stTVIntl *intlTitle;
  55. static char shadows[];
  56. static char markers[];
  57. static char oshadows[];
  58. static char omarkers[];
  59. protected:
  60. ushort command;
  61. uchar flags;
  62. Boolean amDefault;
  63. TButtonCallBack callBack;
  64. private:
  65. void drawTitle( TDrawBuffer&, int, int, ushort, Boolean );
  66. void pressButton( TEvent& );
  67. TRect getActiveRect();
  68. #if !defined( NO_STREAM )
  69. virtual const char *streamableName() const
  70. { return name; }
  71. protected:
  72. TButton( StreamableInit ): TView( streamableInit ) {};
  73. virtual void write( opstream& );
  74. virtual void *read( ipstream& );
  75. public:
  76. static const char * const name;
  77. static TStreamable *build();
  78. #endif // NO_STREAM
  79. };
  80. inline ipstream& operator >> ( ipstream& is, TButton& cl )
  81. { return is >> (TStreamable&)cl; }
  82. inline ipstream& operator >> ( ipstream& is, TButton*& cl )
  83. { return is >> (void *&)cl; }
  84. inline opstream& operator << ( opstream& os, TButton& cl )
  85. { return os << (TStreamable&)cl; }
  86. inline opstream& operator << ( opstream& os, TButton* cl )
  87. { return os << (TStreamable *)cl; }
  88. // Note: you can't stream this class. Wait until I create relative code page
  89. // TViews for international buttons.
  90. class TButtonRef : public TButton
  91. {
  92. public:
  93. TButtonRef( const TRect& bounds,
  94. const char *aTitle,
  95. ushort aCommand,
  96. ushort aFlags
  97. );
  98. ~TButtonRef();
  99. };
  100. #endif // Uses_TButton