void Run() { while (Quit == false) { try { PollIdle(OS.ReadMonotonicTime() + 100); } catch (OS.ErrorException ex) { Wimp.ReportError(Wimp.ErrorBoxFlags.OKIcon, "MonoTestApp", ex.OSError.Number, ex.OSError.Message); } catch (Exception ex) { Reporter.WriteLine(ex.Message); // Split the stacktrace into individual lines and feed each one to // Reporter. string[] lines = ex.StackTrace.Split(new char[] { '\n' }); foreach (string s in lines) { Reporter.WriteLine(s); } } } }
public void Run() { while (Quit == false) { try { PollIdle(OS.ReadMonotonicTime() + 100); } catch (OS.ErrorException ex) { Reporter.WriteLine("{0}", ex.Message); string[] lines = ex.StackTrace.Split(new char[] { '\n' }); foreach (string s in lines) { Reporter.WriteLine("{0}", s); } Wimp.ReportError(Wimp.ErrorBoxFlags.OKIcon, "TBTemplate", ex.OSError.Number, ex.OSError.Message); } catch (Exception ex) { Reporter.WriteLine("{0}", ex.Message); string[] lines = ex.StackTrace.Split(new char[] { '\n' }); foreach (string s in lines) { Reporter.WriteLine("{0}", s); } } } }
/*! \brief Open nested window. */ public void OpenNested(OS.Rect visible, OS.Coord scroll, uint behindWindow, uint parentWindow, uint nestedFlags, uint windowFlags) { // Make sure bit 0 of nested flags is set correctly depending on whether // window flags are supplied. if (windowFlags == 0xffffffff) { nestedFlags &= (~1U); windowFlags = 0; } else { nestedFlags |= 1; } var block = new NativeWimp.WindowStateBlock(WimpWindow.Handle, visible, scroll, behindWindow, windowFlags); Wimp.OpenWindowNested(ref block, parentWindow, nestedFlags); }
/*! \brief Open window in response to an event. */ protected virtual void OnOpen(OpenEventArgs e) { if (Opening != null) { Opening(this, e); } Wimp.OpenWindow(ref e.OpenWimpBlock); }
/*! \brief Open a normal window (no nesting) */ public void Open(OS.Rect visible, OS.Coord scroll, uint behind) { var block = new NativeWimp.WindowStateBlock(WimpWindow.Handle, visible, scroll, behind, 0); // Flags are ignored on a normal window open Wimp.OpenWindow(ref block); }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { Icons.Clear(); AllWindows.Remove(WimpWindow.Handle); Wimp.DeleteWindow(WimpWindow.Handle); Title.Text.Clear(); Title.Validation.Clear(); Title = null; disposed = true; } }
/*! \brief Close window in response to an event. */ protected virtual void OnClose(CloseEventArgs e) { if (Closing != null) { Closing(this, e); } Wimp.CloseWindow(e.CloseWimpBlock.WindowHandle); if (Closed != null) { Closed(this, e); } }
//! \brief Update this object with the current state of the pointer. public void Update() { var block = new NativeWimp.PointerBlock(); Wimp.GetPointerInfo(out block); Pos.X = block.Pos.X; Pos.Y = block.Pos.Y; Buttons = (ButtonState)block.Buttons; WindowHandle = block.WindowHandle; IconHandle = block.IconHandle; Window = GetInstance(WindowHandle); Icon = Window != null?Window.GetIcon(IconHandle) : null; }
protected virtual void OnRedraw(Wimp.RedrawEventArgs e) { // Start the redraw. Given the window handle, the OS fills in RedrawWimpBlock // with details of what needs redrawing. int more = Wimp.RedrawWindow(ref e.Redraw); // The origin of the window only needs to be calculated once before entering // the redraw loop. e.Origin = WimpWindow.GetOrigin(ref e.Redraw.Visible, ref e.Redraw.Scroll); while (more != 0) { OnPaint(e); more = Wimp.GetRectangle(ref e.Redraw); } }
public void mouse_click(object sender, Wimp.MouseClickEventArgs e) { if ((e.MouseClickWimpBlock.Buttons & 2) != 0) { main_menu.Show(e.MouseClickWimpBlock.Pos.X - 64, e.MouseClickWimpBlock.Pos.Y); } else if (e.MouseClickWimpBlock.Buttons == 64) { var window = (Wimp.Window)sender; var drag = new NativeWimp.DragStartBlock(e.MouseClickWimpBlock.WindowHandle, Wimp.DragType.Rubber, new OS.Rect(e.MouseClickWimpBlock.Pos.X, e.MouseClickWimpBlock.Pos.Y, e.MouseClickWimpBlock.Pos.X, e.MouseClickWimpBlock.Pos.Y), window.VisibleArea); Wimp.DragBox(ref drag); } }
// For a derived class, it is recommended to override the event notifier rather // than subscribe to the event. protected override void OnPaint(Wimp.RedrawEventArgs e) { if (ColourSetBy == ColourSetter.Dialogue) { ColourTrans.SetFontColours(ColourTrans.White, font_palette_colour, 7); } else if (ColourSetBy == ColourSetter.Menu) { Wimp.SetFontColours((int)OS.DesktopColour.White, (int)font_wimp_colour); } font.Paint(Text, Font.PlotType.OSUnits, e.Origin.X + 10, e.Origin.Y - 100, 0); // Length ignored (paint whole string) if bit 7 of flags not set // Technically, we should call the base method to ensure that event subscribers // are also notified of this event, but I don't think that's necessary in this // case. // base.OnPaint (e); }
// Type 2 client // Client participates in disc save. void save_data(object sender, Toolbox.SaveAsDialogue.SaveToFileEventArgs e) { try { var saveas = (DocumentSaveAs)sender; // The SaveAs dialogue is a shared toolbox object, so check that this is the // intended target of the event. if (this.Equals(saveas.GetAncestor <TextDocument>())) { FileName = e.Filename; System.IO.File.WriteAllText(e.Filename, Text); saveas.FileSaveCompleted(e.Filename, true); } } catch (Exception ex) { Wimp.ReportError(Wimp.ErrorBoxFlags.OKIcon, "MonoTestTB", 0, ex.Message); } }
public override void KeyPress(int charCode) { Wimp.ProcessKey(charCode); }
/*! \brief Returns a summary of the given window's state and window nesting. * \param [in,out] block Reference to a native type to receive the window state. * \param [out] linkage Defines how the window is nested in the parent. * \return The Wimp window handle of the parent. */ public uint GetNestedState(ref NativeWimp.WindowStateBlock block, out uint linkage) { block.WindowHandle = Handle; return(Wimp.GetNestedWindowState(ref block, out linkage)); }
/*! \brief Returns complete details of this window's state. * \param [in,out] block Reference to a native type to receive window details. * \note This method does \b not return details of any icons. */ public void GetInfo(ref NativeWimp.WindowInfoBlock block) { Wimp.GetWindowInfo(WimpWindow.Handle, ref block); }
/*! \brief Return a summary of this window's state * \param [in,out] block Reference to a native type to receive the window state. * \return Nothing. */ public void GetState(ref NativeWimp.WindowStateBlock block) { block.WindowHandle = Handle; Wimp.GetWindowState(ref block); }
/*! \brief Force the given item of window furniture to be redrawn. */ public void ForceRedrawFurniture(Furniture item) { Wimp.ForceRedrawFurniture(Handle, item); }
// I could overload Poll() above, but PollIdle is probably a better indication of // what it does. /*! \brief Poll the Wimp and dispatch the event returned to the rest of the system. * Calls Wimp.PollIdle using the time supplied. * \param [in] time The number of centi-seconds to sleep for. * \return Nothing. */ public void PollIdle(uint time) { Wimp.PollIdle(PollMask, time, out PollWord); Dispatch(GetEvent()); }
/*! \brief Forces an area of this window to be redrawn later. * \param [in] minX Minimum X coordinate of rectangle to redraw. * \param [in] minY Minimum Y coordinate of rectangle to redraw. * \param [in] maxX Maximum X coordinate of rectangle to redraw. * \param [in] maxY Maximum Y coordinate of rectangle to redraw. * \return Nothing. */ public void ForceRedraw(int minX, int minY, int maxX, int maxY) { Wimp.ForceRedraw(Handle, minX, minY, maxX, maxY); }
/*! \brief Forces an area of this window to be redrawn later. * \param [in] redrawArea A rectangle defining the area of the window to redraw. * \return Nothing. */ public void ForceRedraw(OS.Rect redrawArea) { Wimp.ForceRedraw(Handle, redrawArea.MinX, redrawArea.MinY, redrawArea.MaxX, redrawArea.MaxY); }
/*! \brief Set the work area size of the window. */ public void SetExtent(OS.Rect extent) { var native_extent = new NativeOS.Rect(extent); Wimp.SetExtent(WimpWindow.Handle, ref native_extent); }
/*! \brief Tell the Wimp to mark this icon as deleted. */ public void Delete() { Wimp.DeleteIcon(WindowHandle, Handle); }
/*! \brief Create an icon in the given window from the given attributes. */ public Icon(uint windowHandle, IconAttributes attr) { WindowHandle = windowHandle; Data = attr.Data; Handle = Wimp.CreateIcon(windowHandle, attr); }
public Window(WindowAttributes attr) { WimpWindow = new WindowHandle(Wimp.CreateWindow(attr)); AllWindows.Add(WimpWindow.Handle, this); Title = attr.Title; }
/*! \brief Move the caret to the given position in this window. */ public void SetCaretPosition(OS.Coord Pos, int height, int index) { Wimp.SetCaretPosition(Handle, -1, Pos.X, Pos.Y, height, index); }
/*! \brief Poll the Wimp and dispatch the event returned to the rest of the system. * Calls Wimp.Poll. * \return Nothing. */ public void Poll() { Wimp.Poll(PollMask, out PollWord); Dispatch(GetEvent()); }
//! \brief Returns the bounding box of this window. public OS.Rect GetOutline() { return(Wimp.GetWindowOutline(Handle)); }
/*! \brief Move the caret to the given index in this icon. */ public void SetCaretPosition(int index) { Wimp.SetCaretPosition(WindowHandle, Handle, 0, 0, -1, index); }
// The Toolbox already redraws the title bar automatically when it is updated, // so this is left as a plain Wimp window only method rather than including it // in the WindowHandle class where Toolbox.Window would have access too. /*! \brief Force the title of this window to be redrawn. */ public void ForceRedrawTitle() { Wimp.ForceRedrawTitle(WimpWindow.Handle); }