mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-26 00:15:39 +00:00
b3a7fd2924
* sample/GtkDemo/DemoApplicationWindow.cs : New sample, Unfinished, 5% Done * sample/GtkDemo/DemoButtonBox.cs : New sample, * sample/GtkDemo/DemoColorSelection.cs : New sample, * sample/GtkDemo/DemoDialog.cs : New sample, * sample/GtkDemo/DemoDrawingArea.cs : New sample, * sample/GtkDemo/DemoEditableCells.cs : New sample, Needs clean up * sample/GtkDemo/DemoImages.cs : New sample, Unfinished, 75% Done * sample/GtkDemo/DemoItemFactory.cs : New sample, Unfinished, 5% Done * sample/GtkDemo/DemoListStore.cs : New sample, * sample/GtkDemo/DemoMain.cs : New sample, Unifnished, 60% Done * sample/GtkDemo/DemoMenus.cs : New sample, * sample/GtkDemo/DemoPanes.cs : New sample, * sample/GtkDemo/DemoPixbuf.cs : New sample, Needs clean up * sample/GtkDemo/DemoSizeGroup.cs : New sample, * sample/GtkDemo/DemoStockBrowser.cs : New sample, Unfinished, 20% Done * sample/GtkDemo/DemoTextView.cs : New sample, Unfinished, 99% Done * sample/GtkDemo/DemoTreeStore.cs : New sample, Unfinished, 95% Done * sample/GtkDemo/images : Several Images for the samples * sample/GtkDemo/Makefile : Very simple Makefile * sample/GtkDemo/README : Mentions explicitely unfinished state of port svn path=/trunk/gtk-sharp/; revision=19489
179 lines
4.8 KiB
C#
179 lines
4.8 KiB
C#
//
|
|
// TestMenus.cs
|
|
//
|
|
// Author: Duncan Mak (duncan@ximian.com)
|
|
//
|
|
// Copyright (C) 2002, Duncan Mak, Ximian Inc.
|
|
//
|
|
|
|
/* Menus
|
|
*
|
|
* There are several widgets involved in displaying menus. The
|
|
* MenuBar widget is a horizontal menu bar, which normally appears
|
|
* at the top of an application. The Menu widget is the actual menu
|
|
* that pops up. Both MenuBar and Menu are subclasses of
|
|
* MenuShell; a MenuShell contains menu items
|
|
* (MenuItem). Each menu item contains text and/or images and can
|
|
* be selected by the user.
|
|
*
|
|
* There are several kinds of menu item, including plain MenuItem,
|
|
* CheckMenuItem which can be checked/unchecked, RadioMenuItem
|
|
* which is a check menu item that's in a mutually exclusive group,
|
|
* SeparatorMenuItem which is a separator bar, TearoffMenuItem
|
|
* which allows a Menu to be torn off, and ImageMenuItem which
|
|
* can place a Image or other widget next to the menu text.
|
|
*
|
|
* A MenuItem can have a submenu, which is simply a Menu to pop
|
|
* up when the menu item is selected. Typically, all menu items in a menu bar
|
|
* have submenus.
|
|
*
|
|
* The OptionMenu widget is a button that pops up a Menu when clicked.
|
|
* It's used inside dialogs and such.
|
|
*
|
|
* ItemFactory provides a higher-level interface for creating menu bars
|
|
* and menus; while you can construct menus manually, most people don't
|
|
* do that. There's a separate demo for ItemFactory.
|
|
*
|
|
*/
|
|
|
|
|
|
// TODO : window width is not exactly equal
|
|
// point on the right side
|
|
|
|
using System;
|
|
|
|
using Gtk;
|
|
using GtkSharp;
|
|
|
|
namespace GtkDemo
|
|
{
|
|
public class DemoMenus
|
|
{
|
|
private Gtk.Window window;
|
|
|
|
public DemoMenus ()
|
|
{
|
|
window = new Window ("Menus");
|
|
window.DeleteEvent += new DeleteEventHandler (WindowDelete);
|
|
|
|
AccelGroup accel_group = new AccelGroup ();
|
|
window.AddAccelGroup (accel_group);
|
|
|
|
VBox box1 = new VBox (false, 0);
|
|
window.Add (box1);
|
|
|
|
MenuBar menubar = new MenuBar ();
|
|
box1.PackStart (menubar, false, false, 0);
|
|
|
|
Menu menu = Create_Menu (2, true);
|
|
|
|
MenuItem menuitem = new MenuItem ("test\nline2");
|
|
menuitem.Submenu = menu;
|
|
menubar.Append (menuitem);
|
|
|
|
MenuItem menuitem1 = new MenuItem ("foo");
|
|
menuitem1.Submenu = Create_Menu (3, true);
|
|
menubar.Append (menuitem1);
|
|
|
|
menuitem = new MenuItem ("bar");
|
|
menuitem.Submenu = Create_Menu (4, true);
|
|
menuitem.RightJustified = true;
|
|
menubar.Append (menuitem);
|
|
|
|
menubar = new MenuBar ();
|
|
box1.PackStart (menubar, false, true, 0);
|
|
|
|
VBox box2 = new VBox (false, 10);
|
|
box2.BorderWidth = 10;
|
|
box1.PackStart (box2, true, true, 0);
|
|
|
|
menu = Create_Menu (1, false);
|
|
menu.AccelGroup = accel_group;
|
|
|
|
menu.Append (new SeparatorMenuItem ());
|
|
|
|
menuitem = new CheckMenuItem ("Accelerate Me");
|
|
menu.Append (menuitem);
|
|
menuitem.AddAccelerator ("activate", accel_group, 0xFFBE, 0, AccelFlags.Visible);
|
|
|
|
menuitem = new CheckMenuItem ("Accelerator locked");
|
|
menu.Append (menuitem);
|
|
menuitem.AddAccelerator ("activate", accel_group, 0xFFBF, 0, AccelFlags.Visible | AccelFlags.Locked);
|
|
|
|
menuitem = new CheckMenuItem ("Accelerator Frozen");
|
|
menu.Append (menuitem);
|
|
menuitem.AddAccelerator ("activate", accel_group, 0xFFBF, 0, AccelFlags.Visible);
|
|
menuitem.AddAccelerator ("activate", accel_group, 0xFFC0, 0, AccelFlags.Visible);
|
|
|
|
OptionMenu option_menu = new OptionMenu ();
|
|
option_menu.Menu = menu;
|
|
option_menu.SetHistory (3);
|
|
box2.PackStart (option_menu, true, true, 0);
|
|
|
|
box1.PackStart (new HSeparator (), false, false, 0);
|
|
|
|
box2 = new VBox (false, 10);
|
|
box2.BorderWidth = 10;
|
|
box1.PackStart (box2, false, true, 0);
|
|
|
|
Button close_button = new Button ("close");
|
|
close_button.Clicked += new EventHandler (Close_Button);
|
|
box2.PackStart (close_button, true, true, 0);
|
|
|
|
close_button.CanDefault = true;
|
|
close_button.GrabDefault ();
|
|
|
|
window.ShowAll ();
|
|
}
|
|
|
|
private Menu Create_Menu (int depth, bool tearoff)
|
|
{
|
|
if (depth < 1)
|
|
return null;
|
|
|
|
Menu menu = new Menu ();
|
|
MenuItem menuitem;
|
|
string label;
|
|
GLib.SList group = new GLib.SList (IntPtr.Zero);
|
|
|
|
if (tearoff)
|
|
{
|
|
menuitem = new TearoffMenuItem ();
|
|
menu.Append (menuitem);
|
|
menuitem.Show ();
|
|
}
|
|
|
|
for (int i = 0, j = 1; i < 5; i++, j++)
|
|
{
|
|
label = String.Format ("item {0} - {1}", depth, j);
|
|
menuitem = RadioMenuItem.NewWithLabel (group, label);
|
|
group = ((RadioMenuItem) menuitem).Group;
|
|
menuitem = new MenuItem (label);
|
|
menu.Append (menuitem);
|
|
|
|
if (i == 3)
|
|
menuitem.Sensitive = false;
|
|
|
|
Menu child = Create_Menu ((depth - 1), true);
|
|
|
|
if (child != null)
|
|
menuitem.Submenu = child;
|
|
}
|
|
|
|
return menu;
|
|
}
|
|
|
|
private void Close_Button (object o, EventArgs args)
|
|
{
|
|
window.Hide ();
|
|
window.Destroy ();
|
|
}
|
|
|
|
private void WindowDelete (object o, DeleteEventArgs args)
|
|
{
|
|
window.Hide ();
|
|
window.Destroy ();
|
|
}
|
|
}
|
|
}
|