fix DemoHyperText

small sizing change for DemoExpander

svn path=/trunk/gtk-sharp/; revision=42185
This commit is contained in:
John Luke 2005-03-24 04:32:49 +00:00
parent c14d107865
commit d9d19a3450
3 changed files with 21 additions and 12 deletions

View file

@ -14,12 +14,17 @@ namespace GtkDemo
{
public DemoExpander () : base ("Demo Expander", null, DialogFlags.DestroyWithParent)
{
this.Resizable = false;
this.BorderWidth = 10;
this.VBox.PackStart (new Label ("Expander demo. Click on the triangle for details."), false, true, 3);
VBox vbox = new VBox (false, 5);
this.VBox.PackStart (vbox, true, true, 0);
vbox.BorderWidth = 5;
vbox.PackStart (new Label ("Expander demo. Click on the triangle for details."), false, false, 0);
// Create the expander
Expander expander = new Expander ("Details");
expander.Add (new Label ("Details can be shown or hidden."));
this.VBox.PackStart (expander, false, true, 3);
vbox.PackStart (expander, false, false, 0);
this.AddButton (Stock.Close, ResponseType.Close);

View file

@ -20,6 +20,8 @@ namespace GtkDemo
[Demo ("Hyper Text", "DemoHyperText.cs", "Text Widget")]
public class DemoHyperText : Gtk.Window
{
// FIXME: useless counter
int uid = 0;
bool hoveringOverLink = false;
Gdk.Cursor handCursor, regularCursor;
@ -64,12 +66,11 @@ namespace GtkDemo
// as a link.
void InsertLink (TextBuffer buffer, ref TextIter iter, string text, int page)
{
TextTag tag = new TextTag ("link");
TextTag tag = new TextTag ("link" + uid++);
tag.Foreground = "blue";
tag.Underline = Pango.Underline.Single;
tag.PersistentData.Add ("page", page);
buffer.TagTable.Add (tag);
buffer.InsertWithTags (ref iter, text, tag);
}
@ -101,8 +102,12 @@ namespace GtkDemo
}
else if (page == 3)
{
TextTag tag = new TextTag ("bold");
TextTag tag = buffer.TagTable.Lookup ("bold");
if (tag == null) {
tag = new TextTag ("bold");
tag.Weight = Pango.Weight.Bold;
buffer.TagTable.Add (tag);
}
buffer.InsertWithTags (ref iter, "hypertext:\n", tag);
buffer.Insert (ref iter,
"machine-readable text that is not sequential but is organized" +
@ -127,7 +132,6 @@ namespace GtkDemo
// Looks at all tags covering the position (x, y) in the text view,
// and if one of them is a link, change the cursor to the "hands" cursor
// typically used by web browsers.
void SetCursorIfAppropriate (TextView view, int x, int y)
{
bool hovering = false;
@ -135,8 +139,7 @@ namespace GtkDemo
foreach (TextTag tag in iter.Tags)
{
int page = (int) tag.PersistentData ["page"];
if (page != 0) {
if (tag.PersistentData ["page"] != null && ((int) tag.PersistentData ["page"]) != 0) {
hovering = true;
break;
}
@ -152,6 +155,7 @@ namespace GtkDemo
}
}
[GLib.ConnectBefore]
void OnButtonRelease (object sender, ButtonReleaseEventArgs a)
{
if (a.Event.Button != 1)

View file

@ -11,10 +11,10 @@ DemoStockBrowser
- remove duplication in ListStore, and use DataFunc's
DemoHyperText
- finish
- link tags are recreated too much and never removed
Future
------
IconView
RotatedText
IconView - gtk 2.6
RotatedText - pango 1.6