home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / dtx9302 / tvision / tvcpp / hintstat.cpp next >
Encoding:
C/C++ Source or Header  |  1993-03-05  |  3.7 KB  |  139 lines

  1. /*========================================================*/
  2. /*                       HINTSTAT.CPP                     */
  3. /*           (C) 1993 Michael Maier & DMV-Verlag          */
  4. /* Das Programm zeigt, wie in der Statuszeile zusätzliche */
  5. /* Hilfstexte ausgegeben werden können.                   */
  6. /*        Compiler: Turbo C++ 3.0, Borland C++ 3.1        */
  7. /*========================================================*/
  8.  
  9. #define Uses_TEventQueue
  10. #define Uses_TEvent
  11. #define Uses_TApplication
  12. #define Uses_TKeys
  13. #define Uses_TRect
  14. #define Uses_TMenuBar
  15. #define Uses_TSubMenu
  16. #define Uses_TMenuItem
  17. #define Uses_TMenuBox
  18. #define Uses_TStatusLine
  19. #define Uses_TStatusItem
  20. #define Uses_TStatusDef
  21. #define Uses_TDeskTop
  22. #define Uses_TView
  23. #define Uses_TWindow
  24. #include <tv.h>
  25.  
  26. #include "stdio.h"
  27.  
  28. const int cmNew    = 200;
  29. const int cmOpen   = 201;
  30. const int cmSave   = 202;
  31.  
  32. const int hcNew    = 1000;
  33. const int hcOpen   = 1001;
  34. const int hcSave   = 1002;
  35. const int hcExit   = 1003;
  36. const int hcZoom   = 1004;
  37. const int hcNext   = 1005;
  38. const int hcClose  = 1006;
  39. const int hcFile   = 1007;
  40. const int hcWindow = 1008;
  41.  
  42.  
  43. const char *apstrHilfetexte[] =
  44. {
  45.   "Legt eine neue Datei an",
  46.   "Lädt eine bestehende Datei in den Speicher",
  47.   "Speichert die Datei auf Diskette",
  48.   "Verläßt das Programm",
  49.   "Vergrößert das aktive Fenster",
  50.   "Wechselt zum nächsten Fenster",
  51.   "Schließt das aktive Fenster",
  52.   "Enthält Funktionen zum Dateihandling/Programmende",
  53.   "Enthält Funktionen zum Fensterhandling",
  54.   NULL
  55. };
  56.  
  57. class THintStatusLine: public TStatusLine
  58. {
  59.   public:
  60.      THintStatusLine(const TRect& bounds,
  61.                            TStatusDef& aDefs);
  62.      virtual const char* hint (ushort aHelpCtx);
  63. };
  64.  
  65.  
  66. THintStatusLine::THintStatusLine(const TRect& bounds,
  67.     TStatusDef& aDefs): TStatusLine(bounds, aDefs)
  68. {
  69. };
  70.  
  71.  
  72. const char *THintStatusLine::hint (ushort aHelpCtx)
  73. {
  74.   if(aHelpCtx >= hcNew && aHelpCtx <= hcWindow)
  75.     return(apstrHilfetexte[aHelpCtx - 1000]);
  76.   else
  77.     return("");
  78. };
  79.  
  80. class THintStatusApp: public TApplication
  81. {
  82.   public:
  83.     THintStatusApp();
  84.     static TStatusLine *initStatusLine(TRect r);
  85.     static TMenuBar *initMenuBar(TRect r);
  86. };
  87.  
  88. THintStatusApp::THintStatusApp() :
  89.   TProgInit(&THintStatusApp::initStatusLine,
  90.             &THintStatusApp::initMenuBar,
  91.             &THintStatusApp::initDeskTop)
  92. {
  93. }
  94.  
  95. TMenuBar *THintStatusApp::initMenuBar(TRect r)
  96. {
  97.   r.b.y = r.a.y + 1;
  98.  
  99.   TSubMenu& sub1 =
  100.    *new TSubMenu("~D~atei", kbAltF) +
  101.     *new TMenuItem("~N~eu", cmNew, kbF4, hcNew, "F4") +
  102.      *new TMenuItem("~Ö~ffnen", cmOpen, kbF3, hcOpen, "F3")+
  103.       *new TMenuItem("~S~peichern", cmSave, kbF2, hcSave,
  104.                      "F2") + newLine() +
  105.        *new TMenuItem("Quit", cmQuit, cmQuit, hcExit,
  106.                       "Alt-X");
  107.   sub1.helpCtx = hcFile;
  108.  
  109.   TSubMenu& sub2 =
  110.    *new TSubMenu("~F~enster", kbAltW) +
  111.     *new TMenuItem("~N~ächstes", cmNext, kbF6, hcNext,"F6")+
  112.      *new TMenuItem("~V~ergrößern", cmZoom, kbF5, hcZoom,
  113.                     "F5") +
  114.       *new TMenuItem("~S~chließen", cmClose, kbAltF3,
  115.                      hcClose, "Alt-F3");
  116.   sub2.helpCtx = hcWindow;
  117.  
  118.     return(new TMenuBar(r, sub1 + sub2));
  119. }
  120.  
  121.  
  122. TStatusLine *THintStatusApp::initStatusLine(TRect r)
  123. {
  124.   r.a.y = r.b.y - 1;
  125.   return new THintStatusLine(r, *new TStatusDef(0, 0xFFFF) +
  126.         *new TStatusItem("~F10~ Menu", kbF10, cmMenu) +
  127.         *new TStatusItem(0, kbAltX, cmQuit));
  128. }
  129.  
  130. int main()
  131. {
  132.   THintStatusApp HintStatusApp;
  133.   HintStatusApp.run();
  134.   return(0);
  135. }
  136.  
  137. /*========================================================*/
  138. /*                    Ende von HINTSTAT.CPP               */
  139.