~ubuntu-branches/ubuntu/hoary/monodevelop/hoary

« back to all changes in this revision

Viewing changes to src/Main/Base/Gui/Components/SideBar/AxSideTab.cs

  • Committer: Bazaar Package Importer
  • Author(s): Brandon Hale
  • Date: 2004-10-07 11:51:11 UTC
  • Revision ID: james.westby@ubuntu.com-20041007115111-pxcqnwfxyq5mhcx5
Tags: 0.5.1-3
Use dh_netdeps in debian/rules and debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// <file>
 
2
//     <copyright see="prj:///doc/copyright.txt"/>
 
3
//     <license see="prj:///doc/license.txt"/>
 
4
//     <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
 
5
//     <version value="$version"/>
 
6
// </file>
 
7
 
 
8
using System;
 
9
using System.Drawing;
 
10
using System.Drawing.Drawing2D;
 
11
using System.Collections;
 
12
using MonoDevelop.Core.Services;
 
13
 
 
14
namespace MonoDevelop.Gui.Components
 
15
{
 
16
        public enum SideTabStatus {
 
17
                Normal,
 
18
                Selected,
 
19
                Dragged
 
20
        }
 
21
        
 
22
        public class AxSideTab
 
23
        {/*
 
24
                string    name;
 
25
                bool      canDragDrop  = true;
 
26
                bool      canBeDeleted = true;
 
27
                bool      isClipboardRing = false;
 
28
                SideTabItemCollection items = new SideTabItemCollection();
 
29
                SideTabStatus sideTabStatus;
 
30
                AxSideTabItem   selectedItem = null;
 
31
                AxSideTabItem   choosedItem  = null;
 
32
                
 
33
                ImageList largeImageList = null;
 
34
                ImageList smallImageList = null;
 
35
                int       scrollIndex    = 0;
 
36
                StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));
 
37
                
 
38
                public bool Hidden = false;
 
39
                
 
40
                public bool IsClipboardRing {
 
41
                        get {
 
42
                                return isClipboardRing;
 
43
                        }
 
44
                        set {
 
45
                                isClipboardRing = value;
 
46
                        }
 
47
                }
 
48
                
 
49
                public int ScrollIndex {
 
50
                        get {
 
51
                                return scrollIndex;
 
52
                        }
 
53
                        set {
 
54
                                scrollIndex = value;
 
55
                        }
 
56
                }
 
57
                
 
58
                public ImageList LargeImageList {
 
59
                        get {
 
60
                                return largeImageList;
 
61
                        }
 
62
                        set {
 
63
                                largeImageList = value;
 
64
                        }
 
65
                }
 
66
                
 
67
                public ImageList SmallImageList {
 
68
                        get {
 
69
                                return smallImageList;
 
70
                        }
 
71
                        set {
 
72
                                smallImageList = value;
 
73
                        }
 
74
                }
 
75
                
 
76
                public SideTabStatus SideTabStatus {
 
77
                        get {
 
78
                                return sideTabStatus;
 
79
                        }
 
80
                        
 
81
                        set {
 
82
                                sideTabStatus = value;
 
83
                        }
 
84
                }
 
85
                
 
86
                public bool   CanBeDeleted {
 
87
                        get {
 
88
                                return canBeDeleted;
 
89
                        }
 
90
                        set {
 
91
                                canBeDeleted = value;
 
92
                        }
 
93
                }
 
94
                
 
95
                public string Name {
 
96
                        get {
 
97
                                return name;
 
98
                        }
 
99
                        set {
 
100
                                name = value;
 
101
                        }
 
102
                }
 
103
                
 
104
                public SideTabItemCollection Items  {
 
105
                        get {
 
106
                                return items;
 
107
                        }
 
108
                }
 
109
                
 
110
                public bool CanDragDrop {
 
111
                        get {
 
112
                                return canDragDrop;
 
113
                        }
 
114
                        set {
 
115
                                canDragDrop = value;
 
116
                        }
 
117
                }
 
118
                
 
119
                bool canSaved = true;
 
120
                
 
121
                public bool CanSaved {
 
122
                        get {
 
123
                                return canSaved;
 
124
                        }
 
125
                        set {
 
126
                                canSaved = value;
 
127
                        }
 
128
                }
 
129
                
 
130
                public AxSideTabItem SelectedItem {
 
131
                        get {
 
132
                                return selectedItem;
 
133
                        }
 
134
                        set {
 
135
                                if (selectedItem != null && selectedItem != choosedItem) {
 
136
                                        selectedItem.SideTabItemStatus = SideTabItemStatus.Normal;
 
137
                                }
 
138
                                selectedItem = value;
 
139
                                if (selectedItem != null && selectedItem != choosedItem) {
 
140
                                        selectedItem.SideTabItemStatus = SideTabItemStatus.Selected;
 
141
                                }
 
142
                        }
 
143
                }
 
144
                
 
145
                protected  void OnChoosedItemChanged(EventArgs e)
 
146
                {
 
147
                        if (ChoosedItemChanged != null) {
 
148
                                ChoosedItemChanged(this, e);
 
149
                        }
 
150
                }
 
151
                public event EventHandler ChoosedItemChanged;
 
152
                
 
153
                public AxSideTabItem ChoosedItem {
 
154
                        get {
 
155
                                return choosedItem;
 
156
                        }
 
157
                        set {
 
158
                                if (choosedItem != null) {
 
159
                                        choosedItem.SideTabItemStatus = SideTabItemStatus.Normal;
 
160
                                }
 
161
                                choosedItem = value;
 
162
                                if (choosedItem != null) {
 
163
                                        choosedItem.SideTabItemStatus = SideTabItemStatus.Choosed;
 
164
                                }
 
165
                                OnChoosedItemChanged(null);
 
166
                        }
 
167
                }
 
168
                
 
169
                public ISideTabItemFactory SideTabItemFactory {
 
170
                        get {
 
171
                                return items.SideTabItemFactory;
 
172
                        }
 
173
                        set {
 
174
                                items.SideTabItemFactory = value;
 
175
                        }
 
176
                }
 
177
                
 
178
                protected AxSideTab()
 
179
                {
 
180
                }
 
181
                
 
182
                public AxSideTab(ISideTabItemFactory sideTabItemFactory)
 
183
                {
 
184
                        SideTabItemFactory = sideTabItemFactory;
 
185
                }
 
186
                
 
187
                public AxSideTab(AxSideBar sideBar, string name) : this(sideBar.SideTabItemFactory)
 
188
                {
 
189
                        this.name = name;
 
190
                }
 
191
                
 
192
                public AxSideTab(string name)
 
193
                {
 
194
                        this.name = name;
 
195
                }
 
196
                
 
197
                
 
198
                public bool ScrollDownButtonActivated {
 
199
                        get {
 
200
                                return scrollIndex > 0;
 
201
                        }
 
202
                }
 
203
                
 
204
                public bool ScrollUpButtonActivated {
 
205
                        get {
 
206
                                return true;
 
207
                        }
 
208
                }
 
209
                
 
210
                public void DrawTabHeader(Graphics g, Font font, Point pos, int width)
 
211
                {
 
212
                        switch (sideTabStatus) {
 
213
                                case SideTabStatus.Normal:
 
214
                                        ControlPaint.DrawBorder3D(g, new Rectangle(0, pos.Y, width - 4, font.Height + 4), Border3DStyle.RaisedInner);
 
215
                                        g.DrawString(stringParserService.Parse(name), font, SystemBrushes.ControlText, new RectangleF(1, pos.Y + 1, width - 5, font.Height + 1));
 
216
                                        
 
217
                                        break;
 
218
                                case SideTabStatus.Selected:
 
219
                                        ControlPaint.DrawBorder3D(g, new Rectangle(0, pos.Y, width - 4, font.Height + 4), Border3DStyle.Sunken);
 
220
                                        g.DrawString(stringParserService.Parse(name), font, SystemBrushes.ControlText, new RectangleF(1 + 1, pos.Y + 2, width - 5, font.Height + 2));
 
221
                                        break;
 
222
                                case SideTabStatus.Dragged:
 
223
                                        Rectangle r = new Rectangle(0, pos.Y, width - 4, font.Height + 4);
 
224
                                        ControlPaint.DrawBorder3D(g, r, Border3DStyle.RaisedInner);
 
225
                                        r.X += 2;
 
226
                                        r.Y += 1;
 
227
                                        r.Width  -= 4;
 
228
                                        r.Height -= 2;
 
229
                                        
 
230
                                        g.FillRectangle(SystemBrushes.ControlDarkDark, r);
 
231
                                        
 
232
                                        g.DrawString(stringParserService.Parse(name), font, SystemBrushes.HighlightText, new RectangleF(1 + 1, pos.Y + 2, width - 5, font.Height + 2));
 
233
                                        break;
 
234
                        }
 
235
                }
 
236
                
 
237
                public int Height {
 
238
                        get {
 
239
                                return Items.Count * 20;
 
240
                        }
 
241
                }
 
242
                
 
243
                public Point GetLocation(AxSideTabItem whichItem)
 
244
                {
 
245
                        for (int i = 0; i < Items.Count; ++i) {
 
246
                                AxSideTabItem item = (AxSideTabItem)Items[i];
 
247
                                if (item == whichItem) {
 
248
                                        return new Point(0, i * 20);
 
249
                                }
 
250
                        }
 
251
                        return new Point(-1, -1);
 
252
                }
 
253
                
 
254
                public AxSideTabItem GetItemAt(int x, int y)
 
255
                {
 
256
                        int index = ScrollIndex + y / 20;
 
257
                        return (index >= 0 && index < Items.Count) ? (AxSideTabItem)Items[index] : null;
 
258
                }
 
259
                
 
260
                public AxSideTabItem GetItemAt(Point pos)
 
261
                {
 
262
                        return GetItemAt(pos.X, pos.Y);
 
263
                }
 
264
                
 
265
                public void DrawTabContent(Graphics g, Font f, Rectangle rectangle)
 
266
                {
 
267
                        int itemHeight = 20;
 
268
                        
 
269
                        for (int i = 0; i + ScrollIndex < Items.Count; ++i) {
 
270
                                AxSideTabItem item = (AxSideTabItem)Items[ScrollIndex + i];
 
271
                                if (rectangle.Height < i * itemHeight) {
 
272
                                        break;
 
273
                                }
 
274
                                item.DrawItem(g, f, new Rectangle(rectangle.X,
 
275
                                                                  rectangle.Y + i * itemHeight,
 
276
                                                                  rectangle.Width,
 
277
                                                                  itemHeight));
 
278
                        }
 
279
                }
 
280
                
 
281
                public class SideTabItemCollection : ICollection, IEnumerable
 
282
                {
 
283
                        ArrayList list = new ArrayList();
 
284
                        ISideTabItemFactory sideTabItemFactory = new DefaultSideTabItemFactory();
 
285
                        
 
286
                        public ISideTabItemFactory SideTabItemFactory {
 
287
                                get {
 
288
                                        return sideTabItemFactory;
 
289
                                }
 
290
                                set {
 
291
                                        sideTabItemFactory = value;
 
292
                                }
 
293
                        }
 
294
                        
 
295
                        public SideTabItemCollection()
 
296
                        {
 
297
                        }
 
298
                        
 
299
                        public AxSideTabItem this[int index] {
 
300
                                get {
 
301
                                        return (AxSideTabItem)list[index];
 
302
                                }
 
303
                                set {
 
304
                                        list[index] = value;
 
305
                                }
 
306
                        }
 
307
                        
 
308
                        public int DraggedIndex {
 
309
                                get {
 
310
                                        for (int i = 0; i < Count; ++i) {
 
311
                                                if (this[i].SideTabItemStatus == SideTabItemStatus.Drag)
 
312
                                                        return i;
 
313
                                        }
 
314
                                        return -1;
 
315
                                }
 
316
                        }
 
317
                        
 
318
                        public int Count {
 
319
                                get {
 
320
                                        return list.Count;
 
321
                                }
 
322
                        }
 
323
                        
 
324
                        public virtual bool IsSynchronized {
 
325
                                get {
 
326
                                        return false;
 
327
                                }
 
328
                        }
 
329
                        
 
330
                        public virtual object SyncRoot {
 
331
                                get {
 
332
                                        return this;
 
333
                                }
 
334
                        }
 
335
                        
 
336
                        public virtual AxSideTabItem Add(AxSideTabItem item)
 
337
                        {
 
338
                                list.Add(item);
 
339
                                return item;
 
340
                        }
 
341
                        
 
342
                        public virtual AxSideTabItem Add(string name, object content)
 
343
                        {
 
344
                                return Add(name, content, -1);
 
345
                        }
 
346
                        
 
347
                        public virtual AxSideTabItem Add(string name, object content, int imageIndex)
 
348
                        {
 
349
                                AxSideTabItem item = sideTabItemFactory.CreateSideTabItem(name, imageIndex);
 
350
                                item.Tag = content;
 
351
                                return Add(item);
 
352
                        }
 
353
                        
 
354
                        public virtual void Clear()
 
355
                        {
 
356
                                list.Clear();
 
357
                        }
 
358
                        
 
359
                        public bool Contains(AxSideTabItem item)
 
360
                        {
 
361
                                return list.Contains(item);
 
362
                        }
 
363
                        
 
364
                        public IEnumerator GetEnumerator()
 
365
                        {
 
366
                                return list.GetEnumerator();
 
367
                        }
 
368
                        
 
369
                        public int IndexOf(AxSideTabItem item)
 
370
                        {
 
371
                                return list.IndexOf(item);
 
372
                        }
 
373
                        
 
374
                        public void CopyTo(Array dest, int index)
 
375
                        {
 
376
                                list.CopyTo(dest, index);
 
377
                        }
 
378
                        
 
379
                        public virtual AxSideTabItem Insert(int index, AxSideTabItem item)
 
380
                        {
 
381
                                list.Insert(index, item);
 
382
                                return item;
 
383
                        }
 
384
                        
 
385
                        public virtual AxSideTabItem Insert(int index, string name, object content)
 
386
                        {
 
387
                                return Insert(index, name, content, -1);
 
388
                        }
 
389
                        
 
390
                        public virtual AxSideTabItem Insert(int index, string name, object content, int imageIndex)
 
391
                        {
 
392
                                AxSideTabItem item = sideTabItemFactory.CreateSideTabItem(name, imageIndex);
 
393
                                item.Tag = content;
 
394
                                return Insert(index, item);
 
395
                        }
 
396
                        
 
397
                        public virtual void Remove(AxSideTabItem item)
 
398
                        {
 
399
                                list.Remove(item);
 
400
                        }
 
401
                        
 
402
                        public virtual void RemoveAt(int index)
 
403
                        {
 
404
                                list.RemoveAt(index);
 
405
                        }
 
406
                }*/
 
407
        }
 
408
}