本文整理汇总了C#中Gtk.DrawingArea.SetSizeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingArea.SetSizeRequest方法的具体用法?C# DrawingArea.SetSizeRequest怎么用?C# DrawingArea.SetSizeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.DrawingArea
的用法示例。
在下文中一共展示了DrawingArea.SetSizeRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AdjustWindowSize
public static void AdjustWindowSize(HuffLibrary.Tree HTree, DrawingArea Canvas)
{
int ImageWidth, ImageHeight;
Canvas.SetSizeRequest (0, 0);
//Reduce window size in case our tree is small
GetAreaSize (HTree.GetRootNode (), out ImageWidth, out ImageHeight, cellsize);
int width, height;
Canvas.GdkWindow.GetSize (out width, out height);
Canvas.SetSizeRequest (ImageWidth, ImageHeight);
if (height > ImageHeight)
Canvas.GdkWindow.Resize (width, ImageHeight);
}
示例2: GlToggleButton
public GlToggleButton(GdkGL.Config config)
{
// VBox.
VBox vbox = new VBox (false, 0);
vbox.BorderWidth = 10;
// Drawing area for drawing OpenGL scene.
DrawingArea drawing_area = new DrawingArea ();
drawing_area.SetSizeRequest (200, 200);
// Set OpenGL-capability to the widget.
m_gl = new GlWidget (drawing_area, config);
drawing_area.Realized += new EventHandler (Realize);
drawing_area.ConfigureEvent += new ConfigureEventHandler (Configure);
drawing_area.ExposeEvent += new ExposeEventHandler (Expose);
drawing_area.Unrealized += new EventHandler (Unrealize);
drawing_area.VisibilityNotifyEvent += new VisibilityNotifyEventHandler (VisibilityNotify);
vbox.PackStart (drawing_area, true, true, 0);
drawing_area.Show ();
// Label.
Label label = new Label ("Toggle Animation");
vbox.PackStart (label, false, false, 10);
label.Show ();
Toggled += new EventHandler (ToggleAnimation);
// Add VBox.
vbox.Show ();
Add (vbox);
}
示例3: Main15
//private static Gdk.Pixmap pixmap = null;
//private static Gtk.InputDialog inputDialog = null;
public static int Main15 (string[] args) {
Application.Init ();
win = new Gtk.Window ("Scribble XInput Demo");
win.DeleteEvent += new DeleteEventHandler (WindowDelete);
vBox = new VBox (false, 0);
win.Add (vBox);
darea = new Gtk.DrawingArea ();
darea.SetSizeRequest (200, 200);
// darea.ExtensionEvents=ExtensionMode.Cursor;
vBox.PackStart (darea, true, true, 0);
//darea.ExposeEvent += new ExposeEventHandler (ExposeEvent);
darea.ConfigureEvent += new ConfigureEventHandler (ConfigureEvent);
darea.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEvent);
darea.ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEvent);
darea.Events = EventMask.ExposureMask | EventMask.LeaveNotifyMask |
EventMask.ButtonPressMask | EventMask.PointerMotionMask;
inputButton = new Button("Input Dialog");
vBox.PackStart (inputButton, false, false, 0);
inputButton.Clicked += new EventHandler (InputButtonClicked);
quitButton = new Button("Quit");
vBox.PackStart (quitButton, false, false, 0);
quitButton.Clicked += new EventHandler (QuitButtonClicked);
win.ShowAll ();
Application.Run ();
return 0;
}
示例4: DemoColorSelection
public DemoColorSelection () : base ("Color Selection")
{
BorderWidth = 8;
VBox vbox = new VBox (false,8);
vbox.BorderWidth = 8;
Add (vbox);
// Create the color swatch area
Frame frame = new Frame ();
frame.ShadowType = ShadowType.In;
vbox.PackStart (frame, true, true, 0);
drawingArea = new DrawingArea ();
drawingArea.ExposeEvent += new ExposeEventHandler (ExposeEventCallback);
// set a minimum size
drawingArea.SetSizeRequest (200,200);
// set the color
color = new Gdk.Color (0, 0, 0xff);
drawingArea.ModifyBg (StateType.Normal, color);
frame.Add (drawingArea);
Alignment alignment = new Alignment (1.0f, 0.5f, 0.0f, 0.0f);
Button button = new Button ("_Change the above color");
button.Clicked += new EventHandler (ChangeColorCallback);
alignment.Add (button);
vbox.PackStart (alignment);
ShowAll ();
}
示例5: DemoColorSelection
public DemoColorSelection () : base ("Color Selection")
{
BorderWidth = 8;
VBox vbox = new VBox (false,8);
vbox.BorderWidth = 8;
Add (vbox);
// Create the color swatch area
Frame frame = new Frame ();
frame.ShadowType = ShadowType.In;
vbox.PackStart (frame, true, true, 0);
drawingArea = new DrawingArea ();
// set a minimum size
drawingArea.SetSizeRequest (200,200);
// set the color
color.Red = 0;
color.Green = 0;
color.Blue = 1;
color.Alpha = 1;
drawingArea.OverrideBackgroundColor (StateFlags.Normal, color);
frame.Add (drawingArea);
Alignment alignment = new Alignment (1.0f, 0.5f, 0.0f, 0.0f);
Button button = new Button ("_Change the above color");
button.Clicked += new EventHandler (ChangeColorCallback);
alignment.Add (button);
vbox.PackStart (alignment, false, false, 0);
ShowAll ();
}
示例6: BuildInterface
private void BuildInterface()
{
VBox vbox = this.Child as VBox;
HButtonBox buttonBox = new HButtonBox ();
drawingArea = new DrawingArea ();
drawingArea.SetSizeRequest (640, 480);
captureButton = new Button ("Capture");
previewButton = new Button ("Preview");
previewButton.Sensitive = false;
saveButton = new Button ("Save");
saveButton.Sensitive = false;
cancelButton = new Button ("Cancel");
buttonBox.PackStart (captureButton);
buttonBox.PackStart (previewButton);
buttonBox.PackStart (saveButton);
buttonBox.PackStart (cancelButton);
buttonBox.LayoutStyle = ButtonBoxStyle.Center;
vbox.PackStart (drawingArea);
vbox.PackStart (buttonBox, false, true, 8);
this.ShowAll ();
this.DeleteEvent += new DeleteEventHandler(OnDelete);
captureButton.Clicked += new EventHandler (CaptureButtonClicked);
previewButton.Clicked += new EventHandler(PreviewButtonClicked);
saveButton.Clicked += new EventHandler (SaveButtonClicked);
cancelButton.Clicked += new EventHandler (CancelButtonClicked);
}
示例7: MainWindow_Widget2
public MainWindow_Widget2()
: base("Widget2")
{
SetDefaultSize(800, 600);
SetPosition(WindowPosition.Center);
BorderWidth = 7;
DeleteEvent += delegate
{
Application.Quit();
};
_label = new Label("...");
Entry entry = new Entry();
entry.Changed += OnChangedEntry;
// scale and image
HScale scale = new HScale(0, 100, 1);
{
scale.SetSizeRequest(160, 35);
scale.ValueChanged += OnChangeScale;
LoadImage();
_image = new Image(img1);
}
// Color
ToggleButton red = new ToggleButton("red");
{
red.SetSizeRequest(80, 35);
red.Clicked += OnRed;
_area = new DrawingArea();
_area.SetSizeRequest(150, 150);
}
Calendar calendar = new Calendar();
{
calendar.DaySelected += OnDaySelected;
}
Fixed fix = new Fixed();
fix.Put(entry, 60, 100);
fix.Put(_label, 60, 40);
fix.Put(scale, 60, 200);
fix.Put(_image, 10, 240);
fix.Put(red, 300, 250);
fix.Put(_area, 300, 500);
fix.Put(calendar, 500, 300);
Add(fix);
ShowAll();
}
示例8: DemoDrawingArea
public DemoDrawingArea () : base ("Drawing Area")
{
BorderWidth = 8;
VBox vbox = new VBox (false, 8);
vbox.BorderWidth = 8;
Add (vbox);
// Create the checkerboard area
Label label = new Label ("<u>Checkerboard pattern</u>");
label.UseMarkup = true;
vbox.PackStart (label, false, false, 0);
Frame frame = new Frame ();
frame.ShadowType = ShadowType.In;
vbox.PackStart (frame, true, true, 0);
DrawingArea da = new DrawingArea ();
// set a minimum size
da.SetSizeRequest (100,100);
frame.Add (da);
da.ExposeEvent += new ExposeEventHandler (CheckerboardExpose);
// Create the scribble area
label = new Label ("<u>Scribble area</u>");
label.UseMarkup = true;
vbox.PackStart (label, false, false, 0);
frame = new Frame ();
frame.ShadowType = ShadowType.In;
vbox.PackStart (frame, true, true, 0);
da = new DrawingArea ();
// set a minimum size
da.SetSizeRequest (100, 100);
frame.Add (da);
// Signals used to handle backing pixmap
da.ExposeEvent += new ExposeEventHandler (ScribbleExpose);
da.ConfigureEvent += new ConfigureEventHandler (ScribbleConfigure);
// Event signals
da.MotionNotifyEvent += new MotionNotifyEventHandler (ScribbleMotionNotify);
da.ButtonPressEvent += new ButtonPressEventHandler (ScribbleButtonPress);
// Ask to receive events the drawing area doesn't normally
// subscribe to
da.Events |= EventMask.LeaveNotifyMask | EventMask.ButtonPressMask |
EventMask.PointerMotionMask | EventMask.PointerMotionHintMask;
ShowAll ();
}
示例9: MainWindow
public MainWindow()
: base("Overlaytest")
{
VBox vBox = new VBox ();
_da = new DrawingArea ();
_da.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (0, 0, 0));
_da.SetSizeRequest (400, 300);
_da.DoubleBuffered = false;
vBox.PackStart (_da, false, false, 0);
_scale = new HScale (0, 1, 0.01);
_scale.DrawValue = false;
_scale.ValueChanged += ScaleValueChanged;
vBox.PackStart (_scale, false, false, 0);
HBox hBox = new HBox ();
Button btnOpen = new Button ();
btnOpen.Label = "Open";
btnOpen.Clicked += ButtonOpenClicked;
hBox.PackStart (btnOpen, false, false, 0);
Button btnPlay = new Button ();
btnPlay.Label = "Play";
btnPlay.Clicked += ButtonPlayClicked;
hBox.PackStart (btnPlay, false, false, 0);
Button btnPause = new Button ();
btnPause.Label = "Pause";
btnPause.Clicked += ButtonPauseClicked;
hBox.PackStart (btnPause, false, false, 0);
_lbl = new Label ();
_lbl.Text = "00:00 / 00:00";
hBox.PackEnd (_lbl, false, false, 0);
vBox.PackStart (hBox, false, false, 3);
Add (vBox);
WindowPosition = Gtk.WindowPosition.Center;
DeleteEvent += OnDeleteEvent;
GLib.Timeout.Add (1000, new GLib.TimeoutHandler (UpdatePos));
}
示例10: initDrawingArea
// }}}
// MainWindow::initDrawingArea() {{{
/// <summary>Init the drawing area and put some layout's property</summary>
/// <param name="area">The drawing area</param>
/// <returns>void</returns>
public void initDrawingArea(DrawingArea area)
{
area.SetSizeRequest(this.pref.mainWindowWidth, this.pref.mainWindowHeight);
area.ExposeEvent += onExposeEvent;
// define some colors
Gdk.Color white = new Gdk.Color();
Gdk.Color black = new Gdk.Color();
Gdk.Color.Parse("white", ref white);
Gdk.Color.Parse("black", ref black);
// define area colors
area.ModifyBg(StateType.Normal, white);
area.ModifyBase(StateType.Normal, black);
// XXX move out ?
this.layout.Width = Pango.Units.FromPixels(this.pref.mainWindowWidth);
this.layout.Wrap = Pango.WrapMode.Word;
this.layout.Alignment = Pango.Alignment.Left;
}
示例11: GrabHandle
public GrabHandle (int w, int h)
{
da = new DrawingArea ();
da.SetSizeRequest (w, h);
Orientation = Gtk.Orientation.Vertical;
Child = da;
ShowAll ();
ButtonPressEvent += (o, a) => Dragging = true;
ButtonReleaseEvent += (o, a) => Dragging = false;
EnterNotifyEvent += (o, a) => Inside = true;
LeaveNotifyEvent += (o, a) => Inside = false;
da.ExposeEvent += (o, a) => {
if (da.IsDrawable) {
Gtk.Style.PaintHandle (da.Style, da.GdkWindow, da.State, ShadowType.In,
a.Event.Area, this, "entry", 0, 0, da.Allocation.Width, da.Allocation.Height, Orientation);
}
};
}
示例12: GrabHandle
public GrabHandle(int w, int h)
{
da = new DrawingArea ();
da.SetSizeRequest (w, h);
Orientation = Gtk.Orientation.Vertical;
Child = da;
ShowAll ();
ButtonPressEvent += (o, a) => Dragging = true;
ButtonReleaseEvent += (o, a) => Dragging = false;
EnterNotifyEvent += (o, a) => Inside = true;
LeaveNotifyEvent += (o, a) => Inside = false;
da.Drawn += (o, a) => {
da.StyleContext.Save ();
da.StyleContext.AddClass ("pane-separator");
da.StyleContext.RenderHandle (a.Cr, 0, 0, da.Allocation.Width, da.Allocation.Height);
da.StyleContext.Restore ();
};
}
示例13: Main
public static int Main (string[] args)
{
Application.Init ();
Gtk.Window win = new Gtk.Window ("Scribble demo");
win.DeleteEvent += new DeleteEventHandler (Window_Delete);
darea = new Gtk.DrawingArea ();
darea.SetSizeRequest (200, 200);
win.Add (darea);
darea.ExposeEvent += new ExposeEventHandler (ExposeEvent);
darea.ConfigureEvent += new ConfigureEventHandler (ConfigureEvent);
darea.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEvent);
darea.ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEvent);
darea.Events = EventMask.ExposureMask | EventMask.LeaveNotifyMask |
EventMask.ButtonPressMask | EventMask.PointerMotionMask |
EventMask.PointerMotionHintMask;
win.ShowAll ();
Application.Run ();
return 0;
}
示例14: setupWindow
//Contains all of the components which are on the window
private void setupWindow()
{
//Vertical box (3 sections) which is the main container
VBox MainVBox = new VBox(false, 6);
/*********************Start of menu bar components*********************/
//Note: Flow of menus are:
//Menubar contains MenuItems (e.g. File, Edit, About, etc...)
//MenuItems contains one Menu (i.e. a Submenu)
//Menu contains multiple MenuItems (e.g. Save, Save As, Load, etc...)
MenuBar MainMenuBar = new MenuBar ();
Menu FileMenu = new Menu ();
MenuItem File = new MenuItem ("File");
File.Submenu = FileMenu;
MenuItem ExitItem = new MenuItem ("Exit");
ExitItem.Activated += quitProgram;
FileMenu.Append (ExitItem);
Menu GestureMenu = new Menu ();
MenuItem Gesture = new MenuItem ("Gestures");
Gesture.Submenu = GestureMenu;
MenuItem LoadGesture = new MenuItem ("Load Gesture");
LoadGesture.Activated += openGesture;
GestureMenu.Append (LoadGesture);
MenuItem SaveGestureItem = new MenuItem ("Save Gesture");
SaveGestureItem.Activated += createGesture;
GestureMenu.Append (SaveGestureItem);
Menu PointsMenu = new Menu ();
MenuItem Points = new MenuItem ("Data Points");
Points.Submenu = PointsMenu;
MenuItem LoadPointsItem = new MenuItem ("Load Points");
LoadPointsItem.Activated += loadDataPoints;
PointsMenu.Append (LoadPointsItem);
MenuItem RecordPointsItem = new MenuItem ("Record Points");
RecordPointsItem.Activated += recordPoints;
PointsMenu.Append (RecordPointsItem);
MenuItem BatchRecognizeItem = new MenuItem ("Batch Recognize");
BatchRecognizeItem.Activated += batchRecognize;
PointsMenu.Append (BatchRecognizeItem);
Menu HelpMenu = new Menu ();
MenuItem Help = new MenuItem ("Help");
Help.Submenu = HelpMenu;
MenuItem AboutMenuItem = new MenuItem("About");
HelpMenu.Append (AboutMenuItem);
MainMenuBar.Append (File);
MainMenuBar.Append (Gesture);
MainMenuBar.Append (Points);
MainMenuBar.Append (Help);
/*********************End of menu bar components*********************/
//Drawing area which is the core component of the application
dArea = new DrawingArea ();
dArea.SetSizeRequest (500, 500);
//Horizontal box (4 sections) which contains all of the buttons along the
//bottom of the window
HBox ButtonHBox = new HBox (false, 6);
/*********************Start of Buttons*********************/
Button BtnCreateGesture = new Button ("Create");
Button BtnRecognizeGesture = new Button ("Recognize");
Button BtnClearScreen = new Button ("Clear");
Button BtnRecordPoints = new Button ("Record points");
Button BtnChangeColour = new Button ("Change colour");
//Button functions
BtnCreateGesture.Clicked += new EventHandler (createGesture);
BtnRecognizeGesture.Clicked += new EventHandler (recognizeGesture);
BtnClearScreen.Clicked += new EventHandler (clearScreen);
BtnRecordPoints.Clicked += new EventHandler (recordPoints);
BtnChangeColour.Clicked += changeColour;
//Adding buttons to the current horizontal box
ButtonHBox.PackStart (BtnCreateGesture, true, false, 0);
ButtonHBox.PackStart (BtnRecognizeGesture, true, false, 0);
ButtonHBox.PackStart (BtnClearScreen, true, false, 0);
ButtonHBox.PackStart (BtnRecordPoints, true, false, 0);
ButtonHBox.PackStart (BtnChangeColour, true, false, 0);
/*********************End of Buttons*********************/
//Status bar which shows the score and recognized gesture
sBar = new Statusbar ();
sBar.Push (1, "Ready");
//Entry box for batch function name to be used on the files
//.........这里部分代码省略.........
示例15: InteractivePlotSurface2D
private bool coordsActive_ = true; // Shows X,Y in Tooltip
#endregion Fields
#region Constructors
/// <summary>
/// Default Constructor
/// </summary>
public InteractivePlotSurface2D()
: base()
{
canvas = new DrawingArea (); // allocate local DrawingArea
canvas.CanFocus = true; // enable to receive the focus
// Link the event handlers into the DrawingArea events (default is none)
canvas.SizeAllocated += new SizeAllocatedHandler (SizeAllocated);
canvas.ExposeEvent += new ExposeEventHandler (ExposeEvent);
canvas.EnterNotifyEvent += new EnterNotifyEventHandler (EnterNotify);
canvas.LeaveNotifyEvent += new LeaveNotifyEventHandler (LeaveNotify);
canvas.ButtonPressEvent += new ButtonPressEventHandler (ButtonPress);
canvas.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotify);
canvas.ButtonReleaseEvent += new ButtonReleaseEventHandler (ButtonRelease);
canvas.ScrollEvent += new ScrollEventHandler (ScrollNotify);
canvas.KeyPressEvent += new KeyPressEventHandler (KeyPressed);
canvas.KeyReleaseEvent += new KeyReleaseEventHandler (KeyReleased);
// Subscribe to DrawingArea mouse movement and button press events.
// Enter and Leave notification is necessary to make ToolTips work.
// Specify PointerMotionHint to prevent being deluged with motion events.
canvas.AddEvents ((int)Gdk.EventMask.EnterNotifyMask);
canvas.AddEvents ((int)Gdk.EventMask.LeaveNotifyMask);
canvas.AddEvents ((int)Gdk.EventMask.ButtonPressMask);
canvas.AddEvents ((int)Gdk.EventMask.ButtonReleaseMask);
canvas.AddEvents ((int)Gdk.EventMask.PointerMotionMask);
canvas.AddEvents ((int)Gdk.EventMask.PointerMotionHintMask);
canvas.AddEvents ((int)Gdk.EventMask.ScrollMask);
canvas.SetSizeRequest (400, 300); // Set DrawingArea size
// Set up ToolTips to show coordinates. NB works via Enter/Leave events
// TODO: ToolTips do not work well yet - needs review of approach
this.Canvas.TooltipText = "Coordinates will display here";
}