Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

menus.h

Go to the documentation of this file.
00001 /*
00002  * menus.h
00003  *
00004  * Turbo Vision - Version 2.0
00005  *
00006  * Copyright (c) 1994 by Borland International
00007  * All Rights Reserved.
00008  *
00009  * Modified by Sergio Sigala <sergio@sigala.it>
00010  */
00011 
00012 class TSubMenu;
00013 class TMenuItem;
00014 class TStatusDef;
00015 class TStatusItem;
00016 
00020 TSubMenu& operator + ( TSubMenu& s, TMenuItem& i );
00024 TSubMenu& operator + ( TSubMenu& s1, TSubMenu& s2 );
00028 TStatusDef& operator + ( TStatusDef& s1, TStatusItem& s2 );
00032 TStatusDef& operator + ( TStatusDef& s1, TStatusDef& s2 );
00033 
00034 #if defined( Uses_TMenuItem ) && !defined( __TMenuItem )
00035 #define __TMenuItem
00036 
00041 class TMenu;
00042 
00052 class TMenuItem
00053 {
00054 public:
00059     TMenuItem( const char *aName,
00060                ushort aCommand,
00061                ushort aKeyCode,
00062                ushort aHelpCtx = hcNoContext,
00063                char *p = 0,
00064                TMenuItem *aNext = 0
00065              );
00070     TMenuItem( const char *aName,
00071                ushort aKeyCode,
00072                TMenu *aSubMenu,
00073                ushort aHelpCtx = hcNoContext,
00074                TMenuItem *aNext = 0
00075              );
00081     ~TMenuItem();
00086     void append( TMenuItem *aNext );
00092     TMenuItem *next;
00096     const char *name;
00101     ushort command;
00106     Boolean disabled;
00110     ushort keyCode;
00119     ushort helpCtx;
00120     union
00121         {
00126         const char *param;
00131         TMenu *subMenu;
00132         };
00133 };
00134 
00135 inline void TMenuItem::append( TMenuItem *aNext )
00136 {
00137     next = aNext;
00138 }
00139 
00143 inline TMenuItem &newLine()
00144 {
00145     return *new TMenuItem( 0, 0, 0, hcNoContext, 0, 0 );
00146 }
00147 
00148 #endif  // Uses_TMenuItem
00149 
00150 #if defined( Uses_TSubMenu ) && !defined( __TSubMenu )
00151 #define __TSubMenu
00152 
00164 class TSubMenu : public TMenuItem
00165 {
00166 public:
00171     TSubMenu( const char *nm, ushort key, ushort helpCtx = hcNoContext );
00172 };
00173 
00174 #endif  // Uses_TSubMenu
00175 
00176 #if defined( Uses_TMenu ) && !defined( __TMenu )
00177 #define __TMenu
00178 
00185 class TMenu
00186 {
00187 public:
00192     TMenu() : items(0), deflt(0) {};
00197     TMenu( TMenuItem& itemList )
00198         { items = &itemList; deflt = &itemList; }
00203     TMenu( TMenuItem& itemList, TMenuItem& TheDefault )
00204         { items = &itemList; deflt = &TheDefault; }
00208     ~TMenu();
00213     TMenuItem *items;
00218     TMenuItem *deflt;
00219 };
00220 
00221 #endif  // Uses_TMenu
00222 
00223 /* ---------------------------------------------------------------------- */
00224 /*      class TMenuView                                                   */
00225 /*                                                                        */
00226 /*      Palette layout                                                    */
00227 /*        1 = Normal text                                                 */
00228 /*        2 = Disabled text                                               */
00229 /*        3 = Shortcut text                                               */
00230 /*        4 = Normal selection                                            */
00231 /*        5 = Disabled selection                                          */
00232 /*        6 = Shortcut selection                                          */
00233 /* ---------------------------------------------------------------------- */
00234 
00235 #if defined( Uses_TMenuView ) && !defined( __TMenuView )
00236 #define __TMenuView
00237 
00238 class TRect;
00239 class TMenu;
00240 class TEvent;
00241 
00249 class TMenuView : public TView
00250 {
00251 public:
00255     TMenuView( const TRect& bounds, TMenu *aMenu, TMenuView *aParent = 0 );
00263     TMenuView( const TRect& bounds );
00267     void setBounds( const TRect& bounds );
00275     virtual ushort execute();
00281     TMenuItem *findItem( char ch );
00287     virtual TRect getItemRect( TMenuItem *item );
00295     virtual ushort getHelpCtx();
00299     virtual TPalette& getPalette() const;
00305     virtual void handleEvent( TEvent& event );
00312     TMenuItem *hotKey( ushort keyCode );
00316     TMenuView *newSubView( const TRect& bounds,
00317                            TMenu *aMenu,
00318                            TMenuView *aParentMenu
00319                          );
00320 protected:
00325     TMenuView *parentMenu;
00331     TMenu *menu;
00335     TMenuItem *current;
00336 private:
00337     void nextItem();
00338     void prevItem();
00339     void trackKey( Boolean findNext );
00340     Boolean mouseInOwner( TEvent& e );
00341     Boolean mouseInMenus( TEvent& e );
00342     void trackMouse( TEvent& e , Boolean& mouseActive);
00343     TMenuView *topMenu();
00344     Boolean updateMenu( TMenu *menu );
00345     void do_a_select( TEvent& );
00346     TMenuItem *findHotKey( TMenuItem *p, ushort keyCode );
00347 private:
00348     virtual const char *streamableName() const
00349         { return name; }
00350     static void writeMenu( opstream&, TMenu * );
00351     static TMenu *readMenu( ipstream& );
00352 protected:
00359     TMenuView( StreamableInit );
00363     virtual void write( opstream& os );
00367     virtual void *read( ipstream& is );
00368 public:
00372     static const char * const name;
00376     static TStreamable *build();
00377 };
00378 
00382 inline ipstream& operator >> ( ipstream& is, TMenuView& cl )
00383     { return is >> (TStreamable&)cl; }
00387 inline ipstream& operator >> ( ipstream& is, TMenuView*& cl )
00388     { return is >> (void *&)cl; }
00389 
00393 inline opstream& operator << ( opstream& os, TMenuView& cl )
00394     { return os << (TStreamable&)cl; }
00398 inline opstream& operator << ( opstream& os, TMenuView* cl )
00399     { return os << (TStreamable *)cl; }
00400 
00401 inline TMenuView::TMenuView( const TRect& bounds,
00402                              TMenu *aMenu,
00403                              TMenuView *aParent
00404                            ) :
00405     TView(bounds),
00406     parentMenu( aParent ),
00407     menu( aMenu ),
00408     current( 0 )
00409 {
00410      eventMask |= evBroadcast;
00411 }
00412 
00413 inline TMenuView::TMenuView( const TRect& bounds ) :
00414     TView(bounds), parentMenu(0), menu(0), current(0)
00415 {
00416      eventMask |= evBroadcast;
00417 }
00418 
00419 #endif  // Uses_TMenuView
00420 
00421 /* ---------------------------------------------------------------------- */
00422 /*      class TMenuBar                                                    */
00423 /*                                                                        */
00424 /*      Palette layout                                                    */
00425 /*        1 = Normal text                                                 */
00426 /*        2 = Disabled text                                               */
00427 /*        3 = Shortcut text                                               */
00428 /*        4 = Normal selection                                            */
00429 /*        5 = Disabled selection                                          */
00430 /*        6 = Shortcut selection                                          */
00431 /* ---------------------------------------------------------------------- */
00432 
00433 #if defined( Uses_TMenuBar ) && !defined( __TMenuBar )
00434 #define __TMenuBar
00435 
00436 class TRect;
00437 class TMenu;
00438 
00462 class TMenuBar : public TMenuView
00463 {
00464 public:
00474     TMenuBar( const TRect& bounds, TMenu *aMenu );
00478     TMenuBar( const TRect& bounds, TSubMenu &aMenu );
00482     ~TMenuBar();
00490     virtual void draw();
00496     virtual TRect getItemRect( TMenuItem *item );
00497 private:
00498     virtual const char *streamableName() const
00499         { return name; }
00500 protected:
00507     TMenuBar( StreamableInit );
00508 public:
00512     static const char * const name;
00516     static TStreamable *build();
00517 };
00518 
00522 inline ipstream& operator >> ( ipstream& is, TMenuBar& cl )
00523     { return is >> (TStreamable&)cl; }
00527 inline ipstream& operator >> ( ipstream& is, TMenuBar*& cl )
00528     { return is >> (void *&)cl; }
00529 
00533 inline opstream& operator << ( opstream& os, TMenuBar& cl )
00534     { return os << (TStreamable&)cl; }
00538 inline opstream& operator << ( opstream& os, TMenuBar* cl )
00539     { return os << (TStreamable *)cl; }
00540 
00541 #endif  // Uses_TMenuBar
00542 
00543 /* ---------------------------------------------------------------------- */
00544 /*      class TMenuBox                                                    */
00545 /*                                                                        */
00546 /*      Palette layout                                                    */
00547 /*        1 = Normal text                                                 */
00548 /*        2 = Disabled text                                               */
00549 /*        3 = Shortcut text                                               */
00550 /*        4 = Normal selection                                            */
00551 /*        5 = Disabled selection                                          */
00552 /*        6 = Shortcut selection                                          */
00553 /* ---------------------------------------------------------------------- */
00554 
00555 #if defined( Uses_TMenuBox ) && !defined( __TMenuBox )
00556 #define __TMenuBox
00557 
00558 class TRect;
00559 class TMenu;
00560 class TMenuView;
00561 class TDrawBuffer;
00562 
00569 class TMenuBox : public TMenuView
00570 {
00571 public:
00586     TMenuBox( const TRect& bounds, TMenu *aMenu, TMenuView *aParentMenu);
00591     virtual void draw();
00596     virtual TRect getItemRect( TMenuItem *item );
00600     static const char * frameChars;
00601 private:
00602     void frameLine( TDrawBuffer&, short n );
00603     void drawLine( TDrawBuffer& );
00604     virtual const char *streamableName() const
00605         { return name; }
00606 protected:
00613     TMenuBox( StreamableInit );
00614 public:
00618     static const char * const name;
00622     static TStreamable *build();
00623 };
00624 
00625 
00629 inline ipstream& operator >> ( ipstream& is, TMenuBox& cl )
00630     { return is >> (TStreamable&)cl; }
00634 inline ipstream& operator >> ( ipstream& is, TMenuBox*& cl )
00635     { return is >> (void *&)cl; }
00636 
00640 inline opstream& operator << ( opstream& os, TMenuBox& cl )
00641     { return os << (TStreamable&)cl; }
00645 inline opstream& operator << ( opstream& os, TMenuBox* cl )
00646     { return os << (TStreamable *)cl; }
00647 
00648 #endif  // Uses_TMenuBox
00649 
00650 
00651 #if defined( Uses_TMenuPopup ) && !defined( __TMenuPopup )
00652 #define __TMenuPopup
00653 
00654 /* ---------------------------------------------------------------------- */
00655 /*      class TMenuPopup                                                  */
00656 /*                                                                        */
00657 /*      Palette layout                                                    */
00658 /*        1 = Normal text                                                 */
00659 /*        2 = Disabled text                                               */
00660 /*        3 = Shortcut text                                               */
00661 /*        4 = Normal selection                                            */
00662 /*        5 = Disabled selection                                          */
00663 /*        6 = Shortcut selection                                          */
00664 /* ---------------------------------------------------------------------- */
00665 
00670 class TMenuPopup : public TMenuBox
00671 {
00672     TMenuPopup(TRect&, TMenu*);
00673     virtual void handleEvent(TEvent&);
00674 public:
00675     static const char * const name;
00676 };
00677 
00678 
00679 #endif  // Uses_TMenuPopup
00680 
00681 
00682 
00683 
00684 #if defined( Uses_TStatusItem ) && !defined( __TStatusItem )
00685 #define __TStatusItem
00686 
00696 class TStatusItem
00697 {
00698 public:
00702     TStatusItem( const char *aText,
00703                  ushort key,
00704                  ushort cmd,
00705                  TStatusItem *aNext = 0
00706                 );
00710     ~TStatusItem();
00716     TStatusItem *next;
00722     char *text;
00726     ushort keyCode;
00730     ushort command;
00731 };
00732 
00733 inline TStatusItem::TStatusItem( const char *aText,
00734                                  ushort key,
00735                                  ushort cmd,
00736                                  TStatusItem *aNext
00737                                 ) :
00738     next( aNext ),
00739     text( newStr(aText) ),
00740     keyCode( key ),
00741     command( cmd )
00742 {
00743 }
00744 
00745 inline TStatusItem::~TStatusItem()
00746 {
00747     delete text;
00748 }
00749 
00750 #endif  // Uses_TStatusItem
00751 
00752 #if defined( Uses_TStatusDef ) && !defined( __TStatusDef )
00753 #define __TStatusDef
00754 
00761 class TStatusDef
00762 {
00763 public:
00767     TStatusDef( ushort aMin,
00768                 ushort aMax,
00769                 TStatusItem *someItems = 0,
00770                 TStatusDef *aNext = 0
00771               );
00777     TStatusDef *next;
00783     ushort min;
00789     ushort max;
00794     TStatusItem *items;
00795 };
00796 
00797 inline TStatusDef::TStatusDef( ushort aMin,
00798                                ushort aMax,
00799                                TStatusItem *someItems,
00800                                TStatusDef *aNext
00801                              ) :
00802     next( aNext ),
00803     min( aMin ),
00804     max( aMax ),
00805     items( someItems )
00806 {
00807 }
00808 
00809 #endif  // Uses_TStatusDef
00810 
00811 /* ---------------------------------------------------------------------- */
00812 /*      class TStatusLine                                                 */
00813 /*                                                                        */
00814 /*      Palette layout                                                    */
00815 /*        1 = Normal text                                                 */
00816 /*        2 = Disabled text                                               */
00817 /*        3 = Shortcut text                                               */
00818 /*        4 = Normal selection                                            */
00819 /*        5 = Disabled selection                                          */
00820 /*        6 = Shortcut selection                                          */
00821 /* ---------------------------------------------------------------------- */
00822 
00823 #if defined( Uses_TStatusLine ) && !defined( __TStatusLine )
00824 #define __TStatusLine
00825 
00826 class TRect;
00827 class TEvent;
00828 class TPoint;
00829 
00842 class TStatusLine : public TView
00843 {
00844 public:
00857     TStatusLine( const TRect& bounds, TStatusDef& aDefs );
00863     ~TStatusLine();
00870     virtual void draw();
00874     virtual TPalette& getPalette() const;
00889     virtual void handleEvent( TEvent& event );
00897     virtual const char* hint( ushort aHelpCtx );
00905     void update();
00909     static const char * hintSeparator;
00910 protected:
00914     TStatusItem *items;
00919     TStatusDef *defs;
00920 private:
00921     void drawSelect( TStatusItem *selected );
00922     void findItems();
00923     TStatusItem *itemMouseIsIn( TPoint );
00924     void disposeItems( TStatusItem *item );
00925     virtual const char *streamableName() const
00926         { return name; }
00927     static void writeItems( opstream&, TStatusItem * );
00928     static void writeDefs( opstream&, TStatusDef * );
00929     static TStatusItem *readItems( ipstream& );
00930     static TStatusDef *readDefs( ipstream& );
00931 protected:
00938     TStatusLine( StreamableInit );
00942     virtual void write( opstream& os );
00946     virtual void *read( ipstream& is );
00947 public:
00951     static const char * const name;
00955     static TStreamable *build();
00956 };
00957 
00961 inline ipstream& operator >> ( ipstream& is, TStatusLine& cl )
00962     { return is >> (TStreamable&)cl; }
00966 inline ipstream& operator >> ( ipstream& is, TStatusLine*& cl )
00967     { return is >> (void *&)cl; }
00968 
00972 inline opstream& operator << ( opstream& os, TStatusLine& cl )
00973     { return os << (TStreamable&)cl; }
00977 inline opstream& operator << ( opstream& os, TStatusLine* cl )
00978     { return os << (TStreamable *)cl; }
00979 
00980 #endif  // Uses_TStatusLine

Generated at Sat Sep 22 20:19:10 2001 for TVision by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001