//! \brief Reads the calibration table for the screen. public static int [] ReadCalibration() { int buffer_size; IntPtr buffer = IntPtr.Zero; try { OS.ThrowOnError(NativeMethods.ColourTrans_ReadCalibration(IntPtr.Zero, out buffer_size)); buffer = Marshal.AllocHGlobal(buffer_size); OS.ThrowOnError(NativeMethods.ColourTrans_ReadCalibration(buffer, out buffer_size)); int [] table = new int [buffer_size >> 2]; Marshal.Copy(buffer, table, 0, buffer_size >> 2); return(table); } catch { // Rethrow any exceptions for the caller to deal with. throw; } finally { if (buffer != IntPtr.Zero) { Marshal.FreeHGlobal(buffer); } } }
public void MiscOp_SetR3(uint flags, int method, string r3) { OS.ThrowOnError(NativeMethods.Toolbox_ObjectMiscOp_SetR3(flags, ID, method, r3)); }
/*! \brief Read details about a font. * \param[out] size x,y point size x 16 (in 1/16ths point) * \param[out] res x,y resolution (dots per inch) * \param[out] age Age of font * \param[out] usageCount Usage count of font * \returns Font identifier */ public string ReadFullDefn(OS.Coord size, OS.Coord res, out int age, out int usageCount) { int buffer_size; OS.ThrowOnError(NativeMethods.Font_ReadIdentifier(Handle, null, out buffer_size)); StringBuilder buffer = new StringBuilder(buffer_size); OS.ThrowOnError(NativeMethods.Font_ReadFullDefn(Handle, buffer, out size.X, out size.Y, out res.X, out res.Y, out age, out usageCount)); return(buffer.ToString()); }
/*! \brief Return information on a string. * \param [in] fontHandle Handle of font to use (0 for current handle) if * \b PlotType.GivenFont (bit 8) of flags set. * \param [in] str String to scan * \param [in] flags Plot type * \param [in] offset Offset of mouse click * \param [in,out] coordBlock Coordinate block for input if \b Font.PlotType.GivenBlock (bit 5) * of flags set and output if \b PlotType.ReturnBBox (bit 18) set, otherwise \b null. * \param [in,out] matrix Transformation matrix for input if \b PlotType.GivenMatrix (bit 6) * of flags set and output if \b PlotType.ReturnMatrix (bit 19) set, otherwise \b null. * \param [in] length Length of string to scan - if \b PlotType.GivenLength (bit 7) of flags set * \param [out] offsetReturn x,y coordinate offset to caret position - * if \b PlotType.ReturnCaretPos (bit 17) of flags set; else to split point, * or end of string if splitting not required * \param [out] splitCount Number of split characters encountered - * if \b PlotType.ReturnSplitCount (bit 20) of flags set * \return Index of point in string of caret position - if \b PlotType.ReturnCaretPos * (bit 17) of flags is set; else of split point, or of end of string if splitting * not required. */ public static int ScanString(IntPtr fontHandle, string str, PlotType flags, OS.Coord offset, Font.ScanCoordBlock coordBlock, OS.Matrix matrix, int length, OS.Coord offsetReturn, out int splitCount) { int result_index; OS.ThrowOnError(NativeMethods.Font_ScanString(fontHandle, str, flags, offset.X, offset.Y, coordBlock, matrix, length, out result_index, out offsetReturn.X, out offsetReturn.Y, out splitCount)); return(result_index); }
/*! \brief Get the handle for a font. * \param[in] name Font identifier * \param[in] xSize x point size x 16 (in 1/16ths of a point) * \param[in] ySize y point size x 16 (in 1/16ths of a point) * \param[in] xRes x resolution in dots per inch (0 = use default, -1 = use current) * \param[in] yRes y resolution in dots per inch (0 = use default, -1 = use current) * \return Nothing */ public void Find(string name, int xSize, int ySize, int xRes, int yRes) { int xResOut, yResOut; OS.ThrowOnError(NativeMethods.Font_FindFont(name, xSize, ySize, xRes, yRes, out Handle, out xResOut, out yResOut)); }
/*! \brief Scan for fonts, returning their identifiers one at a time * \param[out] fontIdentifier A StringBuilder object to receive the font identifier. * \param[out] fontName A StringBuilder object to receive the font name. * \param[in] context Counter and flags. * \li bits 0-15 => counter (0 on first call). * \li bit 16 set => return font identifier. * \li bit 17 set => return local font name. * \li bit 22 set => return list of encodings, rather than list of fonts. * \return Updated context for use on next call, or -1 if no more to be listed. */ public static int ListFonts(out StringBuilder fontIdentifier, out StringBuilder fontName, int context) { int context_return, buffer1_size, buffer2_size; OS.ThrowOnError(NativeMethods.Font_ListFonts(IntPtr.Zero, context, 0, IntPtr.Zero, 0, IntPtr.Zero, out context_return, out buffer1_size, out buffer2_size)); fontIdentifier = new StringBuilder(buffer1_size); fontName = new StringBuilder(buffer2_size); OS.ThrowOnError(NativeMethods.Font_ListFonts(fontIdentifier, context, buffer1_size, fontName, buffer2_size, IntPtr.Zero, out context_return, out buffer1_size, out buffer2_size)); return(context_return); }
/*! \brief Release the font resource. */ public void Lose() { if (Handle != IntPtr.Zero) { OS.ThrowOnError(NativeMethods.Font_LoseFont(Handle)); Handle = IntPtr.Zero; } }
/*! \brief Return the end-of-file status of the given open file. * \note Calls SWI "OS_Args",5. */ public static bool ReadEOF(IntPtr fileHandle) { int eof; OS.ThrowOnError(NativeMethods.OSArgs_ReadFileEOF(fileHandle, out eof)); return(eof != 0); }
/*! \brief Return the value of the client handle for the object with the given id. */ public static int GetClientHandle(uint objectID) { int handle; OS.ThrowOnError(NativeMethods.Toolbox_GetClientHandle(0, objectID, out handle)); return(handle); }
/*! \brief Return the position of the given open file. * \note Calls SWI "OS_Args",0. */ public static long ReadFilePtr(IntPtr fileHandle) { int file_ptr; OS.ThrowOnError(NativeMethods.OSArgs_ReadFilePtr(fileHandle, out file_ptr)); return((long)file_ptr); }
/*! \brief Create a Toolbox object from a template held in memory. * \param resData Pointer to the data required to create the object. * \return The Toolbox id of the created object. */ public static uint CreateObject(IntPtr resData) { uint id; OS.ThrowOnError(NativeMethods.Toolbox_CreateObject(CreateObjectFlags.FromMemory, resData, out id)); return(id); }
public void MiscOp_GetR0R1(uint flags, int method, out uint r0, out uint r1) { OS.ThrowOnError(NativeMethods.Toolbox_ObjectMiscOp_GetR0R1(flags, ID, method, out r0, out r1)); }
/*! \brief Create the named Toolbox object. * \param resName The name of the template in the Resource file. * \return The Toolbox id of the created object. */ public static uint CreateObject(string resName) { uint id; OS.ThrowOnError(NativeMethods.Toolbox_CreateObject(0, resName, out id)); return(id); }
public void MiscOp_SetR3R4(uint flags, int method, uint r3, string r4) { OS.ThrowOnError(NativeMethods.Toolbox_ObjectMiscOp_SetR3R4(flags, ID, method, r3, r4)); }
/*! \brief Return the extent of the given open file. * \note Calls SWI "OS_Args",2. */ public static long ReadFileExt(IntPtr fileHandle) { int file_ext; OS.ThrowOnError(NativeMethods.OSArgs_ReadFileExt(fileHandle, out file_ext)); return((long)file_ext); }
/*! \brief Read the internal to OS conversion factor. * returns x,y scale factor in the form os a new OS.Coord */ public static OS.Coord ReadScaleFactor() { int factor_x, factor_y; OS.ThrowOnError(NativeMethods.Font_ReadScaleFactor(out factor_x, out factor_y)); return(new OS.Coord(factor_x, factor_y)); }
/*! \brief Return \e true if this object is currently showing on screen. */ public bool IsOnScreen() { uint state; OS.ThrowOnError(NativeMethods.Toolbox_GetObjectState(0, ID, out state)); return((state & 1) != 0); }
/*! \brief Open an existing file with read/write access. * \param [in] flags The flags used to modify where the file is opened and how errors * are handled. * \param [in] filename Name of the file to open. * \param [in] path Name of path, path string, path variable or \e null (depending on flags). * \return Handle of file. * \note Calls SWI "OS_Find". */ public static IntPtr OpenUpdate(Flags flags, string filename, string path) { IntPtr handle; OS.ThrowOnError(NativeMethods.OSFind_Openup(flags, filename, path, out handle)); return(handle); }
/*! \brief Initialise the Wimp task. * \param [in] version The minimum version of the Wimp that we expect. * \param [in] desc The name of the task as displayed in the task manager. * \param [in] messageList A 0 terminated list of messages that we're * interested in receiving, or null if we are not interested in any messages * (except Quit), or a list containing only a single 0 element if we want all * messages. * \return Nothing. * \note The Wimp makes a copy of the message list, so it is not necessary to * maintain a local copy after this call has been made. */ public void Initialise(int version, string desc, int[] messageList) { OS.ThrowOnError(NativeMethods.Wimp_Initialise(version, desc, messageList, out _WimpVersion, out _Handle)); }
/*! \brief Given a template name within the Resource file, return a pointer to * a block suitable to create an object from. * \param [in] resName The name of the resource template to look up. * \return A pointer to a block that represents the object. */ public static IntPtr TemplateLookup(string resName) { IntPtr template; OS.ThrowOnError(NativeMethods.Toolbox_TemplateLookUp(0, resName, out template)); return(template); }
/*! \brief Query the Toolbox to find the class type of the Toolbox object * with the given ID. * \param [in] ObjectID The Toolbox ID of the object. * \return The class type of the object. */ public static uint GetClass(uint ObjectID) { uint class_type; OS.ThrowOnError(NativeMethods.Toolbox_GetObjectClass(0, ObjectID, out class_type)); return(class_type); }
public void MiscOp_SetR3R4R5(uint flags, int method, uint r3, uint r4, uint r5) { OS.ThrowOnError(NativeMethods.Toolbox_ObjectMiscOp_SetR3R4R5(flags, ID, method, r3, r4, r5)); }
/*! \brief Alter the space allocation of a dynamic area. * \param [in] number The number used to identify the dynamic area. * \param [in] sizeIncrease The required size change in bytes (+ve to extend, -ve to shrink). * \return The number of bytes that were actually moved. */ public static uint ChangeDynamicArea(int number, int sizeIncrease) { uint bytes_moved; OS.ThrowOnError(NativeMethods.OS_ChangeDynamicArea(number, sizeIncrease, out bytes_moved)); return(bytes_moved); }
/*! \brief Display the object in the centre of the screen. */ public void ShowCentred() { OS.ThrowOnError(NativeMethods.Toolbox_ShowObject(0, ID, ShowObjectType.Centre, IntPtr.Zero, 0, -1)); }
/*! \brief Display the object on the screen at its default location. */ public void Show(uint parentID, int parentCmp) { OS.ThrowOnError(NativeMethods.Toolbox_ShowObject(0, ID, ShowObjectType.Default, IntPtr.Zero, parentID, parentCmp)); }
/*! \brief Convert OS coordinates to internal coordinates * \param[in] os x,y coordinates in OS units * \returns New OS.Coord in millipoints */ public static OS.Coord ConvertToPoints(OS.Coord os) { int points_x, points_y; OS.ThrowOnError(NativeMethods.Font_ConvertToPoints(os.X, os.Y, out points_x, out points_y)); return(new OS.Coord(points_x, points_y)); }
/*! \brief Convert internal coordinates to OS coordinates * \param[in] points x,y coordinates in millipoints * \returns New OS.Coord in OS units */ public static OS.Coord ConvertToOS(OS.Coord points) { int os_x, os_y; OS.ThrowOnError(NativeMethods.Font_ConvertToOS(points.X, points.Y, out os_x, out os_y)); return(new OS.Coord(os_x, os_y)); }
/*! \brief Convert internal coordinates to OS coordinates * \param[in] xPoints x coordinate in millipoints * \param[in] yPoints y coordinate in millipoints * \returns New OS.Coord in OS units */ public static OS.Coord ConvertToOS(int xPoints, int yPoints) { int os_x, os_y; OS.ThrowOnError(NativeMethods.Font_ConvertToOS(xPoints, yPoints, out os_x, out os_y)); return(new OS.Coord(os_x, os_y)); }
/*! \brief Force a redraw on the area of the window given. * \param [in] area The rectangular area of the window to redraw. * \return Nothing. */ public void ForceRedraw(OS.Rect area) { var rect = new NativeOS.Rect(area); OS.ThrowOnError(NativeMethods.Window_ForceRedraw(0, ID, Method.ForceRedraw, ref rect)); }
/*! \brief Convert OS coordinates to internal coordinates * \param[in] xOS x coordinate in OS units * \param[in] yOS y coordinate in OS units * \returns New OS.Coord in millipoints */ public static OS.Coord ConvertToPoints(int xOS, int yOS) { int points_x, points_y; OS.ThrowOnError(NativeMethods.Font_ConvertToPoints(xOS, yOS, out points_x, out points_y)); return(new OS.Coord(points_x, points_y)); }