~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/extensions/manticore/browser/LocationBar.cs

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C#; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 
2
 *
 
3
 * The contents of this file are subject to the Mozilla Public License
 
4
 * Version 1.1 (the "License"); you may not use this file except in
 
5
 * compliance with the License. You may obtain a copy of the License at
 
6
 * http://www.mozilla.org/MPL/ 
 
7
 * 
 
8
 * Software distributed under the License is distributed on an "AS IS" basis,
 
9
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
10
 * for the specific language governing rights and limitations under the
 
11
 * License. 
 
12
 *
 
13
 * The Original Code is Manticore.
 
14
 * 
 
15
 * The Initial Developer of the Original Code is
 
16
 * Silverstone Interactive. Portions created by Silverstone Interactive are
 
17
 * Copyright (C) 2001 Silverstone Interactive. 
 
18
 *
 
19
 * Alternatively, the contents of this file may be used under the
 
20
 * terms of the GNU Public License (the "GPL"), in which case the
 
21
 * provisions of the GPL are applicable instead of those above.
 
22
 * If you wish to allow use of your version of this file only
 
23
 * under the terms of the GPL and not to allow others to use your
 
24
 * version of this file under the MPL, indicate your decision by
 
25
 * deleting the provisions above and replace them with the notice
 
26
 * and other provisions required by the GPL.  If you do not delete
 
27
 * the provisions above, a recipient may use your version of this
 
28
 * file under either the MPL or the GPL.
 
29
 *
 
30
 * Contributor(s):
 
31
 *  Ben Goodger <ben@netscape.com>
 
32
 *
 
33
 */
 
34
 
 
35
namespace Silverstone.Manticore.Browser
 
