summaryrefslogtreecommitdiffstats
path: root/tdejava/koala/test/khelpers/KHelpers.java
blob: 08444f49e51038926cd299e0d34ea011d49ecca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import org.trinitydesktop.qt.*;
import org.trinitydesktop.koala.*;

/**
 *  Class KHelpers is the main application window.
 *
 *  Taken from KDE 2.0 Development book
 *
 *  ToolTips, What's This?, and More
 *
 *
 *
 * @see TDEMainWindow
 * @see TDEApplication
 *
 * @author java translation Kenneth J. Pouncey, [email protected]
 * @version 0.1
 */

public class KHelpers extends TDEMainWindow {

   // File menu item id's
   protected int idfilenew;
   protected int idfileopen;
   protected int idfilesave;
   protected int idfilequit;

   // reference to the application
   TDEApplication kapp;

   // time to display the message in the status bar
   int HelpMessageTime = 200;

   public KHelpers () {

      // get a reference to the application
      kapp = TDEApplication.kApplication();

      TQPopupMenu file = new TQPopupMenu(this);

      idfilenew = file.insertItem("&New");
      idfileopen = file.insertItem("&Open...");
      idfilesave = file.insertItem("&Save");
      idfilequit = file.insertItem("&Quit", kapp, TQ_SLOT("closeAllWindows()"));

      connect ( file, TQ_SIGNAL( "highlighted(int)"), this, TQ_SLOT( "slotMenuEntryHelp (int)"));

      menuBar().insertItem("&File",file);

      TQPopupMenu help = helpMenu("KHelpers\n" +
                                    "Copyright (C) 2000 By Joe Developer\n\n" +
                                    "KHelpers demonstates a few of the ways " +
                                    "that your application can provide help to a user");

      help.insertSeparator();
      help.insertItem("Help on a special topic", this, TQ_SLOT("slotSpecialHelp()"));

      menuBar().insertItem("&Help",help);

      // Create the statusbar
      statusBar();

      TQLabel clientarea = new TQLabel(this);
      clientarea.setBackgroundColor(Qt.white());

      TQToolTip.add(clientarea, "Functionless client area");
      TQWhatsThis.add(clientarea,"This client area doesn't do anything.");

      setCentralWidget(clientarea);

      clientarea.setFocus();
   }

   public void slotMenuEntryHelp (int id) {

      if (id == idfilenew) {
         statusBar().message("Create a new document.",HelpMessageTime);
      }
      else if (id == idfileopen) {

         statusBar().message("Open a file.",HelpMessageTime);

      }
      else if (id == idfilesave) {

         statusBar().message("Save the current document.",HelpMessageTime);

      }
      else if (id == idfilequit) {

         statusBar().message("Quit the application.",HelpMessageTime);

      }
   }

   public void slotSpecialHelp() {

      String helpfilename = kapp.name();
      helpfilename += "/specialhelp.html";
      kapp.invokeHelp(helpfilename,"");
   }

}