* TreeView.cs: Don't draw the selected node when we lose
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / PropertyGridTextBox.cs
1 using System;
2
3 namespace System.Windows.Forms.PropertyGridInternal {
4         internal class PropertyGridTextBox : System.Windows.Forms.UserControl {
5                 private TextBox textbox;
6                 private Button dialog_button;
7                 private Button dropdown_button;
8                 /// <summary> 
9                 /// Required designer variable.
10                 /// </summary>
11                 private System.ComponentModel.Container components = null;
12
13                 public PropertyGridTextBox() {
14                         // This call is required by the Windows.Forms Form Designer.
15                         InitializeComponent();
16                         dropdown_button.Paint+=new PaintEventHandler(dropdown_button_Paint);
17
18                         // TODO: Add any initialization after the InitializeComponent call
19
20                 }
21
22                 /// <summary> 
23                 /// Clean up any resources being used.
24                 /// </summary>
25                 protected override void Dispose( bool disposing ) {
26                         if( disposing ) {
27                                 if(components != null) {
28                                         components.Dispose();
29                                 }
30                         }
31                         base.Dispose( disposing );
32                 }
33
34                 #region Component Designer generated code
35                 /// <summary> 
36                 /// Required method for Designer support - do not modify 
37                 /// the contents of this method with the code editor.
38                 /// </summary>
39                 private void InitializeComponent() {
40                         this.dialog_button = new System.Windows.Forms.Button();
41                         this.dropdown_button = new System.Windows.Forms.Button();
42                         this.textbox = new System.Windows.Forms.TextBox();
43                         this.SuspendLayout();
44                         // 
45                         // dialog_button
46                         // 
47                         this.dialog_button.Dock = System.Windows.Forms.DockStyle.Right;
48                         this.dialog_button.Location = new System.Drawing.Point(256, 0);
49                         this.dialog_button.Name = "dialog_button";
50                         this.dialog_button.Size = new System.Drawing.Size(16, 16);
51                         this.dialog_button.TabIndex = 1;
52                         this.dialog_button.Text = "D";
53                         this.dialog_button.Visible = false;
54                         this.dialog_button.Click += new System.EventHandler(this.dialog_button_Click);
55                         // 
56                         // dropdown_button
57                         // 
58                         this.dropdown_button.Dock = System.Windows.Forms.DockStyle.Right;
59                         this.dropdown_button.Location = new System.Drawing.Point(240, 0);
60                         this.dropdown_button.Name = "dropdown_button";
61                         this.dropdown_button.Size = new System.Drawing.Size(16, 16);
62                         this.dropdown_button.TabIndex = 2;
63                         this.dropdown_button.Visible = false;
64                         this.dropdown_button.Click += new System.EventHandler(this.dropdown_button_Click);
65                         // 
66                         // textbox
67                         // 
68                         this.textbox.AutoSize = false;
69                         this.textbox.BackColor = System.Drawing.SystemColors.Window;
70                         this.textbox.BorderStyle = System.Windows.Forms.BorderStyle.None;
71                         this.textbox.Dock = System.Windows.Forms.DockStyle.Fill;
72                         this.textbox.Location = new System.Drawing.Point(0, 0);
73                         this.textbox.Name = "textbox";
74                         this.textbox.Size = new System.Drawing.Size(240, 16);
75                         this.textbox.TabIndex = 3;
76                         this.textbox.Text = "textbox";
77                         // 
78                         // PropertyGridTextBox
79                         // 
80                         this.Controls.Add(this.textbox);
81                         this.Controls.Add(this.dropdown_button);
82                         this.Controls.Add(this.dialog_button);
83                         this.Name = "PropertyGridTextBox";
84                         this.Size = new System.Drawing.Size(272, 16);
85                         this.ResumeLayout(false);
86
87                 }
88                 #endregion
89
90                 private void dropdown_button_Click(object sender, System.EventArgs e) {
91                         if (DropDownButtonClicked != null)
92                                 DropDownButtonClicked(this, EventArgs.Empty);
93                 }
94
95                 private void dialog_button_Click(object sender, System.EventArgs e) {
96                         if (DialogButtonClicked != null)
97                                 DialogButtonClicked(this, EventArgs.Empty);
98                 }
99
100                 
101                 public event EventHandler DropDownButtonClicked;
102                 public event EventHandler DialogButtonClicked;
103
104                 public bool DialogButtonVisible {
105                         get{
106                                 return dialog_button.Visible;
107                         }
108                         set {
109                                 dialog_button.Visible = value;
110                                 dropdown_button.Redraw();
111                         }
112                 }
113                 public bool DropDownButtonVisible {
114                         get{
115                                 return dropdown_button.Visible;
116                         }
117                         set {
118                                 dropdown_button.Visible = value;
119                                 dropdown_button.Redraw();
120                         }
121                 }
122
123                 public bool ReadOnly {
124                         get {
125                                 return textbox.ReadOnly;
126                         }
127                         set {
128                                 textbox.ReadOnly = value;
129                         }
130                 }
131
132                 public new string Text {
133                         get {
134                                 return textbox.Text;
135                         }
136                         set {
137                                 textbox.Text = value;
138                         }
139                 }
140
141                 private void dropdown_button_Paint(object sender, PaintEventArgs e)
142                 {
143                         ThemeEngine.Current.CPDrawComboButton(e.Graphics, dropdown_button.ClientRectangle, dropdown_button.ButtonState);
144                 }
145         }
146 }