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.

131 lines
4.1 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. /* ---------------------------------------------------------------------- */
  12. /* class TMenuView */
  13. /* */
  14. /* Palette layout */
  15. /* 1 = Normal text */
  16. /* 2 = Disabled text */
  17. /* 3 = Shortcut text */
  18. /* 4 = Normal selection */
  19. /* 5 = Disabled selection */
  20. /* 6 = Shortcut selection */
  21. /* ---------------------------------------------------------------------- */
  22. #if defined( Uses_TMenuView ) && !defined( __TMenuView )
  23. #define __TMenuView
  24. class TRect;
  25. class TMenu;
  26. struct TEvent;
  27. class TMenuView : public TView
  28. {
  29. public:
  30. TMenuView( const TRect& bounds, TMenu *aMenu, TMenuView *aParent );
  31. TMenuView( const TRect& bounds );
  32. void setBounds( const TRect& bounds );
  33. virtual ushort execute();
  34. TMenuItem *findItem( char ch );
  35. virtual TRect getItemRect( TMenuItem *item );
  36. virtual ushort getHelpCtx();
  37. virtual TPalette& getPalette() const;
  38. virtual void handleEvent( TEvent& event );
  39. TMenuItem *hotKey( ushort keyCode );
  40. TMenuView *newSubView( const TRect& bounds,
  41. TMenu *aMenu,
  42. TMenuView *aParentMenu
  43. );
  44. // SET: Looks like some users really likes the original behavior of
  45. // having 1 space around menu items. As it reduces the number of menues
  46. // we can have I added a conditional way to control it. The code is in
  47. // TMenuBar, when you create a menu bar (or chanBounds it) the Bar
  48. // calculates the length of the items and if they are greater than size.x
  49. // enters in the compatMenu mode. "Norberto Alfredo Bensa (Beto)"
  50. // <norberto.bensa@abaconet.com.ar> sent me an uncoditional patch that I used
  51. // as base. This variable is 0 by default (TMenuView constructor)
  52. int compactMenu;
  53. protected:
  54. TMenuView *parentMenu;
  55. TMenu *menu;
  56. TMenuItem *current;
  57. private:
  58. void nextItem();
  59. void prevItem();
  60. void trackKey( Boolean findNext );
  61. Boolean mouseInOwner( TEvent& e );
  62. Boolean mouseInMenus( TEvent& e );
  63. void trackMouse( TEvent& e );
  64. TMenuView *topMenu();
  65. Boolean updateMenu( TMenu *menu );
  66. void do_a_select( TEvent& );
  67. TMenuItem *findHotKey( TMenuItem *p, ushort keyCode );
  68. #if !defined( NO_STREAM )
  69. private:
  70. virtual const char *streamableName() const
  71. { return name; }
  72. static void writeMenu( opstream&, TMenu * );
  73. static TMenu *readMenu( ipstream& );
  74. protected:
  75. TMenuView( StreamableInit );
  76. virtual void write( opstream& );
  77. virtual void *read( ipstream& );
  78. public:
  79. static const char * const name;
  80. static TStreamable *build();
  81. #endif // NO_STREAM
  82. };
  83. #if !defined( NO_STREAM )
  84. inline ipstream& operator >> ( ipstream& is, TMenuView& cl )
  85. { return is >> (TStreamable&)cl; }
  86. inline ipstream& operator >> ( ipstream& is, TMenuView*& cl )
  87. { return is >> (void *&)cl; }
  88. inline opstream& operator << ( opstream& os, TMenuView& cl )
  89. { return os << (TStreamable&)cl; }
  90. inline opstream& operator << ( opstream& os, TMenuView* cl )
  91. { return os << (TStreamable *)cl; }
  92. #endif // NO_STREAM
  93. inline TMenuView::TMenuView( const TRect& bounds,
  94. TMenu *aMenu,
  95. TMenuView *aParent
  96. ) :
  97. TView(bounds), compactMenu ( 0 ), parentMenu( aParent ), menu( aMenu ),
  98. current( 0 )
  99. {
  100. eventMask |= evBroadcast;
  101. }
  102. inline TMenuView::TMenuView( const TRect& bounds ) :
  103. TView(bounds), compactMenu(0), parentMenu(0), menu(0), current(0)
  104. {
  105. eventMask |= evBroadcast;
  106. }
  107. #endif // Uses_TMenuView