public virtual void PointerMotion (MouseMotionEventArgs args) { if (mouseDownElement != null) { mouseDownElement.PointerMotion (args); } else { UIElement newMouseOverElement = XYToElement (args.X, args.Y, true); if (newMouseOverElement != mouseOverElement) { if (mouseOverElement != null) MouseLeaveElement (mouseOverElement); if (newMouseOverElement != null) MouseEnterElement (newMouseOverElement); } mouseOverElement = newMouseOverElement; } }
protected virtual void ResourceLoader () { Stream s; fontpal = null; effectpal = null; if (fontpal_path != null) { Console.WriteLine ("loading font palette"); s = (Stream)mpq.GetResource (fontpal_path); if (s != null) { fontpal = new Pcx (); fontpal.ReadFromStream (s, -1, -1); } } if (effectpal_path != null) { Console.WriteLine ("loading cursor palette"); s = (Stream)mpq.GetResource (effectpal_path); if (s != null) { effectpal = new Pcx (); effectpal.ReadFromStream (s, -1, -1); } if (effectpal != null && arrowgrp_path != null) { Console.WriteLine ("loading arrow cursor"); Grp arrowgrp = (Grp)mpq.GetResource (arrowgrp_path); if (arrowgrp != null) { Cursor = new CursorAnimator (arrowgrp, effectpal.Palette); Cursor.SetHotSpot (64, 64); } } } if (background_path != null) { Console.WriteLine ("loading background"); background = GuiUtil.SurfaceFromStream ((Stream)mpq.GetResource (background_path), background_translucent, background_transparent); } Elements = new List<UIElement> (); if (binFile != null) { Console.WriteLine ("loading ui elements"); Bin = (Bin)mpq.GetResource (binFile); if (Bin == null) throw new Exception (String.Format ("specified file '{0}' does not exist", binFile)); /* convert all the BinElements to UIElements for our subclasses to use */ foreach (BinElement el in Bin.Elements) { // Console.WriteLine ("{0}: {1}", el.text, el.flags); UIElement ui_el = null; switch (el.type) { case ElementType.DialogBox: ui_el = new DialogBoxElement (this, el, fontpal.RgbData); break; case ElementType.Image: ui_el = new ImageElement (this, el, fontpal.RgbData, translucentIndex); break; case ElementType.TextBox: ui_el = new TextBoxElement (this, el, fontpal.RgbData); break; case ElementType.ListBox: ui_el = new ListBoxElement (this, el, fontpal.RgbData); break; case ElementType.ComboBox: ui_el = new ComboBoxElement (this, el, fontpal.RgbData); break; case ElementType.LabelLeftAlign: case ElementType.LabelCenterAlign: case ElementType.LabelRightAlign: ui_el = new LabelElement (this, el, fontpal.RgbData); break; case ElementType.Button: case ElementType.DefaultButton: case ElementType.ButtonWithoutBorder: ui_el = new ButtonElement(this, el, fontpal.RgbData); break; case ElementType.Slider: case ElementType.OptionButton: case ElementType.CheckBox: ui_el = new UIElement (this, el, fontpal.RgbData); break; default: Console.WriteLine ("unhandled case {0}", el.type); ui_el = new UIElement (this, el, fontpal.RgbData); break; } Elements.Add (ui_el); } } UIPainter = new UIPainter (Elements); }
public virtual void MouseButtonUp (MouseButtonEventArgs args) { if (args.Button != MouseButton.PrimaryButton && args.Button != MouseButton.WheelUp && args.Button != MouseButton.WheelDown) return; if (mouseDownElement != null) { if (args.Button == MouseButton.PrimaryButton) mouseDownElement.MouseButtonUp (args); mouseDownElement = null; } }
// SDL Event handling public virtual void MouseButtonDown (MouseButtonEventArgs args) { if (args.Button != MouseButton.PrimaryButton && args.Button != MouseButton.WheelUp && args.Button != MouseButton.WheelDown) return; if (mouseDownElement != null) Console.WriteLine ("mouseDownElement already set in MouseButtonDown"); UIElement element = XYToElement (args.X, args.Y, true); if (element != null && element.Visible && element.Sensitive) { mouseDownElement = element; if (args.Button == MouseButton.PrimaryButton) mouseDownElement.MouseButtonDown (args); else mouseDownElement.MouseWheel (args); } }
public virtual void ActivateElement (UIElement element) { if (!element.Visible || !element.Sensitive) return; Console.WriteLine ("activating element {0}", Elements.IndexOf (element)); element.OnActivate (); }
public virtual void MouseLeaveElement (UIElement element) { element.MouseLeave (); }
public virtual void MouseEnterElement (UIElement element) { element.MouseEnter (); }