* DropdownGroupTest.cs: New test for drop down ribbon groups
* VariantsCombinaisonTest.cs: New test for variants combinaisons svn path=/trunk/gtk-sharp-ribbon/; revision=110154
This commit is contained in:
Родитель
d1600e5afc
Коммит
b3e2b1fbf0
|
@ -1,3 +1,8 @@
|
|||
2008-08-11 Laurent Debacker <debackerl@gmail.com>
|
||||
|
||||
* DropdownGroupTest.cs: New test for drop down ribbon groups
|
||||
* VariantsCombinaisonTest.cs: New test for variants combinaisons
|
||||
|
||||
2008-06-28 Laurent Debacker <debackerl@gmail.com>
|
||||
|
||||
* MainWindow.cs: Updated sample to show menu opening in app menu
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
using System;
|
||||
using Cairo;
|
||||
using Gtk;
|
||||
using Ribbons;
|
||||
|
||||
namespace Sample
|
||||
{
|
||||
public class DropdownGroupTest : SyntheticWindow
|
||||
{
|
||||
protected bool composeAvailable = false;
|
||||
|
||||
protected Label pageLabel1;
|
||||
|
||||
public DropdownGroupTest() : base (WindowType.Toplevel)
|
||||
{
|
||||
AddEvents ((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask));
|
||||
|
||||
HBox master = new HBox ();
|
||||
master.AddEvents ((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask));
|
||||
|
||||
Title = "Ribbons Sample";
|
||||
AppPaintable = true;
|
||||
|
||||
Ribbons.Button button0 = new Ribbons.Button ("Hello World");
|
||||
|
||||
RibbonGroup group0 = new RibbonGroup ();
|
||||
group0.Label = "Summer of Code";
|
||||
group0.Child = button0;
|
||||
group0.Expand += onClick;
|
||||
|
||||
DropdownRibbonGroup dropGroup0 = new DropdownRibbonGroup ();
|
||||
dropGroup0.Group = group0;
|
||||
dropGroup0.Label = "Drop 1";
|
||||
|
||||
DropdownRibbonGroup dropGroup1 = new DropdownRibbonGroup ();
|
||||
dropGroup1.Group = group0;
|
||||
dropGroup1.Label = "Drop 2";
|
||||
|
||||
master.PackStart (dropGroup0, false, false, 0);
|
||||
master.PackStart (dropGroup1, false, false, 0);
|
||||
|
||||
Add (master);
|
||||
|
||||
ScreenChanged += Window_OnScreenChanged;
|
||||
Window_OnScreenChanged (this, null);
|
||||
ExposeEvent += Window_OnExpose;
|
||||
DeleteEvent += Window_OnDelete;
|
||||
|
||||
this.Resize (200, 200);
|
||||
this.ShowAll ();
|
||||
}
|
||||
|
||||
private void onClick (object Sender, EventArgs e)
|
||||
{
|
||||
Dialog d = new Dialog ("Test", this, DialogFlags.DestroyWithParent);
|
||||
d.Modal = true;
|
||||
d.AddButton ("Close", ResponseType.Close);
|
||||
d.Run ();
|
||||
d.Destroy ();
|
||||
}
|
||||
|
||||
[GLib.ConnectBefore]
|
||||
private void Window_OnExpose (object sender, ExposeEventArgs args)
|
||||
{
|
||||
Gdk.EventExpose evnt = args.Event;
|
||||
Context cr = Gdk.CairoHelper.Create (GdkWindow);
|
||||
|
||||
/*if(composeAvailable)
|
||||
cr.SetSourceRGBA (0, 0, 0, 0.3);
|
||||
else*/
|
||||
cr.SetSourceRGB (0.3, 0.3, 0.3);
|
||||
|
||||
//cr.SetSourceRGB (0.749, 0.859, 1.0);
|
||||
|
||||
cr.Operator = Operator.Source;
|
||||
cr.Paint ();
|
||||
|
||||
((IDisposable)cr.Target).Dispose();
|
||||
((IDisposable)cr).Dispose();
|
||||
|
||||
args.RetVal = false;
|
||||
}
|
||||
|
||||
private void Window_OnScreenChanged (object Send, ScreenChangedArgs args)
|
||||
{
|
||||
Gdk.Colormap cm = Screen.RgbaColormap;
|
||||
composeAvailable = cm != null; // FIX: Do not seem to detect compose support in all cases
|
||||
|
||||
if(!composeAvailable) cm = Screen.RgbColormap;
|
||||
Colormap = cm;
|
||||
|
||||
Console.WriteLine ("Compose Support: " + composeAvailable);
|
||||
}
|
||||
|
||||
private void Window_OnDelete (object send, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit ();
|
||||
args.RetVal = true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,7 +9,8 @@ namespace Sample
|
|||
{
|
||||
Console.WriteLine ("Starting ...");
|
||||
Application.Init ();
|
||||
MainWindow win = new MainWindow ();
|
||||
//MainWindow win = new MainWindow ();
|
||||
VariantsCombinaisonTest win = new VariantsCombinaisonTest ();
|
||||
win.Show ();
|
||||
Application.Run ();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
<File name="AssemblyInfo.cs" subtype="Code" buildaction="Compile" />
|
||||
<File name="MainWindow.cs" subtype="Code" buildaction="Compile" />
|
||||
<File name="SampleTile.cs" subtype="Code" buildaction="Compile" />
|
||||
<File name="DropdownGroupTest.cs" subtype="Code" buildaction="Compile" />
|
||||
<File name="VariantsCombinaisonTest.cs" subtype="Code" buildaction="Compile" />
|
||||
</Contents>
|
||||
<References>
|
||||
<ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
|
||||
|
|
|
@ -0,0 +1,216 @@
|
|||
using System;
|
||||
using Cairo;
|
||||
using Gtk;
|
||||
using Ribbons;
|
||||
|
||||
namespace Sample
|
||||
{
|
||||
public class VariantsCombinaisonTest : SyntheticWindow
|
||||
{
|
||||
protected bool composeAvailable = false;
|
||||
|
||||
protected Label pageLabel1;
|
||||
|
||||
public VariantsCombinaisonTest() : base (WindowType.Toplevel)
|
||||
{
|
||||
AddEvents ((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask));
|
||||
Title = "Ribbons Sample";
|
||||
AppPaintable = true;
|
||||
|
||||
VariantsCombinaisonSwitcher switcher = new VariantsCombinaisonSwitcher ();
|
||||
|
||||
RibbonGroup group0 = CreateGroup0 ();
|
||||
RibbonGroup group1 = CreateGroup1 ();
|
||||
RibbonGroup group2 = CreateGroup2 ();
|
||||
DropdownRibbonGroup dgroup0 = CreateDropdownGroup0 ();
|
||||
dgroup0.Group = group0;
|
||||
DropdownRibbonGroup dgroup1 = CreateDropdownGroup1 ();
|
||||
dgroup1.Group = group1;
|
||||
DropdownRibbonGroup dgroup2 = CreateDropdownGroup2 ();
|
||||
dgroup2.Group = group2;
|
||||
|
||||
VariantsCombinaison combi0 = new VariantsCombinaison ();
|
||||
combi0.Append (group0);
|
||||
combi0.Append (group1);
|
||||
combi0.Append (group2);
|
||||
switcher.AddCombinaison (combi0);
|
||||
|
||||
VariantsCombinaison combi1 = new VariantsCombinaison ();
|
||||
combi1.Append (group0);
|
||||
combi1.Append (group1);
|
||||
combi1.Append (dgroup2);
|
||||
switcher.AddCombinaison (combi1);
|
||||
|
||||
VariantsCombinaison combi2 = new VariantsCombinaison ();
|
||||
combi2.Append (dgroup0);
|
||||
combi2.Append (dgroup1);
|
||||
combi2.Append (dgroup2);
|
||||
switcher.AddCombinaison (combi2);
|
||||
|
||||
Add (switcher);
|
||||
|
||||
ScreenChanged += Window_OnScreenChanged;
|
||||
Window_OnScreenChanged (this, null);
|
||||
ExposeEvent += Window_OnExpose;
|
||||
DeleteEvent += Window_OnDelete;
|
||||
|
||||
this.Resize (200, 200);
|
||||
this.ShowAll ();
|
||||
}
|
||||
|
||||
private RibbonGroup CreateGroup0 ()
|
||||
{
|
||||
Ribbons.Button button0 = new Ribbons.Button ("Hello World");
|
||||
|
||||
RibbonGroup group0 = new RibbonGroup ();
|
||||
group0.Label = "Summer of Code";
|
||||
group0.Child = button0;
|
||||
group0.Expand += onClick;
|
||||
|
||||
return group0;
|
||||
}
|
||||
|
||||
private DropdownRibbonGroup CreateDropdownGroup0 ()
|
||||
{
|
||||
DropdownRibbonGroup ret = new DropdownRibbonGroup ();
|
||||
ret.Label = "Summer of Code";
|
||||
return ret;
|
||||
}
|
||||
|
||||
private RibbonGroup CreateGroup1 ()
|
||||
{
|
||||
Ribbons.Button button1 = new Ribbons.Button ("Menu Test");
|
||||
button1.Clicked += onClick;
|
||||
Menu button1_menu = new Menu ();
|
||||
MenuItem option1 = new MenuItem ("Option 1");
|
||||
button1_menu.Append (option1);
|
||||
button1.DropDownMenu = button1_menu;
|
||||
|
||||
Menu openMenu = new Menu ();
|
||||
MenuItem abc_txt = new MenuItem ("abc.txt");
|
||||
openMenu.Append (abc_txt);
|
||||
MenuItem foo_txt = new MenuItem ("foo.txt");
|
||||
openMenu.Append (foo_txt);
|
||||
|
||||
Ribbons.Button open = Ribbons.Button.FromStockIcon (Gtk.Stock.Open, "Open", false);
|
||||
open.DropDownMenu = openMenu;
|
||||
open.Clicked += onClick;
|
||||
|
||||
Ribbons.ToolPack fileToolPack = new Ribbons.ToolPack ();
|
||||
fileToolPack.AppendButton (Ribbons.Button.FromStockIcon (Gtk.Stock.New, "New", false));
|
||||
fileToolPack.AppendButton (open);
|
||||
fileToolPack.AppendButton (Ribbons.Button.FromStockIcon (Gtk.Stock.Save, "Save", false));
|
||||
|
||||
Ribbons.ToolPack printerToolPack = new Ribbons.ToolPack ();
|
||||
printerToolPack.AppendButton (Ribbons.Button.FromStockIcon (Gtk.Stock.Print, "Print", false));
|
||||
|
||||
Ribbons.ToolPack fontToolPack = new Ribbons.ToolPack ();
|
||||
fontToolPack.AppendButton (Ribbons.ToggleButton.FromStockIcon (Gtk.Stock.Bold, false));
|
||||
fontToolPack.AppendButton (Ribbons.ToggleButton.FromStockIcon (Gtk.Stock.Italic, false));
|
||||
fontToolPack.AppendButton (Ribbons.ToggleButton.FromStockIcon (Gtk.Stock.Underline, false));
|
||||
|
||||
ComboBox font = new ComboBox (new string[] { "Arial", "Verdana" });
|
||||
font.Active = 0;
|
||||
|
||||
Ribbons.ToolBox flow0 = new ToolBox ();
|
||||
flow0.Append (fileToolPack);
|
||||
flow0.Append (printerToolPack);
|
||||
flow0.Append (fontToolPack);
|
||||
flow0.Append (font);
|
||||
|
||||
HBox btnFlowBox = new HBox (false, 2);
|
||||
btnFlowBox.Add (button1);
|
||||
btnFlowBox.Add (flow0);
|
||||
|
||||
// Little hack because Gtk+ is not designed to support size negociations
|
||||
btnFlowBox.SizeAllocated += delegate(object Sender, SizeAllocatedArgs e)
|
||||
{
|
||||
flow0.HeightRequest = e.Allocation.Height;
|
||||
};
|
||||
|
||||
RibbonGroup group1 = new RibbonGroup ();
|
||||
group1.Label = "I will be back";
|
||||
group1.Child = btnFlowBox;
|
||||
|
||||
return group1;
|
||||
}
|
||||
|
||||
private DropdownRibbonGroup CreateDropdownGroup1 ()
|
||||
{
|
||||
DropdownRibbonGroup ret = new DropdownRibbonGroup ();
|
||||
ret.Label = "I will be back";
|
||||
return ret;
|
||||
}
|
||||
|
||||
private RibbonGroup CreateGroup2 ()
|
||||
{
|
||||
Gallery gallery = new Gallery ();
|
||||
gallery.AppendTile (new SampleTile ("1"));
|
||||
gallery.AppendTile (new SampleTile ("2"));
|
||||
gallery.AppendTile (new SampleTile ("3"));
|
||||
gallery.AppendTile (new SampleTile ("4"));
|
||||
gallery.AppendTile (new SampleTile ("5"));
|
||||
|
||||
RibbonGroup group2 = new RibbonGroup ();
|
||||
group2.Label = "Gallery";
|
||||
group2.Child = gallery;
|
||||
|
||||
return group2;
|
||||
}
|
||||
|
||||
private DropdownRibbonGroup CreateDropdownGroup2 ()
|
||||
{
|
||||
DropdownRibbonGroup ret = new DropdownRibbonGroup ();
|
||||
ret.Label = "Gallery";
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void onClick (object Sender, EventArgs e)
|
||||
{
|
||||
Dialog d = new Dialog ("Test", this, DialogFlags.DestroyWithParent);
|
||||
d.Modal = true;
|
||||
d.AddButton ("Close", ResponseType.Close);
|
||||
d.Run ();
|
||||
d.Destroy ();
|
||||
}
|
||||
|
||||
[GLib.ConnectBefore]
|
||||
private void Window_OnExpose (object sender, ExposeEventArgs args)
|
||||
{
|
||||
Gdk.EventExpose evnt = args.Event;
|
||||
Context cr = Gdk.CairoHelper.Create (GdkWindow);
|
||||
|
||||
/*if(composeAvailable)
|
||||
cr.SetSourceRGBA (0, 0, 0, 0.3);
|
||||
else*/
|
||||
cr.SetSourceRGB (0.6, 0.6, 0.6);
|
||||
|
||||
//cr.SetSourceRGB (0.749, 0.859, 1.0);
|
||||
|
||||
cr.Operator = Operator.Source;
|
||||
cr.Paint ();
|
||||
|
||||
((IDisposable)cr.Target).Dispose();
|
||||
((IDisposable)cr).Dispose();
|
||||
|
||||
args.RetVal = false;
|
||||
}
|
||||
|
||||
private void Window_OnScreenChanged (object Send, ScreenChangedArgs args)
|
||||
{
|
||||
Gdk.Colormap cm = Screen.RgbaColormap;
|
||||
composeAvailable = cm != null; // FIX: Do not seem to detect compose support in all cases
|
||||
|
||||
if(!composeAvailable) cm = Screen.RgbColormap;
|
||||
Colormap = cm;
|
||||
|
||||
Console.WriteLine ("Compose Support: " + composeAvailable);
|
||||
}
|
||||
|
||||
private void Window_OnDelete (object send, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit ();
|
||||
args.RetVal = true;
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче