01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: EditorPane.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.gui.ui;
09:
10: import com.uwyn.rife.swing.Images;
11: import com.uwyn.rife.swing.JBorderlessButton;
12: import com.uwyn.rife.tools.Localization;
13: import java.awt.BorderLayout;
14: import javax.swing.JPanel;
15: import javax.swing.JScrollPane;
16: import javax.swing.JToolBar;
17: import javax.swing.JViewport;
18:
19: public abstract class EditorPane extends JPanel {
20: private EditorToolBar mToolBar = null;
21: private JScrollPane mScrollPane = null;
22: private EditorView mView = null;
23:
24: private JBorderlessButton mPanButton = null;
25:
26: // private PanWindow mPanWindow = null;
27:
28: protected EditorPane() {
29: super ();
30:
31: mScrollPane = new JScrollPane();
32: mScrollPane
33: .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
34: mScrollPane
35: .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
36: mPanButton = new JBorderlessButton(Images.getRepInstance()
37: .getImageIcon("pan.gif"));
38: mPanButton.setDefaultCapable(false);
39: mPanButton.setBorder(null);
40: // mPanButton.addMouseListener(this);
41: mPanButton.setToolTipText(Localization
42: .getString("rife.tooltip.tool.pan"));
43: mScrollPane.setCorner(JScrollPane.LOWER_RIGHT_CORNER,
44: mPanButton);
45: mScrollPane.getViewport().setScrollMode(
46: JViewport.BLIT_SCROLL_MODE);
47:
48: setLayout(new BorderLayout());
49: }
50:
51: protected void constructLayout() {
52: mScrollPane.setViewportView(mView);
53: if (mToolBar.getOrientation() == JToolBar.HORIZONTAL) {
54: add(mToolBar, BorderLayout.NORTH);
55: } else {
56: add(mToolBar, BorderLayout.EAST);
57: }
58: add(mScrollPane, BorderLayout.CENTER);
59:
60: mToolBar.setVisible(true);
61: mScrollPane.setVisible(true);
62: mView.setVisible(true);
63: }
64:
65: protected void setView(EditorView view) {
66: mView = view;
67: }
68:
69: protected void setToolBar(EditorToolBar toolbar) {
70: mToolBar = toolbar;
71: }
72:
73: public EditorToolBar getToolBar() {
74: return mToolBar;
75: }
76:
77: public JScrollPane getScrollPane() {
78: return mScrollPane;
79: }
80:
81: public EditorView getView() {
82: return mView;
83: }
84: }
|