36
{
 
37
  using System;
 
38
  using System.Collections;
 
39
  using System.ComponentModel;
 
40
  using System.Drawing;
 
41
  using System.Data;
 
42
  using System.Windows.Forms;
 
43
 
 
44
  /// <summary>
 
45
        /// Summary description for LocationBar.
 
46
        /// </summary>
 
47
        public class LocationBar : System.Windows.Forms.UserControl
 
48
        {
 
49
    private System.Windows.Forms.Label mAddressLabel;
 
50
    private System.Windows.Forms.TextBox mAddressBar;
 
51
    private System.Windows.Forms.Button mGoButton;
 
52
                /// <summary> 
 
53
                /// Required designer variable.
 
54
                /// </summary>
 
55
                private System.ComponentModel.Container components = null;
 
56
 
 
57
                public LocationBar()
 
58
                {
 
59
                        // This call is required by the Windows.Forms Form Designer.
 
60
                        InitializeComponent();
 
61
 
 
62
                        mAddressBar.KeyDown += new KeyEventHandler(OnKeyDown);
 
63
      mAddressBar.ModifiedChanged += new EventHandler(OnAddressBarModified);
 
64
      mGoButton.Click += new EventHandler(OnGoButtonClick);
 
65
                }
 
66
 
 
67
    public string Text 
 
68
    {
 
69
      get 
 
70
      {
 
71
        return mAddressBar.Text;
 
72
      }
 
73
      set 
 
74
      {
 
75
        if (value != mAddressBar.Text)
 
76
          mAddressBar.Text = value;
 
77
      }
 
78
    }
 
79
 
 
80
    public delegate void LocationBarEventHandler(Object sender, LocationBarEventArgs e);
 
81
    
 
82
    public event LocationBarEventHandler LocationBarCommit;
 
83
 
 
84
    protected void OnKeyDown(Object aSender, KeyEventArgs aKea)
 
85
    {
 
86
      if (aKea.KeyCode == Keys.Enter) 
 
87
        FireLocationBarCommit();
 
88
    }
 
89
 
 
90
    protected void OnGoButtonClick(Object aSender, EventArgs aEa)
 
91
    {
 
92
      FireLocationBarCommit();      
 
93
    }
 
94
 
 
95
    protected void FireLocationBarCommit()
 
96
    {
 
97
      if (LocationBarCommit != null) 
 
98
      {
 
99
        LocationBarEventArgs lbea = new LocationBarEventArgs(mAddressBar.Text);
 
100
        LocationBarCommit(this, lbea);
 
101
      }
 
102
    }
 
103
 
 
104
    public event LocationBarEventHandler LocationBarModified;
 
105
    protected void OnAddressBarModified(Object aSender, EventArgs aEa)
 
106
    {
 
107
      if (LocationBarModified != null) 
 
108
      {
 
109
        LocationBarEventArgs lbea = new LocationBarEventArgs(mAddressBar.Text);
 
110
        LocationBarModified(this, lbea);
 
111
      }
 
112
    }
 
113
 
 
114
    protected override void OnPaint(PaintEventArgs aPea)
 
115
    {
 
116
      Graphics g = aPea.Graphics;
 
117
      g.DrawLine(SystemPens.ControlDark, 0, 0, ClientRectangle.Width, 0);
 
118
      g.DrawLine(SystemPens.ControlLight, 0, 1, ClientRectangle.Width, 1);
 
119
    }
 
120
 
 
121
                #region Component Designer generated code
 
122
                /// <summary> 
 
123
                /// Required method for Designer support - do not modify 
 
124
                /// the contents of this method with the code editor.
 
125
                /// </summary>
 
126
                private void InitializeComponent()
 
127
                {
 
128
      this.mAddressLabel = new System.Windows.Forms.Label();
 
129
      this.mAddressBar = new System.Windows.Forms.TextBox();
 
130
      this.mGoButton = new System.Windows.Forms.Button();
 
131
      this.SuspendLayout();
 
132
      // 
 
133
      // mAddressLabel
 
134
      // 
 
135
      this.mAddressLabel.AutoSize = true;
 
136
      this.mAddressLabel.Location = new System.Drawing.Point(8, 6);
 
137
      this.mAddressLabel.Name = "mAddressLabel";
 
138
      this.mAddressLabel.Size = new System.Drawing.Size(49, 13);
 
139
      this.mAddressLabel.TabIndex = 0;
 
140
      this.mAddressLabel.Text = "A&ddress:";
 
141
      // 
 
142
      // mAddressBar
 
143
      // 
 
144
      this.mAddressBar.Anchor = (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);
 
145
      this.mAddressBar.Location = new System.Drawing.Point(64, 3);
 
146
      this.mAddressBar.Name = "mAddressBar";
 
147
      this.mAddressBar.Size = new System.Drawing.Size(336, 20);
 
148
      this.mAddressBar.TabIndex = 1;
 
149
      this.mAddressBar.Text = "";
 
150
      // 
 
151
      // mGoButton
 
152
      // 
 
153
      this.mGoButton.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
 
154
      this.mGoButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
 
155
      this.mGoButton.Location = new System.Drawing.Point(408, 2);
 
156
      this.mGoButton.Name = "mGoButton";
 
157
      this.mGoButton.Size = new System.Drawing.Size(32, 23);
 
158
      this.mGoButton.TabIndex = 2;
 
159
      this.mGoButton.Text = "Go";
 
160
      // 
 
161
      // LocationBar
 
162
      // 
 
163
      this.Controls.AddRange(new System.Windows.Forms.Control[] {
 
164
                                                                  this.mGoButton,
 
165
                                                                  this.mAddressBar,
 
166
                                                                  this.mAddressLabel});
 
167
      this.Name = "LocationBar";
 
168
      this.Size = new System.Drawing.Size(448, 25);
 
169
      this.ResumeLayout(false);
 
170
 
 
171
    }
 
172
                #endregion
 
173
        }
 
174
 
 
175
  public class LocationBarEventArgs : EventArgs
 
176
  {
 
177
    public LocationBarEventArgs(string aText)
 
178
    {
 
179
      mText = aText;
 
180
    }
 
181
 
 
182
    protected string mText;
 
183
    public string Text
 
184
    {
 
185
      get 
 
186
      {
 
187
        return mText;
 
188
      }
 
189
    }
 
190
  }
 
191
}