1
/* -*- Mode: C#; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/
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
13
* The Original Code is Manticore.
15
* The Initial Developer of the Original Code is
16
* Silverstone Interactive. Portions created by Silverstone Interactive are
17
* Copyright (C) 2001 Silverstone Interactive.
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.
31
* Ben Goodger <ben@netscape.com>
35
namespace Silverstone.Manticore.Browser
38
using System.Collections;
39
using System.ComponentModel;
42
using System.Windows.Forms;
45
/// Summary description for LocationBar.
47
public class LocationBar : System.Windows.Forms.UserControl
49
private System.Windows.Forms.Label mAddressLabel;
50
private System.Windows.Forms.TextBox mAddressBar;
51
private System.Windows.Forms.Button mGoButton;
53
/// Required designer variable.
55
private System.ComponentModel.Container components = null;
59
// This call is required by the Windows.Forms Form Designer.
60
InitializeComponent();
62
mAddressBar.KeyDown += new KeyEventHandler(OnKeyDown);
63
mAddressBar.ModifiedChanged += new EventHandler(OnAddressBarModified);
64
mGoButton.Click += new EventHandler(OnGoButtonClick);
71
return mAddressBar.Text;
75
if (value != mAddressBar.Text)
76
mAddressBar.Text = value;
80
public delegate void LocationBarEventHandler(Object sender, LocationBarEventArgs e);
82
public event LocationBarEventHandler LocationBarCommit;
84
protected void OnKeyDown(Object aSender, KeyEventArgs aKea)
86
if (aKea.KeyCode == Keys.Enter)
87
FireLocationBarCommit();
90
protected void OnGoButtonClick(Object aSender, EventArgs aEa)
92
FireLocationBarCommit();
95
protected void FireLocationBarCommit()
97
if (LocationBarCommit != null)
99
LocationBarEventArgs lbea = new LocationBarEventArgs(mAddressBar.Text);
100
LocationBarCommit(this, lbea);
104
public event LocationBarEventHandler LocationBarModified;
105
protected void OnAddressBarModified(Object aSender, EventArgs aEa)
107
if (LocationBarModified != null)
109
LocationBarEventArgs lbea = new LocationBarEventArgs(mAddressBar.Text);
110
LocationBarModified(this, lbea);
114
protected override void OnPaint(PaintEventArgs aPea)
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);
121
#region Component Designer generated code
123
/// Required method for Designer support - do not modify
124
/// the contents of this method with the code editor.
126
private void InitializeComponent()
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();
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:";
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 = "";
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";
163
this.Controls.AddRange(new System.Windows.Forms.Control[] {
166
this.mAddressLabel});
167
this.Name = "LocationBar";
168
this.Size = new System.Drawing.Size(448, 25);
169
this.ResumeLayout(false);
175
public class LocationBarEventArgs : EventArgs
177
public LocationBarEventArgs(string aText)
182
protected string mText;