Beispiel #1
0
        //! \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);
                }
            }
        }
Beispiel #2
0
 public void MiscOp_SetR3(uint flags, int method, string r3)
 {
     OS.ThrowOnError(NativeMethods.Toolbox_ObjectMiscOp_SetR3(flags,
                                                              ID,
                                                              method,
                                                              r3));
 }
Beispiel #3
0
            /*! \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());
            }
Beispiel #4
0
        /*! \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);
        }
Beispiel #5
0
            /*! \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));
            }
Beispiel #6
0
        /*! \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);
        }
Beispiel #7
0
 /*! \brief Release the font resource. */
 public void Lose()
 {
     if (Handle != IntPtr.Zero)
     {
         OS.ThrowOnError(NativeMethods.Font_LoseFont(Handle));
         Handle = IntPtr.Zero;
     }
 }
Beispiel #8
0
        /*! \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);
        }
Beispiel #9
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);
        }
Beispiel #10
0
        /*! \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);
        }
Beispiel #11
0
        /*! \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);
        }
Beispiel #12
0
 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));
 }
Beispiel #13
0
        /*! \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);
        }
Beispiel #14
0
 public void MiscOp_SetR3R4(uint flags, int method, uint r3, string r4)
 {
     OS.ThrowOnError(NativeMethods.Toolbox_ObjectMiscOp_SetR3R4(flags,
                                                                ID,
                                                                method,
                                                                r3,
                                                                r4));
 }
Beispiel #15
0
        /*! \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);
        }
Beispiel #16
0
        /*! \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));
        }
Beispiel #17
0
            /*! \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);
            }
Beispiel #18
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);
        }
Beispiel #19
0
 /*! \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));
 }
Beispiel #20
0
        /*! \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);
        }
Beispiel #21
0
            /*! \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);
            }
Beispiel #22
0
 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));
 }
Beispiel #23
0
        /*! \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);
        }
Beispiel #24
0
 /*! \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));
 }
Beispiel #25
0
 /*! \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));
 }
Beispiel #26
0
        /*! \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));
        }
Beispiel #27
0
        /*! \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));
        }
Beispiel #28
0
        /*! \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));
        }
Beispiel #29
0
            /*! \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));
            }
Beispiel #30
0
        /*! \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));
        }