1
// NotebookButtonBar.cs
4
// Lluis Sanchez Gual <lluis@novell.com>
6
// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
8
// Permission is hereby granted, free of charge, to any person obtaining a copy
9
// of this software and associated documentation files (the "Software"), to deal
10
// in the Software without restriction, including without limitation the rights
11
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
// copies of the Software, and to permit persons to whom the Software is
13
// furnished to do so, subject to the following conditions:
15
// The above copyright notice and this permission notice shall be included in
16
// all copies or substantial portions of the Software.
18
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31
namespace MonoDevelop.Components
33
[System.ComponentModel.Category("MonoDevelop.Components")]
34
[System.ComponentModel.ToolboxItem(true)]
35
public class NotebookButtonBar: Toolbar
40
public NotebookButtonBar()
42
IconSize = IconSize.Menu;
43
ToolbarStyle = ToolbarStyle.BothHoriz;
48
public Widget Notebook {
49
get { return notebook; }
51
notebook = value as Notebook;
52
notebook.SwitchPage += OnPageChanged;
54
ShowPage (notebook.Page);
58
void OnPageChanged (object s, Gtk.SwitchPageArgs args)
63
Gtk.Widget[] buttons = Children;
64
for (int n=0; n<buttons.Length; n++) {
65
ToggleToolButton b = (ToggleToolButton) buttons [n];
66
b.Active = (n == args.PageNum);
76
foreach (Gtk.Widget c in Children)
78
foreach (Gtk.Widget page in notebook.Children) {
79
Gtk.Widget t = notebook.GetTabLabel (page);
80
notebook.SetTabLabel (page, new Gtk.Label (""));
83
nw = new Gtk.Label (((Gtk.Label)t).Text);
85
nw = new Gtk.Label ("");
86
ToggleToolButton button = new ToggleToolButton ();
87
button.IsImportant = true;
88
button.LabelWidget = t;
89
button.Clicked += new EventHandler (OnButtonToggled);
96
public void SetButton (int index, string label, string icon)
98
ToggleToolButton button = (ToggleToolButton) Children [index];
100
button.StockId = icon;
103
protected ToggleToolButton AddButton (string label, Gtk.Widget page)
105
if (notebook == null)
108
ToggleToolButton button = new ToggleToolButton ();
109
button.Label = label;
110
button.IsImportant = true;
111
button.Clicked += new EventHandler (OnButtonToggled);
115
notebook.AppendPage (page, new Gtk.Label ());
120
public void RemoveButton (int npage)
122
if (notebook == null)
124
notebook.RemovePage (npage);
125
Gtk.Widget cw = Children [npage];
131
void OnButtonToggled (object s, EventArgs args)
133
int i = Array.IndexOf (Children, s);
138
public virtual void ShowPage (int npage)
140
if (notebook.CurrentPage == npage) {
141
ToggleToolButton but = (ToggleToolButton) Children [npage];
146
if (updating) return;
148
notebook.CurrentPage = npage;
151
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
153
GdkWindow.DrawRectangle (Style.BackgroundGC (State), true, Allocation);
155
foreach (Widget child in Children) {
156
PropagateExpose (child, evnt);