All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
com.google.scrollview.ui.SVMenuBar Class Reference
Inheritance diagram for com.google.scrollview.ui.SVMenuBar:

Public Member Functions

 SVMenuBar (SVWindow scrollView)
 
void actionPerformed (ActionEvent e)
 
void add (String parent, String name, int id)
 
void add (String parent, String name, int id, boolean b)
 

Detailed Description

The SVMenuBar class provides the functionality to add a menubar to ScrollView. Each menubar item gets associated with a (client-defined) command-id, which SVMenuBar will return upon clicking it.

Author
wanke.nosp@m.@goo.nosp@m.gle.c.nosp@m.om

Definition at line 31 of file SVMenuBar.java.

Constructor & Destructor Documentation

com.google.scrollview.ui.SVMenuBar.SVMenuBar ( SVWindow  scrollView)
inline

Create a new SVMenuBar and place it at the top of the ScrollView window.

Parameters
scrollViewThe window our menubar belongs to.

Definition at line 44 of file SVMenuBar.java.

44  {
45  root = new JMenuBar();
46  svWindow = scrollView;
47  items = new HashMap<String, SVAbstractMenuItem>();
48  svWindow.setJMenuBar(root);
49  }

Member Function Documentation

void com.google.scrollview.ui.SVMenuBar.actionPerformed ( ActionEvent  e)
inline

A click on one of the items in our menubar has occured. Forward it to the item itself to let it decide what happens.

Definition at line 56 of file SVMenuBar.java.

56  {
57  // Get the corresponding menuitem.
58  SVAbstractMenuItem svm = items.get(e.getActionCommand());
59 
60  svm.performAction(svWindow, SVEventType.SVET_MENU);
61  }
SVEventType
Definition: scrollview.h:45
void com.google.scrollview.ui.SVMenuBar.add ( String  parent,
String  name,
int  id 
)
inline

Add a new entry to the menubar.

Parameters
parentThe menu we add our new entry to (should have been defined before). If the parent is "", we will add the entry to the root (top-level)
nameThe caption of the new entry.
idThe Id of the new entry. If it is -1, the entry will be treated as a menu.

Definition at line 73 of file SVMenuBar.java.

73  {
74  // A duplicate entry - we just throw it away, since its already in.
75  if (items.get(name) != null) { return; }
76  // A new submenu at the top-level
77  if (parent.equals("")) {
78  JMenu jli = new JMenu(name);
79  SVAbstractMenuItem mli = new SVSubMenuItem(name, jli);
80  items.put(name, mli);
81  root.add(jli);
82  }
83  // A new sub-submenu
84  else if (id == -1) {
85  SVAbstractMenuItem jmi = items.get(parent);
86  JMenu jli = new JMenu(name);
87  SVAbstractMenuItem mli = new SVSubMenuItem(name, jli);
88  items.put(name, mli);
89  jmi.add(jli);
90  }
91  // A new child entry. Add to appropriate parent.
92  else {
93  SVAbstractMenuItem jmi = items.get(parent);
94  if (jmi == null) {
95  System.out.println("ERROR: Unknown parent " + parent);
96  System.exit(1);
97  }
98  SVAbstractMenuItem mli = new SVEmptyMenuItem(id, name);
99  mli.mi.addActionListener(this);
100  items.put(name, mli);
101  jmi.add(mli);
102  }
103  }
name_table name
void com.google.scrollview.ui.SVMenuBar.add ( String  parent,
String  name,
int  id,
boolean  b 
)
inline

Add a new checkbox entry to the menubar.

Parameters
parentThe menu we add our new entry to (should have been defined before). If the parent is "", we will add the entry to the root (top-level)
nameThe caption of the new entry.
idThe Id of the new entry. If it is -1, the entry will be treated as a menu.
bWhether the entry is initally flagged.

Definition at line 118 of file SVMenuBar.java.

118  {
119  SVAbstractMenuItem jmi = items.get(parent);
120  if (jmi == null) {
121  System.out.println("ERROR: Unknown parent " + parent);
122  System.exit(1);
123  }
124  SVAbstractMenuItem mli = new SVCheckboxMenuItem(id, name, b);
125  mli.mi.addActionListener(this);
126  items.put(name, mli);
127  jmi.add(mli);
128  }
name_table name

The documentation for this class was generated from the following file: