Subversion Repositories RTK

Compare Revisions

Ignore whitespace Rev 244 → Rev 245

/tags/v0_5_0-2/!RTK/!Help,feb
New file
0,0 → 1,8
| This file is part of the RISC OS Toolkit (RTK).
| Copyright © 2003 Graham Shaw.
| Distribution and use are subject to the GNU Lesser General Public License,
| a copy of which may be found in the file !RTK.Copyright.
 
If "<RTK$Dir>"="" Then Set RTK$Dir <Obey$Dir>
IfThere <RTK$Dir>.html.index/html Then Set RTK$Help <RTK$Dir>.html.index/html
If ("<Alias$@RunType_FAF>"="") OR ("<RTK$Help>"="") Then Filer_Run <RTK$Dir>.README Else Filer_Run <RTK$Help>
Property changes:
Added: svn:executable
+ *
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/namespace.h
New file
0,0 → 1,30
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use subject to the GNU LGPL.
// (For details see the file !RTK.Copyright.)
 
/// The namespace used to hold the RISC OS Toolkit (RTK).
namespace rtk {
 
/// The namespace used to hold RTK utility classes.
namespace util {};
 
/// The namespace used to hold the RTK graphics library.
namespace graphics {};
 
/// The namespace used to hold the RTK low-level RISC OS interface library.
namespace swi {};
 
/// The namespace used to hold the RTK high-level RISC OS interface library.
namespace os {};
 
/// The namespace used to hold RTK desktop components.
namespace desktop {};
 
/// The namespace used to hold RTK event objects.
namespace events {};
 
/// The namespace used to hold RTK data transfer components.
namespace transfer {};
 
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/Doxyfile
New file
0,0 → 1,938
# Doxyfile 1.2.15
 
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project
#
# All text after a hash (#) is considered a comment and will be ignored
# The format is:
# TAG = value [value, ...]
# For lists items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (" ")
 
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
 
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
 
PROJECT_NAME = RTK
 
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# if some version control system is used.
 
PROJECT_NUMBER =
 
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
 
OUTPUT_DIRECTORY =
 
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
# The default language is English, other supported languages are:
# Brazilian, Chinese, Croatian, Czech, Danish, Dutch, Finnish, French,
# German, Greek, Hungarian, Italian, Japanese, Korean, Norwegian, Polish,
# Portuguese, Romanian, Russian, Slovak, Slovene, Spanish and Swedish.
 
OUTPUT_LANGUAGE = English
 
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
# documentation are documented, even if no documentation was available.
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
 
EXTRACT_ALL = YES
 
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
 
EXTRACT_PRIVATE = NO
 
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
 
EXTRACT_STATIC = NO
 
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
# defined locally in source files will be included in the documentation.
# If set to NO only classes defined in header files are included.
 
EXTRACT_LOCAL_CLASSES = YES
 
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
 
HIDE_UNDOC_MEMBERS = NO
 
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these class will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
 
HIDE_UNDOC_CLASSES = NO
 
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
# the file and class documentation (similar to JavaDoc).
# Set to NO to disable this.
 
BRIEF_MEMBER_DESC = YES
 
# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
# the brief description of a member or function before the detailed description.
# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
# brief descriptions will be completely suppressed.
 
REPEAT_BRIEF = YES
 
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
# Doxygen will generate a detailed section even if there is only a brief
# description.
 
ALWAYS_DETAILED_SEC = NO
 
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited
# members of a class in the documentation of that class as if those members were
# ordinary class members. Constructors, destructors and assignment operators of
# the base classes will not be shown.
 
INLINE_INHERITED_MEMB = NO
 
# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
# path before files name in the file list and in the header files. If set
# to NO the shortest path that makes the file name unique will be used.
 
FULL_PATH_NAMES = NO
 
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
# can be used to strip a user defined part of the path. Stripping is
# only done if one of the specified strings matches the left-hand part of
# the path. It is allowed to use relative paths in the argument list.
 
STRIP_FROM_PATH =
 
# The INTERNAL_DOCS tag determines if documentation
# that is typed after a \internal command is included. If the tag is set
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
 
INTERNAL_DOCS = NO
 
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
# doxygen to hide any special comment blocks from generated source code
# fragments. Normal C and C++ comments will always remain visible.
 
STRIP_CODE_COMMENTS = YES
 
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
# file names in lower case letters. If set to YES upper case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# users are adviced to set this option to NO.
 
CASE_SENSE_NAMES = YES
 
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
# (but less readable) file names. This can be useful is your file systems
# doesn't support long names like on DOS, Mac, or CD-ROM.
 
SHORT_NAMES = NO
 
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
# will show members with their full class and namespace scopes in the
# documentation. If set to YES the scope will be hidden.
 
HIDE_SCOPE_NAMES = NO
 
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
# will generate a verbatim copy of the header file for each class for
# which an include is specified. Set to NO to disable this.
 
VERBATIM_HEADERS = YES
 
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
# will put list of the files that are included by a file in the documentation
# of that file.
 
SHOW_INCLUDE_FILES = YES
 
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
# will interpret the first line (until the first dot) of a JavaDoc-style
# comment as the brief description. If set to NO, the JavaDoc
# comments will behave just like the Qt-style comments (thus requiring an
# explict @brief command for a brief description.
 
JAVADOC_AUTOBRIEF = YES
 
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
# reimplements.
 
INHERIT_DOCS = YES
 
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
# is inserted in the documentation for inline members.
 
INLINE_INFO = YES
 
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
# will sort the (detailed) documentation of file and class members
# alphabetically by member name. If set to NO the members will appear in
# declaration order.
 
SORT_MEMBER_DOCS = NO
 
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
# tag is set to YES, then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
 
DISTRIBUTE_GROUP_DOC = NO
 
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
# Doxygen uses this value to replace tabs by spaces in code fragments.
 
TAB_SIZE = 4
 
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
 
GENERATE_TODOLIST = YES
 
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
# commands in the documentation.
 
GENERATE_TESTLIST = YES
 
# The GENERATE_BUGLIST tag can be used to enable (YES) or
# disable (NO) the bug list. This list is created by putting \bug
# commands in the documentation.
 
GENERATE_BUGLIST = YES
 
# This tag can be used to specify a number of aliases that acts
# as commands in the documentation. An alias has the form "name=value".
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
# put the command \sideeffect (or @sideeffect) in the documentation, which
# will result in a user defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
 
ALIASES =
 
# The ENABLED_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
 
ENABLED_SECTIONS =
 
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
# the initial value of a variable or define consist of for it to appear in
# the documentation. If the initializer consists of more lines than specified
# here it will be hidden. Use a value of 0 to hide initializers completely.
# The appearance of the initializer of individual variables and defines in the
# documentation can be controlled using \showinitializer or \hideinitializer
# command in the documentation regardless of this setting.
 
MAX_INITIALIZER_LINES = 30
 
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C.
# For instance some of the names that are used will be different. The list
# of all members will be omitted, etc.
 
OPTIMIZE_OUTPUT_FOR_C = NO
 
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources
# only. Doxygen will then generate output that is more tailored for Java.
# For instance namespaces will be presented as packages, qualified scopes
# will look different, etc.
 
OPTIMIZE_OUTPUT_JAVA = NO
 
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
# at the bottom of the documentation of classes and structs. If set to YES the
# list will mention the files that were used to generate the documentation.
 
SHOW_USED_FILES = YES
 
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
 
# The QUIET tag can be used to turn on/off the messages that are generated
# by doxygen. Possible values are YES and NO. If left blank NO is used.
 
QUIET = YES
 
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated by doxygen. Possible values are YES and NO. If left blank
# NO is used.
 
WARNINGS = YES
 
# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
# automatically be disabled.
 
WARN_IF_UNDOCUMENTED = YES
 
# The WARN_FORMAT tag determines the format of the warning messages that
# doxygen can produce. The string should contain the $file, $line, and $text
# tags, which will be replaced by the file and line number from which the
# warning originated and the warning text.
 
WARN_FORMAT = "$file:$line: $text"
 
# The WARN_LOGFILE tag can be used to specify a file to which warning
# and error messages should be written. If left blank the output is written
# to stderr.
 
WARN_LOGFILE =
 
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
 
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
 
INPUT =
 
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank the following patterns are tested:
# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp
# *.h++ *.idl *.odl
 
FILE_PATTERNS =
 
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used.
 
RECURSIVE = YES
 
# The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
 
EXCLUDE =
 
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
# that are symbolic links (a Unix filesystem feature) are excluded from the input.
 
EXCLUDE_SYMLINKS = NO
 
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories.
 
EXCLUDE_PATTERNS =
 
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
 
EXAMPLE_PATH =
 
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
 
EXAMPLE_PATTERNS =
 
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
# searched for input files to be used with the \include or \dontinclude
# commands irrespective of the value of the RECURSIVE tag.
# Possible values are YES and NO. If left blank NO is used.
 
EXAMPLE_RECURSIVE = NO
 
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
 
IMAGE_PATH =
 
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
# by executing (via popen()) the command <filter> <input-file>, where <filter>
# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
# input file. Doxygen will then use the output that the filter program writes
# to standard output.
 
INPUT_FILTER =
 
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
# INPUT_FILTER) will be used to filter the input files when producing source
# files to browse.
 
FILTER_SOURCE_FILES = NO
 
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
 
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
 
SOURCE_BROWSER = NO
 
# Setting the INLINE_SOURCES tag to YES will include the body
# of functions and classes directly in the documentation.
 
INLINE_SOURCES = NO
 
# If the REFERENCED_BY_RELATION tag is set to YES (the default)
# then for each documented function all documented
# functions referencing it will be listed.
 
REFERENCED_BY_RELATION = YES
 
# If the REFERENCES_RELATION tag is set to YES (the default)
# then for each documented function all documented entities
# called/used by that function will be listed.
 
REFERENCES_RELATION = YES
 
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
 
# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
# of all compounds will be generated. Enable this if the project
# contains a lot of classes, structs, unions or interfaces.
 
ALPHABETICAL_INDEX = NO
 
# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
# in which this list will be split (can be a number in the range [1..20])
 
COLS_IN_ALPHA_INDEX = 5
 
# In case all classes in a project start with a common prefix, all
# classes will be put under the same header in the alphabetical index.
# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
# should be ignored while generating the index headers.
 
IGNORE_PREFIX =
 
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
 
# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
# generate HTML output.
 
GENERATE_HTML = YES
 
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `html' will be used as the default path.
 
HTML_OUTPUT = html
 
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
# doxygen will generate files with .html extension.
 
HTML_FILE_EXTENSION = .html
 
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
# standard header.
 
HTML_HEADER =
 
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
# each generated HTML page. If it is left blank doxygen will generate a
# standard footer.
 
HTML_FOOTER = footer.html
 
# The HTML_STYLESHEET tag can be used to specify a user defined cascading
# style sheet that is used by each HTML page. It can be used to
# fine-tune the look of the HTML output. If the tag is left blank doxygen
# will generate a default style sheet
 
HTML_STYLESHEET =
 
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to
# NO a bullet list will be used.
 
HTML_ALIGN_MEMBERS = YES
 
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the
# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
# of the generated HTML documentation.
 
GENERATE_HTMLHELP = NO
 
# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
# controls if a separate .chi index file is generated (YES) or that
# it should be included in the master .chm file (NO).
 
GENERATE_CHI = NO
 
# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
# controls whether a binary table of contents is generated (YES) or a
# normal table of contents (NO) in the .chm file.
 
BINARY_TOC = NO
 
# The TOC_EXPAND flag can be set to YES to add extra items for group members
# to the contents of the Html help documentation and to the tree view.
 
TOC_EXPAND = NO
 
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
# top of each HTML page. The value NO (the default) enables the index and
# the value YES disables it.
 
DISABLE_INDEX = NO
 
# This tag can be used to set the number of enum values (range [1..20])
# that doxygen will group on one line in the generated HTML documentation.
 
ENUM_VALUES_PER_LINE = 4
 
# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
# generated containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports
# JavaScript and frames is required (for instance Mozilla, Netscape 4.0+,
# or Internet explorer 4.0+). Note that for large projects the tree generation
# can take a very long time. In such cases it is better to disable this feature.
# Windows users are probably better off using the HTML help feature.
 
GENERATE_TREEVIEW = NO
 
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
# used to set the initial width (in pixels) of the frame in which the tree
# is shown.
 
TREEVIEW_WIDTH = 250
 
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
 
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
# generate Latex output.
 
GENERATE_LATEX = NO
 
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `latex' will be used as the default path.
 
LATEX_OUTPUT = latex
 
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be invoked. If left blank `latex' will be used as the default command name.
 
LATEX_CMD_NAME = latex
 
# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
# generate index for LaTeX. If left blank `makeindex' will be used as the
# default command name.
 
MAKEINDEX_CMD_NAME = makeindex
 
# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
# LaTeX documents. This may be useful for small projects and may help to
# save some trees in general.
 
COMPACT_LATEX = NO
 
# The PAPER_TYPE tag can be used to set the paper type that is used
# by the printer. Possible values are: a4, a4wide, letter, legal and
# executive. If left blank a4wide will be used.
 
PAPER_TYPE = a4
 
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
# packages that should be included in the LaTeX output.
 
EXTRA_PACKAGES =
 
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
# the generated latex document. The header should contain everything until
# the first chapter. If it is left blank doxygen will generate a
# standard header. Notice: only use this tag if you know what you are doing!
 
LATEX_HEADER =
 
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
# contain links (just like the HTML output) instead of page references
# This makes the output suitable for online browsing using a pdf viewer.
 
PDF_HYPERLINKS = YES
 
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
# plain latex in the generated Makefile. Set this option to YES to get a
# higher quality PDF documentation.
 
USE_PDFLATEX = NO
 
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
# command to the generated LaTeX files. This will instruct LaTeX to keep
# running if errors occur, instead of asking the user for help.
# This option is also used when generating formulas in HTML.
 
LATEX_BATCHMODE = YES
 
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
 
# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
# The RTF output is optimised for Word 97 and may not look very pretty with
# other RTF readers or editors.
 
GENERATE_RTF = NO
 
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `rtf' will be used as the default path.
 
RTF_OUTPUT = rtf
 
# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
# RTF documents. This may be useful for small projects and may help to
# save some trees in general.
 
COMPACT_RTF = NO
 
# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
# will contain hyperlink fields. The RTF file will
# contain links (just like the HTML output) instead of page references.
# This makes the output suitable for online browsing using WORD or other
# programs which support those fields.
# Note: wordpad (write) and others do not support links.
 
RTF_HYPERLINKS = NO
 
# Load stylesheet definitions from file. Syntax is similar to doxygen's
# config file, i.e. a series of assigments. You only have to provide
# replacements, missing definitions are set to their default value.
 
RTF_STYLESHEET_FILE =
 
# Set optional variables used in the generation of an rtf document.
# Syntax is similar to doxygen's config file.
 
RTF_EXTENSIONS_FILE =
 
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
 
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
# generate man pages
 
GENERATE_MAN = NO
 
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `man' will be used as the default path.
 
MAN_OUTPUT = man
 
# The MAN_EXTENSION tag determines the extension that is added to
# the generated man pages (default is the subroutine's section .3)
 
MAN_EXTENSION = .3
 
# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
# then it will generate one additional man file for each entity
# documented in the real man page(s). These additional files
# only source the real man page, but without them the man command
# would be unable to find the correct page. The default is NO.
 
MAN_LINKS = NO
 
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
 
# If the GENERATE_XML tag is set to YES Doxygen will
# generate an XML file that captures the structure of
# the code including all documentation. Note that this
# feature is still experimental and incomplete at the
# moment.
 
GENERATE_XML = NO
 
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
 
# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
# generate an AutoGen Definitions (see autogen.sf.net) file
# that captures the structure of the code including all
# documentation. Note that this feature is still experimental
# and incomplete at the moment.
 
GENERATE_AUTOGEN_DEF = NO
 
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
 
# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
# evaluate all C-preprocessor directives found in the sources and include
# files.
 
ENABLE_PREPROCESSING = YES
 
# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
# names in the source code. If set to NO (the default) only conditional
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
 
MACRO_EXPANSION = NO
 
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
# PREDEFINED and EXPAND_AS_PREDEFINED tags.
 
EXPAND_ONLY_PREDEF = NO
 
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
# in the INCLUDE_PATH (see below) will be search if a #include is found.
 
SEARCH_INCLUDES = YES
 
# The INCLUDE_PATH tag can be used to specify one or more directories that
# contain include files that are not input files but should be processed by
# the preprocessor.
 
INCLUDE_PATH =
 
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
# directories. If left blank, the patterns specified with FILE_PATTERNS will
# be used.
 
INCLUDE_FILE_PATTERNS =
 
# The PREDEFINED tag can be used to specify one or more macro names that
# are defined before the preprocessor is started (similar to the -D option of
# gcc). The argument of the tag is a list of macros of the form: name
# or name=definition (no spaces). If the definition and the = are
# omitted =1 is assumed.
 
PREDEFINED =
 
# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
# Use the PREDEFINED tag if you want to use a different macro definition.
 
EXPAND_AS_DEFINED =
 
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
# doxygen's preprocessor will remove all function-like macros that are alone
# on a line and do not end with a semicolon. Such function macros are typically
# used for boiler-plate code, and will confuse the parser if not removed.
 
SKIP_FUNCTION_MACROS = YES
 
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
 
# The TAGFILES tag can be used to specify one or more tagfiles.
 
TAGFILES =
 
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.
 
GENERATE_TAGFILE =
 
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes
# will be listed.
 
ALLEXTERNALS = NO
 
# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
# in the modules index. If set to NO, only the current project's groups will
# be listed.
 
EXTERNAL_GROUPS = YES
 
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
 
PERL_PATH = /usr/bin/perl
 
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
 
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
# generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or
# super classes. Setting the tag to NO turns the diagrams off. Note that this
# option is superceded by the HAVE_DOT option below. This is only a fallback. It is
# recommended to install and use dot, since it yield more powerful graphs.
 
CLASS_DIAGRAMS = YES
 
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz, a graph visualization
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
 
HAVE_DOT = NO
 
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect inheritance relations. Setting this tag to YES will force the
# the CLASS_DIAGRAMS tag to NO.
 
CLASS_GRAPH = YES
 
# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect implementation dependencies (inheritance, containment, and
# class references variables) of the class with other documented classes.
 
COLLABORATION_GRAPH = YES
 
# If set to YES, the inheritance and collaboration graphs will show the
# relations between templates and their instances.
 
TEMPLATE_RELATIONS = YES
 
# If set to YES, the inheritance and collaboration graphs will hide
# inheritance and usage relations if the target is undocumented
# or is not a class.
 
HIDE_UNDOC_RELATIONS = YES
 
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
# tags are set to YES then doxygen will generate a graph for each documented
# file showing the direct and indirect include dependencies of the file with
# other documented files.
 
INCLUDE_GRAPH = YES
 
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
# documented header file showing the documented files that directly or
# indirectly include this file.
 
INCLUDED_BY_GRAPH = YES
 
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
# will graphical hierarchy of all classes instead of a textual one.
 
GRAPHICAL_HIERARCHY = YES
 
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. Possible values are png, jpg, or gif
# If left blank png will be used.
 
DOT_IMAGE_FORMAT = png
 
# The tag DOT_PATH can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found on the path.
 
DOT_PATH =
 
# The DOTFILE_DIRS tag can be used to specify one or more directories that
# contain dot files that are included in the documentation (see the
# \dotfile command).
 
DOTFILE_DIRS =
 
# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
# this value, doxygen will try to truncate the graph, so that it fits within
# the specified constraint. Beware that most browsers cannot cope with very
# large images.
 
MAX_DOT_GRAPH_WIDTH = 1024
 
# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
# this value, doxygen will try to truncate the graph, so that it fits within
# the specified constraint. Beware that most browsers cannot cope with very
# large images.
 
MAX_DOT_GRAPH_HEIGHT = 1024
 
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
# generate a legend page explaining the meaning of the various boxes and
# arrows in the dot generated graphs.
 
GENERATE_LEGEND = YES
 
# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
# remove the intermedate dot files that are used to generate
# the various graphs.
 
DOT_CLEANUP = YES
 
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
 
# The SEARCHENGINE tag specifies whether or not a search engine should be
# used. If set to NO the values of all tags below this one will be ignored.
 
SEARCHENGINE = NO
 
# The CGI_NAME tag should be the name of the CGI script that
# starts the search engine (doxysearch) with the correct parameters.
# A script with this name will be generated by doxygen.
 
CGI_NAME = search.cgi
 
# The CGI_URL tag should be the absolute URL to the directory where the
# cgi binaries are located. See the documentation of your http daemon for
# details.
 
CGI_URL =
 
# The DOC_URL tag should be the absolute URL to the directory where the
# documentation is located. If left blank the absolute path to the
# documentation, with file:// prepended to it, will be used.
 
DOC_URL =
 
# The DOC_ABSPATH tag should be the absolute path to the directory where the
# documentation is located. If left blank the directory on the local machine
# will be used.
 
DOC_ABSPATH =
 
# The BIN_ABSPATH tag must point to the directory where the doxysearch binary
# is installed.
 
BIN_ABSPATH = /usr/local/bin/
 
# The EXT_DOC_PATHS tag can be used to specify one or more paths to
# documentation generated for other projects. This allows doxysearch to search
# the documentation for these projects as well.
 
EXT_DOC_PATHS =
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/SetPaths,feb
New file
0,0 → 1,8
| This file is part of the RISC OS Toolkit (RTK).
| Copyright © 2004 Graham Shaw.
| Distribution and use are subject to the GNU Lesser General Public License,
| a copy of which may be found in the file !RTK.Copyright.
 
Set RTK_Build$Dir <Obey$Dir>
Set RTK_Build$Path <Obey$Dir>.
Set Sys$ReturnCode 0
Property changes:
Added: svn:executable
+ *
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/include.doc
New file
0,0 → 1,3
!RTK.html.*/html
!RTK.html.*/png
!RTK.html.*/css
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/footer.html,faf
New file
0,0 → 1,8
<hr>
<table width="100%"><tr>
<td align="left"><i>Reference Manual</i></td>
<td align="centre"><i>The RISC OS Toolkit</i></td>
<td align="right"><i>Version 0.5.0 (01 Feb 2004)</i></td>
</tr></table>
</body>
</html>
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/include.bin
New file
0,0 → 1,9
!RTK.!Boot
!RTK.!Help
!RTK.!Run
!RTK.!Sprites
!RTK.Copyright
!RTK.History
!RTK.README
!RTK.a.rtk
!RTK.rtk.*.h.*
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/!Boot,feb
New file
0,0 → 1,9
| This file is part of the RISC OS Toolkit (RTK).
| Copyright © 2003 Graham Shaw.
| Distribution and use are subject to the GNU Lesser General Public License,
| a copy of which may be found in the file !RTK.Copyright.
 
If "<RTK$Dir>"="" Then Set RTK$Dir <Obey$Dir>
If "<RTK$Path>"="" Then Set RTK$Path <Obey$Dir>.
IfThere <RTK$Dir>.html.index/html Then Set RTK$Help <RTK$Dir>.html.index/html
IconSprites <RTK$Dir>.!Sprites
Property changes:
Added: svn:executable
+ *
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/README
New file
0,0 → 1,139
# This file is part of the RISC OS Toolkit (RTK).
# Copyright © 2003-2004 Graham Shaw.
# Distribution and use are subject to the GNU Lesser General Public License,
# a copy of which may be found in the file !RTK.Copyright.
 
-----------------------------------------------------------------------
The RISC OS Toolkit
 
Version 0.5.0 (01 Feb 2004)
-----------------------------------------------------------------------
 
Introduction
 
The RISC OS Toolkit (RTK) is a class library for developing RISC OS
application programs in C++. It differs from other such libraries
currently available for RISC OS in its support for automatic layout.
This is achieved by specifying the relationship between different
visual components (for example, the fact that they are arranged in a
grid or a column). The precise coordinates are calculated by the RTK.
This eliminates the need for a template editor, and allows the layout
to change at run-time to accommodate varying content.
 
(Support will be provided for RISC OS template files, but that is not
intended to be the normal method of use.)
 
Other goals are:
* to provide high-level support for common window types, icon types
and protocols;
* to provide an extensible, type-safe event delivery mechanism.
* to implement style-guide compliant behaviour by default.
 
Please be aware that the RTK is still under development. Most of the
basic infrastructure is complete, but there are many more classes that
could be added. Some functions are correct but not efficient.
 
Requirements
 
Supported operating systems include:
* RISC OS 4.02
* RISC OS 5.03
 
The RTK may work with earlier versions of RISC OS provided that the
nested window manager is present.
 
Supported compilers include:
* GCC 2.95.4 (release 3)
* GCC 2.95.4 (experimental 32-bit, 05 May 2003)
 
The Acorn C/C++ compiler (up to version 3.19 at least) is not
supported because there are important parts of the C++ language that
it does not implement.
 
Installation
 
The !RTK application directory can be located anywhere.
 
Ensure that it has been booted and/or run before attempting to compile
or link against it.
 
(If two or more versions are present, running !RTK will change the
active version whereas booting it will not.)
 
Use
 
When compiling, append -Irtk: to the GCC command line. This adds
rtk: to the list of paths that are searched for include files.
 
When linking, append -lrtk:a.rtk to the GCC command line. This adds
rtk:a.rtk to the list of libraries searched by the linker.
 
Include directives should be of the form:
 
#include "rtk/desktop/application.h"
 
Be aware that all RTK classes are declared within namespaces. You must
either specify the namespace expicitly:
 
rtk::desktop::application
 
or place a using directive at the start of each source file:
 
using namespace rtk::desktop
 
The main() function is normally of the form:
 
int main(void)
{
myapp app;
app.run();
return 0;
}
 
where myapp is a class derived from rtk::desktop::application.
 
Documentation available from the RTK web site currently includes:
* the RTK reference manual
* a number of example programs
 
Building from Source
 
To build the RTK from souce code the following tools must be present
on the Run$Path:
* make
* gcc
* libfile
* fixdeps
 
Suitable versions of make, gcc and libfile may be found within
supported distributions of GCC. fixdeps may be obtained from the RTK
web site.
 
No configuration is necessary. Change the current directory to !RTK
then issue the command:
 
make all
 
Please note that some difficulties have been encountered when using
recursive makefiles with the experimental 32-bit version of make. They
can be overcome by executing the makefiles individually from an obey
file.
 
Support
 
The RTK home page may be found at:
 
http://www.sagitta.demon.co.uk/rtk/
 
There is also a mailing list. To subscribe, send an empty message to:
 
mailto:rtk-request@sagitta.demon.co.uk
 
with a subject of "subscribe".
 
Todo
 
* a multi-line text field class
* a template layout class
* a discard/cancel/save dialogue box class
* printing
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/!Run,feb
New file
0,0 → 1,9
| This file is part of the RISC OS Toolkit (RTK).
| Copyright © 2003 Graham Shaw.
| Distribution and use are subject to the GNU Lesser General Public License,
| a copy of which may be found in the file !RTK.Copyright.
 
Set RTK$Dir <Obey$Dir>
Set RTK$Path <Obey$Dir>.
IfThere <RTK$Dir>.html.index/html Then Set RTK$Help <RTK$Dir>.html.index/html
IconSprites <RTK$Dir>.!Sprites
Property changes:
Added: svn:executable
+ *
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/graphics/gcontext.cc
New file
0,0 → 1,44
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/graphics/font.h"
#include "rtk/graphics/gcontext.h"
 
namespace rtk {
namespace graphics {
 
gcontext::gcontext(const point& origin):
_origin(origin)
{}
 
gcontext::~gcontext()
{}
 
void gcontext::fcolour(int fcolour)
{
if (fcolour!=_fcolour)
{
fcolour_notify(fcolour);
_fcolour=fcolour;
}
}
 
void gcontext::bcolour(int bcolour)
{
if (bcolour!=_bcolour)
{
bcolour_notify(bcolour);
_bcolour=bcolour;
}
}
 
void gcontext::fcolour_notify(int fcolour)
{}
 
void gcontext::bcolour_notify(int bcolour)
{}
 
}; /* namespace graphics */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/graphics/point.h
New file
0,0 → 1,152
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_GRAPHICS_POINT
#define _RTK_GRAPHICS_POINT
 
namespace std {
 
class ostream;
 
}; /* namespace std */
 
namespace rtk {
namespace graphics {
 
/** A class for representing a point in a two-dimensional plane.
* Coordinates are signed integers. The x-axis runs from left to
* right and the y-axis runs from bottom to top. Overflow is not
* detected and its effects are undefined. The origin and scale
* of the coordinate system are context-dependent.
*/
class point
{
private:
/** The x-coordinate. */
int _x;
/** The y-coordinate. */
int _y;
public:
/** Construct point with default coordinates of (0,0). */
point():
_x(0),
_y(0)
{}
 
/** Construct point from x- and y-coordinates.
* @param x the required x-coordinate
* @param y the required y-coordinate
*/
point(int x,int y):
_x(x),
_y(y)
{}
 
/** Get x-coordinate.
* @return the x-coordinate
*/
int x() const
{ return _x; }
 
/** Get y-coordinate.
* @return the y-coordinate
*/
int y() const
{ return _y; }
 
/** Set x-coordinate.
* @param x the required x-coordinate
*/
point& x(int x)
{ _x=x; return *this; }
 
/** Set y-coordinate.
* @param y the required y-coordinate
*/
point& y(int y)
{ _y=y; return *this; }
 
/** Add components of another point.
* The effect of pa+=pb is the same as pa=pa+pb.
* @param p the augend
* @return a reference to this point
*/
point& operator+=(const point& p)
{ _x+=p._x; _y+=p._y; return *this; }
 
/** Subtract components of another point.
* The effect of pa-=pb is the same as pa=pa-pb.
* @param p the subtrahend
* @return a reference to this point
*/
point& operator-=(const point& p)
{ _x-=p._x; _y-=p._y; return *this; }
};
 
/** Negate components of a point.
* The result is such that -point(x,y)==point(-x,-y).
* @param p the point to be negated
* @return a point with equal but opposite coordinates
*/
inline point operator-(const point& p)
{
return point(-p.x(),-p.y());
}
 
/** Add components of two points.
* The result is such that point(ax,ay)+point(bx,by)==point(ax+bx,ay+by).
* @param pa the addend
* @param pb the augend
* @return the sum
*/
inline point operator+(const point& pa,const point& pb)
{
return point(pa.x()+pb.x(),pa.y()+pb.y());
}
 
/** Subtract components of two points.
* The result is such that point(ax,ay)-point(bx,by)==point(ax-bx,ay-by).
* @param pa the minuend
* @param pb the subtrahend
* @return the remainder
*/
inline point operator-(const point& pa,const point& pb)
{
return point(pa.x()-pb.x(),pa.y()-pb.y());
}
 
/** Test whether two points coincide.
* @param pa the first point
* @param pb the second point
* @return true if the points coincide, otherwise false
*/
inline bool operator==(const point& pa,const point& pb)
{
return (pa.x()==pb.x())&&(pa.y()==pb.y());
}
 
/** Test whether two points differ.
* @param pa the first point
* @param pb the second point
* @return true if the points differ, otherwise false
*/
inline bool operator!=(const point& pa,const point& pb)
{
return (pa.x()!=pb.x())||(pa.y()!=pb.y());
}
 
/** Write point to output stream.
* The output is human-readable and of the form (x,y).
* It uses whatever formatting state is applicable at the time.
* @param out the output stream
* @param p the point to be written
* @return a reference to the output stream
*/
ostream& operator<<(ostream& out,const point& p);
 
}; /* namespace graphics */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/graphics/vdu_gcontext.h
New file
0,0 → 1,56
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_GRAPHICS_VDU_GCONTEXT
#define _RTK_GRAPHICS_VDU_GCONTEXT
 
#include "rtk/graphics/gcontext.h"
 
namespace rtk {
namespace graphics {
 
/** A class to represent a graphics context linked to the RISC OS VDU drivers.
* For efficiency, this class assumes that it has exclusive control over
* the RISC OS VDU drivers unless told otherwise. If there is a posiblility
* that the driver state has been changed by another agent (for example,
* after a call to Wimp_Poll), then vdu_context::current() must be called
* to ensure that the required state is re-established.
*/
class vdu_gcontext:
public gcontext
{
private:
/** The current VDU graphics context. */
static vdu_gcontext* _current;
public:
/** Set current VDU graphics context.
* If the current context is unchanged then no action is taken.
* If it is changed then any assumed state (currently the foreground
* and background colours) is re-established.
* @param current the required current context
*/
static void current(vdu_gcontext* current);
public:
/** Construct VDU graphics context.
* @param origin the initial origin
*/
vdu_gcontext(const point& origin);
 
/** Destroy VDU graphics context.
*/
virtual ~vdu_gcontext();
 
virtual void plot(int code,const point& p);
virtual void draw(const string& s,const point& p);
virtual void draw(const font& f,const string& s,const point& p);
protected:
virtual void fcolour_notify(int fcolour);
virtual void bcolour_notify(int bcolour);
};
 
}; /* namespace graphics */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/graphics/gcontext.h
New file
0,0 → 1,126
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_GRAPHICS_GCONTEXT
#define _RTK_GRAPHICS_GCONTEXT
 
#include <string>
 
#include "rtk/graphics/point.h"
 
namespace rtk {
namespace graphics {
 
class font;
 
/** An abstract class to represent an abstract graphics context.
* Using this class it is possible to issue graphical output instructions
* without knowing to where the output is being directed.
*/
class gcontext
{
private:
/** The origin of this graphics context, with respect to the screen. */
point _origin;
/** The current foreground colour.
* This is one of the 16 standard Wimp colours.
*/
int _fcolour;
/** The current background colour.
* This is one of the 16 standard Wimp colours.
*/
int _bcolour;
public:
/** Construct graphics context.
* @param origin the initial origin
*/
gcontext(const point& origin);
 
/** Destroy graphics context.
*/
virtual ~gcontext();
 
/** Get origin.
* @return the origin
*/
const point& origin() const
{ return _origin; }
 
/** Add offset to origin.
* @param offset the required offset
* @return a reference to this
*/
gcontext& operator+=(const point& offset)
{ _origin+=offset; return *this; }
 
/** Subtract offset from origin.
* @param offset the required offset
* @return a reference to this
*/
gcontext& operator-=(const point& offset)
{ _origin-=offset; return *this; }
 
/** Plot to graphics context.
* This method is equivalent to OS_Plot.
* @param code the RISC OS plot action code
* @param p the point to plot (with respect to the origin of this
* graphics context)
*/
virtual void plot(int code,const point& p)=0;
 
/** Draw string to graphics context using desktop font.
* @param s the string to be drawn
* @param p the point at which to begin
*/
virtual void draw(const string& s,const point& p)=0;
 
/** Draw string to graphics context using specified font.
* @param f the font to be used
* @param s the string to be drawn
* @param p the point at which to begin
*/
virtual void draw(const font& f,const string& s,const point& p)=0;
 
/** Get current foreground colour.
* This is one of the 16 standard Wimp colours.
* @return the current foreground colour
*/
int fcolour() const
{ return _fcolour; }
 
/** Get current background colour.
* This is one of the 16 standard Wimp colours.
* @return the current background colour
*/
int bcolour() const
{ return _bcolour; }
 
/** Set current foreground colour.
* This is one of the 16 standard Wimp colours.
* @param fcolour the required foreground colour
*/
void fcolour(int fcolour);
 
/** Set current background colour.
* This is one of the 16 standard Wimp colours.
* @param bcolour the required background colour
*/
void bcolour(int bcolour);
protected:
/** Notify subclass that foreground colour has changed.
* @param fcolour the new foreground colour
*/
virtual void fcolour_notify(int fcolour);
 
/** Notify subclass that background colour has changed.
* @param bcolour the new background colour
*/
virtual void bcolour_notify(int bcolour);
};
 
}; /* namespace graphics */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/graphics/timestamp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/graphics/font.cc
New file
0,0 → 1,83
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/graphics/point.h"
#include "rtk/graphics/font.h"
#include "rtk/os/font.h"
#include "rtk/os/colourtrans.h"
 
namespace rtk {
namespace graphics {
 
struct font::_font
{
int refcount;
int handle;
};
 
font::font(const string& id,int xsize,int ysize):
_f(0)
{
try
{
_f=new _font;
os::Font_FindFont(id.c_str(),xsize,ysize,0,0,&_f->handle,0,0);
}
catch (...)
{
delete _f;
}
}
 
font::font(const font& f):
_f(f._f)
{
++_f->refcount;
}
 
font::~font()
{
if (!--_f->refcount)
{
os::Font_LoseFont(_f->handle);
delete _f;
}
}
 
font& font::operator=(const font& f)
{
++f._f->refcount;
if (!--_f->refcount)
{
os::Font_LoseFont(_f->handle);
delete _f;
}
_f=f._f;
return *this;
}
 
void font::paint(const string& s,const point& p) const
{
// Note: s.c_str() is used in preference to s.data() because
// Font_Paint must be able to access the character following
// the end of the string.
os::ColourTrans_SetFontColours(_f->handle,0xffffff00,0x00000000,14,0,0,0);
os::Font_Paint(_f->handle,s.c_str(),0x190,p,0,0,s.length());
}
 
int font::width(const string& s) const
{
// Note: s.c_str() is used in preference to s.data() because
// Font_Paint must be able to access the character following
// the end of the string.
const int maxint=0xffffff;
point size;
os::Font_ScanString(_f->handle,s.c_str(),0x180,point(maxint,maxint),0,0,
s.length(),0,&size,0);
return size.x()/400;
}
 
}; /* namespace graphics */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/graphics/box.cc
New file
0,0 → 1,221
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include <algorithm>
 
#include "rtk/graphics/box.h"
 
namespace rtk {
namespace graphics {
 
box& box::operator+=(const point& p)
{
_xmin+=p.x();
_ymin+=p.y();
_xmax+=p.x();
_ymax+=p.y();
return *this;
}
 
box& box::operator-=(const point& p)
{
_xmin-=p.x();
_ymin-=p.y();
_xmax-=p.x();
_ymax-=p.y();
return *this;
}
 
box& box::operator+=(const box& b)
{
_xmin+=b._xmin;
_ymin+=b._ymin;
_xmax+=b._xmax;
_ymax+=b._ymax;
return *this;
}
 
box& box::operator-=(const box& b)
{
_xmin-=b._xmin;
_ymin-=b._ymin;
_xmax-=b._xmax;
_ymax-=b._ymax;
return *this;
}
 
box& box::operator|=(const box& b)
{
if (_xmin>b._xmin) _xmin=b._xmin;
if (_ymin>b._ymin) _ymin=b._ymin;
if (_xmax<b._xmax) _xmax=b._xmax;
if (_ymax<b._ymax) _ymax=b._ymax;
return *this;
}
 
box& box::operator&=(const box& b)
{
if (_xmin<b._xmin) _xmin=b._xmin;
if (_ymin<b._ymin) _ymin=b._ymin;
if (_xmax>b._xmax) _xmax=b._xmax;
if (_ymax>b._ymax) _ymax=b._ymax;
return *this;
}
 
box& box::extend_left(const box& b)
{
_xmin-=b._xmax-b._xmin;
if (_ymin>b._ymin) _ymin=b._ymin;
if (_ymax<b._ymax) _ymax=b._ymax;
return *this;
}
 
box& box::extend_right(const box& b)
{
_xmax+=b._xmax-b._xmin;
if (_ymin>b._ymin) _ymin=b._ymin;
if (_ymax<b._ymax) _ymax=b._ymax;
return *this;
}
 
box& box::extend_up(const box& b)
{
_ymax+=b._ymax-b._ymin;
if (_xmin>b._xmin) _xmin=b._xmin;
if (_xmax<b._xmax) _xmax=b._xmax;
return *this;
}
 
box& box::extend_down(const box& b)
{
_ymin-=b._ymax-b._ymin;
if (_xmin>b._xmin) _xmin=b._xmin;
if (_xmax<b._xmax) _xmax=b._xmax;
return *this;
}
 
box& box::extend_left(unsigned int xsize)
{
_xmin-=xsize;
return *this;
}
 
box& box::extend_right(unsigned int xsize)
{
_xmax+=xsize;
return *this;
}
 
box& box::extend_up(unsigned int ysize)
{
_ymax+=ysize;
return *this;
}
 
box& box::extend_down(unsigned int ysize)
{
_ymin-=ysize;
return *this;
}
 
box operator+(const box& b,const point& p)
{
return box(
b.xmin()+p.x(),
b.ymin()+p.y(),
b.xmax()+p.x(),
b.ymax()+p.y());
}
 
box operator-(const box& b,const point& p)
{
return box(
b.xmin()-p.x(),
b.ymin()-p.y(),
b.xmax()-p.x(),
b.ymax()-p.y());
}
 
box operator|(const box& b,const point& p)
{
return box(
min(b.xmin(),p.x()),
min(b.ymin(),p.y()),
max(b.xmax(),p.x()),
max(b.ymax(),p.y()));
}
 
box operator+(const box& ba,const box& bb)
{
return box(
ba.xmin()+bb.xmin(),
ba.ymin()+bb.ymin(),
ba.xmax()+bb.xmax(),
ba.ymax()+bb.ymax());
}
 
box operator-(const box& ba,const box& bb)
{
return box(
ba.xmin()-bb.xmin(),
ba.ymin()-bb.ymin(),
ba.xmax()-bb.xmax(),
ba.ymax()-bb.ymax());
}
 
box operator|(const box& ba,const box& bb)
{
return box(
min(ba.xmin(),bb.xmin()),
min(ba.ymin(),bb.ymin()),
max(ba.xmax(),bb.xmax()),
max(ba.ymax(),bb.ymax()));
}
 
box operator&(const box& ba,const box& bb)
{
return box(
max(ba.xmin(),bb.xmin()),
max(ba.ymin(),bb.ymin()),
min(ba.xmax(),bb.xmax()),
min(ba.ymax(),bb.ymax()));
}
 
bool operator<=(const point& p,const box& b)
{
return
(p.x()>=b.xmin())&&
(p.y()>=b.ymin())&&
(p.x()<b.xmax())&&
(p.y()<b.ymax());
}
 
bool operator==(const box& ba,const box& bb)
{
return (
(ba.xmin()^bb.xmin())|
(ba.ymin()^bb.ymin())|
(ba.xmax()^bb.xmax())|
(ba.ymax()^bb.ymax()))==0;
}
 
bool operator!=(const box &ba,const box& bb)
{
return (
(ba.xmin()^bb.xmin())|
(ba.ymin()^bb.ymin())|
(ba.xmax()^bb.xmax())|
(ba.ymax()^bb.ymax()))!=0;
}
 
ostream& operator<<(ostream& out,const box& b)
{
out << '(' << b.xmin() << ',' << b.ymin() << ','
<< b.xmax() << ',' << b.ymax() << ')';
return out;
}
 
}; /* namespace graphics */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/graphics/font.h
New file
0,0 → 1,65
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_GRAPHICS_FONT
#define _RTK_GRAPHICS_FONT
 
#include <string>
 
namespace rtk {
namespace graphics {
 
class point;
 
class font
{
private:
/** A reference-counted structure for sharing font data. */
struct _font;
/** A pointer to the shared font data. */
_font* _f;
public:
/** Construct font object.
* @param id the font identifier
* @param xsize the required font width (16 units = 1 point)
* @param ysize the required font height (16 units = 1 point)
*/
font(const string& id,int xsize,int ysize);
 
/** Construct copy of font object.
* Font objects may be freely copied. The underlying font handle
* is reference-counted and shared.
* @param f the font to be copied
*/
font(const font& f);
 
/** Destroy font object.
*/
~font();
 
/** Assign font object.
* Font objects may be freely copied. The underlying font handle
* is reference-counted and shared.
* @param f the font to be copied
*/
font& operator=(const font& f);
 
/** Plot string to screen using font.
* @param s the string to plot
* @param p the point at which to begin plotting (in OS units)
*/
void paint(const string& s,const point& p) const;
 
/** Get width required to plot string using font.
* @param s the string to plot
* @return the required width (in OS units)
*/
int width(const string& s) const;
};
 
}; /* namespace graphics */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/graphics/Makefile
New file
0,0 → 1,22
# This file is part of the RISC OS Toolkit (RTK).
# Copyright © 2003-2004 Graham Shaw.
# Distribution and use are subject to the GNU Lesser General Public License,
# a copy of which may be found in the file !RTK.Copyright.
 
CPPFLAGS = -Irtk_build:
CXXFLAGS = -mthrowback -munixlib -mpoke-function-name -Wall -W -Wno-unused -O2
 
include fixdeps:Rules/make
 
OBJ = point.o \
box.o \
font.o \
gcontext.o \
vdu_gcontext.o
 
all: timestamp
 
timestamp: $(OBJ)
touch timestamp
 
include $(OBJ:.o=.d)
Property changes:
Added: svn:executable
+ *
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/graphics/point.cc
New file
0,0 → 1,20
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include <iostream>
 
#include "rtk/graphics/point.h"
 
namespace rtk {
namespace graphics {
 
ostream& operator<<(ostream& out,const point& p)
{
out << '(' << p.x() << ',' << p.y() << ')';
return out;
}
 
}; /* namespace graphics */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/graphics/vdu_gcontext.cc
New file
0,0 → 1,69
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/graphics/font.h"
#include "rtk/graphics/vdu_gcontext.h"
#include "rtk/os/os.h"
#include "rtk/os/wimp.h"
 
namespace rtk {
namespace graphics {
 
vdu_gcontext::vdu_gcontext(const point& _origin):
gcontext(_origin)
{}
 
vdu_gcontext::~vdu_gcontext()
{}
 
vdu_gcontext* vdu_gcontext::_current=0;
 
void vdu_gcontext::current(vdu_gcontext* current)
{
if (current!=_current)
{
current=current;
if (current)
{
os::Wimp_SetColour(current->fcolour());
os::Wimp_SetColour(current->bcolour()|0x80);
os::Wimp_TextColour(current->fcolour());
os::Wimp_TextColour(current->bcolour()|0x80);
}
}
}
 
void vdu_gcontext::plot(int code,const point& p)
{
current(this);
os::OS_Plot(code,origin()+p);
}
 
void vdu_gcontext::draw(const string &s,const point& p)
{
current(this);
os::Wimp_TextOp2(s.c_str(),origin()+p);
}
 
void vdu_gcontext::draw(const font& f,const string& s,const point& p)
{
current(this);
f.paint(s,origin()+p);
}
 
void vdu_gcontext::fcolour_notify(int fcolour)
{
os::Wimp_SetColour(fcolour);
os::Wimp_TextColour(fcolour);
}
 
void vdu_gcontext::bcolour_notify(int bcolour)
{
os::Wimp_SetColour(bcolour|0x80);
os::Wimp_TextColour(bcolour|0x80);
}
 
}; /* namespace graphics */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/graphics/box.h
New file
0,0 → 1,433
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_GRAPHICS_BOX
#define _RTK_GRAPHICS_BOX
 
#include "rtk/graphics/point.h"
 
namespace std {
 
class ostream;
 
}; /* namespace std */
 
namespace rtk {
namespace graphics {
 
/** A class for representing an axis-aligned box in a two-dimensional plane.
* Minimum values for coordinates are inclusive, maximum values are
* exclusive. It is permissible, but not necessarily meaningful, for
* the maximum coordinate to be less than the minimum coordinate.
*/
class box
{
private:
/** The minimum x-coordinate. */
int _xmin;
 
/** The minimum y-coordinate. */
int _ymin;
 
/** The maximum x-coordinate. */
int _xmax;
 
/** The maximum y-coordinate. */
int _ymax;
public:
/** Construct box with default coordinates of (0,0,0,0). */
box():
_xmin(0),
_ymin(0),
_xmax(0),
_ymax(0)
{}
 
/** Construct box given bottom-left and top-right corners.
* @param min the bottom-left corner (minimum x- and y-coordinates)
* @param max the top-right corner (maximum x- and y-coordinates)
*/
box(const point& min,const point& max):
_xmin(min.x()),
_ymin(min.y()),
_xmax(max.x()),
_ymax(max.y())
{}
 
/** Construct box given minimum and maximum x- and y-coordinates.
* @param xmin the minimum x-coordinate
* @param ymin the minimum y-coordinate
* @param xmax the maximum x-coordinate
* @param ymax the maximum y-coordinate
*/
box(int xmin,int ymin,int xmax,int ymax):
_xmin(xmin),
_ymin(ymin),
_xmax(xmax),
_ymax(ymax)
{}
 
/** Get minimum x-coordinate.
* This is the position of the left side of the box.
* @return the minimum x-coordinate
*/
int xmin() const
{ return _xmin; }
 
/** Get minimum y-coordinate.
* This is the position of the lower side of the box.
* @return the minimum y-coordinate
*/
int ymin() const
{ return _ymin; }
 
/** Get maximum x-coordinate.
* This is the position of the right side of the box.
* @return the maximum x-coordinate
*/
int xmax() const
{ return _xmax; }
 
/** Get maximum y-coordinate.
* This is the position of the upper side of the box.
* @return the maximum y-coordinate
*/
int ymax() const
{ return _ymax; }
 
/** Get point with minimum x-coordinate and minimum y-coordinate.
* This is the bottom-left corner of the box.
* @return a point with the specified coordinates
*/
point xminymin() const
{ return point(_xmin,_ymin); }
 
/** Get point with minimum x-coordinate and maximum y-coordinate.
* This is the top-left corner of the box.
* @return a point with the specified coordinates
*/
point xminymax() const
{ return point(_xmin,_ymax); }
 
/** Get point with maximum x-coordinate and minimum y-coordinate.
* This is the bottom-right corner of the box.
* @return a point with the specified coordinates
*/
point xmaxymin() const
{ return point(_xmax,_ymin); }
 
/** Get point with maximum x-coordinate and maximum y-coordinate.
* This is the top-right corner of the box.
* @return a point with the specified coordinates
*/
point xmaxymax() const
{ return point(_xmax,_ymax); }
 
/** Set minimum x-coordinate.
* @param xmin the required minimum x-coordinate
* @return a reference to this
*/
box& xmin(int xmin)
{ _xmin=xmin; return *this; }
 
/** Set minimum y-coordinate.
* @param ymin the required minimum y-coordinate
* @return a reference to this
*/
box& ymin(int ymin)
{ _ymin=ymin; return *this; }
 
/** Set maximum x-coordinate.
* @param xmax the required maximum x-coordinate
* @return a reference to this
*/
box& xmax(int xmax)
{ _xmax=xmax; return *this; }
 
/** Set maximum y-coordinate.
* @param ymax the required maximum y-coordinate
* @return a reference to this
*/
box& ymax(int ymax)
{ _ymax=ymax; return *this; }
 
/** Set minimum x-coordinate and minimum y-coordinate.
* @param p a point with the required x- and y-coordinates
* @return a reference to this
*/
box& xminymin(const point& p)
{ _xmin=p.x(); _ymin=p.y(); return *this; }
 
/** Set minimum x-coordinate and maximum y-coordinate.
* @param p a point with the required x- and y-coordinates
* @return a reference to this
*/
box& set_xminymax(const point& p)
{ _xmin=p.x(); _ymax=p.y(); return *this; }
 
/** Set maximum x-coordinate and minimum y-coordinate.
* @param p a point with the required x- and y-coordinates
* @return a reference to this
*/
box& set_xmaxymin(const point& p)
{ _xmax=p.x(); _ymin=p.y(); return *this; }
 
/** Set maximum x-coordinate and maximum y-coordinate.
* @param p a point with the required x- and y-coordinates
* @return a reference to this
*/
box& set_xmaxymax(const point& p)
{ _xmax=p.x(); _ymax=p.y(); return *this; }
 
/** Get size of box in x- and y-directions.
* @return a point with its x- and y-coordinates equal to the
* width and height of the box respectively.
*/
point size() const
{ return point(_xmax-_xmin,_ymax-_ymin); }
 
/** Get size of box in x-direction.
* @return the size of the box in the x-direction
*/
int xsize() const
{ return _xmax-_xmin; }
 
/** Get size of box in y-direction.
* @return the size of the box in the y-direction
*/
int ysize() const
{ return _ymax-_ymin; }
 
/** Add components of a point.
* This operation can be used to move a box by an offset without
* changing its size. The result overwrites the existing value of
* this.
* @param p the augend (a point)
* @return a reference to this
*/
box& operator+=(const point& p);
 
/** Subtract components of a point.
* This operation can be used to move a box by the reverse of an
* offset without changing its size. The result overwrites the
* existing value of this.
* @param p the subtrahend (a point)
* @return a reference to this
*/
box& operator-=(const point& p);
 
/** Calculate union with a point.
* The result is the smallest box that contains both this box and
* the point. It overwrites the existing value of this.
* @param p the point
* @return a reference to this
*/
box& operator|=(const point& p);
 
/** Add components of another box.
* This operation can be used to place a border around a box.
* For example, adding box(-1,-1,1,1) would expand the addend by
* one unit in every direction. The result overwrites the existing
* value of this.
* @param b the augend (a box)
* @return a reference to this
*/
box& operator+=(const box& b);
 
/** Subtract components of another box.
* This operation can be used to remove a border from around a box.
* For example, subtracting box(-1,-1,1,1) would reduce the minuend by
* one unit in every direction. The result overwrites the existing
* value of this.
* @param b the subtrahend (a box)
* @return a reference to this
*/
box& operator-=(const box& b);
 
/** Calculate union with another box.
* The result is the smallest box that contains both arguments.
* It overwrites the existing value of this.
* @param b the other box
* @return a reference to this
*/
box& operator|=(const box& b);
 
/** Calculate intersection with another box.
* The result is the largest box that is contained both by both
* arguments. It overwrites the existing value of this.
* If the two boxes do not intersect then the result will have
* zero or negative height and/or width.
* @param b the other box
* @return a reference to this
*/
box& operator&=(const box& b);
 
/** Extend this box by attaching another box to its left side.
* This box is extended left by the width of b. It is also
* extended upward and/or downward so that any y-coordinate
* contained within b is also contained within the result.
* @param b the extension box
* @return a reference to this
*/
box& extend_left(const box& b);
 
/** Extend this box by attaching another box to its right side.
* This box is extended right by the width of b. It is also
* extended upward and/or downward so that any y-coordinate
* contained within b is also contained within the result.
* @param b the extension box
* @return a reference to this
*/
box& extend_right(const box& b);
 
/** Extend this box by attaching another box to its upper side.
* This box is extended upward by the height of b. It is also
* extended left and/or right so that any x-coordinate
* contained within b is also contained within the result.
* @param b the extension box
* @return a reference to this
*/
box& extend_up(const box& b);
 
/** Extend this box by attaching another box to its lower side.
* This box is extended downward by the height of b. It is also
* extended left and/or right so that any x-coordinate
* contained within b is also contained within the result.
* @param b the extension box
* @return a reference to this
*/
box& extend_down(const box& b);
 
/** Extend this box to the left.
* This box is extended left by xsize.
* @param xsize the distance by which to extend
* @return a reference to this
*/
box& extend_left(unsigned int xsize);
 
/** Extend this box to the right.
* @param xsize the distance by which to extend
* @return a reference to this
*/
box& extend_right(unsigned int xsize);
 
/** Extend this box upwards.
* @param ysize the distance by which to extend
* @return a reference to this
*/
box& extend_up(unsigned int ysize);
 
/** Extend this box downwards.
* @param ysize the distance by which to extend
* @return a reference to this
*/
box& extend_down(unsigned int ysize);
};
 
/** Add components of point to box.
* This operation can be used to move a box by an offset without changing
* its size. The result is such that
* box(ax,ay,bx,by)+point(cx,cy)==box(ax+cx,ay+cy,bx+cx,by+cy).
* @param b the addend (a box)
* @param p the augend (a point)
* @return the sum
*/
box operator+(const box& b,const point& p);
 
/** Subtract components of point from box.
* This operation can be used to move a box by the reverse of an offset
* without changing its size. The result is such that
* box(ax,ay,bx,by)-point(cx,cy)==box(ax-cx,ay-cy,bx-cx,by-cy).
* @param b the minuend (a box)
* @param p the subtrahend (a point)
* @return the remainder
*/
box operator-(const box& b,const point& p);
 
/** Calculate union of box and point.
* The result is the smallest box that contains both arguments.
* @param b the box
* @param p the point
* @return the union
*/
box operator|(const box& b,const point& p);
 
/** Add components of one box to another.
* This operation can be used to place a border around a box.
* For example, adding box(-1,-1,1,1) would expand the addend by
* one unit in every direction. The result is such that
* box(ax,ay,bx,by)+box(cx,cy,dx,dy)==box(ax+cx,ay+cy,bx+dx,by+dy).
* @param ba the addend (a box)
* @param bb the augend (another box)
* @return the sum
*/
box operator+(const box& ba,const box& bb);
 
/** Subtract components of one box to another.
* This operation can be used to remove a border from around a box.
* For example, subtracting box(-1,-1,1,1) would reduce the minuend by
* one unit in every direction. The result is such that
* box(ax,ay,bx,by)-box(cx,cy,dx,dy)==box(ax-cx,ay-cy,bx-dx,by-dy).
* @param ba the minuend (a box)
* @param bb the subtrahend (another box)
* @return the difference
*/
box operator-(const box& ba,const box& bb);
 
/** Calculate union of two boxes.
* The result is the smallest box that contains both arguments.
* @param ba the first box
* @param bb the second box
* @return the union
*/
box operator|(const box& ba,const box& bb);
 
/** Calculate intersection of two boxes.
* The result is the largest box contained within both arguments.
* If the arguments do not intersect then the result will have
* zero or negative height and/or width.
* @param ba the first box
* @param bb the second box
* @return the intersection
*/
box operator&(const box& ba,const box& bb);
 
/** Test whether a point is inside a box.
* To be inside the box the coordinates of the point must be strictly
* less than the maximum coordinates of the box, but not less than
* the minimum coordinates.
* @param p the point
* @param b the box
* @return true if point is inside, otherwise false
*/
bool operator<=(const point& p,const box& b);
 
/** Test whether two boxes coincide.
* @param ba the first box
* @param bb the second box
* @return true if the boxes coincide, otherwise false
*/
bool operator==(const box& ba,const box& bb);
 
/** Test whether two boxes differ.
* @param ba the first box
* @param bb the second box
* @return true if the boxes differ, otherwise false
*/
bool operator!=(const box& ba,const box& bb);
 
/** Write box to output stream.
* The output is human-readable and of the form (xmin,ymin,xmax,ymax).
* It uses whatever formatting state is applicable at the time.
* @param out the output stream
* @param b the box to be written
* @return a reference to the output stream
*/
ostream& operator<<(ostream& out,const box& b);
 
}; /* namespace graphics */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/colourtrans.cc
New file
0,0 → 1,28
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/colourtrans.h"
#include "rtk/os/call_swi.h"
#include "rtk/os/colourtrans.h"
 
namespace rtk {
namespace os {
 
void ColourTrans_SetFontColours(int handle,int bcolour,int fcolour,int max,
int* _bcolour,int* _fcolour,int* _max)
{
_kernel_swi_regs regs;
regs.r[0]=handle;
regs.r[1]=bcolour;
regs.r[2]=fcolour;
regs.r[3]=max;
call_swi(swi::ColourTrans_SetFontColours,&regs);
if (_bcolour) *_bcolour=regs.r[1];
if (_fcolour) *_fcolour=regs.r[2];
if (_max) *_max=regs.r[3];
}
 
}; /* namespace os */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/wimp.cc
New file
0,0 → 1,377
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/wimp.h"
#include "rtk/os/call_swi.h"
#include "rtk/os/wimp.h"
 
namespace rtk {
namespace os {
 
void Wimp_Initialise(int version,const char* name,int* messages,
int* _version,int* _handle)
{
_kernel_swi_regs regs;
regs.r[0]=version;
regs.r[1]=0x4B534154;
regs.r[2]=(int)name;
regs.r[3]=(int)messages;
call_swi(swi::Wimp_Initialise,&regs);
if (_version) *_version=regs.r[0];
if (_handle) *_handle=regs.r[1];
}
 
void Wimp_CreateWindow(const window_create& block,int* _handle)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_CreateWindow,&regs);
if (_handle) *_handle=regs.r[0];
}
 
void Wimp_CreateIcon(int priority,const icon_create& block,int* _handle)
{
_kernel_swi_regs regs;
regs.r[0]=priority;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_CreateIcon,&regs);
if (_handle) *_handle=regs.r[0];
}
 
void Wimp_DeleteWindow(const window_delete& block)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_DeleteWindow,&regs);
}
 
void Wimp_DeleteIcon(const icon_delete& block)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_DeleteIcon,&regs);
}
 
void Wimp_OpenWindow(const window_open& block,int phandle,int flags)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
regs.r[2]=0x4b534154;
regs.r[3]=phandle;
regs.r[4]=flags;
call_swi(swi::Wimp_OpenWindow,&regs);
}
 
void Wimp_OpenWindow(const window_open& block)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_OpenWindow,&regs);
}
 
void Wimp_CloseWindow(const window_close& block)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_CloseWindow,&regs);
}
 
void Wimp_Poll(int mask,wimp_block& block,int* pollword,int* _code)
{
_kernel_swi_regs regs;
regs.r[0]=mask;
regs.r[1]=(int)&block;
regs.r[3]=(int)pollword;
call_swi(swi::Wimp_Poll,&regs);
if (_code) *_code=regs.r[0];
}
 
void Wimp_RedrawWindow(window_redraw& block,int* _more)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_RedrawWindow,&regs);
if (_more) *_more=regs.r[0];
}
 
void Wimp_UpdateWindow(window_redraw& block,int* _more)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_UpdateWindow,&regs);
if (_more) *_more=regs.r[0];
}
 
void Wimp_GetRectangle(window_redraw& block,int* _more)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_GetRectangle,&regs);
if (_more) *_more=regs.r[0];
}
 
void Wimp_GetWindowState(window_state_get& block)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_GetWindowState,&regs);
}
 
void Wimp_SetIconState(icon_state_set& block)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_SetIconState,&regs);
}
 
void Wimp_GetIconState(icon_state_get& block)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_GetIconState,&regs);
}
 
void Wimp_GetPointerInfo(pointer_info_get& block)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_GetPointerInfo,&regs);
}
 
void Wimp_DragBox(drag_box& block)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_DragBox,&regs);
}
 
void Wimp_ForceRedraw(int handle,const box& bbox)
{
_kernel_swi_regs regs;
regs.r[0]=handle;
regs.r[1]=bbox.xmin();
regs.r[2]=bbox.ymin();
regs.r[3]=bbox.xmax();
regs.r[4]=bbox.ymax();
call_swi(swi::Wimp_ForceRedraw,&regs);
}
 
void Wimp_SetCaretPosition(int whandle,int ihandle,const point& p,
int height,int index)
{
_kernel_swi_regs regs;
regs.r[0]=whandle;
regs.r[1]=ihandle;
regs.r[2]=p.x();
regs.r[3]=p.y();
regs.r[4]=height;
regs.r[5]=index;
call_swi(swi::Wimp_SetCaretPosition,&regs);
}
 
void Wimp_GetCaretPosition(caret_position_get& block)
{
_kernel_swi_regs regs;
regs.r[1]=(int)&block;
call_swi(swi::Wimp_GetCaretPosition,&regs);
}
 
void Wimp_CreateMenu(int handle,const point& p)
{
_kernel_swi_regs regs;
regs.r[1]=handle;
regs.r[2]=p.x();
regs.r[3]=p.y();
call_swi(swi::Wimp_CreateMenu,&regs);
}
 
void Wimp_SetExtent(int handle,const box& workarea)
{
_kernel_swi_regs regs;
regs.r[0]=handle;
regs.r[1]=(int)&workarea;
call_swi(swi::Wimp_SetExtent,&regs);
}
 
void Wimp_ProcessKey(int code)
{
_kernel_swi_regs regs;
regs.r[0]=code;
call_swi(swi::Wimp_ProcessKey,&regs);
}
 
void Wimp_StartTask(const char* command,int* _handle)
{
_kernel_swi_regs regs;
regs.r[0]=(int)command;
call_swi(swi::Wimp_StartTask,&regs);
if (_handle) *_handle=regs.r[0];
}
 
void Wimp_ReportError(const _kernel_oserror &block,const char* title,
int flags,int* _result)
{
_kernel_swi_regs regs;
if (title==0) title="";
regs.r[0]=(int)&block;
regs.r[1]=flags;
regs.r[2]=(int)title;
call_swi(swi::Wimp_ReportError,&regs);
if (_result) *_result=regs.r[1];
}
 
void Wimp_ReportError(int errnum,const char* message,const char* title,
int flags,int* _result)
{
_kernel_swi_regs regs;
_kernel_oserror block;
block.errnum=errnum;
strcpy(block.errmess,message);
if (title==0) title="";
regs.r[0]=(int)&block;
regs.r[1]=flags;
regs.r[2]=(int)title;
call_swi(swi::Wimp_ReportError,&regs);
if (_result) *_result=regs.r[1];
}
 
void Wimp_SetColour(int colour)
{
_kernel_swi_regs regs;
regs.r[0]=colour;
call_swi(swi::Wimp_SetColour,&regs);
}
 
void Wimp_SendMessage(int wimpcode,wimp_block& wimpblock,int thandle,
int ihandle,int* _thandle)
{
_kernel_swi_regs regs;
regs.r[0]=wimpcode;
regs.r[1]=(int)&wimpblock;
regs.r[2]=thandle;
regs.r[3]=ihandle;
call_swi(swi::Wimp_SendMessage,&regs);
if (_thandle) *_thandle=regs.r[2];
}
 
void Wimp_CreateSubMenu(int handle,const point& p)
{
_kernel_swi_regs regs;
regs.r[1]=handle;
regs.r[2]=p.x();
regs.r[3]=p.y();
call_swi(swi::Wimp_CreateSubMenu,&regs);
}
 
void Wimp_SpriteOp40(const char* name,int* _xsize,int* _ysize,
int* _mask,int* _mode)
{
_kernel_swi_regs regs;
regs.r[0]=40;
regs.r[2]=(int)name;
call_swi(swi::Wimp_SpriteOp,&regs);
if (_xsize) *_xsize=regs.r[3];
if (_ysize) *_ysize=regs.r[4];
if (_mask) *_mask=regs.r[5];
if (_mode) *_mode=regs.r[6];
}
 
void Wimp_ReadPixTrans(sprite_area* area,const char* name,
unsigned int* _scale,unsigned char* _table)
{
_kernel_swi_regs regs;
regs.r[0]=(area)?0x100:0x000;
regs.r[1]=(int)area;
regs.r[2]=(int)name;
regs.r[6]=(int)_scale;
regs.r[7]=(int)_table;
call_swi(swi::Wimp_ReadPixTrans,&regs);
}
 
void Wimp_ReadPixTrans(sprite_area* area,sprite* sp,
unsigned int* _scale,unsigned char* _table)
{
_kernel_swi_regs regs;
regs.r[0]=0x200;
regs.r[1]=(int)area;
regs.r[2]=(int)sp;
regs.r[6]=(int)_scale;
regs.r[7]=(int)_table;
call_swi(swi::Wimp_ReadPixTrans,&regs);
}
 
void Wimp_TextColour(int colour)
{
_kernel_swi_regs regs;
regs.r[0]=colour;
call_swi(swi::Wimp_TextColour,&regs);
}
 
void Wimp_TransferBlock(int src_thandle,const void* src_buffer,
int dst_thandle,void* dst_buffer,unsigned int count)
{
_kernel_swi_regs regs;
regs.r[0]=src_thandle;
regs.r[1]=(int)src_buffer;
regs.r[2]=dst_thandle;
regs.r[3]=(int)dst_buffer;
regs.r[4]=count;
call_swi(swi::Wimp_TransferBlock,&regs);
}
 
void Wimp_ReadSysInfo(int index,int* _r0,int* _r1)
{
_kernel_swi_regs regs;
regs.r[0]=index;
call_swi(swi::Wimp_ReadSysInfo,&regs);
if (_r0) *_r0=regs.r[0];
if (_r1) *_r1=regs.r[1];
}
 
void Wimp_TextOp0(int fcolour,int bcolour)
{
_kernel_swi_regs regs;
regs.r[0]=0;
regs.r[1]=fcolour;
regs.r[2]=bcolour;
call_swi(swi::Wimp_TextOp,&regs);
}
 
void Wimp_TextOp1(const char* s,int count,int* _width)
{
_kernel_swi_regs regs;
regs.r[0]=1;
regs.r[1]=(int)s;
regs.r[2]=count;
call_swi(swi::Wimp_TextOp,&regs);
if (_width) *_width=regs.r[0];
}
 
void Wimp_TextOp2(const char* s,const point& p)
{
_kernel_swi_regs regs;
regs.r[0]=2;
regs.r[1]=(int)s;
regs.r[2]=-1;
regs.r[3]=-1;
regs.r[4]=p.x();
regs.r[5]=p.y();
call_swi(swi::Wimp_TextOp,&regs);
}
 
void Wimp_ResizeIcon(int whandle,int ihandle,const box& bbox)
{
_kernel_swi_regs regs;
regs.r[0]=whandle;
regs.r[1]=ihandle;
regs.r[2]=bbox.xmin();
regs.r[3]=bbox.ymin();
regs.r[4]=bbox.xmax();
regs.r[5]=bbox.ymax();
call_swi(swi::Wimp_ResizeIcon,&regs);
}
 
}; /* namespace os */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/colourtrans.h
New file
0,0 → 1,27
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_OS_COLOURTRANS
#define _RTK_OS_COLOURTRANS
 
namespace rtk {
namespace os {
 
/** Set colours for use by font manager.
* @param handle the font handle, or 0 for the current font
* @param bcolour the background palette entry
* @param fcolour the foreground palette entry
* @param max the maximum foreground colour offset (0-14)
* @param _bcolour a buffer for the returned background logical colour
* @param _fcolour a buffer for the returned foreground logical colour
* @param _max a buffer for the returned maximum sensible colour offset
*/
void ColourTrans_SetFontColours(int handle,int bcolour,int fcolour,int max,
int* _bcolour,int* _fcolour,int* _max);
 
}; /* namespace os */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/exception.cc
New file
0,0 → 1,23
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include <kernel.h>
 
#include "rtk/os/exception.h"
 
namespace rtk {
namespace os {
 
exception::exception(_kernel_oserror* err):
_err(err)
{}
 
const char* exception::what() const
{
return _err->errmess;
}
 
}; /* namespace os */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/wimp.h
New file
0,0 → 1,585
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_OS_WIMP
#define _RTK_OS_WIMP
 
#include "kernel.h"
 
#include "rtk/graphics/point.h"
#include "rtk/graphics/box.h"
 
namespace rtk {
namespace os {
 
using rtk::graphics::point;
using rtk::graphics::box;
 
struct sprite;
struct sprite_area;
 
/** A union to represent a Wimp event block. */
union wimp_block
{
/** The event block as an array of bytes. */
char byte[256];
/** The event block as an array of words. */
int word[64];
};
 
/** A union to represent a Wimp icon data block. */
union icon_data
{
/** The icon data as an array of words. */
int word[3];
/** The icon data as an array of pointers. */
void* pointer[3];
/** The icon data as an array of const pointers. */
const void* const_pointer[3];
};
 
/** A structure to represent the state of an icon. */
struct icon
{
/** The bounding box. */
box bbox;
/** The icon flags. */
int flags;
/** The icon data. */
icon_data data;
};
 
/** A structure for specifying a window handle and an icon handle. */
struct icon_base
{
/** The window handle. */
int whandle;
/** The icon handle. */
int ihandle;
};
 
/** A structure for use by Wimp_CreateIcon. */
struct icon_create
{
/** The window handle. */
int whandle;
/** The icon state. */
os::icon icon;
};
 
/** A structure for use by Wimp_DeleteIcon. */
struct icon_delete:
public icon_base
{};
 
/** A structure for use by Wimp_GetIconState. */
struct icon_state_get:
public icon_base
{
/** The icon state. */
os::icon icon;
};
 
/** A structure for use by Wimp_SetIconState. */
struct icon_state_set:
public icon_base
{
/** The exclusive-or mask. */
int eor;
/** The bit-inverse-clear mask. */
int bic;
};
 
/** A structure for use by Wimp_GetPointerInfo. */
struct pointer_info_get
{
/** The pointer position. */
point p;
/** The mouse button state. */
int buttons;
/** The handle of the window containing the pointer.
* (-1 for backdrop, -2 for icon bar.)
*/
int whandle;
/** The handle of the icon containing the pointer.
* (-1 for work area, -2 to -13 for window furniture: see PRM.)
*/
int ihandle;
};
 
/** A structure for use by Wimp_GetCaretPosition. */
struct caret_position_get:
public icon_base
{
/** The caret position. */
point p;
/** The caret height. */
int height;
/** The character index. */
int index;
};
 
/** A window block containing word 0 only. */
struct window_base_1
{
/** The window handle. */
int handle;
};
 
/** A window block containing words 0 to 6 inclusive. */
struct window_base_7:
public window_base_1
{
/** The visible area bounding box. */
box bbox;
/** The scroll offset. */
point scroll;
};
 
/** A window block containing words 0 to 7 inclusive. */
struct window_base_8:
public window_base_7
{
/** The handle of the window about this one in the stack.
* (-1 for top, -2 for bottom.)
*/
int behind;
};
 
/** A window block containing words 0 to 8 inclusive. */
struct window_base_9:
public window_base_8
{
/** The window flags. */
int wflags;
};
 
/** A structure for use by Wimp_CreateWindow. */
struct window_create
{
/** The visible area bounding box. */
box bbox;
/** The scroll offset. */
point scroll;
/** The handle of the window about this one in the stack.
* (-1 for top, -2 for bottom.)
*/
int behind;
/** The window flags. */
int wflags;
/** The title foreground colour. */
char tf_colour;
/** The title background colour. */
char tb_colour;
/** The work area foreground colour. */
char wf_colour;
/** The work area background colour. */
char wb_colour;
/** The outer scroll bar colour. */
char so_colour;
/** The inner scroll bar colour. */
char si_colour;
/** The title background colour when highlighted. */
char th_colour;
/** Reserved (must be 0). */
char reserved;
/** The work area extent. */
box workarea;
/** The title bar icon flags. */
int tflags;
/** The work area flags (giving the button type). */
int waflags;
/** The sprite area pointer. */
int spritearea;
/** The minimum width of the window. */
int minxsize:16;
/** The minimum height of the window. */
int minysize:16;
/** The title bar icon data. */
icon_data title;
/** The number of icons. */
int numicons;
};
 
/** A structure for use by Wimp_DeleteWindow. */
struct window_delete:
public window_base_1
{};
 
/** A structure for use by Wimp_OpenWindow. */
struct window_open:
public window_base_8
{};
 
/** A structure for use by Wimp_CloseWindow. */
struct window_close:
public window_base_1
{};
 
/** A structure for use by Wimp_GetWindowState. */
struct window_state_get:
public window_base_9
{};
 
 
/** A structure for use by Wimp_GetRectangle and related functions. */
struct window_redraw:
public window_base_7
{
/** The current clip box. */
box clip;
};
 
/** A structure to represent a RISC OS menu item. */
struct menu_item
{
/** The menu flags. */
int mflags;
/** The submenu pointer or dialogue box handle. */
int submenu;
/** The icon flags. */
int iflags;
/** The icon data. */
icon_data icon;
};
 
/** A structure to represent a RISC OS menu.
* The structure defined here contains one menu item. Use size_of
* and casts to create menus with different lengths.
*/
struct menu
{
/** The icon data for the title. */
icon_data title;
/** The title foreground colour. */
char tf_colour;
/** The title background colour. */
char tb_colour;
/** The work area foreground colour. */
char wf_colour;
/** The work area background colour. */
char wb_colour;
/** The width of the menu. */
int width;
/** The height of each menu item. */
int height;
/** The gap between menu items. */
int gap;
/** The first menu item. */
menu_item item[1];
};
 
/** A structure for use by Wimp_DragBox. */
struct drag_box
{
int whandle;
int type;
box dbox;
box pbox;
int r12;
int draw_func;
int remove_func;
int move_func;
};
 
/** Register a task with the window manager.
* @param version the most recent window manager version number known to
* task, multiplied by 100
* @param name the task name (null terminated)
* @param messages a pointer to a null-terminated list of messages that
* the task wishes to receive
* @param _version a buffer for the returned window manager version
* @param _handle a buffer for the returned task handle
*/
void Wimp_Initialise(int version,const char* name,int* messages,
int* _version,int* _handle);
 
/** Create window.
* @param block the window block
* @param _handle a buffer for the returned window handle
*/
void Wimp_CreateWindow(const window_create& block,int* _handle);
 
/** Create icon.
* @param priority the icon handle or priority
* @param block the icon block
* @param _handle a buffer for the returned icon handle
*/
void Wimp_CreateIcon(int priority,const icon_create& block,int* _handle);
 
/** Delete window.
* @param block the window block
*/
void Wimp_DeleteWindow(const window_delete& block);
 
/** Delete icon.
* @param block the icon block
*/
void Wimp_DeleteIcon(const icon_delete& block);
 
/** Open window.
* @param block the window block
*/
void Wimp_OpenWindow(const window_open& block);
 
/** Open window (nested).
* @param block the window block
* @param phandle the parent window handle (-1 if none)
* @param flags the nesting flags
*/
void Wimp_OpenWindow(const window_open& block,int phandle,int flags);
 
/** Close window.
* @param block the window block
*/
void Wimp_CloseWindow(const window_close& block);
 
/** Poll Wimp.
* @param mask the event mask
* @param block the event block
* @param pollword the pollword
* @param _code a buffer for the returned event code
*/
void Wimp_Poll(int mask,wimp_block& block,int* pollword,int* _code);
 
/** Begin redraw of window (in response to Wimp_Poll).
* @param block the redraw block
* @param _more a buffer for the returned control flag (true if more to do,
* otherwise false)
*/
void Wimp_RedrawWindow(window_redraw& block,int* _more);
 
/** Begin redraw of window (at any time).
* @param block the redraw block
* @param _more a buffer for the returned control flag (true if more to do,
* otherwise false)
*/
void Wimp_UpdateWindow(window_redraw& block,int* _more);
 
/** Get next rectangle for redraw.
* @param block the redraw block
* @param _more a buffer for the returned control flag (true if more to do,
* otherwise false)
*/
void Wimp_GetRectangle(window_redraw& block,int* _more);
 
/** Get window state.
* @param block the window block
*/
void Wimp_GetWindowState(window_state_get& block);
 
/** Set icon state.
* @param block the icon block
*/
void Wimp_SetIconState(icon_state_set& block);
 
/** Get icon state.
* @param block the icon block
*/
void Wimp_GetIconState(icon_state_get& block);
 
/** Get position of pointer and state of mouse buttons.
* @param block the pointer information block
*/
void Wimp_GetPointerInfo(pointer_info_get& block);
 
/** Begin drag operation.
* @param block the drag box box
*/
void Wimp_DragBox(drag_box& block);
 
/** Force area of screen or window to be redrawn.
* @param handle the window handle (-1 for desktop, -2 for icon bar)
* @param bbox the area to be redrawn
*/
void Wimp_ForceRedraw(int handle,const box& bbox);
 
/** Set caret position.
* @param whandle the window handle (-1 to disown caret)
* @param ihandle the icon handle (-1 if none)
* @param p the required caret position
* @param height the required caret height (-1 if using index)
* @param index the required character index (-1 if not specified)
*/
void Wimp_SetCaretPosition(int whandle,int ihandle,const point& p,
int height,int index);
 
/** Get caret position.
* @param block the caret position block
*/
void Wimp_GetCaretPosition(caret_position_get& block);
 
/** Create top-level dialogue box.
* @param handle the window handle
* @param p the required position of the top left-hand corner of
* the visible area
*/
void Wimp_CreateMenu(int handle,const point& p);
 
/** Create top-level menu.
* @param m the menu data
* @param p the required position of the top left-hand corner of
* the visible area
*/
inline void Wimp_CreateMenu(os::menu* m,const point& p)
{ Wimp_CreateMenu((int)m,p); }
 
/** Set extent of window.
* @param handle the window handle
* @param workarea the required dimensions of the work area
*/
void Wimp_SetExtent(int handle,const box& workarea);
 
/** Create or pass on keypress.
* @param code the character code
*/
void Wimp_ProcessKey(int code);
 
/** Start child task.
* @param command the command to be executed (null terminated)
* @param _handle buffer for returned task handle (0 if none)
*/
void Wimp_StartTask(const char* command,int* _handle);
 
/** Report error.
* @param block the RISC OS error block
* @param title the application name (null terminated, for use
* in the window title)
* @param flags the error dialogue flags
* @param _result a buffer for the response (0=none, 1=OK, 2=cancel)
*/
void Wimp_ReportError(const _kernel_oserror& block,const char* title,
int flags,int* _result);
 
/** Report error.
* @param errnum the RISC OS error number
* @param message the error message (null terminated)
* @param title the application name (null terminated, for use in
* the window title)
* @param flags the error dialogue flags
* @param _result a buffer for the response (0=none, 1=OK, 2=cancel)
*/
void Wimp_ReportError(int errnum,const char* message,const char* title,
int flags,int* _result);
 
/** Set graphics colour to a standard Wimp colour.
* @param colour the required standard colour (bits 0-3), GCOL action
* (bits 4-6) and foreground (bit 7=0) or background (bit 7=1) flag
*/
void Wimp_SetColour(int colour);
 
/** Send message.
* @param wimpcode the Wimp event code
* @param block the message
* @param thandle the destination task handle or window handle
* (-2=icon bar)
* @param ihandle the icon handle (if thandle==-2)
* @param _thandle a buffer for the returned task handle
*/
void Wimp_SendMessage(int wimpcode,wimp_block& block,int thandle,
int ihandle,int* _thandle);
 
/** Create dialogue box within menu tree.
* @param handle the window handle
* @param p the required position of the top left-hand corner of
* the visible area
*/
void Wimp_CreateSubMenu(int handle,const point& p);
 
/** Create sub-menu.
* @param m the menu data
* @param p the required position of the top left-hand corner of
* the visible area
*/
inline void Wimp_CreateSubMenu(os::menu* m,const point& p)
{ Wimp_CreateSubMenu((int)m,p); }
 
/** Read sprite information.
* This function is equivalent to OS_SpriteOp40, but is limited to
* sprites in the Wimp sprite pool.
* @param name the null-terminated sprite name
* @param _xsize a buffer for the returned width in pixels
* @param _ysize a buffer for the returned height in pixels
* @param _mask a buffer for the returned mask flag
* @param _mode a buffer for the returned sprite mode
*/
void Wimp_SpriteOp40(const char* name,int* _xsize,int* _ysize,
int* _mask,int* _mode);
 
/** Read pixel translation table for sprite (by name).
* @param area the sprite area that contains the sprite (0 for system
* area, 1 for Wimp sprite area)
* @param name the name of the sprite
* @param _scale a buffer for the returned scale factors (4 words)
* @param _table a buffer for the returned translation table
* (2, 4 or 16 bytes)
*/
void Wimp_ReadPixTrans(sprite_area* area,const char* name,
unsigned int* _scale,unsigned char* _table);
 
/** Read pixel translation table for sprite (by pointer).
* @param area the sprite area that contains the sprite (0 for system
* area)
* @param sp the sprite pointer
* @param _scale a buffer for the returned scale factors (4 words)
* @param _table a buffer for the returned translation table
* (2, 4 or 16 bytes)
*/
void Wimp_ReadPixTrans(sprite_area* area,sprite* sp,
unsigned int* _scale,unsigned char* _table);
 
/** Set text colour to a standard Wimp colour.
* @param colour the required standard colour (bits 0-3), and foreground
* (bit 7=0) or background (bit 7=1) flag
*/
void Wimp_TextColour(int colour);
 
/** Transfer data from one task to another.
* @param src_thandle the source task handle
* @param src_buffer the source buffer
* @param dst_thandle the destination task handle
* @param dst_buffer the destination buffer
* @param count the number of bytes to transfer
*/
void Wimp_TransferBlock(int src_thandle,const void* src_buffer,
int dst_thandle,void* dst_buffer,unsigned int count);
 
/** Read system information.
* @param index an index to select the required information
* @param _r0 a buffer for the value returned in R0
* @param _r1 a buffer for the value returned in R1 (if any)
*/
void Wimp_ReadSysInfo(int index,int* _r0,int* _r1);
 
/** Set colours for use by Wimp_TextOp2.
* @param fcolour the foreground palette entry
* @param bcolour the background palette entry
*/
void Wimp_TextOp0(int fcolour,int bcolour);
 
/** Determine width required to plot string using desktop font.
* @param s the string to be plotted (control character terminated)
* @param count the number of characters to include
* @param _width a buffer for the returned width
*/
void Wimp_TextOp1(const char* s,int count,int* _width);
 
/** Plot string to screen using desktop font.
* @param s the string to plot (null terminated)
* @param p the point at which to begin plotting
*/
void Wimp_TextOp2(const char* s,const point& p);
 
/** Resize or move icon.
* @param whandle the window handle (-1 for iconbar)
* @param ihandle the icon handle
* @param bbox the required bounding box
*/
void Wimp_ResizeIcon(int whandle,int ihandle,const box& bbox);
 
}; /* namespace os */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/call_swi.h
New file
0,0 → 1,32
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_OS_SWI
#define _RTK_OS_SWI
 
#include "kernel.h"
 
#include "rtk/os/exception.h"
 
class _kernel_swi_regs;
 
namespace rtk {
namespace os {
 
/** Call a RISC OS software interrupt.
* @param number the software interrupt number
* @param regs the register state (for input and output)
*/
inline void call_swi(unsigned int number,_kernel_swi_regs* regs)
{
const int X=0x20000;
_kernel_oserror* err=_kernel_swi(X+number,regs,regs);
if (err) throw exception(err);
}
 
}; /* namespace os */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/timestamp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/exception.h
New file
0,0 → 1,49
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_OS_EXCEPTION
#define _RTK_OS_EXCEPTION
 
#include <exception>
#include "kernel.h"
 
namespace rtk {
namespace os {
 
/** An exception class to represent a RISC OS error block.
*/
class exception:
public std::exception
{
private:
/** A pointer to the RISC OS error block. */
_kernel_oserror* _err;
public:
/** Construct exception from RISC OS error block.
* The error block is not copied, and must remain in existence for
* the lifetime of the exception object. It is not freed when the
* exception object is destroyed (in part because it is likely to
* be owned by the operating system rather than the application).
* @param err a pointer to the error block
*/
exception(_kernel_oserror* err);
 
/** Destroy exception.
*/
virtual ~exception() {}
 
/** Get message.
* The value returned is a pointer into the original error block used
* to construct the exception object. It is supposed to remain valid
* for at least the lifetime of this object.
* @return the message from the error block
*/
virtual const char* what() const;
};
 
}; /* namespace os */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/os.cc
New file
0,0 → 1,269
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include <kernel.h>
 
#include "rtk/swi/os.h"
#include "rtk/os/call_swi.h"
#include "rtk/os/os.h"
 
namespace rtk {
namespace os {
 
void OS_Byte161(int address,int* _value)
{
_kernel_swi_regs regs;
regs.r[0]=161;
regs.r[1]=address;
call_swi(swi::OS_Byte,&regs);
if (_value) *_value=regs.r[2];
}
 
void OS_File1(const char* name,unsigned int loadaddr,unsigned int execaddr,
unsigned int attr)
{
_kernel_swi_regs regs;
regs.r[0]=1;
regs.r[1]=(int)name;
regs.r[2]=loadaddr;
regs.r[3]=execaddr;
regs.r[5]=attr;
call_swi(swi::OS_File,&regs);
}
 
void OS_File4(const char* name,unsigned int attr)
{
_kernel_swi_regs regs;
regs.r[0]=4;
regs.r[1]=(int)name;
regs.r[5]=attr;
call_swi(swi::OS_File,&regs);
}
 
void OS_File6(const char* name,unsigned int* _objtype,unsigned int* _loadaddr,
unsigned int* _execaddr,unsigned int* _length,unsigned int* _attr)
{
_kernel_swi_regs regs;
regs.r[0]=6;
regs.r[1]=(int)name;
call_swi(swi::OS_File,&regs);
if (_objtype) *_objtype=regs.r[0];
if (_loadaddr) *_loadaddr=regs.r[2];
if (_execaddr) *_execaddr=regs.r[3];
if (_length) *_length=regs.r[4];
if (_attr) *_attr=regs.r[5];
}
 
void OS_File8(const char* name,unsigned int entries)
{
_kernel_swi_regs regs;
regs.r[0]=8;
regs.r[1]=(int)name;
regs.r[4]=entries;
call_swi(swi::OS_File,&regs);
}
 
void OS_File17(const char* name,unsigned int* _objtype,unsigned int* _loadaddr,
unsigned int* _execaddr,unsigned int* _length,unsigned int* _attr)
{
_kernel_swi_regs regs;
regs.r[0]=17;
regs.r[1]=(int)name;
call_swi(swi::OS_File,&regs);
if (_objtype) *_objtype=regs.r[0];
if (_loadaddr) *_loadaddr=regs.r[2];
if (_execaddr) *_execaddr=regs.r[3];
if (_length) *_length=regs.r[4];
if (_attr) *_attr=regs.r[5];
}
 
void OS_File18(const char* name,unsigned int filetype)
{
_kernel_swi_regs regs;
regs.r[0]=18;
regs.r[1]=(int)name;
regs.r[2]=filetype;
call_swi(swi::OS_File,&regs);
}
 
void OS_Args5(int handle,bool* _eof)
{
_kernel_swi_regs regs;
regs.r[0]=5;
regs.r[1]=handle;
call_swi(swi::OS_Args,&regs);
if (_eof) *_eof=regs.r[2]!=0;
}
 
void OS_Find(int code,const char* name,const char* path,int* _handle)
{
_kernel_swi_regs regs;
regs.r[0]=code;
regs.r[1]=(int)name;
regs.r[2]=(int)path;
call_swi(swi::OS_Find,&regs);
if (_handle) *_handle=regs.r[0];
}
 
void OS_Find0(int handle)
{
_kernel_swi_regs regs;
regs.r[0]=0;
regs.r[1]=handle;
call_swi(swi::OS_Find,&regs);
}
 
void OS_GBPB2(int handle,const void* buffer,unsigned int count,
unsigned int* _fp)
{
_kernel_swi_regs regs;
regs.r[0]=2;
regs.r[1]=handle;
regs.r[2]=(int)buffer;
regs.r[3]=count;
call_swi(swi::OS_GBPB,&regs);
if (_fp) *_fp=regs.r[4];
}
 
void OS_GBPB4(int handle,void* buffer,unsigned int count,
unsigned int* _excess,unsigned int* _fp)
{
_kernel_swi_regs regs;
regs.r[0]=4;
regs.r[1]=handle;
regs.r[2]=(int)buffer;
regs.r[3]=count;
call_swi(swi::OS_GBPB,&regs);
if (_excess) *_excess=regs.r[3];
if (_fp) *_fp=regs.r[4];
}
 
void OS_GBPB12(const char* name,void* buffer,unsigned int count,
int offset,unsigned int length,const char* pattern,
unsigned int* _count,int* _offset)
{
_kernel_swi_regs regs;
regs.r[0]=12;
regs.r[1]=(int)name;
regs.r[2]=(int)buffer;
regs.r[3]=count;
regs.r[4]=offset;
regs.r[5]=length;
regs.r[6]=(int)pattern;
call_swi(swi::OS_GBPB,&regs);
if (_count) *_count=regs.r[3];
if (_offset) *_offset=regs.r[4];
}
 
void OS_SetVarVal(const char* varname,const char* value,unsigned int length,
unsigned int context,unsigned int vartype,unsigned int* _context,
unsigned int* _vartype)
{
_kernel_swi_regs regs;
regs.r[0]=(int)varname;
regs.r[1]=(int)value;
regs.r[2]=length;
regs.r[3]=context;
regs.r[4]=vartype;
call_swi(swi::OS_SetVarVal,&regs);
if (_context) *_context=regs.r[3];
if (_vartype) *_vartype=regs.r[4];
}
 
void OS_FSControl25(const char* src_name,const char* dst_name)
{
_kernel_swi_regs regs;
regs.r[0]=25;
regs.r[1]=(int)src_name;
regs.r[2]=(int)dst_name;
call_swi(swi::OS_FSControl,&regs);
}
 
void OS_FSControl26(const char* src_name,const char* dst_name,
unsigned int mask,unsigned long long start_time,
unsigned long long end_time,void* extra_info)
{
_kernel_swi_regs regs;
regs.r[0]=26;
regs.r[1]=(int)src_name;
regs.r[2]=(int)dst_name;
regs.r[3]=mask;
regs.r[4]=start_time>>0;
regs.r[5]=start_time>>32;
regs.r[6]=end_time>>0;
regs.r[7]=end_time>>32;
regs.r[8]=(int)extra_info;
call_swi(swi::OS_FSControl,&regs);
}
 
void OS_FSControl37(const char* pathname,char* buffer,const char* pathvar,
const char* path,unsigned int size,unsigned int* _size)
{
_kernel_swi_regs regs;
regs.r[0]=37;
regs.r[1]=(int)pathname;
regs.r[2]=(int)buffer;
regs.r[3]=(int)pathvar;
regs.r[4]=(int)path;
regs.r[5]=size;
call_swi(swi::OS_FSControl,&regs);
if (_size) *_size=regs.r[5];
}
 
void OS_SpriteOp40(sprite_area* area,sprite* sp,int* _xsize,int* _ysize,
int* _mask,int* _mode)
{
_kernel_swi_regs regs;
regs.r[0]=0x228;
regs.r[1]=(int)area;
regs.r[2]=(int)sp;
call_swi(swi::OS_SpriteOp,&regs);
if (_xsize) *_xsize=regs.r[3];
if (_ysize) *_ysize=regs.r[4];
if (_mask) *_mask=regs.r[5];
if (_mode) *_mode=regs.r[6];
}
 
void OS_SpriteOp40(sprite_area* area,const char* name,int* _xsize,int* _ysize,
int* _mask,int* _mode)
{
_kernel_swi_regs regs;
regs.r[0]=(area)?0x128:0x028;
regs.r[1]=(int)area;
regs.r[2]=(int)name;
call_swi(swi::OS_SpriteOp,&regs);
if (_xsize) *_xsize=regs.r[3];
if (_ysize) *_ysize=regs.r[4];
if (_mask) *_mask=regs.r[5];
if (_mode) *_mode=regs.r[6];
}
 
void OS_ReadModeVariable(int index,int* _value)
{
_kernel_swi_regs regs;
regs.r[0]=-1;
regs.r[1]=index;
call_swi(swi::OS_ReadModeVariable,&regs);
if (_value) *_value=regs.r[2];
}
 
void OS_Plot(int code,const point& p)
{
_kernel_swi_regs regs;
regs.r[0]=code;
regs.r[1]=p.x();
regs.r[2]=p.y();
call_swi(swi::OS_Plot,&regs);
}
 
void OS_ReadMonotonicTime(unsigned int* _time)
{
_kernel_swi_regs regs;
call_swi(swi::OS_ReadMonotonicTime,&regs);
if (_time) *_time=regs.r[0];
}
 
}; /* namespace os */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/os.h
New file
0,0 → 1,224
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_OS_OS
#define _RTK_OS_OS
 
#include "rtk/graphics/point.h"
#include "rtk/graphics/box.h"
 
namespace rtk {
namespace os {
 
using rtk::graphics::point;
using rtk::graphics::box;
 
struct sprite;
struct sprite_area;
 
struct file_info
{
unsigned int loadaddr;
unsigned int execaddr;
unsigned int length;
unsigned int attr;
unsigned int objtype;
unsigned int filetype;
char name[];
};
 
/** Read byte from CMOS RAM.
* @param address the address to read
* @param _value a buffer for the returned value
*/
void OS_Byte161(int address,int* _value);
 
/** Write catalogue information.
* @param name the object name
* @param loadaddr the required load address
* @param execaddr the required execution address
* @param attr the required file attributes
*/
void OS_File1(const char* name,unsigned int loadaddr,unsigned int execaddr,
unsigned int attr);
 
/** Write file attributes.
* @param name the object name
* @param attr the required file attributes
*/
void OS_File4(const char* name,unsigned int attr);
 
/** Delete object.
* @param name the object name
* @param _objtype a buffer for the returned object type
* @param _loadaddr a buffer for the returned load address
* @param _execaddr a buffer for the returned execution address
* @param _length a buffer for the returned object length
* @param _attr a buffer for the returned object attributes
*/
void OS_File6(const char* name,unsigned int* _objtype,unsigned int* _loadaddr,
unsigned int* _execaddr,unsigned int* _length,unsigned int* _attr);
 
/** Create directory.
* @param name the object name
* @param entries the initial number of entries, or 0 for default
*/
void OS_File8(const char* name,unsigned int entries);
 
/** Read catalogue information.
* @param name the object name
* @param _objtype a buffer for the returned object type
* @param _loadaddr a buffer for the returned load address
* @param _execaddr a buffer for the returned execution address
* @param _length a buffer for the returned object length
* @param _attr a buffer for the returned object attributes
*/
void OS_File17(const char* name,unsigned int* _objtype,unsigned int* _loadaddr,
unsigned int* _execaddr,unsigned int* _length,unsigned int* _attr);
 
/** Write filetype.
* @param name the object name
* @param filetype the required filetype
*/
void OS_File18(const char* name,unsigned int filetype);
 
/** Read EOF status.
* @param handle the file handle
* @param _eof a buffer for the returned EOF status (true=EOF)
*/
void OS_Args5(int handle,bool* _eof);
 
/** Open file.
* @param code the reason code
* @param name the object name
* @param path the path (if any)
* @param _handle a buffer for the returned file handle
*/
void OS_Find(int code,const char* name,const char* path,int* _handle);
 
/** Close file.
* @param handle the file handle
*/
void OS_Find0(int handle);
 
/** Write bytes to file.
* @param handle the file handle
* @param buffer the data to be written
* @param count the number of bytes to be written
* @param _fp a buffer for the returned file pointer
*/
void OS_GBPB2(int handle,const void* buffer,unsigned int count,
unsigned int* _fp);
 
/** Read bytes from file.
* @param handle the file handle
* @param buffer a buffer for the data to be read
* @param count the number of bytes to be read
* @param _excess a buffer for the returned number of bytes not transferred
* @param _fp a buffer for the returned file pointer
*/
void OS_GBPB4(int handle,void* buffer,unsigned int count,
unsigned int* _excess,unsigned int* _fp);
 
/** Read catalogue information from directory.
* @param name the directory pathname
* @param buffer a buffer for the catalogue entries to be read
* @param count the number of catalogue entries to be read
* @param offset the offset at which to begin
* @param length the length of the buffer
* @param pattern the pattern to match
* @param _count a buffer for the returned number of directory entries read
* @param _offset a buffer for the returned offset, or -1 if finished
*/
void OS_GBPB12(const char* name,void* buffer,unsigned int count,
int offset,unsigned int length,const char* pattern,
unsigned int* _count,int* _offset);
 
/** Set system variable.
* @param varname the variable name
* @param value the required value
* @param length the length of the required value
* @param context the context pointer, or 0 if none
* @param vartype the variable type
* @param _context a buffer for the returned context pointer
* @param _vartype a buffer for the returned variable type
*/
void OS_SetVarVal(const char* varname,const char* value,unsigned int length,
unsigned int context,unsigned int vartype,unsigned int* _context,
unsigned int* _vartype);
 
/** Rename object.
* @param src_name the source name
* @param dst_name the destination name
*/
void OS_FSControl25(const char* src_name,const char* dst_name);
 
/** Copy objects.
* @param src_name the source name
* @param dst_name the destination name
* @param mask a bitmap describing the required action
* @param start_time the optional inclusive start time
* @param end_time the optional inclusive end time
* @param extra_info an optional pointer to extra information
*/
void OS_FSControl26(const char* src_name,const char* dst_name,
unsigned int mask,unsigned long long start_time,
unsigned long long end_time,void* extra_info);
 
/** Canonicalise pathname.
* @param name the object name
* @param buffer a buffer for the result
* @param pathvar the name of a system variable containing the path
* @param path the path to use if path_variable is null or non-existant
* @param size the size of the buffer
* @param _size the space remaining after the result (but the terminator)
* has been placed in the buffer
*/
void OS_FSControl37(const char* name,char* buffer,const char* pathvar,
const char* path,unsigned int size,unsigned int* _size);
 
/** Read sprite information (given pointer).
* @param area the sprite area
* @param sp the sprite pointer
* @param _xsize a buffer for the returned horizontal size
* @param _ysize a buffer for the returned vertical size
* @param _mask a buffer for the returned mask status
* @param _mode a buffer for the returned screen mode
*/
void OS_SpriteOp40(sprite_area* area,sprite* sp,int* _xsize,int* _ysize,
int* _mask,int* _mode);
 
/** Read sprite information (given name).
* @param area the sprite area
* @param name the sprite name
* @param _xsize a buffer for the returned horizontal size
* @param _ysize a buffer for the returned vertical size
* @param _mask a buffer for the returned mask status
* @param _mode a buffer for the returned screen mode
*/
void OS_SpriteOp40(sprite_area* area,const char* name,int* _xsize,int* _ysize,
int* _mask,int* _mode);
 
/** Read mode variable.
* @param index the variable number
* @param _value a buffer for the returned value
*/
void OS_ReadModeVariable(int index,int* _value);
 
/** Read monotonic time.
* @param _time a buffer for the returned time (in centiseconds)
*/
void OS_ReadMonotonicTime(unsigned int* _time);
 
/** Plot point.
* @param code the plot action code
* @param p the point to plot
*/
void OS_Plot(int code,const point& p);
 
}; /* namespace os */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/dragasprite.cc
New file
0,0 → 1,32
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/dragasprite.h"
#include "rtk/os/call_swi.h"
#include "rtk/os/dragasprite.h"
 
namespace rtk {
namespace os {
 
void DragASprite_Start(int flags,sprite_area* area,const char* name,
box* dbox,box* pbox)
{
_kernel_swi_regs regs;
regs.r[0]=flags;
regs.r[1]=(int)area;
regs.r[2]=(int)name;
regs.r[3]=(int)dbox;
regs.r[4]=(int)pbox;
call_swi(swi::DragASprite_Start,&regs);
}
 
void DragASprite_Stop()
{
_kernel_swi_regs regs;
call_swi(swi::DragASprite_Stop,&regs);
}
 
}; /* namespace os */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/font.cc
New file
0,0 → 1,70
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/graphics/point.h"
#include "rtk/swi/font.h"
#include "rtk/os/call_swi.h"
#include "rtk/os/font.h"
 
namespace rtk {
namespace os {
 
void Font_FindFont(const char* id,int xsize,int ysize,int xres,int yres,
int* _handle,int* _xres,int* _yres)
{
_kernel_swi_regs regs;
regs.r[1]=(int)id;
regs.r[2]=xsize;
regs.r[3]=ysize;
regs.r[4]=xres;
regs.r[5]=yres;
call_swi(swi::Font_FindFont,&regs);
if (_handle) *_handle=regs.r[0];
if (_xres) *_xres=regs.r[4];
if (_yres) *_yres=regs.r[5];
}
 
void Font_LoseFont(int handle)
{
_kernel_swi_regs regs;
regs.r[0]=handle;
call_swi(swi::Font_LoseFont,&regs);
}
 
void Font_Paint(int handle,const char* s,int plot,const point& p,void* coord,
void* trans,int length)
{
_kernel_swi_regs regs;
regs.r[0]=handle;
regs.r[1]=(int)s;
regs.r[2]=plot;
regs.r[3]=p.x();
regs.r[4]=p.y();
regs.r[5]=(int)coord;
regs.r[6]=(int)trans;
regs.r[7]=length;
call_swi(swi::Font_Paint,&regs);
}
 
void Font_ScanString(int handle,const char* s,int plot,const point& p,
void* coord,void* trans,int length,int* _split,point* _p,int* _length)
{
_kernel_swi_regs regs;
regs.r[0]=handle;
regs.r[1]=(int)s;
regs.r[2]=plot;
regs.r[3]=p.x();
regs.r[4]=p.y();
regs.r[5]=(int)coord;
regs.r[6]=(int)trans;
regs.r[7]=length;
call_swi(swi::Font_ScanString,&regs);
if (_split) *_split=regs.r[1];
if (_p) *_p=point(regs.r[3],regs.r[4]);
if (_length) *_length=regs.r[7];
}
 
}; /* namespace os */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/dragasprite.h
New file
0,0 → 1,41
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_OS_DRAGASPRITE
#define _RTK_OS_DRAGASPRITE
 
#include "rtk/graphics/box.h"
 
namespace rtk {
namespace os {
 
using rtk::graphics::box;
 
struct sprite_area;
 
/** Start dragging sprite.
* The flags are:
* - bits 0-1 = horizontal location (00=left, 01=centre, 10=right)
* - bits 2-3 = vertical location (00=bottom, 01=centre, 10=top)
* - bits 4-5 = parent bounding box identity (00=screen, 01=window, 10=pbox)
* - bit 6 = parent bounding box applies to (0=dragged box, 1=pointer)
* - bit 7 = drop shadow (0=false, 1=true)
*
* @param flags the flags
* @param area the sprite area (0=system, 1=wimp)
* @param name the sprite name
* @param dbox the dragged box
* @param pbox the parent box
*/
void DragASprite_Start(int flags,sprite_area* area,const char* name,
box* dbox,box* pbox);
 
/** Stop dragging sprite. */
void DragASprite_Stop();
 
}; /* namespace os */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/font.h
New file
0,0 → 1,78
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_OS_FONT
#define _RTK_OS_FONT
 
namespace rtk {
namespace graphics {
 
class point;
 
}; /* namespace graphics */
 
namespace os {
 
using rtk::graphics::point;
 
/** Obtain handle for font.
* @param id the font identifier (null terminated)
* @param xsize the required font width (16 units = 1 point)
* @param ysize the required font height (16 units = 1 point)
* @param xres the required horizontal resolution (dots per inch,
* or 0 to use default, or -1 to use current)
* @param yres the required vertical resolution (dot per inch,
* or 0 to use default, or -1 to use current)
* @param _handle a buffer for the returned font handle
* @param _xres a buffer for the returned horizontal resolution
* @param _yres a buffer for the returned vertical resolution
*/
void Font_FindFont(const char* id,int xsize,int ysize,int xres,int yres,
int* _handle,int* _xres,int* _yres);
 
/** Release handle for font.
* @param handle the handle to be released
*/
void Font_LoseFont(int handle);
 
/** Plot string to screen using font.
* Termination of the string is desirable whether or not flag bit 7 is set
* because the byte after the last printable character must be readable.
* It must be terminated if bit 7 is clear.
* @param handle the font handle
* @param s the string to plot (normally null terminated)
* @param plot the plot method flags
* @param p the point at which to begin plotting (OS coordinates or
* millipoints, depending on flag bit 4)
* @param coord the coordinate block (if flag bit 5 set)
* @param trans the transformation block (if flag bit 6 set)
* @param length the length of the string
*/
void Font_Paint(int handle,const char* s,int plot,const point& p,void* coord,
void* trans,int length);
 
/** Return information about how string would be plotted using font.
* @param handle the font handle
* @param s the string to plot (normally null terminated)
* @param plot the plot method flags
* @param p the offset to mouse click (if flag bit 17 set), else
* the offset to split point
* @param coord the coordinate block (if flag bit 5 and/or 18 set)
* @param trans the transformation block (if flag bit 6 and/or 19 set)
* @param length the length of the string
* @param _split a buffer for the returned character offset to caret position
* (if flag bit 17 set), else to split point
* @param _p a buffer for the returned spatial offset to caret position
* (if flag bit 17 set), else to split point
* @param _length the number of split characters encountered (if flag
* bit 20 set), else length of string
*/
void Font_ScanString(int handle,const char* s,int plot,const point& p,
void* coord,void* trans,int length,int* _split,point* _p,int* _length);
 
}; /* namespace os */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/os/Makefile
New file
0,0 → 1,23
# This file is part of the RISC OS Toolkit (RTK).
# Copyright © 2003-2004 Graham Shaw.
# Distribution and use are subject to the GNU Lesser General Public License,
# a copy of which may be found in the file !RTK.Copyright.
 
CPPFLAGS = -Irtk_build:
CXXFLAGS = -mthrowback -munixlib -mpoke-function-name -Wall -W -Wno-unused -O2
 
include fixdeps:Rules/make
 
OBJ = exception.o \
os.o \
font.o \
wimp.o \
colourtrans.o \
dragasprite.o
 
all: timestamp
 
timestamp: $(OBJ)
touch timestamp
 
include $(OBJ:.o=.d)
Property changes:
Added: svn:executable
+ *
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/swi/colourtrans.h
New file
0,0 → 1,52
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_SWI_COLOURTRANS
#define _RTK_SWI_COLOURTRANS
 
namespace rtk {
namespace swi {
 
const int ColourTrans_SelectTable =0x40740;
const int ColourTrans_SelectGCOLTable =0x40741;
const int ColourTrans_ReturnGCOL =0x40742;
const int ColourTrans_SetGCOL =0x40743;
const int ColourTrans_ReturnColourNumber=0x40744;
const int ColourTrans_ReturnGCOLForMode =0x40745;
const int ColourTrans_ReturnColourNumberForMode=0x40746;
const int ColourTrans_ReturnOppGCOL =0x40747;
const int ColourTrans_SetOppGCOL =0x40748;
const int ColourTrans_ReturnOppColourNumber=0x40749;
const int ColourTrans_ReturnOppGCOLForMode=0x4074A;
const int ColourTrans_ReturnOppColourNumberForMode=0x4074B;
const int ColourTrans_GCOLToColourNumber=0x4074C;
const int ColourTrans_ColourNumberToGCOL=0x4074D;
const int ColourTrans_ReturnFontColours =0x4074E;
const int ColourTrans_SetFontColours =0x4074F;
const int ColourTrans_InvalidateCache =0x40750;
const int ColourTrans_SetCalibration =0x40751;
const int ColourTrans_ReadCalibration =0x40752;
const int ColourTrans_ConvertDeviceColour=0x40753;
const int ColourTrans_ConvertDevicePalette=0x40754;
const int ColourTrans_ConvertRGBToCIE =0x40755;
const int ColourTrans_ConvertCIEToRGB =0x40756;
const int ColourTrans_WriteCalibrationToFile=0x40757;
const int ColourTrans_ConvertRGBToHSV =0x40758;
const int ColourTrans_ConvertHSVToRGB =0x40759;
const int ColourTrans_ConvertRGBToCMYK =0x4075A;
const int ColourTrans_ConvertCMYKToRGB =0x4075B;
const int ColourTrans_ReadPalette =0x4075C;
const int ColourTrans_WritePalette =0x4075D;
const int ColourTrans_SetColour =0x4075E;
const int ColourTrans_MiscOp =0x4075F;
const int ColourTrans_WriteLoadingsToFile=0x40760;
const int ColourTrans_SetTextColour =0x40761;
const int ColourTrans_SetOppTextColour =0x40762;
const int ColourTrans_GenerateTable =0x40763;
 
}; /* namespace swi */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/swi/wimp.h
New file
0,0 → 1,139
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_SWI_WIMP
#define _RTK_SWI_WIMP
 
namespace rtk {
namespace swi {
 
const int Wimp_Initialise =0x400C0;
const int Wimp_CreateWindow =0x400C1;
const int Wimp_CreateIcon =0x400C2;
const int Wimp_DeleteWindow =0x400C3;
const int Wimp_DeleteIcon =0x400C4;
const int Wimp_OpenWindow =0x400C5;
const int Wimp_CloseWindow =0x400C6;
const int Wimp_Poll =0x400C7;
const int Wimp_RedrawWindow =0x400C8;
const int Wimp_UpdateWindow =0x400C9;
const int Wimp_GetRectangle =0x400CA;
const int Wimp_GetWindowState =0x400CB;
const int Wimp_GetWindowInfo =0x400CC;
const int Wimp_SetIconState =0x400CD;
const int Wimp_GetIconState =0x400CE;
const int Wimp_GetPointerInfo =0x400CF;
const int Wimp_DragBox =0x400D0;
const int Wimp_ForceRedraw =0x400D1;
const int Wimp_SetCaretPosition =0x400D2;
const int Wimp_GetCaretPosition =0x400D3;
const int Wimp_CreateMenu =0x400D4;
const int Wimp_DecodeMenu =0x400D5;
const int Wimp_WhichIcon =0x400D6;
const int Wimp_SetExtent =0x400D7;
const int Wimp_SetPointerShape =0x400D8;
const int Wimp_OpenTemplate =0x400D9;
const int Wimp_CloseTemplate =0x400DA;
const int Wimp_LoadTemplate =0x400DB;
const int Wimp_ProcessKey =0x400DC;
const int Wimp_CloseDown =0x400DD;
const int Wimp_StartTask =0x400DE;
const int Wimp_ReportError =0x400DF;
const int Wimp_GetWindowOutline =0x400E0;
const int Wimp_PollIdle =0x400E1;
const int Wimp_PlotIcon =0x400E2;
const int Wimp_SetMode =0x400E3;
const int Wimp_SetPalette =0x400E4;
const int Wimp_ReadPalette =0x400E5;
const int Wimp_SetColour =0x400E6;
const int Wimp_SendMessage =0x400E7;
const int Wimp_CreateSubMenu =0x400E8;
const int Wimp_SpriteOp =0x400E9;
const int Wimp_BaseOfSprites =0x400EA;
const int Wimp_BlockCopy =0x400EB;
const int Wimp_SlotSize =0x400EC;
const int Wimp_ReadPixTrans =0x400ED;
const int Wimp_ClaimFreeMemory =0x400EE;
const int Wimp_CommandWindow =0x400EF;
const int Wimp_TextColour =0x400F0;
const int Wimp_TransferBlock =0x400F1;
const int Wimp_ReadSysInfo =0x400F2;
const int Wimp_SetFontColours =0x400F3;
const int Wimp_GetMenuState =0x400F4;
const int Wimp_RegisterFilter =0x400F5;
const int Wimp_AddMessages =0x400F6;
const int Wimp_RemoveMessages =0x400F7;
const int Wimp_SetColourMapping =0x400F8;
const int Wimp_TextOp =0x400F9;
const int Wimp_SetWatchdogState =0x400FA;
const int Wimp_Extend =0x400FB;
const int Wimp_ResizeIcon =0x400FC;
 
const int Null_Reason_Code =0;
const int Redraw_Window_Request =1;
const int Open_Window_Request =2;
const int Close_Window_Request =3;
const int Pointer_Leaving_Window=4;
const int Pointer_Entering_Window=5;
const int Mouse_Click =6;
const int User_Drag_Box =7;
const int Key_Pressed =8;
const int Menu_Selection =9;
const int Scroll_Request =10;
const int Lose_Caret =11;
const int Gain_Caret =12;
const int PollWord_NonZero =13;
const int User_Message =17;
const int User_Message_Recorded =18;
const int User_Message_Acknowledge=19;
 
const int Message_Quit =0x00;
const int Message_DataSave =0x01;
const int Message_DataSaveAck =0x02;
const int Message_DataLoad =0x03;
const int Message_DataLoadAck =0x04;
const int Message_DataOpen =0x05;
const int Message_RAMFetch =0x06;
const int Message_RAMTransmit =0x07;
const int Message_PreQuit =0x08;
const int Message_PaletteChange =0x09;
const int Message_SaveDesktop =0x0A;
const int Message_DeviceClaim =0x0B;
const int Message_DeviceInUse =0x0C;
const int Message_DataSaved =0x0D;
const int Message_Shutdown =0x0E;
 
const int Message_FilerOpenDir =0x400;
const int Message_FilerCloseDir =0x401;
const int Message_FilerOpenDirAt=0x402;
const int Message_FilerSelectionDirectory=0x403;
const int Message_FilerAddSelection=0x404;
const int Message_FilerAction =0x405;
const int Message_FilerControlAction=0x406;
const int Message_FilerSelection=0x407;
 
const int Message_AlarmSet =0x500;
const int Message_AlarmGoneOff =0x501;
const int Message_HelpRequest =0x502;
const int Message_HelpReply =0x503;
 
const int Message_MenuWarning =0x400C0;
const int Message_ModeChange =0x400C1;
const int Message_TaskInitialise=0x400C2;
const int Message_TaskClosedown =0x400C3;
const int Message_SlotSize =0x400C4;
const int Message_SetSlot =0x400C5;
const int Message_TaskNameRq =0x400C6;
const int Message_TaskNameIs =0x400C7;
const int Message_TaskStarted =0x400C8;
const int Message_MenusDeleted =0x400C9;
const int Message_Iconize =0x400CA;
const int Message_WindowClosed =0x400CB;
const int Message_WindowInfo =0x400CC;
 
}; /* namespace swi */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/swi/os.h
New file
0,0 → 1,177
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_SWI_OS
#define _RTK_SWI_OS
 
namespace rtk {
namespace swi {
 
const int OS_WriteC =0x00;
const int OS_WriteS =0x01;
const int OS_Write0 =0x02;
const int OS_NewLine =0x03;
const int OS_ReadC =0x04;
const int OS_CLI =0x05;
const int OS_Byte =0x06;
const int OS_Word =0x07;
const int OS_File =0x08;
const int OS_Args =0x09;
const int OS_BGet =0x0A;
const int OS_BPut =0x0B;
const int OS_GBPB =0x0C;
const int OS_Find =0x0D;
const int OS_ReadLine =0x0E;
const int OS_Control =0x0F;
const int OS_GetEnv =0x10;
const int OS_Exit =0x11;
const int OS_SetEnv =0x12;
const int OS_IntOn =0x13;
const int OS_IntOff =0x14;
const int OS_CallBack =0x15;
const int OS_EnterOS =0x16;
const int OS_BreakPt =0x17;
const int OS_BreakCtrl =0x18;
const int OS_UnusedSWI =0x19;
const int OS_UpdateMEMC =0x1A;
const int OS_SetCallBack =0x1B;
const int OS_Mouse =0x1C;
const int OS_Heap =0x1D;
const int OS_Module =0x1E;
const int OS_Claim =0x1F;
const int OS_Release =0x20;
const int OS_ReadUnsigned =0x21;
const int OS_GenerateEvent =0x22;
const int OS_ReadVarVal =0x23;
const int OS_SetVarVal =0x24;
const int OS_GSInit =0x25;
const int OS_GSRead =0x26;
const int OS_GSTrans =0x27;
const int OS_BinaryToDecimal =0x28;
const int OS_FSControl =0x29;
const int OS_ChangeDynamicArea =0x2A;
const int OS_GenerateError =0x2B;
const int OS_ReadEscapeState =0x2C;
const int OS_EvaluateExpression =0x2D;
const int OS_SpriteOp =0x2E;
const int OS_ReadPalette =0x2F;
const int OS_ServiceCall =0x30;
const int OS_ReadVduVariables =0x31;
const int OS_ReadPoint =0x32;
const int OS_UpCall =0x33;
const int OS_CallAVector =0x34;
const int OS_ReadModeVariable =0x35;
const int OS_RemoveCursors =0x36;
const int OS_RestoreCursors =0x37;
const int OS_SWINumberToString =0x38;
const int OS_SWINumberFromString=0x39;
const int OS_ValidateAddress =0x3A;
const int OS_CallAfter =0x3B;
const int OS_CallEvery =0x3C;
const int OS_RemoveTickerEvent =0x3D;
const int OS_InstallKeyHandler =0x3E;
const int OS_CheckModeValid =0x3F;
const int OS_ChangeEnvironment =0x40;
const int OS_ClaimScreenMemory =0x41;
const int OS_ReadMonotonicTime =0x42;
const int OS_SubstituteArgs =0x43;
const int OS_PrettyPrint =0x44;
const int OS_Plot =0x45;
const int OS_WriteN =0x46;
const int OS_AddToVector =0x47;
const int OS_WriteEnv =0x48;
const int OS_ReadArgs =0x49;
const int OS_ReadRAMFsLimits =0x4A;
const int OS_ClaimDeviceVector =0x4B;
const int OS_ReleaseDeviceVector=0x4C;
const int OS_DelinkApplication =0x4D;
const int OS_RelinkApplication =0x4E;
const int OS_HeapSort =0x4F;
const int OS_ExitAndDie =0x50;
const int OS_ReadMemMapInfo =0x51;
const int OS_ReadMemMapEntries =0x52;
const int OS_SetMemMapEntries =0x53;
const int OS_AddCallBack =0x54;
const int OS_ReadDefaultHandler =0x55;
const int OS_SetECFOrigin =0x56;
const int OS_SerialOp =0x57;
const int OS_ReadSysInfo =0x58;
const int OS_Confirm =0x59;
const int OS_ChangedBox =0x5A;
const int OS_CRC =0x5B;
const int OS_ReadDynamicArea =0x5C;
const int OS_PrintChar =0x5D;
const int OS_ChangeRedirection =0x5E;
const int OS_RemoveCallBack =0x5F;
const int OS_FindMemMapEntries =0x60;
const int OS_SetColour =0x61;
const int OS_Pointer =0x64;
const int OS_ScreenMode =0x65;
const int OS_DynamicArea =0x66;
const int OS_Memory =0x68;
const int OS_ClaimProcessorVector=0x69;
const int OS_Reset =0x6A;
const int OS_MMUControl =0x6B;
const int OS_ResyncTime =0x6C;
const int OS_PlatformFeatures =0x6D;
const int OS_SynchroniseCodeAreas=0x6E;
const int OS_CallASWI =0x6F;
const int OS_AMBControl =0x70;
const int OS_CallASWIR12 =0x71;
const int OS_SpecialControl =0x72;
const int OS_EnterUSR32 =0x73;
const int OS_EnterUSR26 =0x74;
 
const int OS_ConvertStandardDateAndTime=0xC0;
const int OS_ConvertDateAndTime =0xC1;
const int OS_ConvertHex1 =0xD0;
const int OS_ConvertHex2 =0xD1;
const int OS_ConvertHex4 =0xD2;
const int OS_ConvertHex6 =0xD3;
const int OS_ConvertHex8 =0xD4;
const int OS_ConvertCardinal1 =0xD5;
const int OS_ConvertCardinal2 =0xD6;
const int OS_ConvertCardinal3 =0xD7;
const int OS_ConvertCardinal4 =0xD8;
const int OS_ConvertInteger1 =0xD9;
const int OS_ConvertInteger2 =0xDA;
const int OS_ConvertInteger3 =0xDB;
const int OS_ConvertInteger4 =0xDC;
const int OS_ConvertBinary1 =0xDD;
const int OS_ConvertBinary2 =0xDE;
const int OS_ConvertBinary3 =0xDF;
const int OS_ConvertBinary4 =0xE0;
const int OS_ConvertSpacedCardinal1=0xE1;
const int OS_ConvertSpacedCardinal2=0xE2;
const int OS_ConvertSpacedCardinal3=0xE3;
const int OS_ConvertSpacedCardinal4=0xE4;
const int OS_ConvertSpacedInteger1=0xE5;
const int OS_ConvertSpacedInteger2=0xE6;
const int OS_ConvertSpacedInteger3=0xE7;
const int OS_ConvertSpacedInteger4=0xE8;
const int OS_ConvertFixedNetStation=0xE9;
const int OS_ConvertNetStation =0xEA;
const int OS_ConvertFixedFileSize=0xEB;
const int OS_ConvertFileSize =0xEC;
const int OS_WriteI =0x100;
 
const int ModeFlags =0;
const int ScrRCol =1;
const int ScrBRow =2;
const int NColour =3;
const int XEigFactor =4;
const int YEigFactor =5;
const int LineLength =6;
const int ScreenSize =7;
const int YShftFactor =8;
const int Log2BPP =9;
const int Log2BPC =10;
const int XWindLimit =11;
const int YWindLimit =12;
 
}; /* namespace swi */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/swi/dragasprite.h
New file
0,0 → 1,18
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_SWI_DRAGASPRITE
#define _RTK_SWI_DRAGASPRITE
 
namespace rtk {
namespace swi {
 
const int DragASprite_Start =0x42400;
const int DragASprite_Stop =0x42401;
 
}; /* namespace swi */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/swi/font.h
New file
0,0 → 1,57
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_SWI_FONT
#define _RTK_SWI_FONT
 
namespace rtk {
namespace swi {
 
const int Font_CacheAddr =0x40080;
const int Font_FindFont =0x40081;
const int Font_LoseFont =0x40082;
const int Font_ReadDefn =0x40083;
const int Font_ReadInfo =0x40084;
const int Font_StringWidth =0x40085;
const int Font_Paint =0x40086;
const int Font_Caret =0x40087;
const int Font_ConverttoOS =0x40088;
const int Font_Converttopoints =0x40089;
const int Font_SetFont =0x4008A;
const int Font_CurrentFont =0x4008B;
const int Font_FutureFont =0x4008C;
const int Font_FindCaret =0x4008D;
const int Font_CharBBox =0x4008E;
const int Font_ReadScaleFactor =0x4008F;
const int Font_SetScaleFactor =0x40090;
const int Font_ListFonts =0x40091;
const int Font_SetFontColours =0x40092;
const int Font_SetPalette =0x40093;
const int Font_ReadThresholds =0x40094;
const int Font_SetThresholds =0x40095;
const int Font_FindCaretJ =0x40096;
const int Font_StringBBox =0x40097;
const int Font_ReadColourTable =0x40098;
const int Font_MakeBitmap =0x40099;
const int Font_UnCacheFile =0x4009A;
const int Font_SetFontMax =0x4009B;
const int Font_ReadFontMax =0x4009C;
const int Font_ReadFontPrefix =0x4009D;
const int Font_SwitchOutputToBuffer=0x4009E;
const int Font_ReadFontMetrics =0x4009F;
const int Font_DecodeMenu =0x400A0;
const int Font_ScanString =0x400A1;
const int Font_SetColourTable =0x400A2;
const int Font_CurrentRGB =0x400A3;
const int Font_FutureRGB =0x400A4;
const int Font_ReadEncodingFilename=0x400A5;
const int Font_FindField =0x400A6;
const int Font_ApplyFields =0x400A7;
const int Font_LookupFont =0x400A8;
 
}; /* namespace swi */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/timestamp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/ramfetch.h
New file
0,0 → 1,72
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_RAMFETCH
#define _RTK_EVENTS_RAMFETCH
 
#include "rtk/events/message.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace events {
 
/** A class to represent a RISC OS Message_RAMFetch user message. */
class ramfetch:
public message
{
public:
/** A mixin class for handling ramfetch events.
* If a class wishes to receive ramfetch events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle ramfetch event.
* @param ev the ramfetch event to be handled
*/
virtual void handle_event(ramfetch& ev)=0;
};
 
/** Construct ramfetch event.
* @param target the target of the event
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
ramfetch(desktop::component& target,int wimpcode,
os::wimp_block& wimpblock);
 
/** Destroy ramfetch event.
*/
virtual ~ramfetch();
protected:
virtual bool deliver(desktop::component& dest);
public:
/** Get data transfer buffer.
* @return the data transfer buffer
*/
void* buffer() const;
 
/** Get size of the data transfer buffer.
* @return the size of the data transfer buffer
*/
unsigned int buffer_size() const;
 
/** Send Message_RAMTransmit in reply to this event.
* @param count the number of bytes transferred
*/
void reply(unsigned int count) const;
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/close_window.h
New file
0,0 → 1,61
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003-2004 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_CLOSE_WINDOW
#define _RTK_EVENTS_CLOSE_WINDOW
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace desktop {
 
class basic_window;
 
}; /* namespace desktop */
 
namespace events {
 
/** A class to represent a RISC OS Close_Window_Request event.
*/
class close_window:
public event
{
public:
/** A mixin class for handling close_window events.
* If a class wishes to receive close_window events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle close_window event.
* @param ev the close_window event to be handled
*/
virtual void handle_event(close_window& ev)=0;
};
 
/** Construct close_window event.
* @param target the target of the event (the window to be closed)
*/
close_window(desktop::basic_window& target);
 
/** Destroy close_window event.
*/
virtual ~close_window();
 
/** Get target.
* @return the target of the event (the window to be closed)
*/
desktop::basic_window* target() const
{ return (desktop::basic_window*)event::target(); }
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/help_request.cc
New file
0,0 → 1,55
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/wimp.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/desktop/application.h"
#include "rtk/events/help_request.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
help_request::help_request(component& target,os::wimp_block& wimpblock):
event(target),
_position(point(wimpblock.word[5],wimpblock.word[6])),
_buttons(wimpblock.word[7]),
_msg_ref(wimpblock.word[2]),
_help_task(wimpblock.word[1])
{
// Calculate origin of target with respect to origin of screen.
point origin;
target.parent_application(origin);
 
// Translate pointer location from coordinate space of screen
// to coordinate space of target.
_position-=origin;
}
 
help_request::~help_request()
{}
 
bool help_request::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
void help_request::reply(const string& text) const
{
os::wimp_block block;
block.word[3]=_msg_ref;
block.word[4]=swi::Message_HelpReply;
unsigned int i=text.copy(block.byte+20,223);
block.byte[20+i]=0;
block.word[0]=20+((i+4)&~3);
os::Wimp_SendMessage(swi::User_Message,block,_help_task,0,0);
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/ramtransmit.cc
New file
0,0 → 1,52
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/wimp.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/desktop/application.h"
#include "rtk/events/ramtransmit.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
ramtransmit::ramtransmit(component& target,int wimpcode,
os::wimp_block& wimpblock):
message(target,wimpcode,wimpblock)
{}
 
ramtransmit::~ramtransmit()
{}
 
void* ramtransmit::buffer() const
{
return reinterpret_cast<void*>(wimpblock().word[5]);
}
 
unsigned int ramtransmit::buffer_size() const
{
return wimpblock().word[6];
}
 
void ramtransmit::reply(void* buffer,unsigned int buffer_size) const
{
os::wimp_block block;
prepare_reply(block,swi::Message_RAMFetch,npos);
block.word[5]=reinterpret_cast<int>(buffer);
block.word[6]=buffer_size;
os::Wimp_SendMessage(swi::User_Message_Recorded,block,thandle(),0,0);
}
 
bool ramtransmit::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/save_to_app.h
New file
0,0 → 1,102
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_SAVE_TO_APP
#define _RTK_EVENTS_SAVE_TO_APP
 
#include <string>
 
#include "rtk/graphics/point.h"
#include "rtk/events/event.h"
 
namespace rtk {
namespace events {
 
using rtk::graphics::point;
 
/** An event class for requesting that data be saved to a given application. */
class save_to_app:
public event
{
private:
/** The destination window handle. */
int _whandle;
 
/** The destination icon handle. */
int _ihandle;
 
/** The destination position. */
point _position;
 
/** The leafname to which the data should be saved. */
string _leafname;
public:
/** A mixin class for handling save_to_app events.
* If a class wishes to receive save_to_app events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle save_to_app event.
* @param ev the save_to_app event to be handled
*/
virtual void handle_event(save_to_app& ev)=0;
};
 
/** Construct save_to_app event.
* The destination window handle, icon handle and position are obtained
* using Wimp_GetPointerInfo.
* @param target the target of the event
* @param leafname the leafname to which the data should be saved
*/
save_to_app(desktop::component& target,const string& leafname);
 
/** Construct save_to_app event.
* @param target the target of the event
* @param whandle the destination window handle
* @param ihandle the destination icon handle
* @param position the destination position
* @param leafname the leafname to which the data should be saved
*/
save_to_app(desktop::component& target,int whandle,int ihandle,
const point& position,const string& leafname);
 
/** Destroy save_to_app event.
*/
virtual ~save_to_app();
 
/** Get destination window handle.
* @return the destination window handle
*/
int whandle() const
{ return _whandle; }
 
/** Get destination icon handle.
* @return the destination icon handle
*/
int ihandle() const
{ return _ihandle; }
 
/** Get destination position.
* @return the destination position
*/
point position() const
{ return _position; }
 
/** Get leafname.
* @return the leafname to which the data should be saved
*/
const string& leafname() const
{ return _leafname; }
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/saved.cc
New file
0,0 → 1,31
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/events/saved.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
saved::saved(component& target,transfer::save& saveop):
event(target),
_saveop(&saveop)
{};
 
saved::~saved()
{}
 
bool saved::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/ramtransmit.h
New file
0,0 → 1,73
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_RAMTRANSMIT
#define _RTK_EVENTS_RAMTRANSMIT
 
#include "rtk/events/message.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace events {
 
/** A class to represent a RISC OS Message_RAMTransmit user message. */
class ramtransmit:
public message
{
public:
/** A mixin class for handling ramtransmit events.
* If a class wishes to receive ramtransmit events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle ramtransmit event.
* @param ev the ramtransmit event to be handled
*/
virtual void handle_event(ramtransmit& ev)=0;
};
 
/** Construct ramtransmit event.
* @param target the target of the event
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
ramtransmit(desktop::component& target,int wimpcode,
os::wimp_block& wimpblock);
 
/** Destroy ramtransmit event.
*/
virtual ~ramtransmit();
protected:
virtual bool deliver(desktop::component& dest);
public:
/** Get data transfer buffer.
* @return the data transfer buffer
*/
void* buffer() const;
 
/** Get size of the data transfer buffer.
* @return the size of the data transfer buffer
*/
unsigned int buffer_size() const;
 
/** Send Message_RAMFetch in reply to this event.
* @param buffer the data transfer buffer
* @param buffer_size the size of the data transfer buffer
*/
void reply(void* buffer,unsigned int buffer_size) const;
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/entering_window.h
New file
0,0 → 1,61
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003-2004 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_ENTERING_WINDOW
#define _RTK_EVENTS_ENTERING_WINDOW
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace desktop {
 
class basic_window;
 
}; /* namespace desktop */
 
namespace events {
 
/** A class to represent a RISC OS Pointer_Entering_Window event.
*/
class entering_window:
public event
{
public:
/** A mixin class for handling entering_window events.
* If a class wishes to receive entering_window events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle entering_window event.
* @param ev the entering_window event to be handled
*/
virtual void handle_event(entering_window& ev)=0;
};
 
/** Construct entering_window event.
* @param target the target of the event (the window entered)
*/
entering_window(desktop::basic_window& target);
 
/** Destroy entering_window event.
*/
virtual ~entering_window();
 
/** Get target.
* @return the target of the event (the window entered)
*/
desktop::basic_window* target() const
{ return (desktop::basic_window*)target(); }
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/menu_selection.cc
New file
0,0 → 1,41
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/desktop/menu_item.h"
#include "rtk/events/menu_selection.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
using rtk::desktop::menu_item;
 
menu_selection::menu_selection(menu_item& target,int buttons):
event(target),
_buttons(buttons)
{}
 
menu_selection::menu_selection(menu_item& target):
event(target)
{
os::pointer_info_get block;
os::Wimp_GetPointerInfo(block);
_buttons=block.buttons;
}
 
menu_selection::~menu_selection()
{}
 
bool menu_selection::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/menu_selection.h
New file
0,0 → 1,72
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_MENU_SELECTION
#define _RTK_EVENTS_MENU_SELECTION
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace desktop {
 
class menu_item;
 
}; /* namespace desktop; */
 
namespace events {
 
/** A class to represent a RISC OS Menu_Selection event.
* <P>The mouse button state is a bitmap. Bit 0 corresponds to Adjust,
* bit 1 to Menu and bit 2 to Select.
*/
class menu_selection:
public event
{
public:
/** A mixin class for handling menu_selection events.
* If a class wishes to receive menu_selection events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle menu_selection event.
* @param ev the menu_selection event to be handled
*/
virtual void handle_event(menu_selection& ev)=0;
};
private:
int _buttons;
public:
/** Construct menu_selection event.
* @param target the target of the event (the selected menu item)
* @param buttons the mouse button state
*/
menu_selection(desktop::menu_item& target,int buttons);
 
/** Construct menu_selection event.
* The mouse button state is read using Wimp_GetPointerInfo.
* @param target the target of the event (the selected menu item)
*/
menu_selection(desktop::menu_item& target);
 
/** Destroy menu_selection event.
*/
virtual ~menu_selection();
 
/** Get mouse button state.
* @return the mouse button state
*/
int buttons() const
{ return _buttons; }
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/reopen_menu.cc
New file
0,0 → 1,29
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/component.h"
#include "rtk/events/reopen_menu.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
reopen_menu::reopen_menu(component& target):
event(target)
{}
 
reopen_menu::~reopen_menu()
{}
 
bool reopen_menu::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/menusdeleted.cc
New file
0,0 → 1,29
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/component.h"
#include "rtk/events/menusdeleted.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
menusdeleted::menusdeleted(component& target):
event(target)
{}
 
menusdeleted::~menusdeleted()
{}
 
bool menusdeleted::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/leaving_window.h
New file
0,0 → 1,61
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003-2004 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_LEAVING_WINDOW
#define _RTK_EVENTS_LEAVING_WINDOW
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace desktop {
 
class basic_window;
 
}; /* namespace desktop */
 
namespace events {
 
/** A class to represent a RISC OS Pointer_Leaving_Window event.
*/
class leaving_window:
public event
{
public:
/** A mixin class for handling leaving_window events.
* If a class wishes to receive leaving_window events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle leaving_window event.
* @param ev the leaving_window event to be handled
*/
virtual void handle_event(leaving_window& ev)=0;
};
 
/** Construct leaving_window event.
* @param target the target of the event (the window left)
*/
leaving_window(desktop::basic_window& target);
 
/** Destroy leaving_window event.
*/
virtual ~leaving_window();
 
/** Get target.
* @return the target of the event (the window left)
*/
desktop::basic_window* target() const
{ return (desktop::basic_window*)target(); }
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/wimp.h
New file
0,0 → 1,78
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_WIMP
#define _RTK_EVENTS_WIMP
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace events {
 
/** A class to represent a RISC OS Wimp event.
*/
class wimp:
public event
{
private:
/** The Wimp event code. */
int _wimpcode;
/** The Wimp event block. */
os::wimp_block* _wimpblock;
public:
/** A mixin class for handling Wimp events.
* If a class wishes to receive Wimp events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle Wimp event.
* @param ev the Wimp event to be handled
*/
virtual bool handle_event(wimp& ev)=0;
};
 
/** Construct Wimp event.
* The event block is not copied, and must remain in existance
* for the lifetime of this object. It is not freed when this
* object is destroyed.
* @param target the target of the event
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
wimp(desktop::component& target,int wimpcode,os::wimp_block& wimpblock);
 
/** Destroy Wimp event.
*/
virtual ~wimp();
 
/** Get event code.
* @return the event code
*/
int event_code();
 
/** Get event data.
* The value returned is a reference to the original wimp block
* passed to the constructor. It can be expected to remain valid
* for at least the lifetime of this object.
* @return the event data.
*/
const os::wimp_block& event_data();
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/null_reason.cc
New file
0,0 → 1,29
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/component.h"
#include "rtk/events/null_reason.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
null_reason::null_reason(component& target):
event(target)
{}
 
null_reason::~null_reason()
{}
 
bool null_reason::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/null_reason.h
New file
0,0 → 1,51
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_NULL_REASON
#define _RTK_EVENTS_NULL_REASON
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace events {
 
/** A class to represent a RISC OS Null_Reason event.
* A null_reason event occurs when there are no other events waiting to be
* processed.
*/
class null_reason:
public event
{
public:
/** A mixin class for handling null_reason events.
* If a class wishes to receive null_reason events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle null_reason event.
* @param ev the null_reason event to be handled
*/
virtual void handle_event(null_reason& ev)=0;
};
 
/** Construct null_reason event.
* @param target the target of the event
*/
null_reason(desktop::component& target);
 
/** Destroy null_reason event.
*/
virtual ~null_reason();
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/quit.h
New file
0,0 → 1,49
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_QUIT
#define _RTK_EVENTS_QUIT
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace events {
 
/** A class to represent a RISC OS Message_Quit user message.
*/
class quit:
public event
{
public:
/** A mixin class for handling quit events.
* If a class wishes to receive quit events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle quit event.
* @param ev the quit event to be handled
*/
virtual void handle_event(quit& ev)=0;
};
 
/** Construct quit event.
* @param target the target of the event
*/
quit(desktop::component& target);
 
/** Destroy quit event.
*/
virtual ~quit();
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/message.h
New file
0,0 → 1,108
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_MESSAGE
#define _RTK_EVENTS_MESSAGE
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace events {
 
/** A class to represent a RISC OS user message.
* This can be a User_Message, a User_Message_Recorded or a
* User_Message_Acknowledge.
*/
class message:
public event
{
public:
/** A type for representing byte counts. */
typedef unsigned int size_type;
 
/** A null value for use in place of a byte count. */
static const size_type npos=static_cast<size_type>(-1);
private:
/** The Wimp event code. */
int _wimpcode;
 
/** The Wimp event block. */
os::wimp_block* _wimpblock;
public:
/** A mixin class for handling message events.
* If a class wishes to receive message events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle message event.
* @param ev the message event to be handled
*/
virtual void handle_event(message& ev)=0;
};
 
/** Construct message event.
* The message block is not copied, and must remain in existance
* for the lifetime of this object. It is not freed when this
* object is destroyed.
* @param target the target of the event
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
message(desktop::component& target,int wimpcode,os::wimp_block& wimpblock);
 
/** Destroy message event.
*/
virtual ~message();
 
/** Get task handle of sender.
* This is equal to data().word[1].
* @return the task handle of the sender
*/
int thandle() const;
 
/** Get message action code.
* This is equal to data().word[4].
* @return the message action code
*/
int msgcode() const;
 
/** Get Wimp event code.
* @return the wimp event code
*/
int wimpcode() const
{ return _wimpcode; }
 
/** Get Wimp event block.
* The value returned is a reference to the original message block
* passed to the constructor. It can be expected to remain valid
* for at least the lifetime of this object.
* @return the wimp event block
*/
const os::wimp_block& wimpblock() const
{ return *_wimpblock; }
 
/** Prepare reply to message.
* @param reply the wimp block that will contain the reply
* @param msgcode the required message action code
* @param size the required reply length in bytes, or npos to preserve
*/
void prepare_reply(os::wimp_block& reply,int msgcode,size_type size) const;
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/datasave.cc
New file
0,0 → 1,82
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/wimp.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/desktop/application.h"
#include "rtk/events/datasave.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
datasave::datasave(component& target,int wimpcode,os::wimp_block& wimpblock):
message(target,wimpcode,wimpblock)
{}
 
datasave::~datasave()
{}
 
int datasave::whandle() const
{
return wimpblock().word[5];
}
 
int datasave::ihandle() const
{
return wimpblock().word[6];
}
 
point datasave::position() const
{
return point(wimpblock().word[7],wimpblock().word[8]);
}
 
unsigned int datasave::estsize() const
{
return wimpblock().word[9];
}
 
unsigned int datasave::filetype() const
{
return wimpblock().word[10];
}
 
string datasave::leafname() const
{
return string(wimpblock().byte+44);
}
 
void datasave::reply(void* buffer,unsigned int buffer_size) const
{
os::wimp_block block;
prepare_reply(block,swi::Message_RAMFetch,28);
block.word[5]=reinterpret_cast<int>(buffer);
block.word[6]=buffer_size;
os::Wimp_SendMessage(swi::User_Message_Recorded,block,thandle(),0,0);
}
 
void datasave::reply(const string& pathname,bool secure) const
{
os::wimp_block block;
prepare_reply(block,swi::Message_DataSaveAck,npos);
if (!secure) block.word[9]=-1;
unsigned int i=pathname.copy(block.byte+44,211);
block.byte[44+i]=0;
block.word[0]=44+((i+4)&~3);
os::Wimp_SendMessage(swi::User_Message,block,thandle(),0,0);
}
 
bool datasave::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/dataloadack.cc
New file
0,0 → 1,63
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/wimp.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/desktop/application.h"
#include "rtk/events/dataloadack.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
dataloadack::dataloadack(component& target,int wimpcode,
os::wimp_block& wimpblock):
message(target,wimpcode,wimpblock)
{}
 
dataloadack::~dataloadack()
{}
 
int dataloadack::whandle() const
{
return wimpblock().word[5];
}
 
int dataloadack::ihandle() const
{
return wimpblock().word[6];
}
 
point dataloadack::position() const
{
return point(wimpblock().word[7],wimpblock().word[8]);
}
 
unsigned int dataloadack::estsize() const
{
return wimpblock().word[9];
}
 
unsigned int dataloadack::filetype() const
{
return wimpblock().word[10];
}
 
string dataloadack::pathname() const
{
return string(wimpblock().byte+44);
}
 
bool dataloadack::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/loaded.cc
New file
0,0 → 1,31
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/events/loaded.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
loaded::loaded(component& target,transfer::load& loadop):
event(target),
_loadop(&loadop)
{};
 
loaded::~loaded()
{}
 
bool loaded::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/Makefile
New file
0,0 → 1,45
# This file is part of the RISC OS Toolkit (RTK).
# Copyright © 2003-2004 Graham Shaw.
# Distribution and use are subject to the GNU Lesser General Public License,
# a copy of which may be found in the file !RTK.Copyright.
 
CPPFLAGS = -Irtk_build:
CXXFLAGS = -mthrowback -munixlib -mpoke-function-name -Wall -W -Wno-unused -O2
 
include fixdeps:Rules/make
 
OBJ = event.o \
wimp.o \
null_reason.o \
close_window.o \
entering_window.o \
leaving_window.o \
mouse_click.o \
user_drag_box.o \
key_pressed.o \
menu_selection.o \
message.o \
quit.o \
menuwarning.o \
menusdeleted.o \
datasave.o \
datasaveack.o \
dataload.o \
dataloadack.o \
dataopen.o \
ramfetch.o \
ramtransmit.o \
help_request.o \
reopen_menu.o \
save_to_file.o \
save_to_app.o \
loaded.o \
saved.o \
redirection.o
 
all: timestamp
 
timestamp: $(OBJ)
touch timestamp
 
include $(OBJ:.o=.d)
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/dataopen.cc
New file
0,0 → 1,59
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/wimp.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/desktop/application.h"
#include "rtk/events/dataopen.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
dataopen::dataopen(component& target,int wimpcode,os::wimp_block& wimpblock):
message(target,wimpcode,wimpblock)
{}
 
dataopen::~dataopen()
{}
 
bool dataopen::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
int dataopen::whandle() const
{
return wimpblock().word[5];
}
 
point dataopen::position() const
{
return point(wimpblock().word[7],wimpblock().word[8]);
}
 
unsigned int dataopen::filetype() const
{
return wimpblock().word[10];
}
 
string dataopen::pathname() const
{
return string(wimpblock().byte+44);
}
 
void dataopen::reply() const
{
os::wimp_block block;
prepare_reply(block,swi::Message_DataLoadAck,npos);
os::Wimp_SendMessage(swi::User_Message,block,thandle(),0,0);
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/close_window.cc
New file
0,0 → 1,31
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003-2004 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/component.h"
#include "rtk/desktop/basic_window.h"
#include "rtk/events/close_window.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
using rtk::desktop::basic_window;
 
close_window::close_window(basic_window& target):
event(target)
{}
 
close_window::~close_window()
{}
 
bool close_window::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/menuwarning.h
New file
0,0 → 1,49
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2004 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_MENUWARNING
#define _RTK_EVENTS_MENUWARNING
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace events {
 
/** A class to represent a RISC OS Message_MenuWarning user message.
*/
class menuwarning:
public event
{
public:
/** A mixin class for handling menuwarning events.
* If a class wishes to receive menuwarning events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle menuwarning event.
* @param ev the menuwarning event to be handled
*/
virtual void handle_event(menuwarning& ev)=0;
};
 
/** Construct menuwarning event.
* @param target the target of the event
*/
menuwarning(desktop::component& target);
 
/** Destroy menuwarning event.
*/
virtual ~menuwarning();
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/mouse_click.cc
New file
0,0 → 1,49
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/events/mouse_click.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
mouse_click::mouse_click(component& target,const point& position,
int buttons,int shift):
event(target),
_position(position),
_buttons(buttons),
_shift(shift)
{}
 
mouse_click::mouse_click(component& target,os::wimp_block& wimpblock):
event(target),
_position(point(wimpblock.word[0],wimpblock.word[1])),
_buttons(wimpblock.word[2]),
_shift(0)
{
// Calculate origin of target with respect to origin of screen.
point origin;
target.parent_application(origin);
 
// Translate pointer location from coordinate space of screen
// to coordinate space of target.
_position-=origin;
}
 
mouse_click::~mouse_click()
{}
 
bool mouse_click::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/dataopen.h
New file
0,0 → 1,85
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_DATAOPEN
#define _RTK_EVENTS_DATAOPEN
 
#include <string>
 
#include "rtk/graphics/point.h"
#include "rtk/events/message.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace events {
 
using rtk::graphics::point;
 
/** A class to represent a RISC OS Message_DataOpen user message. */
class dataopen:
public message
{
public:
/** A mixin class for handling dataopen events.
* If a class wishes to receive dataopen events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle dataopen event.
* @param ev the dataopen event to be handled
*/
virtual void handle_event(dataopen& ev)=0;
};
 
/** Construct dataopen event.
* @param target the target of the event
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
dataopen(desktop::component& target,int wimpcode,
os::wimp_block& wimpblock);
 
/** Destroy dataopen event.
*/
virtual ~dataopen();
protected:
virtual bool deliver(desktop::component& dest);
public:
/** Get destination window handle.
* @return the destination window handle
*/
int whandle() const;
 
/** Get destination position.
* @return the destination position
*/
point position() const;
 
/** Get filetype of data.
* @return the filetype of the data
*/
unsigned int filetype() const;
 
/** Get proposed leafname for data.
* @return the proposed leafname
*/
string pathname() const;
 
/** Send Message_DataLoadAck in reply to this event. */
void reply() const;
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/save_to_file.cc
New file
0,0 → 1,32
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/component.h"
#include "rtk/events/save_to_file.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
save_to_file::save_to_file(component& target,const string& pathname,
bool selection):
event(target),
_pathname(pathname),
_selection(selection)
{}
 
save_to_file::~save_to_file()
{}
 
bool save_to_file::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/mouse_click.h
New file
0,0 → 1,101
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_MOUSE_CLICK
#define _RTK_EVENTS_MOUSE_CLICK
 
#include "rtk/graphics/point.h"
#include "rtk/events/event.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace events {
 
using rtk::graphics::point;
 
/** A class to represent a RISC OS Mouse_Click event.
* The mouse button state is a bitmap:
* - bit 0 = Adjust,
* - bit 1 = Menu,
* - bit 2 = Select.
*/
class mouse_click:
public event
{
public:
/** A mixin class for handling mouse_click events.
* If a class wishes to receive mouse_click events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle mouse_click event.
* @param ev the mouse_click event to be handled
*/
virtual void handle_event(mouse_click& ev)=0;
};
private:
/** The position of the mouse pointer. */
graphics::point _position;
 
/** The mouse button state. */
int _buttons;
 
/** The shift state. */
int _shift;
public:
/** Construct mouse_click event.
* @param target the target of the event
* @param position the mouse position, with respect to the target
* @param buttons the mouse button state
* @param shift the shift state
*/
mouse_click(desktop::component& target,const point& position,
int buttons,int shift);
 
/** Construct mouse_click event from wimp block.
* The mouse position and mouse button state are taken from the
* wimp block, the shift state is currently unimplemented.
* @param target the target of the event
* @param block the wimp block
*/
mouse_click(desktop::component& target,os::wimp_block& block);
 
/** Destroy mouse_click event. */
virtual ~mouse_click();
 
/** Get position of mouse pointer.
* @return the position of the mouse pointer, with respect to
* the target
*/
const point& position() const
{ return _position; }
 
/** Get mouse button state.
* @return the mouse button state
*/
int buttons() const
{ return _buttons; }
 
/** Get shift state.
* @return the shift state
*/
int shift() const
{ return _shift; }
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/save_to_app.cc
New file
0,0 → 1,46
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/events/save_to_app.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
save_to_app::save_to_app(component& target,const string& leafname):
event(target),
_leafname(leafname)
{
os::pointer_info_get block;
os::Wimp_GetPointerInfo(block);
_whandle=block.whandle;
_ihandle=block.ihandle;
_position=block.p;
};
 
save_to_app::save_to_app(component& target,int whandle,int ihandle,
const point& position,const string& leafname):
event(target),
_whandle(whandle),
_ihandle(ihandle),
_position(position),
_leafname(leafname)
{}
 
save_to_app::~save_to_app()
{}
 
bool save_to_app::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/save_to_file.h
New file
0,0 → 1,76
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_SAVE_TO_FILE
#define _RTK_EVENTS_SAVE_TO_FILE
 
#include <string>
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace events {
 
/** An event class for requesting that data be saved to a given pathname. */
class save_to_file:
public event
{
private:
/** The pathname to which the data should be saved. */
string _pathname;
 
/** The selection flag.
* True if the save operation is restricted to the current selection,
* otherwise false.
*/
bool _selection;
public:
/** A mixin class for handling save_to_file events.
* If a class wishes to receive save_to_file events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle save_to_file event.
* @param ev the save_to_file event to be handled
*/
virtual void handle_event(save_to_file& ev)=0;
};
 
/** Construct save_to_file event.
* @param target the target of the event
* @param pathname the pathname to which the data should be saved
* @param selection true if the save operation is restricted to the
* current selection, otherwise false
*/
save_to_file(desktop::component& target,const string& pathname,
bool selection);
 
/** Destroy save_to_file event.
*/
virtual ~save_to_file();
 
/** Get pathname.
* @return the pathname to which the data should be saved.
*/
const string& pathname()
{ return _pathname; }
 
/** Get selection flag.
* @return true if the save operation is restricted to the current
* selection, otherwise false
*/
bool selection()
{ return _selection; }
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/help_request.h
New file
0,0 → 1,99
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_HELP_REQUEST
#define _RTK_EVENTS_HELP_REQUEST
 
#include <string>
 
#include "rtk/graphics/point.h"
#include "rtk/events/event.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace events {
 
using rtk::graphics::point;
 
/** A class to represent a RISC OS Message_HelpRequest event.
* The mouse button state is a bitmap:
* - bit 0 = Adjust,
* - bit 1 = Menu,
* - bit 2 = Select.
*/
class help_request:
public event
{
public:
/** A mixin class for handling help_request events.
* If a class wishes to receive help_request events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle help_request event.
* @param ev the help_request event to be handled
*/
virtual void handle_event(help_request& ev)=0;
};
private:
/** The position of the mouse pointer. */
graphics::point _position;
 
/** The mouse button state. */
int _buttons;
 
/** The shift state. */
int _shift;
 
/** The message reference. */
int _msg_ref;
 
/** The help application task handle. */
int _help_task;
public:
/** Construct help_request event from wimp block.
* The mouse position and mouse button state are taken from the
* wimp block, the shift state is currently unimplemented.
* @param target the target of the event
* @param block the wimp block
*/
help_request(desktop::component& target,os::wimp_block& block);
 
/** Destroy help_request event. */
virtual ~help_request();
 
/** Get position of mouse pointer.
* @return the position of the mouse pointer, with respect to
* the target
*/
const point& position() const
{ return _position; }
 
/** Get mouse button state.
* @return the mouse button state
*/
int buttons() const
{ return _buttons; }
 
/** Send reply.
* @param text the help text to be displayed.
*/
void reply(const string& text) const;
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/entering_window.cc
New file
0,0 → 1,31
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003-2004 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/component.h"
#include "rtk/desktop/basic_window.h"
#include "rtk/events/entering_window.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
using rtk::desktop::basic_window;
 
entering_window::entering_window(basic_window& target):
event(target)
{}
 
entering_window::~entering_window()
{}
 
bool entering_window::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/saved.h
New file
0,0 → 1,65
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_SAVED
#define _RTK_EVENTS_SAVED
 
#include <string>
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace transfer {
 
class save;
 
}; /* namespace transfer */
 
namespace events {
 
/** An event class for reporting that a file has been saved. */
class saved:
public event
{
private:
/** The save operation that saved the file. */
transfer::save* _saveop;
public:
/** A mixin class for handling saved events.
* If a class wishes to receive saved events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle saved event.
* @param ev the saved event to be handled
*/
virtual void handle_event(saved& ev)=0;
};
 
/** Construct saved event.
* @param target the target of the event
* @param saveop the saved operation that saved the file
*/
saved(desktop::component& target,transfer::save& saveop);
 
/** Destroy saved event. */
virtual ~saved();
 
/** Get save operation.
* @return the save operation that saved the file
*/
transfer::save& saveop()
{ return *_saveop; }
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/datasaveack.cc
New file
0,0 → 1,70
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/wimp.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/desktop/application.h"
#include "rtk/events/datasaveack.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
datasaveack::datasaveack(component& target,int wimpcode,
os::wimp_block& wimpblock):
message(target,wimpcode,wimpblock)
{}
 
datasaveack::~datasaveack()
{}
 
int datasaveack::whandle() const
{
return wimpblock().word[5];
}
 
int datasaveack::ihandle() const
{
return wimpblock().word[6];
}
 
point datasaveack::position() const
{
return point(wimpblock().word[7],wimpblock().word[8]);
}
 
unsigned int datasaveack::estsize() const
{
return wimpblock().word[9];
}
 
unsigned int datasaveack::filetype() const
{
return wimpblock().word[10];
}
 
string datasaveack::pathname() const
{
return string(wimpblock().byte+44);
}
 
void datasaveack::reply() const
{
os::wimp_block block;
prepare_reply(block,swi::Message_DataLoad,npos);
os::Wimp_SendMessage(swi::User_Message_Recorded,block,thandle(),0,0);
}
 
bool datasaveack::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/redirection.cc
New file
0,0 → 1,26
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/events/redirection.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
redirection::redirection():
_redirect(0)
{}
 
redirection::~redirection()
{}
 
void redirection::redirect(component* redirect)
{
_redirect=redirect;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/dataload.cc
New file
0,0 → 1,69
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/wimp.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/desktop/application.h"
#include "rtk/events/dataload.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
dataload::dataload(component& target,int wimpcode,os::wimp_block& wimpblock):
message(target,wimpcode,wimpblock)
{}
 
dataload::~dataload()
{}
 
int dataload::whandle() const
{
return wimpblock().word[5];
}
 
int dataload::ihandle() const
{
return wimpblock().word[6];
}
 
point dataload::position() const
{
return point(wimpblock().word[7],wimpblock().word[8]);
}
 
unsigned int dataload::estsize() const
{
return wimpblock().word[9];
}
 
unsigned int dataload::filetype() const
{
return wimpblock().word[10];
}
 
string dataload::pathname() const
{
return string(wimpblock().byte+44);
}
 
void dataload::reply() const
{
static os::wimp_block block;
prepare_reply(block,swi::Message_DataLoadAck,npos);
os::Wimp_SendMessage(swi::User_Message,block,thandle(),0,0);
}
 
bool dataload::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/datasaveack.h
New file
0,0 → 1,95
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_DATASAVEACK
#define _RTK_EVENTS_DATASAVEACK
 
#include <string>
 
#include "rtk/graphics/point.h"
#include "rtk/events/message.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace events {
 
using rtk::graphics::point;
 
/** A class to represent a RISC OS Message_DataSaveAck user message. */
class datasaveack:
public message
{
public:
/** A mixin class for handling datasaveack events.
* If a class wishes to receive datasaveack events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle datasaveack event.
* @param ev the datasaveack event to be handled
*/
virtual void handle_event(datasaveack& ev)=0;
};
 
/** Construct datasaveack event.
* @param target the target of the event
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
datasaveack(desktop::component& target,int wimpcode,
os::wimp_block& wimpblock);
 
/** Destroy datasaveack event.
*/
virtual ~datasaveack();
protected:
virtual bool deliver(desktop::component& dest);
public:
/** Get destination window handle.
* @return the destination window handle
*/
int whandle() const;
 
/** Get destination icon handle.
* @return the destination icon handle
*/
int ihandle() const;
 
/** Get destination position.
* @return the destination position
*/
point position() const;
 
/** Get estimated size of data.
* @return the estimated size of the data
*/
unsigned int estsize() const;
 
/** Get filetype of data.
* @return the filetype of the data
*/
unsigned int filetype() const;
 
/** Get pathname for data.
* @return the pathname
*/
string pathname() const;
 
/** Send Message_DataLoad in reply to this event. */
void reply() const;
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/redirection.h
New file
0,0 → 1,53
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_REDIRECTION
#define _RTK_EVENTS_REDIRECTION
 
namespace rtk {
namespace desktop {
 
class component;
 
}; /* namespace desktop */
 
namespace events {
 
/** A class for redirecting events.
* This is a mixin class which allow a component to redirect event delivery.
*/
class redirection
{
private:
/** The redirected parent, or 0 if redirection is disabled. */
desktop::component* _redirect;
public:
/** Create redirection mixin.
* By default, redirection is disabled.
*/
redirection();
 
/** Destroy redirection mixin.
* Note that this class must have at least one virtual method
* so that dynamic_cast<>() will work correctly.
*/
virtual ~redirection();
 
/** Get redirected parent.
* @return the redirected parent, or 0 if redirection is disabled.
*/
desktop::component* redirect() const
{ return _redirect; }
 
/** Set redirected parent.
* @param redirect the redirected parent, or 0 to disable redirection.
*/
void redirect(desktop::component* redirect);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/dataload.h
New file
0,0 → 1,94
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_DATALOAD
#define _RTK_EVENTS_DATALOAD
 
#include <string>
 
#include "rtk/graphics/point.h"
#include "rtk/events/message.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace events {
 
using rtk::graphics::point;
 
/** A class to represent a RISC OS Message_DataLoad user message. */
class dataload:
public message
{
public:
/** A mixin class for handling dataload events.
* If a class wishes to receive dataload events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle dataload event.
* @param ev the dataload event to be handled
*/
virtual void handle_event(dataload& ev)=0;
};
 
/** Construct dataload event.
* @param target the target of the event
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
dataload(desktop::component& target,int wimpcode,
os::wimp_block& wimpblock);
 
/** Destroy dataload event. */
virtual ~dataload();
protected:
virtual bool deliver(desktop::component& dest);
public:
/** Get destination window handle.
* @return the destination window handle
*/
int whandle() const;
 
/** Get destination icon handle.
* @return the destination icon handle
*/
int ihandle() const;
 
/** Get destination position.
* @return the destination position
*/
point position() const;
 
/** Get estimated size of data.
* @return the estimated size of the data
*/
unsigned int estsize() const;
 
/** Get filetype of data.
* @return the filetype of the data
*/
unsigned int filetype() const;
 
/** Get pathname for data.
* @return the pathname
*/
string pathname() const;
 
/** Send Message_DataLoadAck in reply to this event. */
void reply() const;
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/leaving_window.cc
New file
0,0 → 1,31
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003-2004 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/component.h"
#include "rtk/desktop/basic_window.h"
#include "rtk/events/leaving_window.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
using rtk::desktop::basic_window;
 
leaving_window::leaving_window(basic_window& target):
event(target)
{}
 
leaving_window::~leaving_window()
{}
 
bool leaving_window::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/wimp.cc
New file
0,0 → 1,31
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/component.h"
#include "rtk/events/wimp.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
wimp::wimp(component& target,int wimpcode,os::wimp_block& wimpblock):
event(target),
_wimpcode(wimpcode),
_wimpblock(&wimpblock)
{}
 
wimp::~wimp()
{}
 
bool wimp::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/key_pressed.cc
New file
0,0 → 1,45
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/events/key_pressed.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
key_pressed::key_pressed(component& target,int code):
event(target),
_code(code),
_processed(false)
{}
 
key_pressed::key_pressed(component& target,os::wimp_block& wimpblock):
event(target),
_code(wimpblock.word[6]),
_processed(false)
{}
 
key_pressed::~key_pressed()
{
if (!_processed) os::Wimp_ProcessKey(_code);
}
 
bool key_pressed::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
void key_pressed::processed(bool value)
{
_processed=value;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/reopen_menu.h
New file
0,0 → 1,50
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_REOPEN_MENU
#define _RTK_EVENTS_REOPEN_MENU
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace events {
 
/** An event class for use when the menu tree is to be reopened.
* @todo This mechanism does not currently work for top-level dialogue boxes.
*/
class reopen_menu:
public event
{
public:
/** A mixin class for handling reopen_menu events.
* If a class wishes to receive reopen_menu events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle reopen_menu event.
* @param ev the reopen_menu event to be handled
*/
virtual void handle_event(reopen_menu& ev)=0;
};
 
/** Construct reopen_menu event.
* @param target the target of the event
*/
reopen_menu(desktop::component& target);
 
/** Destroy reopen_menu event.
*/
virtual ~reopen_menu();
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/key_pressed.h
New file
0,0 → 1,92
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_KEY_PRESSED
#define _RTK_EVENTS_KEY_PRESSED
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace events {
 
/** A class to represent a RISC OS Key_Pressed event.
*/
class key_pressed:
public event
{
public:
/** A mixin class for handling key_pressed events.
* If a class wishes to receive key_pressed events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*
* The processed flag is initially false. If it remains false after
* all handlers have been called, Wimp_ProcessKey() will be called
* so that the keypress can be seen by other tasks. (This action is
* performed automatically by the destructor.)
*/
class handler
{
public:
/** Handle key_pressed event.
* @param ev the key_pressed event to be handled
*/
virtual void handle_event(key_pressed& ev)=0;
};
private:
/** The character code. */
int _code;
 
/** The processed flag.
* True if the keypress has been processed, otherwise false.
*/
bool _processed;
public:
/** Construct key_pressed event.
* @param target the target of the event
* @param code the character code for the key that was pressed
*/
key_pressed(desktop::component& target,int code);
 
/** Construct key_pressed event from Wimp_Poll block.
* @param target the target of the event
* @param block a block of the type returned by Wimp_Poll
*/
key_pressed(desktop::component& target,os::wimp_block& block);
 
/** Destroy key_pressed event.
*/
virtual ~key_pressed();
 
/** Get character code.
* @return the character code for the key that was pressed
*/
int code()
{ return _code; }
 
/** Get processed flag.
* @return true if the keypress has been processed, otherwise false
*/
bool processed()
{ return _processed; }
 
/** Set processed flag.
* @param value true if the keypress has been processed, otherwise false
*/
void processed(bool value);
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/timestamp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/menusdeleted.h
New file
0,0 → 1,49
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_MENUSDELETED
#define _RTK_EVENTS_MENUSDELETED
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace events {
 
/** A class to represent a RISC OS Message_MenusDeleted user message.
*/
class menusdeleted:
public event
{
public:
/** A mixin class for handling menusdeleted events.
* If a class wishes to receive menusdeleted events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle menusdeleted event.
* @param ev the menusdeleted event to be handled
*/
virtual void handle_event(menusdeleted& ev)=0;
};
 
/** Construct menusdeleted event.
* @param target the target of the event
*/
menusdeleted(desktop::component& target);
 
/** Destroy menusdeleted event.
*/
virtual ~menusdeleted();
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/event.cc
New file
0,0 → 1,42
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/component.h"
#include "rtk/events/event.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
event::event(component& target):
_target(&target)
{}
 
event::~event()
{}
 
void event::target(component& target)
{
_target=&target;
}
 
bool event::post()
{
bool handled=false;
component* dest=_target;
while (dest)
{
// Request parent before delivering event, in case component
// does not exist after event has been handled.
component* parent=dest->redirected_parent();
handled|=deliver(*dest);
dest=parent;
}
return handled;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/quit.cc
New file
0,0 → 1,29
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/component.h"
#include "rtk/events/quit.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
quit::quit(component& target):
event(target)
{}
 
quit::~quit()
{}
 
bool quit::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/event.h
New file
0,0 → 1,69
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_EVENT
#define _RTK_EVENTS_EVENT
 
namespace rtk {
namespace graphics {};
 
namespace desktop {
 
class component;
 
}; /* namespace desktop */
 
namespace events {
 
/** An abstract class to represent an RTK event.
*/
class event
{
private:
/** The target of the event. */
desktop::component* _target;
public:
/** Construct event.
* @param target the target of the event
*/
event(desktop::component& target);
 
/** Destroy event.
*/
virtual ~event();
 
/** Get target.
* @return the target of the event
*/
desktop::component* target() const
{ return _target; }
 
/** Set target.
* @param target the required target of the event
*/
void target(desktop::component& target);
 
/** Post event.
* Search upwards from the target for a component with a suitable
* handler for this event, then pass this event to that handler.
* Continue until all suitable handlers have been called.
* @return true if one or more suitable handlers were found,
* otherwise false
*/
bool post();
protected:
/** Deliver event to component.
* If the specified destination has a handler method for this event
* then call that method.
* @param dest the destination to which this event should be delivered
* @return true if a handler was found, otherwise false
*/
virtual bool deliver(desktop::component& dest)=0;
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/user_drag_box.cc
New file
0,0 → 1,47
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/wimp.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/desktop/application.h"
#include "rtk/events/user_drag_box.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
user_drag_box::user_drag_box(component& target,const graphics::box& dbox):
event(target),
_dbox(dbox)
{}
 
user_drag_box::user_drag_box(component& target,os::wimp_block& wimpblock):
event(target),
_dbox(wimpblock.word[0],wimpblock.word[1],wimpblock.word[2],
wimpblock.word[3])
{
// Calculate origin of target with respect to origin of screen.
point origin;
target.parent_application(origin);
 
// Translate pointer location from coordinate space of screen
// to coordinate space of target.
_dbox-=origin;
}
 
user_drag_box::~user_drag_box()
{}
 
bool user_drag_box::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/message.cc
New file
0,0 → 1,55
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/events/message.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
message::message(component& target,int wimpcode,os::wimp_block& wimpblock):
event(target),
_wimpcode(wimpcode),
_wimpblock(&wimpblock)
{}
 
message::~message()
{}
 
int message::thandle() const
{
return _wimpblock->word[1];
}
 
int message::msgcode() const
{
return _wimpblock->word[4];
}
 
void message::prepare_reply(os::wimp_block& reply,int msgcode,
size_type size) const
{
if (size==npos) size=_wimpblock->word[0];
unsigned int words=(size+3)>>2;
for (unsigned int i=5;i<words;++i) reply.word[i]=_wimpblock->word[i];
reply.word[0]=size;
reply.word[1]=0;
reply.word[2]=0;
reply.word[3]=_wimpblock->word[2];
reply.word[4]=msgcode;
}
 
bool message::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/user_drag_box.h
New file
0,0 → 1,70
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_USER_DRAG_BOX
#define _RTK_EVENTS_USER_DRAG_BOX
 
#include <string>
 
#include "rtk/graphics/box.h"
#include "rtk/events/event.h"
 
namespace rtk {
namespace events {
 
using rtk::graphics::point;
 
/** A class to represent a RISC OS User_Drag_Box event. */
class user_drag_box:
public event
{
public:
/** A mixin class for handling user_drag_box events.
* If a class wishes to receive user_drag_box events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle user_drag_box event.
* @param ev the user_drag_box event to be handled
*/
virtual void handle_event(user_drag_box& ev)=0;
};
private:
/** The final position of the drag box, with respect to the target. */
graphics::box _dbox;
public:
/** Construct user_drag_box event.
* @param target the target of the event
* @param dbox the final position of the drag box, with respect to
* the target.
*/
user_drag_box(desktop::component& target,const graphics::box& dbox);
 
/** Construct user_drag_box event from wimp block.
* @param target the target of the event
* @param block the wimp block
*/
user_drag_box(desktop::component& target,os::wimp_block& block);
 
/** Destroy user_drag_box event. */
virtual ~user_drag_box();
 
/** Get final position of drag box.
* @return the final position of the drag box, with respect to
* the target.
*/
graphics::box dbox() const
{ return _dbox; }
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/ramfetch.cc
New file
0,0 → 1,52
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/wimp.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/desktop/application.h"
#include "rtk/events/ramfetch.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
ramfetch::ramfetch(component& target,int wimpcode,os::wimp_block& wimpblock):
message(target,wimpcode,wimpblock)
{}
 
ramfetch::~ramfetch()
{}
 
void* ramfetch::buffer() const
{
return reinterpret_cast<void*>(wimpblock().word[5]);
}
 
unsigned int ramfetch::buffer_size() const
{
return wimpblock().word[6];
}
 
void ramfetch::reply(unsigned int count) const
{
os::wimp_block block;
prepare_reply(block,swi::Message_RAMTransmit,npos);
block.word[6]=count;
bool last=count!=buffer_size();
int wimpcode=(last)?swi::User_Message:swi::User_Message_Recorded;
os::Wimp_SendMessage(wimpcode,block,thandle(),0,0);
}
 
bool ramfetch::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/menuwarning.cc
New file
0,0 → 1,29
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2004 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/component.h"
#include "rtk/events/menuwarning.h"
 
namespace rtk {
namespace events {
 
using rtk::desktop::component;
 
menuwarning::menuwarning(component& target):
event(target)
{}
 
menuwarning::~menuwarning()
{}
 
bool menuwarning::deliver(component& dest)
{
handler* h=dynamic_cast<handler*>(&dest);
if (h) h->handle_event(*this);
return h;
}
 
}; /* namespace events */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/loaded.h
New file
0,0 → 1,65
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_LOADED
#define _RTK_EVENTS_LOADED
 
#include <string>
 
#include "rtk/events/event.h"
 
namespace rtk {
namespace transfer {
 
class load;
 
}; /* namespace transfer */
 
namespace events {
 
/** An event class for reporting that a file has been loaded. */
class loaded:
public event
{
private:
/** The load operation that loaded the file. */
transfer::load* _loadop;
public:
/** A mixin class for handling loaded events.
* If a class wishes to receive loaded events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle loaded event.
* @param ev the loaded event to be handled
*/
virtual void handle_event(loaded& ev)=0;
};
 
/** Construct loaded event.
* @param target the target of the event
* @param loadop the load operation that loaded the file
*/
loaded(desktop::component& target,transfer::load& loadop);
 
/** Destroy loaded event. */
virtual ~loaded();
 
/** Get load operation.
* @return the load operation that loaded the file
*/
transfer::load& loadop()
{ return *_loadop; }
protected:
virtual bool deliver(desktop::component& dest);
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/dataloadack.h
New file
0,0 → 1,92
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_DATALOADACK
#define _RTK_EVENTS_DATALOADACK
 
#include <string>
 
#include "rtk/graphics/point.h"
#include "rtk/events/message.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace events {
 
using rtk::graphics::point;
 
/** A class to represent a RISC OS Message_DataLoadAck user message. */
class dataloadack:
public message
{
public:
/** A mixin class for handling dataloadack events.
* If a class wishes to receive dataloadack events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle dataloadack event.
* @param ev the dataloadack event to be handled
*/
virtual void handle_event(dataloadack& ev)=0;
};
 
/** Construct dataloadack event.
* @param target the target of the event
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
dataloadack(desktop::component& target,int wimpcode,
os::wimp_block& wimpblock);
 
/** Destroy dataloadack event.
*/
virtual ~dataloadack();
protected:
virtual bool deliver(desktop::component& dest);
public:
/** Get destination window handle.
* @return the destination window handle
*/
int whandle() const;
 
/** Get destination icon handle.
* @return the destination icon handle
*/
int ihandle() const;
 
/** Get destination position.
* @return the destination position
*/
point position() const;
 
/** Get estimated size of data.
* @return the estimated size of the data
*/
unsigned int estsize() const;
 
/** Get filetype of data.
* @return the filetype of the data
*/
unsigned int filetype() const;
 
/** Get pathname for data.
* @return the pathname
*/
string pathname() const;
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/events/datasave.h
New file
0,0 → 1,106
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_EVENTS_DATASAVE
#define _RTK_EVENTS_DATASAVE
 
#include <string>
 
#include "rtk/graphics/point.h"
#include "rtk/events/message.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace events {
 
using rtk::graphics::point;
 
/** A class to represent a RISC OS Message_DataSave user message. */
class datasave:
public message
{
public:
/** A mixin class for handling datasave events.
* If a class wishes to receive datasave events then it should
* inherit from this mixin class and provide an implementation for
* handle_event().
*/
class handler
{
public:
/** Handle datasave event.
* @param ev the datasave event to be handled
*/
virtual void handle_event(datasave& ev)=0;
};
 
/** Construct datasave event.
* @param target the target of the event
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
datasave(desktop::component& target,int wimpcode,
os::wimp_block& wimpblock);
 
/** Destroy datasave event.
*/
virtual ~datasave();
protected:
virtual bool deliver(desktop::component& dest);
public:
/** Get destination window handle.
* @return the destination window handle
*/
int whandle() const;
 
/** Get destination icon handle.
* @return the destination icon handle
*/
int ihandle() const;
 
/** Get destination position.
* @return the destination position
*/
point position() const;
 
/** Get estimated size of data.
* @return the estimated size of the data
*/
unsigned int estsize() const;
 
/** Get filetype of data.
* @return the filetype of the data
*/
unsigned int filetype() const;
 
/** Get proposed leafname for data.
* @return the proposed leafname
*/
string leafname() const;
 
/** Send Message_RAMFetch in reply to this event.
* @param buffer the data transfer buffer
* @param buffer_size the size of the data transfer buffer
*/
void reply(void* buffer,unsigned int buffer_size) const;
 
/** Send Message_DataSaveAck in reply to this event.
* The pathname is secure if it is permanent location for the file
* to be stored (as opposed to a temporary name such as <Wimp$Scrap>).
* @param pathname the required pathname
* @param secure true if pathname is secure, otherwise false
*/
void reply(const string& pathname,bool secure=false) const;
};
 
}; /* namespace events */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/transfer/save.cc
New file
0,0 → 1,240
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include <string.h>
#include <algorithm>
 
#include "rtk/swi/wimp.h"
#include "rtk/os/os.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/application.h"
#include "rtk/events/wimp.h"
#include "rtk/events/message.h"
#include "rtk/events/datasave.h"
#include "rtk/events/dataload.h"
#include "rtk/events/ramtransmit.h"
#include "rtk/events/save_to_app.h"
#include "rtk/events/save_to_file.h"
#include "rtk/events/saved.h"
#include "rtk/transfer/save.h"
 
namespace rtk {
namespace transfer {
 
save::save():
_state(state_idle),
_thandle(0),
_filetype(0xffd),
_allow_ram_transfer(true),
_secure(false),
_ldata(0),
_lsize(0)
{
os::Wimp_ReadSysInfo(5,&_thandle,0);
}
 
save::~save()
{}
 
graphics::box save::min_bbox() const
{
return graphics::box();
}
 
void save::handle_event(events::datasaveack& ev)
{
// A Message_DataSaveAck is acted upon in response to a Message_DataSave.
if (_state==state_datasave)
{
get_file(ev.pathname());
_pathname=ev.pathname();
_secure=ev.estsize()!=static_cast<size_type>(-1);
ev.reply();
_state=state_dataload;
}
}
 
void save::handle_event(events::dataloadack& ev)
{
// A Message_DataLoadAck is acted upon in response to a Message_DataLoad.
if (_state==state_dataload)
{
_state=state_idle;
events::saved ev2(*this,*this);
ev2.post();
}
}
 
void save::handle_event(events::ramfetch& ev)
{
// A Message_RAMFetch is acted upon in response to a Message_DataSave
// or a Message_RAMTransmit, but only if RAM transfers are enabled.
if (((_state==state_datasave)||(_state==state_ramtransmit))&&
_allow_ram_transfer)
{
size_type rfree=ev.buffer_size();
void* rdata=ev.buffer();
if (!_lsize) get_block(&_ldata,&_lsize);
while (rfree&&_lsize)
{
size_type count=min(rfree,_lsize);
os::Wimp_TransferBlock(_thandle,_ldata,ev.thandle(),rdata,count);
rdata=static_cast<char*>(rdata)+count;
_ldata=static_cast<const char*>(_ldata)+count;
rfree-=count;
_lsize-=count;
if (!_lsize) get_block(&_ldata,&_lsize);
}
ev.reply(ev.buffer_size()-rfree);
if (rfree)
{
// If there is space at the end of the buffer then this is
// the last message and no reply is expected.
finish();
_state=state_idle;
events::saved ev2(*this,*this);
ev2.post();
}
else
{
// If there is no space at the end of the buffer then at
// least one more Message_RAMFetch is expected.
_state=state_ramtransmit;
}
}
}
 
void save::handle_event(events::save_to_app& ev)
{
os::wimp_block& block=*new os::wimp_block;
block.word[3]=0;
block.word[4]=swi::Message_DataSave;
block.word[5]=ev.whandle();
block.word[6]=ev.ihandle();
block.word[7]=ev.position().x();
block.word[8]=ev.position().y();
block.word[9]=estsize();
block.word[10]=filetype();
unsigned int i=ev.leafname().copy(block.byte+44,211);
block.byte[44+i]=0;
block.word[0]=44+((i+4)&~3);
if (desktop::application* app=ev.target()->parent_application())
app->send_message(swi::User_Message,block,ev.whandle(),ev.ihandle());
start();
_ldata=0;
_lsize=0;
_pathname=string();
_secure=false;
_state=state_datasave;
}
 
void save::handle_event(events::save_to_file& ev)
{
_pathname=string();
_secure=false;
get_file(ev.pathname());
_pathname=ev.pathname();
_secure=true;
_state=state_idle;
events::saved ev2(*this,*this);
ev2.post();
}
 
save& save::filetype(unsigned int filetype)
{
_filetype=filetype;
return *this;
}
 
save& save::allow_ram_transfer(bool value)
{
_allow_ram_transfer=value;
return *this;
}
 
void save::deliver_wimp_block(int wimpcode,os::wimp_block& wimpblock)
{
switch (wimpcode)
{
case 17:
case 18:
case 19:
deliver_message(wimpcode,wimpblock);
break;
default:
{
events::wimp ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
}
}
 
void save::deliver_message(int wimpcode,os::wimp_block& wimpblock)
{
switch (wimpblock.word[4])
{
case swi::Message_DataSave:
{
events::datasave ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
case swi::Message_DataSaveAck:
{
events::datasaveack ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
case swi::Message_DataLoad:
{
events::dataload ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
case swi::Message_DataLoadAck:
{
events::dataloadack ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
case swi::Message_RAMFetch:
{
events::ramfetch ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
case swi::Message_RAMTransmit:
{
events::ramtransmit ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
default:
{
events::message ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
}
}
 
void save::get_file(const string& pathname)
{
start();
int fhandle;
os::OS_Find(0x83,pathname.c_str(),0,&fhandle);
get_block(&_ldata,&_lsize);
while (_lsize)
{
os::OS_GBPB2(fhandle,_ldata,_lsize,0);
get_block(&_ldata,&_lsize);
}
os::OS_Find0(fhandle);
finish();
}
 
}; /* namespace transfer */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/transfer/load.cc
New file
0,0 → 1,198
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/wimp.h"
#include "rtk/os/os.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/application.h"
#include "rtk/events/wimp.h"
#include "rtk/events/message.h"
#include "rtk/events/ramfetch.h"
#include "rtk/events/datasaveack.h"
#include "rtk/events/loaded.h"
#include "rtk/transfer/load.h"
 
namespace rtk {
namespace transfer {
 
load::load():
_state(state_idle),
_thandle(0),
_filetype(0xffd),
_allow_ram_transfer(true),
_ldata(0),
_lsize(0)
{
os::Wimp_ReadSysInfo(5,&_thandle,0);
}
 
load::~load()
{}
 
graphics::box load::min_bbox() const
{
return graphics::box();
}
 
void load::handle_event(events::datasave& ev)
{
// A Message_DataSave is acted upon at any time.
if (_allow_ram_transfer)
{
// If RAM transfers are enabled then reply with Message_RAMFetch.
start(ev.estsize());
_ldata=0;
_lsize=0;
get_block(&_ldata,&_lsize);
ev.reply(_ldata,_lsize);
// Keep a copy of the Message_DataSave so that a Message_DataSaveAck
// be sent if the Message_RAMFetch fails.
unsigned int size=(ev.wimpblock().word[0]+3)>>2;
for (unsigned int i=0;i!=size;++i)
_datasave_block.word[i]=ev.wimpblock().word[i];
_state=state_ramfetch_first;
}
else
{
// If RAM transfers are disabled then reply with Message_DataSaveAck.
ev.reply("<Wimp$Scrap>");
_state=state_idle;
}
}
 
void load::handle_event(events::dataload& ev)
{
// A Message_DataLoad is acted upon at any time.
put_file(ev.pathname(),ev.estsize());
ev.reply();
_state=state_idle;
events::loaded ev2(*this,*this);
ev2.post();
remove();
}
 
void load::handle_event(events::dataopen& ev)
{
// A Message_DataOpen is acted upon at any time.
// Unlike Message_DataLoad, the reply is sent before the file is loaded.
ev.reply();
put_file(ev.pathname(),0);
_state=state_idle;
events::loaded ev2(*this,*this);
ev2.post();
remove();
}
 
void load::handle_event(events::ramfetch& ev)
{
// A Message_RAMFetch will be a User_Message_Acknowledge if it has
// been delivered to this component.
// It is acted upon only if it was the first Message_RAMFetch
// following a Message_DataSave.
if (_state==state_ramfetch_first)
{
events::datasave ev2(*this,swi::User_Message,_datasave_block);
ev2.reply("<Wimp$Scrap>");
_state=state_idle;
}
}
 
void load::handle_event(events::ramtransmit& ev)
{
// A Message_RAMTransmit is acted upon in response to a Message_RAMFetch.
if ((_state==state_ramfetch_first)||(_state==state_ramfetch))
{
put_block(ev.buffer_size());
if (ev.buffer_size()==_lsize)
{
_ldata=0;
_lsize=0;
get_block(&_ldata,&_lsize);
ev.reply(_ldata,_lsize);
_state=state_ramfetch;
}
else
{
finish();
_state=state_idle;
events::loaded ev(*this,*this);
ev.post();
remove();
}
}
}
 
load& load::allow_ram_transfer(bool value)
{
_allow_ram_transfer=value;
return *this;
}
 
void load::deliver_wimp_block(int wimpcode,os::wimp_block& wimpblock)
{
switch (wimpcode)
{
case 17:
case 18:
case 19:
deliver_message(wimpcode,wimpblock);
break;
default:
{
events::wimp ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
}
}
 
void load::deliver_message(int wimpcode,os::wimp_block& wimpblock)
{
switch (wimpblock.word[4])
{
case swi::Message_RAMFetch:
{
events::ramfetch ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
case swi::Message_RAMTransmit:
{
events::ramtransmit ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
default:
{
events::message ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
}
}
 
void load::put_file(const string& pathname,size_type estsize)
{
start(estsize);
int fhandle;
os::OS_Find(0x4f,pathname.c_str(),0,&fhandle);
bool eof;
os::OS_Args5(fhandle,&eof);
while (!eof)
{
_ldata=0;
_lsize=0;
get_block(&_ldata,&_lsize);
unsigned int excess=0;
os::OS_GBPB4(fhandle,_ldata,_lsize,&excess,0);
put_block(_lsize-excess);
os::OS_Args5(fhandle,&eof);
}
os::OS_Find0(fhandle);
finish();
}
 
}; /* namespace transfer */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/transfer/timestamp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/transfer/save.h
New file
0,0 → 1,199
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_TRANSFER_SAVE
#define _RTK_TRANSFER_SAVE
 
#include "rtk/desktop/component.h"
#include "rtk/events/datasaveack.h"
#include "rtk/events/dataloadack.h"
#include "rtk/events/ramfetch.h"
#include "rtk/events/save_to_app.h"
#include "rtk/events/save_to_file.h"
#include "rtk/events/redirection.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace transfer {
 
/** An abstract class to represent a save operation using the
* data transfer protocol.
* Implementations must override start(), get(), finish() and estsize()
* to define the source of the data.
*/
class save:
public desktop::component,
public events::datasaveack::handler,
public events::dataloadack::handler,
public events::ramfetch::handler,
public events::save_to_app::handler,
public events::save_to_file::handler,
public events::redirection
{
public:
/** A type for representing byte counts. */
typedef unsigned int size_type;
 
/** A null value for use in place of a byte count. */
static const size_type npos=static_cast<size_type>(-1);
private:
/** An enumeration to represent the current state of the
* save operation. */
enum state_type
{
/** The state in which the save operation is waiting for an RTK
* save_to_file or save_to_app event. */
state_idle,
/** The state in which the save operation has sent a Message_DataSave
* and is waiting for either Message_RAMFetch or Message_DataSaveAck.
*/
state_datasave,
/** The state in which the save operation has sent a Message_DataLoad
* and is waiting for a Message_DataLoadAck. */
state_dataload,
/** The state in which the save operation has sent an initial or
* intermediate Message_RAMTransmit and is waiting for a
* Message_RAMFetch. */
state_ramtransmit
};
 
/** The current state of the save operation. */
state_type _state;
 
/** The local task handle. */
int _thandle;
 
/** The filetype of the data to be saved. */
unsigned int _filetype;
 
/** The RAM transfer allowed flag. */
bool _allow_ram_transfer;
 
/** The pathname to which the data was most recently saved. */
string _pathname;
 
/** The data secure flag. */
bool _secure;
 
/** The current local data buffer. */
const void* _ldata;
 
/** The current local data buffer size. */
size_type _lsize;
public:
/** Construct save object. */
save();
 
/** Destroy save object. */
virtual ~save();
 
virtual graphics::box min_bbox() const;
 
virtual void handle_event(events::datasaveack& ev);
virtual void handle_event(events::dataloadack& ev);
virtual void handle_event(events::ramfetch& ev);
virtual void handle_event(events::save_to_app& ev);
virtual void handle_event(events::save_to_file& ev);
 
/** Get filetype.
* @return the filetype of the data to be saved
*/
unsigned int filetype() const
{ return _filetype; }
 
/** Get RAM transfer allowed flag.
* @return true if RAM transfers are allowed, otherwise false.
*/
bool allow_ram_transfer() const
{ return _allow_ram_transfer; }
 
/** Get pathname.
* This is set to the empty string if the data has not been saved,
* or if the most recent save operation used the RAM transfer
* protocol.
* @return the pathname to which the data was most recently saved
*/
const string& pathname() const
{ return _pathname; }
 
/** Get data secure flag.
* The date is secure if it has been written to a parmanent file
* (as opposed to a temporary file such as <Wimp$Scrap>).
* @return the data secure flag
*/
bool secure() const
{ return _secure; }
 
/** Set filetype.
* @param filetype the filetype of the data to be saved.
*/
save& filetype(unsigned int filetype);
 
/** Set RAM transfer allowed flag.
* Applications are not obliged to support RAM transfers, but nor is
* any extra work needed to implement them when using this class.
* They should be enabled unless there is a good reason not to.
* @param value true if RAM transfers are allowed, otherwise false.
* @return a reference to this
*/
save& allow_ram_transfer(bool value);
 
/** Deliver Wimp event block.
* @internal
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
void deliver_wimp_block(int wimpcode,os::wimp_block& wimpblock);
 
/** Deliver Wimp message.
* @internal
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
void deliver_message(int wimpcode,os::wimp_block& wimpblock);
protected:
/** Start new save operation.
* If start() is called before a previous operation has been completed
* then the previous operation should be aborted.
*/
virtual void start()=0;
 
/** Get data as memory block.
* A memory block is returned containing some or all of the remaining
* data. To obtain all of the data, repeat until the returned count
* is zero.
* @param data the buffer for the returned block pointer
* @param count a buffer for the returned block length in bytes
*/
virtual void get_block(const void** data,size_type* count)=0;
 
/** Finish save operation. */
virtual void finish()=0;
 
/** Get estimated size.
* @return the estimated size of the data
*/
virtual size_type estsize()=0;
 
/** Get data as file.
* All data is copied to the specified pathname.
* The default implementation of this method uses read() to
* fetch the data and OS_GBPB to write it to disc.
* It can be overridden if a more efficient method is known,
* but there is no obligation to do so.
* @param pathname the pathname to which the data should be copied
*/
virtual void get_file(const string& pathname);
};
 
}; /* namespace transfer */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/transfer/load.h
New file
0,0 → 1,172
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_TRANSFER_LOAD
#define _RTK_TRANSFER_LOAD
 
#include "rtk/os/wimp.h"
#include "rtk/desktop/component.h"
#include "rtk/events/datasave.h"
#include "rtk/events/dataload.h"
#include "rtk/events/dataopen.h"
#include "rtk/events/ramfetch.h"
#include "rtk/events/ramtransmit.h"
#include "rtk/events/redirection.h"
 
namespace rtk {
namespace transfer {
 
/** A abstract class to represent a load operation using the
* data transfer protocol.
* Implementations must override start(), get(), put() and finish()
* to define what is done with the data.
*/
class load:
public desktop::component,
public events::datasave::handler,
public events::dataload::handler,
public events::dataopen::handler,
public events::ramfetch::handler,
public events::ramtransmit::handler,
public events::redirection
{
public:
/** A type for representing byte counts. */
typedef unsigned int size_type;
 
/** A null value for use in place of a byte count. */
static const size_type npos=static_cast<size_type>(-1);
private:
/** An enumeration to represent the state of the load operation. */
enum state_type
{
/** The state in which the load operation is waiting for a
* Message_DataSave or Message_DataLoad. */
state_idle,
/** The state in which the load operation has sent an initial
* Message_RAMFetch and is waiting for either Message_RAMTransmit
* or for the Message_RAMFetch to be returned. */
state_ramfetch_first,
/** The state in which the load operation has sent an intermediate
* Message_RAMFetch and is waiting for a Message_RAMTransmit. */
state_ramfetch
};
 
/** The current state of the load operation. */
state_type _state;
 
/** The local task handle. */
int _thandle;
 
/** The filetype of the data loaded. */
unsigned int _filetype;
 
/** The RAM transfer allowed flag. */
bool _allow_ram_transfer;
 
/** The current local data buffer. */
void* _ldata;
 
/** The current local data buffer size. */
size_type _lsize;
 
/** A copy of the Message_DataSave message block.
* This is needed to produce the Message_DataSavAck that is sent if
* the Message_RAMFetch is negatively acknowledged.
*/
os::wimp_block _datasave_block;
public:
/** Construct load object.
* By default, RAM transfers are allowed.
*/
load();
 
/** Destroy load object. */
virtual ~load();
 
virtual graphics::box min_bbox() const;
 
virtual void handle_event(events::datasave& ev);
virtual void handle_event(events::dataload& ev);
virtual void handle_event(events::dataopen& ev);
virtual void handle_event(events::ramfetch& ev);
virtual void handle_event(events::ramtransmit& ev);
 
/** Get filetype of data loaded
* @return the filetype of the data
*/
unsigned int filetype() const
{ return _filetype; }
 
/** Get RAM transfer allowed flag.
* @return true if RAM transfers are allowed, otherwise false
*/
bool allow_ram_transfer() const
{ return _allow_ram_transfer; }
 
/** Set RAM transfer allowed flag.
* Applications are not obliged to support RAM transfers, but nor is
* any extra work needed to implement them when using this class.
* They should be enabled unless there is a good reason not to.
* @param value true if RAM transfers are allowed, otherwise false
* @return a reference to this
*/
load& allow_ram_transfer(bool value);
 
/** Deliver Wimp event block.
* @internal
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
void deliver_wimp_block(int wimpcode,os::wimp_block& wimpblock);
 
/** Deliver Wimp message.
* @internal
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
void deliver_message(int wimpcode,os::wimp_block& wimpblock);
protected:
/** Start new load operation.
* If start() is called before a previous operation has been completed
* then the previous operation should be aborted.
* @param estsize the estimated file size in bytes
*/
virtual void start(size_type estsize)=0;
 
/** Get block.
* The callee is free to offer any size of block, and may offer
* a different size each time it is called.
* @param data a buffer for the returned block pointer
* @param size a buffer for the returned block size in bytes
*/
virtual void get_block(void** data,size_type* size)=0;
 
/** Put data from block.
* The caller is not required to fill the buffer supplied by get(),
* but should at least partially fill it.
* @param count the block length in bytes
*/
virtual void put_block(size_type count)=0;
 
/** Finish load operation. */
virtual void finish()=0;
 
/** Put data from file.
* All data is copied from the specified pathname.
* The default implementation of this method uses OS_GBPB to fetch
* the data from disc and write() to send it to the application.
* It can be overridden if a more efficient method is known,
* but there is no obligation to do so.
* @param pathname the pathname from which the data should be copied
* @param estsize the estimated file size in bytes
*/
virtual void put_file(const string& pathname,size_type estsize);
};
 
}; /* namespace transfer */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/transfer/save_linelist.cc
New file
0,0 → 1,85
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/transfer/save_linelist.h"
 
namespace rtk {
namespace transfer {
 
save_linelist::save_linelist():
_linelist(&_default_linelist),
_pos(_default_linelist.end()),
_eol(false)
{}
 
save_linelist::~save_linelist()
{}
 
void save_linelist::start()
{
_pos=_linelist->begin();
_eol=false;
}
 
void save_linelist::get_block(const void** data,size_type* count)
{
if (_eol)
{
static char linefeed='\n';
if (data) *data=&linefeed;
if (count) *count=1;
_eol=false;
}
else if (_pos!=_linelist->end())
{
const string& s=*_pos++;
if (s.length())
{
if (data) *data=s.data();
if (count) *count=s.length();
_eol=true;
}
else
{
// Cannot return a block of length 0 (because that would
// terminate the save operation), so must return a newline
// now.
static char linefeed='\n';
if (data) *data=&linefeed;
if (count) *count=1;
_eol=false;
}
}
else
{
// If finished then return an empty block.
if (data) *data=0;
if (count) *count=0;
}
}
 
void save_linelist::finish()
{}
 
save_linelist::size_type save_linelist::estsize()
{
size_type size=0;
for (list<string>::const_iterator i=_linelist->begin();
i!=_linelist->end();++i)
{
const string& s=*i;
size+=s.length()+1;
}
return size;
}
 
save_linelist& save_linelist::linelist(list<string>& linelist)
{
_linelist=&linelist;
return *this;
}
 
}; /* namespace transfer */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/transfer/load_linelist.cc
New file
0,0 → 1,79
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/swi/wimp.h"
#include "rtk/os/os.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/application.h"
#include "rtk/events/wimp.h"
#include "rtk/events/message.h"
#include "rtk/events/ramfetch.h"
#include "rtk/events/datasaveack.h"
#include "rtk/events/save_to_app.h"
#include "rtk/events/save_to_file.h"
#include "rtk/transfer/load_linelist.h"
 
namespace rtk {
namespace transfer {
 
load_linelist::load_linelist(size_type buffer_size):
load(),
_linelist(&_default_linelist),
_buffer(new char[buffer_size]),
_buffer_size(buffer_size),
_newline(true)
{}
 
load_linelist::~load_linelist()
{
delete[] _buffer;
}
 
void load_linelist::start(size_type estsize)
{
_linelist->clear();
_newline=true;
}
 
void load_linelist::get_block(void** data,size_type* size)
{
if (data) *data=_buffer;
if (size) *size=_buffer_size;
}
 
void load_linelist::put_block(size_type count)
{
char* p=_buffer;
char* q=p;
for (size_type i=0;i!=count;++i)
{
if (*p++=='\n')
{
if (_newline) _linelist->push_back(string());
_linelist->back()+=string(q,p-1);
q=p;
_newline=true;
}
}
if (p!=q)
{
if (_newline) _linelist->push_back(string());
_linelist->back()+=string(q,p);
q=p;
_newline=false;
}
}
 
void load_linelist::finish()
{}
 
load_linelist& load_linelist::linelist(list<string>& linelist)
{
_linelist=&linelist;
return *this;
}
 
}; /* namespace transfer */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/transfer/save_linelist.h
New file
0,0 → 1,78
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_TRANSFER_SAVE_LINELIST
#define _RTK_TRANSFER_SAVE_LINELIST
 
#include <list>
#include <string>
 
#include "rtk/transfer/save.h"
 
namespace rtk {
namespace transfer {
 
/** A class for saving lines of text. */
class save_linelist:
public save
{
private:
/** A pointer to the line list to be saved.
* This always points to a list<string>: it can never be null.
*/
list<string>* _linelist;
 
/** The current position within _linelist. */
list<string>::const_iterator _pos;
 
/** The default value for _linelist. */
list<string> _default_linelist;
 
/** The end-of-line flag.
* When true, a line of text has been saved but the associated newline
* character has not.
*/
bool _eol;
public:
/** Construct save_linelist operation. */
save_linelist();
 
/** Destroy save_linelist operation. */
virtual ~save_linelist();
protected:
virtual void start();
virtual void get_block(const void** data,size_type* count);
virtual void finish();
virtual size_type estsize();
public:
/** Get line list to be saved.
* The returned list reference is writable, so it is possible to add
* strings to the default list and save that (as opposed to specifying
* an external list).
* @return a reference to the data to be saved
*/
list<string>& linelist()
{ return *_linelist; }
 
/** Set line list to be saved.
* The default list may be reactivated by specifying default_linelist()
* as the argument to this function.
* @param linelist the data to be saved
*/
save_linelist& linelist(list<string>& linelist);
 
/** Get default line list.
* This is the list that is used if an external list has not been
* specified. It is the default value of linelist().
* @return a reference to the default line list
*/
list<string>& default_linelist()
{ return _default_linelist; }
};
 
}; /* namespace transfer */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/transfer/load_linelist.h
New file
0,0 → 1,80
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_TRANSFER_LOAD_LINELIST
#define _RTK_TRANSFER_LOAD_LINELIST
 
#include <list>
#include <string>
 
#include "rtk/transfer/load.h"
 
namespace rtk {
namespace transfer {
 
/** A class for loading lines of text. */
class load_linelist:
public load
{
private:
/** A pointer to the list of lines that have been loaded.
* This always points to a list of string: it can never be null.
*/
list<string>* _linelist;
 
/** The default value for _linelist. */
list<string> _default_linelist;
 
/** The buffer used to receive data before it is parsed into lines. */
char* _buffer;
 
/** The size of _buffer. */
size_type _buffer_size;
 
/** The newline flag.
* True if the next character parsed should begin a new line,
* false if it should be appended to the previous line.
*/
bool _newline;
public:
/** Construct load_linelist object. */
load_linelist(size_type buffer_size=0x400);
 
/** Destroy load_linelist object. */
virtual ~load_linelist();
protected:
virtual void start(size_type estsize);
virtual void get_block(void** data,size_type* size);
virtual void put_block(size_type count);
virtual void finish();
public:
/** Get line list.
* The returned list reference is writable, so it is possible to swap
* the list content into an external list.
* @return a reference to the data that has been loaded
*/
list<string>& linelist()
{ return *_linelist; }
 
/** Set line list.
* The default list may be reactivated by specifying default_linelist()
* as the argument to this function.
* @param linelist the list into which the data is loaded
*/
load_linelist& linelist(list<string>& linelist);
 
/** Get default line list.
* This is the list that is used if an external list has not been
* specified. It is the default value of linelist().
* @return a reference to the default line list
*/
list<string>& default_linelist()
{ return _default_linelist; }
};
 
}; /* namespace transfer */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/transfer/Makefile
New file
0,0 → 1,21
# This file is part of the RISC OS Toolkit (RTK).
# Copyright © 2003-2004 Graham Shaw.
# Distribution and use are subject to the GNU Lesser General Public License,
# a copy of which may be found in the file !RTK.Copyright.
 
CPPFLAGS = -Irtk_build:
CXXFLAGS = -mthrowback -munixlib -mpoke-function-name -Wall -W -Wno-unused -O2
 
include fixdeps:Rules/make
 
OBJ = load.o \
load_linelist.o \
save.o \
save_linelist.o
 
all: timestamp
 
timestamp: $(OBJ)
touch timestamp
 
include $(OBJ:.o=.d)
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/prog_info_dbox.cc
New file
0,0 → 1,43
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/display_field.h"
#include "rtk/desktop/prog_info_dbox.h"
 
namespace rtk {
namespace desktop {
 
prog_info_dbox::prog_info_dbox()
{
title("About this program");
close_icon(false);
 
_grid.xgap(8).ygap(8);
_grid.margin(8);
inherited::add(_grid);
}
 
prog_info_dbox::~prog_info_dbox()
{
remove();
}
 
prog_info_dbox& prog_info_dbox::add(const string& name,const string& value)
{
int ycells=_grid.ycells();
 
icon& name_icon=*new icon();
name_icon.text(name);
name_icon.xbaseline(xbaseline_right);
 
display_field& value_icon=*new display_field();
value_icon.text(value);
 
_grid.add(name_icon,0,ycells).add(value_icon,1,ycells);
return *this;
}
 
}; /* namespace desktop */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/virtual_column_layout.cc
New file
0,0 → 1,249
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include <algorithm>
#include <functional>
 
#include "rtk/util/divider.h"
#include "rtk/graphics/gcontext.h"
#include "rtk/desktop/virtual_column_layout.h"
 
namespace rtk {
namespace desktop {
 
using rtk::util::divider;
 
virtual_column_layout::virtual_column_layout(size_type ycells):
_ycells(ycells),
_ymax(ycells+1,0),
_ygap(0)
{}
 
virtual_column_layout::~virtual_column_layout()
{
remove();
}
 
box virtual_column_layout::auto_bbox() const
{
// Reset x-baseline set.
_xbs=xbaseline_set();
 
// Request min_bbox for each cell. Incorporate into x-baseline set
// and total height.
int ysize=0;
for (size_type y=0;y!=_ycells;++y)
{
box mcbbox=cell_min_bbox(y);
_xbs.add(mcbbox,cell_xbaseline(y));
ysize+=mcbbox.ysize();
}
 
// Calculate combined width.
int xsize=_xbs.xsize();
 
// Add gaps to total height.
if (_ycells) ysize+=(_ycells-1)*_ygap;
 
// Add margin to width and height.
xsize+=_margin.xsize();
ysize+=_margin.ysize();
 
// Construct minimum bounding box, with respect to top left-hand
// corner of layout.
box abbox(0,-ysize,xsize,0);
 
// Translate to external origin and return.
abbox-=external_origin(abbox,xbaseline_left,ybaseline_top);
return abbox;
}
 
box virtual_column_layout::bbox() const
{
return _bbox;
}
 
void virtual_column_layout::reformat(const point& origin,const box& pbbox)
{
// Fit bounding box to parent.
box bbox=fit(pbbox);
 
// Update origin and bounding box of this component, force redraw
// if necessary. (This must happen before reformat() is called for
// any children.)
bool moved=(origin!=this->origin())||(bbox!=this->bbox());
if (moved) force_redraw(true);
_bbox=bbox;
inherited::reformat(origin,bbox);
if (moved) force_redraw(true);
 
// Remove margin.
box ibox(_bbox-_margin);
 
// Get bounding box before adding excess.
box abbox=auto_bbox();
 
// Calculate excess.
int yexcess=_bbox.ysize()-abbox.ysize();
if (yexcess<0) yexcess=0;
int yspread=abbox.ysize();
yspread-=_margin.ysize();
if (_ycells) yspread-=(_ycells-1)*_ygap;
if (yspread<0) yspread=0;
divider ydiv(yexcess,yspread);
 
// Set maximum y-coordinate for each cell.
int ypos=ibox.ymax();
_ymax[0]=ypos;
for (size_type y=0;y!=_ycells;++y)
{
// Get minimum bounding box for cell.
box mcbbox=cell_min_bbox(y);
 
// Set maximum y-coordinate for next cell.
int ysize=mcbbox.ysize();
ypos-=ysize+ydiv(ysize);
ypos-=_ygap;
_ymax[y+1]=ypos;
}
 
// Place children.
for (size_type y=0;y!=_ycells;++y)
{
// Create y-baseline set for just this cell.
ybaseline_set ybs;
ybs.add(cell_min_bbox(y),cell_ybaseline(y));
 
// Construct bounding box for cell with respect to origin
// of layout.
box cbbox(ibox.xmin(),_ymax[y+1]+_ygap,ibox.xmax(),_ymax[y]);
 
// Calculate offset from top left-hand corner of cell to
// origin of child.
int xoffset=_xbs.offset(xbaseline_left,cell_xbaseline(y),
cbbox.xsize());
int yoffset=ybs.offset(ybaseline_bottom,cell_ybaseline(y),
cbbox.ysize());
point coffset(xoffset,yoffset);
 
// Calculate origin of cell with respect to origin of layout.
point cpos(cbbox.xminymin()+coffset);
 
// Reformat child.
cell_reformat(y,cpos,cbbox-cpos);
}
}
 
void virtual_column_layout::redraw(gcontext& context,const box& clip)
{
// Remove margin.
box ibox(_bbox-_margin);
 
// Look for the first row with a lower edge which overlaps (or is
// below) the clip box: _ymax[y0+1] + _ygap < clip.ymax().
vector<int>::iterator yf0=upper_bound(
_ymax.begin(),_ymax.end(),clip.ymax()-_ygap,greater<int>());
size_type y0=yf0-_ymax.begin();
if (y0) --y0;
 
// Look for the first row with an upper edge which is below the
// clip box: _ymax[y1] <= clip.ymin().
vector<int>::iterator yf1=lower_bound(
_ymax.begin(),_ymax.end(),clip.ymin(),greater<int>());
size_type y1=yf1-_ymax.begin();
if (y1>_ycells) y1=_ycells;
 
// Redraw children.
// For safety, use an inequality in the for loop.
for (size_type y=y0;y<y1;++y)
{
// Create y-baseline set for just this cell.
ybaseline_set ybs;
ybs.add(cell_min_bbox(y),cell_ybaseline(y));
 
// Construct bounding box for cell with respect to origin
// of layout.
box cbbox(ibox.xmin(),_ymax[y+1]+_ygap,ibox.xmax(),_ymax[y]);
 
// Calculate offset from top left-hand corner of cell to
// origin of child.
int xoffset=_xbs.offset(xbaseline_left,cell_xbaseline(y),
cbbox.xsize());
int yoffset=ybs.offset(ybaseline_bottom,cell_ybaseline(y),
cbbox.ysize());
point coffset(xoffset,yoffset);
 
// Calculate origin of cell with respect to origin of layout.
point cpos(cbbox.xminymin()+coffset);
 
// Redraw cell.
context+=cpos;
cell_redraw(y,context,clip-cpos);
context-=cpos;
}
inherited::redraw(context,clip);
}
 
virtual_column_layout& virtual_column_layout::cells(size_type ycells)
{
_ycells=ycells;
_ymax.resize(ycells+1,0);
invalidate();
return *this;
}
 
virtual_column_layout& virtual_column_layout::ygap(int ygap)
{
_ygap=ygap;
invalidate();
return *this;
}
 
virtual_column_layout& virtual_column_layout::margin(const box& margin)
{
_margin=margin;
invalidate();
return *this;
}
 
virtual_column_layout& virtual_column_layout::margin(int margin)
{
_margin=box(-margin,-margin,margin,margin);
invalidate();
return *this;
}
 
virtual_column_layout::xbaseline_type virtual_column_layout::cell_xbaseline(
size_type y) const
{
return xbaseline_text;
}
 
virtual_column_layout::ybaseline_type virtual_column_layout::cell_ybaseline(
size_type y) const
{
return ybaseline_text;
}
 
void virtual_column_layout::cell_reformat(size_type y,const point& origin,
const box &bbox)
{}
 
virtual_column_layout::size_type virtual_column_layout::find_y(const point& p)
{
// Look for the first cell with a top edge which is below the point:
// _ymax[x] <= p.x().
vector<int>::const_iterator yf=
lower_bound(_ymax.begin(),_ymax.end(),p.y(),greater<int>());
if (yf==_ymax.begin()) return npos;
size_type y=(yf-_ymax.begin())-1;
 
// Return npos if point outside cell limits, otherwise return y.
if ((p.y()>=_ymax[y])||(p.y()<_ymax[y+1]+_ygap)) return npos;
return y;
}
 
}; /* namespace desktop */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/menu.cc
New file
0,0 → 1,373
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include <algorithm>
 
#include "rtk/swi/wimp.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/window.h"
#include "rtk/desktop/menu_item.h"
#include "rtk/desktop/menu.h"
#include "rtk/desktop/application.h"
#include "rtk/events/wimp.h"
#include "rtk/events/mouse_click.h"
#include "rtk/events/message.h"
#include "rtk/events/menusdeleted.h"
 
namespace rtk {
namespace desktop {
 
menu::menu():
_mdata(0),
_opened(false),
_auto_reopen(true),
_tf_colour(7),
_tb_colour(2),
_wf_colour(7),
_wb_colour(0),
_height(44),
_gap(0),
_title(0),
_titlesize(0)
{}
 
menu::~menu()
{
for (vector<menu_item*>::iterator i=_items.begin();i!=_items.end();++i)
{
if (menu_item* c=*i) c->remove();
}
remove();
uncreate();
}
 
box menu::min_bbox() const
{
if (!size_valid()) resize();
return _min_bbox;
}
 
void menu::resize() const
{
int xsize=16;
int ysize=0;
if (_title)
{
int width=0;
os::Wimp_TextOp1(_title,0,&width);
xsize+=width;
}
for (vector<menu_item*>::const_iterator i=_items.begin();
i!=_items.end();++i)
{
if (i!=_items.begin()) ysize+=_gap;
ysize+=_height;
if (menu_item* c=*i)
{
c->resize();
xsize=max(xsize,c->min_bbox().xsize());
if (c->separator()) ysize+=24;
}
}
box mbbox(0,0,xsize,ysize);
mbbox-=external_origin(mbbox,xbaseline_left,ybaseline_top);
_min_bbox=mbbox;
inherited::resize();
}
 
void menu::reformat(const point& origin,const box& pbbox)
{
inherited::reformat(origin,pbbox);
}
 
void menu::reformat(const point& origin,const box& pbbox,size_type level)
{
inherited::reformat(origin,pbbox);
create();
if (!_opened)
{
point p=pbbox.xminymax();
application* app=parent_application(p);
if (!level) os::Wimp_CreateMenu(&**_mdata,p);
else os::Wimp_CreateSubMenu(&**_mdata,p);
if (app) app->register_menu_data(_mdata,level);
_opened=true;
}
}
 
void menu::unformat()
{
for (vector<menu_item*>::const_iterator i=_items.begin();
i!=_items.end();++i)
{
if (menu_item* c=*i) c->unformat();
}
_opened=false;
inherited::unformat();
}
 
void menu::remove_notify(component& c)
{
vector<menu_item*>::iterator f=
std::find(_items.begin(),_items.end(),&c);
if (f!=_items.end())
{
*f=0;
invalidate();
}
}
 
menu& menu::cells(size_type ycells)
{
for (size_type i=min(ycells,_items.size());i!=_items.size();++i)
if (menu_item* mi=_items[i]) mi->remove();
_items.resize(ycells,0);
invalidate();
return *this;
}
 
menu& menu::add(menu_item& item,size_type y)
{
if (y==npos) y=_items.size();
if (y>=_items.size()) cells(y+1);
if (_items[y]) _items[y]->remove();
_items[y]=&item;
link_child(item);
invalidate();
return *this;
}
 
menu& menu::title(const string& value,size_type capacity)
{
size_type length=value.length();
if (capacity<length) capacity=length;
if (capacity>_titlesize)
{
delete[] _title;
_title=0;
_titlesize=0;
_title=new char[capacity+1];
_titlesize=capacity;
}
if (_title)
{
size_type i=value.copy(_title,_titlesize);
_title[i]=0;
}
invalidate();
return *this;
}
 
menu& menu::auto_reopen(bool value)
{
_auto_reopen=value;
invalidate();
return *this;
}
 
menu& menu::tf_colour(int tf_colour)
{
_tf_colour=tf_colour;
invalidate();
return *this;
}
 
menu& menu::tb_colour(int tb_colour)
{
_tb_colour=tb_colour;
invalidate();
return *this;
}
 
menu& menu::wf_colour(int wf_colour)
{
_wf_colour=wf_colour;
invalidate();
return *this;
}
 
menu& menu::wb_colour(int wb_colour)
{
_wb_colour=wb_colour;
invalidate();
return *this;
}
 
void menu::create()
{
// Calculate required size in words.
unsigned int count=_items.size();
if (count==0) count=1;
unsigned int size=7+6*count;
 
// If required size!=current size then replace with new menu data.
if ((!_mdata)||(_mdata->size()!=size))
{
if (_mdata)
{
_mdata->dec_count();
_mdata=0;
}
_mdata=new menu_data(size);
_mdata->inc_count();
}
 
(*_mdata)->title.pointer[0]=_title;
(*_mdata)->title.pointer[1]=0;
(*_mdata)->title.word[2]=_titlesize;
(*_mdata)->tf_colour=_tf_colour;
(*_mdata)->tb_colour=_tb_colour;
(*_mdata)->wf_colour=_wf_colour;
(*_mdata)->wb_colour=_wb_colour;
 
(*_mdata)->width=min_bbox().xsize();
(*_mdata)->height=_height;
(*_mdata)->gap=_gap;
int index=0;
vector<menu_item*>::iterator i=_items.begin();
while (i!=_items.end())
{
(*_mdata)->item[index].mflags=(*i)->menu_flags();
(*_mdata)->item[index].submenu=(*i)->dummy_submenu_handle();
(*_mdata)->item[index].iflags=(*i)->icon_flags();
(*_mdata)->item[index].icon=(*i)->icon_data();
++index;
++i;
}
if (index==0)
{
(*_mdata)->item[0].mflags=0;
(*_mdata)->item[0].submenu=-1;
(*_mdata)->item[0].iflags=0;
index++;
}
(*_mdata)->item[0].mflags|=0x100;
(*_mdata)->item[index-1].mflags|=0x80;
}
 
void menu::uncreate()
{
// Do we need to ensure that it has been closed?
_opened=false;
if (_mdata)
{
_mdata->dec_count();
_mdata=0;
}
}
 
int menu::handle() const
{
return (_mdata)?(int)(&**_mdata):0;
}
 
void menu::reopen()
{
_opened=false;
invalidate();
}
 
void menu::show(const events::mouse_click& ev)
{
// Translate pointer location from coordinate space of target
// to coordinate space of screen.
component* target=ev.target();
point p=ev.position();
application* app=target->parent_application(p);
point offset=min_bbox().xminymax();
 
if ((dynamic_cast<icon*>(target))&&
(dynamic_cast<application*>(target->parent())))
{
// If target is an icon on the icon bar then open menu so that
// its bottom left-hand corner is 64 OS units to the left of
// the pointer and 96 OS units above the bottom of the screen
// (as specified in the style guide).
if (app)
app->add(*this,point(p.x()-64,96+min_bbox().ysize())-offset);
}
else
{
// In any other case, open menu so that its top left-hand
// corner is 64 OS units to the left of the pointer and the
// top of the first menu item is aligned with the pointer
// (as specified in the style guide).
if (app)
app->add(*this,point(p.x()-64,p.y())-offset);
}
}
 
void menu::deliver_wimp_block(int wimpcode,os::wimp_block &wimpblock,
unsigned int level)
{
switch (wimpcode)
{
case 9:
{
unsigned int index=wimpblock.word[level];
if ((index<_items.size())&&_items[index])
_items[index]->deliver_wimp_block(wimpcode,wimpblock,level);
}
break;
case 17:
case 18:
deliver_message(wimpcode,wimpblock,level);
break;
default:
{
events::wimp ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
}
}
 
void menu::deliver_message(int wimpcode,os::wimp_block &wimpblock,
unsigned int level)
{
switch (wimpblock.word[4])
{
case swi::Message_MenuWarning:
{
unsigned int index=wimpblock.word[8+level];
if (index<_items.size())
{
_items[index]->deliver_wimp_block(wimpcode,
wimpblock,level);
// The menu tree must be updated as submenu handles
// become known, so that it can be re-opened correctly
// if the user clicks with adjust.
(*_mdata)->item[index].submenu=
_items[index]->submenu_handle();
}
}
break;
case swi::Message_MenusDeleted:
{
events::menusdeleted ev(*this);
ev.post();
}
break;
default:
{
events::message ev(*this,wimpcode,wimpblock);
ev.post();
}
break;
}
}
 
menu::menu_data::menu_data(unsigned int size):
_size(size),
_data(new int[_size])
{}
 
menu::menu_data::~menu_data()
{
delete[] _data;
}
 
}; /* namespace desktop */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/component.h
New file
0,0 → 1,650
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003-2004 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_DESKTOP_COMPONENT
#define _RTK_DESKTOP_COMPONENT
 
#include <string>
 
#include "rtk/graphics/point.h"
#include "rtk/graphics/box.h"
 
namespace rtk {
namespace graphics {
 
class gcontext;
 
}; /* namespace graphics */
 
namespace os {
 
struct sprite_area;
 
}; /* namespace sprite_area */
 
namespace events {
 
class mouse_click;
 
}; /* namespace events */
 
namespace desktop {
 
class basic_window;
class application;
class menu;
 
using rtk::graphics::point;
using rtk::graphics::box;
using rtk::graphics::gcontext;
 
/** An abstract class from which all RTK desktop components are derived.
* A component can have a parent and a location with respect to that
* parent. It can also be reformatted and redrawn.
*
* Some types of component correspond directly to RISC OS windows, icons
* or menus. Other make themselves visible by means of the redraw
* mechanism, or have no visible effect themselves and exist only to
* control the position of other components.
*
* In order to avoid unnecessary work, component layout is postponed until
* the end of each iteration of the main polling loop. Layout occurs in
* two stages: resizing (to determine the minimum amount of space that the
* component needs) and reformatting (to fit it into the possibly greater
* amount of space that is available).
*
* Not all components are visited during a given instance of the layout
* process. If it is apparent that nothing has changed since the
* previous iteration then a component can be omitted by its parent.
* A component indicates that it wishes to be visited by invalidating
* itself.
*
* Coordinates are normally specified in OS units with respect to the
* origin of the component in question. Each component declares what
* its origin represents with respect to a set of pre-defined baselines.
* Components that use the same baseline are aligned with each other
* when placed in a row or column. It is possible to switch between
* baselines to change how a component is aligned.
*
* Communication between components is performed using events. An event
* can originate from the Wimp, or it can be internally generated by
* this library, or it can be application-specific. In all cases an
* event is associated with a particular target, which is usually the
* lowest point in the component heirarchy which can be said to have
* contained it. The event is then passed upwards, and can be handled
* by any or all of the target component and its ancestors.
*/
class component
{
public:
/** An enumeration for specifying a vertical baseline type. */
enum xbaseline_type
{
/** A vertical baseline aligned with the left of the component. */
xbaseline_left,
/** A vertical baseline aligned with the right of the component. */
xbaseline_right,
/** A vertical baseline aligned with the centre of the component. */
xbaseline_centre,
/** A vertical baseline for use by Latin, Greek or Cyrillic text. */
xbaseline_text
};
/** An enumeration for specifying a horizontal baseline type. */
enum ybaseline_type
{
/** A horizontal baseline aligned with the bottom of the component. */
ybaseline_bottom,
/** A horizontal baseline aligned with the top of the component. */
ybaseline_top,
/** A horizontal baseline aligned with the centre of the component. */
ybaseline_centre,
/** A horizontal baseline for use by Latin, Greek or Cyrillic text. */
ybaseline_text
};
enum
{
/** The number of allowed vertical baseline types. */
xbaseline_max=xbaseline_centre+1,
/** The number of allowed horizontal baseline types. */
ybaseline_max=ybaseline_centre+1
};
class xbaseline_set;
class ybaseline_set;
private:
/** The parent pointer. */
component* _parent;
 
/** The origin of this component, with respect to its parent. */
point _origin;
 
/** The vertical baseline of this component. */
xbaseline_type _xbaseline:8;
 
/** The horizontal baseline of this component. */
ybaseline_type _ybaseline:8;
 
/** The size-valid flag.
* True if resize() has been called since the last time this
* component or any of its descendants was invalidated, otherwise
* false.
*/
mutable bool _size_valid:1;
 
/** The layout-valid flag.
* True if reformat() has been called since the last time this
* component or any of its descendants was invalidated, otherwise
* false. (Must be false if _size_valid is false.)
*/
bool _layout_valid:1;
 
/** The no-redirect flag.
* True if it has been determined that this object does not support
* event redirection, otherwise false.
* (This flag defaults to false. It is changed to true if and when
* a dynamic cast to component::redirect fails.)
*/
mutable bool _no_redirect:1;
 
/** The redraw-forced flag.
* True if a redraw has been forced for the whole of this component
* and no part of it has been redrawn.
*/
bool _forced_redraw:1;
 
/** The horizontal fit-to-parent flag.
* If true, and if the component is capable of doing so, the bounding
* box should expand horizontally to fill the space available.
*/
bool _xfit:1;
 
/** The vertical fit-to-parent flag.
* If true, and if the component is capable of doing so, the bounding
* box should expand vertically to fill the space available.
*/
bool _yfit:1;
 
/** The horizontal fit-to-content flag.
* This flag is provided for use by sizeable_component. It is
* declared here so that it can be stored as part of a larger
* set of bitfields, thereby reducing memory usage.
* If true then the x-component of the minimum bounding box is
* calculated automatically using auto_bbox().
*/
bool _xauto:1;
 
/** The vertical fit-to-content flag.
* This flag is provided for use by sizeable_component. It is
* declared here so that it can be stored as part of a larger
* set of bitfields, thereby reducing memory usage.
* If true then the y-component of the minimum bounding box is
* calculated automatically using auto_bbox().
*/
bool _yauto:1;
public:
/** Construct component.
* @param origin the initial origin of the component, with respect
* to its parent
*/
component(const point& origin=point());
 
/** Destroy component. */
virtual ~component();
 
/** Get parent.
* @return the parent of this component if it has one, otherwise 0
*/
component* parent() const
{ return _parent; }
 
/** Get parent after redirection.
* @return the parent of this component, after redirection and if it
* has one, otherwise 0
*/
inline component* redirected_parent() const
{ return (_no_redirect)?_parent:_redirected_parent(); }
 
/** Get the window that owns the work area for this component.
* @return the window if there is one, otherwise 0
*/
basic_window* parent_work_area() const;
 
/** Get the window that owns the work area for this component.
* Additionally, translate the point p from the coordinate space
* of this component to that of the work area (or the desktop if
* no work area is found).
* @param p the point to be translated
* @return the window if there is one, otherwise 0
*/
basic_window* parent_work_area(point& p) const;
 
/** Get the application from which this component is descended.
* If this component is an application then return this.
* @return the application if there is one, otherwise 0
*/
application* parent_application();
 
/** Get the application from which this component is descended.
* Additionally, translate the point p from the coordinate space
* of this component to that of the desktop.
* If this component is an application then return this.
* @param p the point to be translated
* @return the application if there is one, otherwise 0
*/
application* parent_application(point& p);
 
/** Determine whether this component is a window.
* This function is equivalent to dynamic_cast<window*>, but probably
* much faster to execute.
* @return this if component is a window, otherwise 0
*/
virtual basic_window* as_window();
 
/** Determine whether this component is an application.
* This function is equivalent to dynamic_cast<application*>, but
* probably much faster to execute.
* @return this if component is an application, otherwise 0
*/
virtual application* as_application();
 
/** Find child at given position.
* If this function is not overridden then it will return 0, which
* is the correct behaviour for a component with no children.
* @param p the position at which to look, with respect to the
* origin of this component
* @return the child at that position if there is one, otherwise 0
*/
virtual component* find(const point& p) const;
 
/** Remove this component from its parent.
* If this component has no parent then no action is taken.
*/
void remove();
 
/** Get vertical baseline.
* The origin of a component must lie on one of the allowed
* vertical baselines. This function indicates which one.
* @return the vertical baseline
*/
xbaseline_type xbaseline() const
{ return _xbaseline; }
 
/** Get horizontal baseline.
* The origin of a component must lie on one of the allowed
* horizontal baselines. This function indicates which one.
* @return the horizontal baseline
*/
ybaseline_type ybaseline() const
{ return _ybaseline; }
 
/** Set vertical baseline.
* The origin of a component can be switched from one vertical
* baseline to another. Doing so may affect how it is aligned
* with respect to other components.
*/
void xbaseline(xbaseline_type xbaseline);
 
/** Set horizontal baseline.
* The origin of a component can be switched from one horizontal
* baseline to another. Doing so may affect how it is aligned
* with respect to other components.
*/
void ybaseline(ybaseline_type ybaseline);
 
/** Get horizontal fit-to-parent flag.
* If true, and if the component is capable of doing so, the bounding
* box should expand horizontally to fill the space available.
* @return the horizontal fit-to-parent flag
*/
bool xfit() const
{ return _xfit; }
 
/** Get vertical fit-to-parent flag.
* If true, and if the component is capable of doing so, the bounding
* box should expand vertically to fill the space available.
* @return the vertical fit-to-parent flag
*/
bool yfit() const
{ return _yfit; }
 
/** Set horizontal fit-to-parent flag.
* If true, and if the component is capable of doing so, the bounding
* box should expand horizontally to fill the space available.
* @param xfit the required horizontal fit-to-parent flag
*/
void xfit(bool xfit);
 
/** Set vertical fit-to-parent flag.
* If true, and if the component is capable of doing so, the bounding
* box should expand vertically to fill the space available.
* @param yfit the required vertical fit-to-parent flag
*/
void yfit(bool yfit);
 
/** Get origin.
* @return the origin of this component, with respect to the origin
* of its parent
*/
const point& origin() const
{ return _origin; }
 
/** Set origin.
* For this to have a useful effect the parent must allow its
* children to move freely. (Most types of parent do not, and
* will immediately countermand an instruction to change the
* position of a child.)
* @param origin the required origin of this component, with
* respect to the origin of its parent
* @param suppress_redraw true to prevent this function from
* causing a redraw, otherwise false
*/
component& origin(const point& origin,bool suppress_redraw=false);
 
/** Get current bounding box.
* If this function is not overridden then it will return the
* same value as min_bbox(), which is the correct behaviour if
* the component does not expand to fill the space available.
* @return the current bounding box of this component with respect
* to its origin
*/
virtual box bbox() const;
 
/** Get minimum bounding box.
* This is the smallest bounding box into which the component will fit.
* The result should be cached if the cost of recalculation is high.
* It must take account of the current values of xbaseline() and
* ybaseline(). In some cases this function will ensure that
* size_valid() is true, but it is not required to, and min_bbox()
* should not be used in place of an explicit call to resize().
* @return the minimum bounding box with respect to the origin
*/
virtual box min_bbox() const=0;
 
/** Determine whether the size of this component is valid.
* The size is valid if resize() has been called since the last
* time this component or any of its descendants was invalidated.
* Note that the underlying instance variable inspected by this
* function is mutable.
* @return true if size valid, otherwise false
*/
bool size_valid() const
{ return _size_valid; }
 
/** Determine whether the layout of this component is valid.
* The layout is valid if reformat() has been called since the
* last time this component or any of its descendants was
* invalidated.
* @return true if layout valid, otherwise false
*/
bool layout_valid() const
{ return _layout_valid; }
 
/** Invalidate this component and its ancestors.
* Invalidating a component ensures that resize() and reformat()
* will be called before the application next calls Wimp_Poll.
* A component must invalidate itself if its minimum bounding
* box has changed. It may invalidate itself if it would like
* reformat() to be called for other reasons.
*/
void invalidate();
 
/** Resize component.
* This function should be called when size_valid() is false.
* (It is not an error to call it at other times, but there is no
* reason to do so.) It must call resize() for any children for
* which size_valid() is false, and must set size_valid() for this
* component to true. (The default implementation is to perform
* the latter action, which is the correct behaviour for a
* component with no children and no requirement to cache
* information about its size.)
*/
virtual void resize() const;
 
/** Reformat component.
* This function should be called when the required bounding
* box of the component has changed or when layout_valid() is
* false. (It is not an error to call it at other times, but
* there is no reason to do so.) It must call reformat() for
* any children for which layout_valid() is false, and must set
* layout_valid() for this component to true, and must move the
* origin to the requested location. (The default implementation
* is to perform the latter two actions, which is the correct
* behaviour for a component with no children and no requirement
* to create any RISC OS windows, icons or menus.)
*
* If a component has moved with respect to its parent then this
* function should force both its old and new bounding boxes to
* be redrawn. (It is not necessary to detect whether the parent
* has moved, because in that case the parent will already have
* forced a redraw.) The requested bounding box passed to this
* function should be no smaller than the minimum bounding box.
* @param origin the new origin of this component, with respect to
* its parent
* @param pbbox the proposed bounding box for this component, with
* respect to its own origin
*/
virtual void reformat(const point& origin,const box& pbbox);
 
/** Unformat component.
* This function should be called when a component ceases to be
* a descendent of an application object. It should delete
* (or at least hide and deregister) any RISC OS windows or
* icons that it has created.
*/
virtual void unformat();
 
/** Redraw component.
* On entry, the origin of the graphics context must be
* coincident with the origin of the component. The graphics
* context origin may be moved while within this function,
* but must be restored to its original value before returning.
* (This avoids the need to make copies of the graphics
* context, and is the reason why that argument has not been
* declared const.)
*
* It is not an error if the specified clip box lies partly
* or wholly outside the bounding box of the component,
* however components are expected to be selective about which
* children they redraw.
* @param context the graphics context within which the
* redraw should take place
* @param clip the bounding box of the region to be redrawn,
* with respect to the origin of this component
*/
virtual void redraw(gcontext& context,const box& clip);
 
/** Force redraw.
* Instruct the Wimp to redraw the area currently occupied by
* this component.
* This function should be called both before and after any
* change to either the origin or the bounding box of the
* component.
* @param suppress_window true to suppress redraw if this component
* is a window, otherwise false
*/
void force_redraw(bool suppress_window=false);
 
/** Set caret position.
* @param p the required position of the caret
* @param height the required height of the caret
* @param index the required index into string
* @todo the caret position is not set correctly if the component
* is an icon.
*/
void set_caret_position(point p,int height,int index);
 
/** Begin drag action.
* @param dbox the box to be dragged
*/
void drag_box(const box& dbox);
 
/** Begin drag sprite action.
* @param dbox the box to be dragged
* @param area the sprite area, or 0 for the wimp sprite area
* @param name the sprite name
*/
void drag_sprite(const box& dbox,os::sprite_area* area,const string& name);
protected:
/** Link parent pointer of child to this component.
* This function provides restricted access to the private function
* set_parent(). It should be called by a container component
* whenever a child is added.
* @param c the child for which this is the new parent
*/
void link_child(component& c);
 
/** Notify parent that child is about to be removed.
* This function is called by component::set_parent() immediately
* before _parent is changed. It should not be called for any other
* reason. It should be overridden by container components to remove
* the child from whatever data structure(s) that container uses to
* track its children. It does not normally need to do anything to
* the child, because the required actions should already be in hand.
* The default behavior is to do nothing.
* @param c the child about to be removed
*/
virtual void remove_notify(component& c);
 
/** Notify component that its baselines may have been changed.
* The default behaviour is to add the specified offset to the origin
* of the component, so that its absolute position remains fixed even
* though its baselines have changed. If a component records other
* information (such as its bounding box) that is not automatically
* recalculated by reformat() then this should be modified too.
* @param offset the positional offset from the old baselines to the
* new baselines
*/
virtual void baseline_notify(const point& offset);
 
bool xauto() const
{ return _xauto; }
 
bool yauto() const
{ return _yauto; }
 
void set_xauto(bool xauto)
{ _xauto=xauto; }
 
void set_yauto(bool yauto)
{ _yauto=yauto; }
 
/** Get location of internal origin with respect to external origin.
* This function can be used, in conjunction with external_origin(),
* to establish an internal origin which is permanently fixed to a
* given pair of baselines.
* @param bbox the bounding box with respect to the internal origin
* @param ixbaseline the internal vertical baseline
* @param iybaseline the internal horizontal baseline
* @return the internal origin with respect to the external origin
*/
point internal_origin(const box& bbox,xbaseline_type ixbaseline,
ybaseline_type iybaseline) const;
 
/** Get location of external origin with respect to internal origin.
* This function can be used, in conjunction with internal_origin(),
* to establish an internal origin which is permanently fixed to a
* given pair of baselines.
* @param bbox the bounding box with respect to the internal origin
* @param ixbaseline the internal vertical baseline
* @param iybaseline the internal horizontal baseline
* @return the external origin with respect to the internal origin
*/
point external_origin(const box& bbox,xbaseline_type ixbaseline,
ybaseline_type iybaseline) const;
 
box fit(const box& pbbox) const;
private:
/** Set the parent of this component.
* This function is called when one component takes owenership of
* another.
* @param p the required parent
* @param mc true if the child is being linked as a menu or dialogue
* box, otherwise false
* @postcondition parent()==p
*/
void set_parent(component* p);
 
/** Get parent after redirection.
* This is a non-optimised version of redirected_parent(), for use
* by that function when _no_redirect is false.
*/
component* _redirected_parent() const;
};
 
/** A class for representing the relationship between a set of
* vertical baselines.
*/
class component::xbaseline_set
{
private:
/** The minimum x-coordinate with respect to xbaseline_text. */
int _xmin;
/** The maximum x-coordinate with respect to xbaseline_text. */
int _xmax;
/** The maximum width for xbaseline_left, right or centre. */
int _xsize;
public:
/** Construct vertical baseline set. */
xbaseline_set();
/** Add component to baseline set.
* The baselines are moved as necessary to accommodate the component.
* @param bbox the bounding box of the component
* @param xbaseline the vertical baseline of the component
* @return a reference to this
*/
xbaseline_set& add(const box& bbox,xbaseline_type xbaseline);
/** Get offset between two baselines.
* @param src_xbaseline the source baseline
* @param dst_xbaseline the destination baseline
* @param xsize an optional width to be filled by the baseline set
* @return the offset from the source to the destination.
*/
int offset(xbaseline_type src_xbaseline,xbaseline_type dst_xbaseline,
int xsize=0) const;
/** Get minimum width.
* This is the minimum width required to accommodate the baseline set.
*/
int xsize() const;
};
 
/** A class for representing the relationship between a set of
* horizontal baselines.
*/
class component::ybaseline_set
{
private:
/** The minimum y-coordinate with respect to ybaseline_text. */
int _ymin;
/** The maximum y-coordinate with respect to ybaseline_text. */
int _ymax;
/** The maximum width for ybaseline_bottom, top or centre. */
int _ysize;
public:
/** Construct horizontal baseline set. */
ybaseline_set();
/** Add component to baseline set.
* The baselines are moved as necessary to accommodate the component.
* @param bbox the bounding box of the component
* @param ybaseline the horizontal baseline of the component
* @return a reference to this
*/
ybaseline_set& add(const box& bbox,ybaseline_type ybaseline);
/** Get offset between two baselines.
* @param src_ybaseline the source baseline
* @param dst_ybaseline the destination baseline
* @param ysize an optional height to be filled by the baseline set
* @return the offset from the source to the destination.
*/
int offset(ybaseline_type src_ybaseline,ybaseline_type dst_ybaseline,
int ysize=0) const;
/** Get minimum height.
* This is the minimum height required to accommodate the baseline set.
*/
int ysize() const;
};
 
}; /* namespace desktop */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/row_layout.h
New file
0,0 → 1,135
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_DESKTOP_ROW_LAYOUT
#define _RTK_DESKTOP_ROW_LAYOUT
 
#include <vector>
 
#include "rtk/desktop/sizeable_component.h"
 
namespace rtk {
namespace desktop {
 
/** A layout class for arranging components in a row.
* It is possible to specify the gap to be placed between cells and the
* margin to be placed around the layout as a whole. Cells that share
* the same horizontal baseline are aligned with each other. The layout
* will expand to fill any extra space made available to it. Note that
* the algorithm used to do this is implementation-dependent, so may
* change in future versions of this library.
*/
class row_layout:
public sizeable_component
{
private:
/** The class from which this one is derived. */
typedef sizeable_component inherited;
public:
/** A type for representing cell counts or indices. */
typedef unsigned int size_type;
 
/** A null value for use in place of a cell index. */
static const size_type npos=static_cast<size_type>(-1);
private:
/** Vector containing child pointer for each cell. */
vector<component*> _components;
 
/** Vector containing position of left edge of each cell with
* respect to origin of layout. The position of the right edge
* is obtained by subtracting _xgap from the left edge of the
* following cell. A hypothetical value for _xmin[xcells()] is
* included in the vector so that the position of the right edge
* of the last cell can be determined. */
vector<int> _xmin;
 
/** The cached y-baseline set for the layout. */
mutable ybaseline_set _ybs;
 
/** The size of gap to be placed between cells. */
int _xgap;
 
/** The margin to be placed around the whole layout. */
box _margin;
 
/** The current bounding box. */
box _bbox;
public:
/** Construct row layout.
* @param xcells the required number of cells (defaults to 0)
*/
row_layout(size_type xcells=0);
 
/** Destroy row layout. */
virtual ~row_layout();
 
virtual box auto_bbox() const;
virtual component* find(const point& p) const;
virtual box bbox() const;
virtual void resize() const;
virtual void reformat(const point& origin,const box& pbbox);
virtual void unformat();
virtual void redraw(gcontext& context,const box& clip);
protected:
virtual void remove_notify(component& c);
public:
/** Get number of cells.
* @return the number of cells
*/
size_type xcells() const
{ return _components.size(); }
 
/** Set number of cells.
* @param xcells the required number of cells
* @return a reference to this
*/
row_layout& cells(size_type xcells);
 
/** Add component to layout.
* If a component already exists at the specified position
* then it is replaced.
* @param c the component to be added
* @param x the cell index (defaults to npos, meaning new cell)
* @return a reference to this
*/
row_layout& add(component& c,size_type x=npos);
 
/** Get size of gap between cells.
* @return the size of gap between cells
*/
int xgap() const
{ return _xgap; }
 
/** Set size of gap between cells.
* @param xgap the required gap between cells
* @return a reference to this
*/
row_layout& xgap(int xgap);
 
/** Get margin around layout.
* @return a box indicating the margin width for each side of the layout
*/
box margin() const
{ return _margin; }
 
/** Set margin around layout.
* @param margin a box specifying the required margin width for each
* side of the layout
* @return a reference to this
*/
row_layout& margin(const box& margin);
 
/** Set margin around layout.
* @param margin an integer specifying the required margin width for
* all sides of the layout
* @return a reference to this
*/
row_layout& margin(int margin);
};
 
}; /* namespace desktop */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/info_dbox.cc
New file
0,0 → 1,18
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/info_dbox.h"
 
namespace rtk {
namespace desktop {
 
info_dbox::info_dbox()
{}
 
info_dbox::~info_dbox()
{}
 
}; /* namespace desktop */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/display_field.cc
New file
0,0 → 1,21
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/display_field.h"
 
namespace rtk {
namespace desktop {
 
display_field::display_field()
{
validation("R2");
border(true);
hcentre(true).vcentre(true);
fcolour(7).bcolour(1);
yfit(false);
}
 
}; /* namespace desktop */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/action_button.cc
New file
0,0 → 1,22
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/action_button.h"
 
namespace rtk {
namespace desktop {
 
action_button::action_button()
{
validation("R5,3");
border(true);
hcentre(true).vcentre(true);
fcolour(7).bcolour(1);
button(3);
yfit(false);
}
 
}; /* namespace desktop */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/card_layout.h
New file
0,0 → 1,80
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_DESKTOP_CARD_LAYOUT
#define _RTK_DESKTOP_CARD_LAYOUT
 
#include <map>
#include <string>
 
#include "rtk/desktop/sizeable_component.h"
 
namespace rtk {
namespace desktop {
 
/** A layout class for arranging components in a stack.
* At any given time, one component is visible and the remainder are hidden.
*/
class card_layout:
public sizeable_component
{
private:
/** The class from which this one is derived. */
typedef sizeable_component inherited;
 
/** A map of child components indexed by tag. */
map<string,component*> _components;
 
/** The cached x-baseline set for the layout. */
mutable xbaseline_set _xbs;
 
/** The cached y-baseline set for the layout. */
mutable ybaseline_set _ybs;
 
/** The currently selected tag. */
string _tag;
 
/** The currently selected child, or 0 if none. */
component* _component;
 
/** The current bounding box. */
box _bbox;
public:
/** Construct card layout. */
card_layout();
 
/** Destroy card layout. */
virtual ~card_layout();
 
virtual box auto_bbox() const;
virtual component* find(const point& p) const;
virtual box bbox() const;
virtual void resize() const;
virtual void reformat(const point& origin,const box &pbbox);
virtual void unformat();
virtual void redraw(gcontext& context,const box& clip);
protected:
virtual void remove_notify(component& c);
public:
/** Add card.
* If the requested tag is already in use then the child corresponding
* to that tag is removed.
* @param c the component that will provide the card content
* @param tag the tag by which the card may be selected
* @return a reference to this
*/
card_layout& add(component& c,const string& tag);
 
/** Select card.
* @param tag the tag of the card to be selected
* @return a reference to this
*/
card_layout& select(const string& tag);
};
 
}; /* namespace desktop */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/info_dbox.h
New file
0,0 → 1,33
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_DESKTOP_INFO_DBOX
#define _RTK_DESKTOP_INFO_DBOX
 
#include "rtk/desktop/prog_info_dbox.h"
 
namespace rtk {
namespace desktop {
 
/** A class to represent a program information dialogue box.
* @deprecated This class has been replaced by prog_info_dbox.
*/
class info_dbox:
public prog_info_dbox
{
public:
/** Construct program information dialogue box.
* Initially the box is unpopulated.
*/
info_dbox();
 
/** Destroy program information dialogue box. */
virtual ~info_dbox();
};
 
}; /* namespace desktop */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/basic_window.h
New file
0,0 → 1,541
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003-2004 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_DESKTOP_BASIC_WINDOW
#define _RTK_DESKTOP_BASIC_WINDOW
 
#include <map>
#include <string>
 
#include "rtk/desktop/component.h"
#include "rtk/events/close_window.h"
 
namespace rtk {
namespace os {
 
union wimp_block;
 
}; /* namespace os */
 
namespace desktop {
 
class icon;
 
/** A class to represent a RISC OS window.
* Windows of this class by default have no window furniture. For a
* standard top-level window use the class rtk::desktop::window.
*
* A window object can have at most one child. Usually this will be
* a layout object which in turn contains further children.
*
* Coordinates:
* - The bounding box of the window corresponds to the visible area.
* - The origin and bounding box of the child correspond to the origin
* and extent of the work area. Scrolling is achieved by moving
* the origin of the child.
* - If the window has an adjust icon then the work area will expand
* automatically to cover the visible area.
* - If the window does not have an adjust icon then the visible area
* will expand automatically to cover the work area.
*/
 
class basic_window:
public component,
public events::close_window::handler
{
private:
/** The class from which this one is derived. */
typedef component inherited;
public:
/** A type for representing the size of a buffer. */
typedef unsigned int size_type;
private:
/** The child pointer. */
component* _child;
 
/** The RISC OS window handle. */
int _handle;
 
/** A map from icon handles to icon components.
* All descendant icons that currently have a RISC OS icon handle
* are included.
*/
map<int,icon*> _ihandles;
 
/** The current bounding box. */
box _bbox;
 
/** The current extent. */
box _extent;
 
/** The window created flag.
* True if a RISC OS window exists for this component, otherwise false.
*/
unsigned int _created:1;
 
/** The registered false.
* True if this window is registered with an application, otherwise false.
*/
unsigned int _registered:1;
 
/** The window opened flag.
* True if the RISC OS window is or might be open, otherwise false.
*/
unsigned int _opened:1;
 
/** The dialogue box flag.
* True if the window is a dialogue box, otherwise false.
*/
unsigned int _dbox:1;
 
/** The movable flag.
* True if this window is movable (by the user), otherwise false.
*/
unsigned int _movable:1;
 
/** The back icon flag.
* True if this window has a back icon, otherwise false.
*/
unsigned int _back_icon:1;
 
/** The close icon flag.
* True if this window has a close icon, otherwise false.
*/
unsigned int _close_icon:1;
 
/** The title bar flag.
* True if this window has a title bar, otherwise false.
*/
unsigned int _title_bar:1;
 
/** The toggle-size icon flag.
* True if this window has a toggle-size icon, otherwise false.
*/
unsigned int _toggle_icon:1;
 
/** The horizontal scroll bar flag.
* True if this window has a horizontal scroll bar, otherwise false.
*/
unsigned int _x_scroll_bar:1;
 
/** The vertical scroll bar flag.
* True if this window has a vertical scroll bar, otherwise false.
*/
unsigned int _y_scroll_bar:1;
 
/** The adjust-size icon flag.
* True if this window has an adjust-size icon, otherwise false.
*/
unsigned int _adjust_icon:1;
 
/** The border flag.
* True if this window has a border, otherwise false.
*/
unsigned int _border:1;
 
/** The button type. */
unsigned int _button:4;
 
/** The title bar foreground colour.
* This is one of the 16 standard Wimp colours.
*/
unsigned int _tf_colour:8;
 
/** The title bar background colour.
* This is one of the 16 standard Wimp colours.
*/
unsigned int _tb_colour:8;
 
/** The window foreground colour.
* This is one of the 16 standard Wimp colours.
*/
unsigned int _wf_colour:8;
 
/** The window background colour.
* This is one of the 16 standard Wimp colours.
*/
unsigned int _wb_colour:8;
 
/** The current title buffer.
* This may be null, in which case no buffer has been allocated.
*/
char* _title;
 
/** The current title buffer size.
* This is the maximum number of characters that the title buffer can
* hold, not counting the terminator.
*/
size_type _titlesize;
public:
/** Construct basic window.
* By default a basic window:
* - is not movable;
* - does not have a title bar;
* - does not have a back icon;
* - does not have a close icon;
* - does not have scroll bars;
* - does not have a toggle icon;
* - does not have an adjust icon;
* - does not have a border;
* - has a button type of 10;
* - has a title foreground colour of 7;
* - has a title background colour of 2;
* - has a work area foreground colour of 7; and
* - has a work area background colour of 1.
* @param size the required initial size
*/
basic_window(point size=point(640,512));
 
/** Destroy basic window.
*/
virtual ~basic_window();
 
virtual basic_window* as_window();
virtual component* find(const point& p) const;
virtual box bbox() const;
virtual box min_bbox() const;
virtual void resize() const;
virtual void reformat(const point& origin,const box& pbbox);
virtual void unformat();
virtual void redraw(gcontext& context,const box& clip);
protected:
void remove_notify(component& c);
void baseline_notify(const point& offset);
public:
/** Add child to window.
* If the window already has a child then it is removed.
* @param c the child to be added
*/
basic_window& add(component& c);
 
/** Reformat window as dialogue box.
* This function is used in place of reformat(point&,box&) when
* the window is to be opened as a dialogue box.
* @param origin the new origin of this component, with respect to
* its parent
* @param pbbox the proposed bounding box for this component, with
* respect to its own origin
* @param level the level within the menu heirarchy (0=top level,
* add 1 for each level down)
*/
void reformat(const point& origin,const box& pbbox,size_type level);
 
/** Get window title.
* @return the window title
*/
string title() const;
 
/** Get movable flag.
* @return true if window is movable (by the user), otherwise false
*/
bool movable() const
{ return _movable; }
 
/** Get back icon flag.
* @return true if window has a back icon, otherwise false
*/
bool back_icon() const
{ return _back_icon; }
 
/** Get close icon flag.
* @return true if window has a close icon, otherwise false
*/
bool close_icon() const
{ return _close_icon; }
 
/** Get title bar flag.
* @return true if window has a title bar, otherwise false
*/
bool title_bar() const
{ return _title_bar; }
 
/** Get toggle-size icon flag.
* @return true if window has a toggle-size icon, otherwise false
*/
bool toggle_icon() const
{ return _toggle_icon; }
 
/** Get horizontal scroll bar flag.
* @return true if window has a horizontal scroll bar, otherwise false
*/
bool x_scroll_bar() const
{ return _x_scroll_bar; }
 
/** Get vertical scroll bar flag.
* @return true if window has a vertical scroll bar, otherwise false
*/
bool y_scroll_bar() const
{ return _y_scroll_bar; }
 
/** Get adjust-size icon flag.
* @return true if window has an adjust-size icon, otherwise false
*/
bool adjust_icon() const
{ return _adjust_icon; }
 
/** Get border flag.
* @return true if window has a border, otherwise false
*/
bool border() const
{ return _border; }
 
/** Get button type.
* @return the work area button type
*/
int button() const
{ return _button; }
 
/** Get title bar background colour.
* This is one of the 16 standard Wimp colours.
* @return the title bar background colour
*/
int tb_colour() const
{ return _tb_colour; }
 
/** Get title bar foreground colour.
* This is one of the 16 standard Wimp colours.
* @return the title bar foreground colour
*/
int tf_colour() const
{ return _tf_colour; }
 
/** Get window background colour.
* This is one of the 16 standard Wimp colours.
* @return the window background colour
*/
int wb_colour() const
{ return _wb_colour; }
 
/** Get window foreground colour.
* This is one of the 16 standard Wimp colours.
* @return the window foreground colour
*/
int wf_colour() const
{ return _wf_colour; }
 
/** Set window title.
* If the title is likely to change then its capacity should be set
* to the maximum number of characters likely to be needed.
* @param title the required window title
* @param capacity the required capacity (defaults to length of
* specified window title)
* @return a reference to this
*/
basic_window& title(const string& title,size_type capacity=0);
 
/** Set movable flag.
* @param value true if the window is to be movable, otherwise false
* @return a reference to this
*/
basic_window& movable(bool value);
 
/** Set back icon flag.
* @param value true if the window is to have a back icon, otherwise
* false
* @return a reference to this
*/
basic_window& back_icon(bool value);
 
/** Set close icon flag.
* @param value true if the window is to have a close icon, otherwise
* false
* @return a reference to this
*/
basic_window& close_icon(bool value);
 
/** Set title bar flag.
* @param value true if the window is to have a title bar, otherwise
* false
* @return a reference to this
*/
basic_window& title_bar(bool value);
 
/** Set toggle-size icon flag.
* @param value true if the window is to have a toggle-size icon,
* otherwise false
* @return a reference to this
*/
basic_window& toggle_icon(bool value);
 
/** Set horizontal scroll bar flag.
* @param value true if the window is to have a horizontal scroll bar,
* otherwise false
* @return a reference to this
*/
basic_window& x_scroll_bar(bool value);
 
/** Set vertical scroll bar flag.
* @param value true if the window is to have a vertical scroll bar,
* otherwise false
* @return a reference to this
*/
basic_window& y_scroll_bar(bool value);
 
/** Set adjust-size icon flag.
* @param value true if the window is to have an adjust-size icon,
* otherwise false
* @return a reference to this
*/
basic_window& adjust_icon(bool value);
 
/** Set border flag.
* @param value true if the window is to have a border, otherwise false
* @return a reference to this
*/
basic_window& border(bool value);
 
/** Set button type.
* This must be set before the window is created by the Wimp.
* @param value the required button type
* @return a reference to this
*/
basic_window& button(int value);
 
/** Set title bar background colour.
* This is one of the 16 standard Wimp colours.
* @param colour the required title bar background colour
* @return a reference to this
*/
basic_window& tb_colour(int colour);
 
/** Set title bar foreground colour.
* This is one of the 16 standard Wimp colours.
* @param colour the required title bar foreground colour
* @return a reference to this
*/
basic_window& tf_colour(int colour);
 
/** Set window background colour.
* This is one of the 16 standard Wimp colours.
* @param colour the required window background colour
* @return a reference to this
*/
basic_window& wb_colour(int colour);
 
/** Set window foreground colour.
* This is one of the 16 standard Wimp colours.
* @param colour the required window foreground colour
* @return a reference to this
*/
basic_window& wf_colour(int colour);
 
/** Default handler for close_window events.
* If this handler remains registered then the window will close itself
* (by removing itself from the component heirarchy) when the close
* button is pressed.
* @param ev the close_window event
*/
void handle_event(events::close_window& ev);
 
/** Deliver Wimp event block.
* @internal
* The event block is converted into a suitable event object and
* posted to the appropriate target. This function should be
* used when it has been established that this window, or a child
* of this window, is the target.
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
void deliver_wimp_block(int wimpcode,os::wimp_block& wimpblock);
 
/** Deliver Wimp message.
* @internal
* The event block (which should contain a message) is converted
* into a suitable event object and posted to the appropriate target.
* This function should be used when it has been established that
* this window, or a child of this window, is the target.
* @param wimpcode the Wimp event code
* @param wimpblock the Wimp event block
*/
void deliver_message(int wimpcode,os::wimp_block& wimpblock);
 
/** Register icon for event delivery.
* @internal
* This function is called by an icon object when it is given an
* icon handle by the Wimp. The window object uses this information
* to deliver Wimp event blocks.
* @param ic the icon object to be registered.
*/
void register_icon(icon& ic);
 
/** Deregister icon for event delivery.
* @internal
* This function is called by an icon object when it releases an
* icon handle.
* @param ic the icon object to be deregistered.
*/
void deregister_icon(icon& ic);
 
/** Find icon.
* @param handle the icon handle
* @return the icon, or 0 if not found
*/
icon* find_icon(int handle) const;
 
/** Instruct Wimp to create window.
* @internal
*/
void create();
 
/** Instruct Wimp to delete window.
* @internal
*/
void uncreate();
 
/** Get window handle.
* Be aware that this class assumes that it has full control over
* any RISC OS windows that it creates. It may override, or fail to
* take account of, changes that are made directly using the window
* handle.
* @return the window handle
*/
int handle() const
{ return _handle; }
 
/** Get window flags.
* @internal
* @return window flags for use by the Wimp
*/
int window_flags() const;
 
/** Get work area flags.
* @internal
* @return work area flags for use by the Wimp
*/
int work_area_flags() const;
 
/** Get handle of window in front of this one.
* @internal
* @return the handle of the window in front of this one, or -1 if
* this window is at the top of the window stack
*/
int behind() const;
private:
/** Reformat window.
* @internal
* This function is equivalent to reformat(const point&,const box&),
* except that the required position in the window stack can (and must)
* be specified.
* @param origin the new origin of this component, with respect to
* its parent
* @param pbbox the proposed bounding box for this component, with
* respect to its own origin
* @param behind the window behind which this one should be opened,
* or -1 to open at the top of the window stack
*/
void _reformat(const point& origin,const box& pbbox,int behind);
 
/** Calculate extent.
* @internal
* @param bbox the proposed bounding box of this component
* @return the extent
*/
box calculate_extent(const box& bbox);
};
 
}; /* namespace desktop */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/save_dbox.cc
New file
0,0 → 1,288
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003-2004 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include <sstream>
#include <iomanip>
 
#include "rtk/os/exception.h"
#include "rtk/os/os.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/save_dbox.h"
#include "rtk/desktop/application.h"
#include "rtk/events/save_to_file.h"
#include "rtk/events/save_to_app.h"
#include "rtk/transfer/save.h"
 
namespace {
 
/** Choose sprite name for save dialogue.
* If no preferred sprite name is supplied then one is chosen to match
* the filetype. If the preferred or chosen sprite name does not exist
* then one of 'directory', 'applicaton' or 'file_xxx' is used instead.
* @param filetype the filetype
* @param sprname the preferred sprite name
* @return the sprite name to be used by the save dialogue
*/
string sprite_name(unsigned int filetype,const string& sprname)
{
string name(sprname);
if (!name.length())
{
if (filetype==0x1000)
{
name="directory";
}
else if (filetype==0x2000)
{
name="application";
}
else
{
ostringstream out;
out << "file_" << hex << setw(3) << filetype;
name=out.str();
}
}
try
{
rtk::os::Wimp_SpriteOp40(name.c_str(),0,0,0,0);
}
catch (rtk::os::exception& ex)
{
if (filetype==0x1000)
{
name="directory";
}
else if (filetype==0x2000)
{
name="application";
}
else
{
name="file_xxx";
}
}
return name;
}
 
}; /* anonymous namespace */
 
namespace rtk {
namespace desktop {
 
save_dbox::save_dbox():
_filetype(0xffd),
_saveop(0)
{
title("Save as");
back_icon(false);
close_icon(false);
 
_filetype_icon.sprite_name(sprite_name(_filetype,_sprname));
_filetype_icon.button(6);
_filetype_icon.xfit(false);
_filetype_icon.yfit(false);
_filetype_icon.xbaseline(xbaseline_centre);
 
_pathname_field.text("Untitled",255);
_pathname_field.validation(_pathname_field.validation()+";A~ ");
 
_cancel_button.text("Cancel");
_save_button.text("Save");
 
_selection_button.text("Selection");
_selection_button.text_and_sprite(true);
_selection_button.enabled(false);
 
_row.add(_cancel_button);
_row.add(_save_button);
_row.xgap(16);
 
_column.add(_filetype_icon,0);
_column.add(_pathname_field,1);
_column.add(_row,3);
_column.ygap(8);
_column.margin(16);
 
inherited::add(_column);
}
 
save_dbox::~save_dbox()
{
remove();
}
 
void save_dbox::handle_event(events::mouse_click& ev)
{
if ((ev.target()==&_filetype_icon)&&(ev.buttons()&0x50))
{
// Dragging filetype icon.
int flags;
os::OS_Byte161(28,&flags);
if (flags&0x02)
{
// Solid drags enabled.
_filetype_icon.drag_sprite(_filetype_icon.bbox(),
(os::sprite_area*)1,sprite_name(_filetype,_sprname));
}
else
{
// Solid drags disabled.
_filetype_icon.drag_box(_filetype_icon.bbox());
}
}
else if (ev.target()==&_save_button)
{
handle_save();
}
else if (ev.target()==&_cancel_button)
{
handle_cancel();
}
}
 
void save_dbox::handle_event(events::user_drag_box& ev)
{
component* target=this;
if (_saveop)
{
if (application* app=parent_application())
{
app->add(*_saveop);
}
target=_saveop;
}
events::save_to_app ev2(*target,leafname());
ev2.post();
}
 
void save_dbox::handle_event(events::key_pressed& ev)
{
switch (ev.code())
{
case 0x0d:
handle_save();
ev.processed(true);
break;
case 0x1b:
handle_cancel();
ev.processed(true);
break;
}
}
 
string save_dbox::pathname() const
{
return _pathname_field.text();
}
 
string save_dbox::leafname() const
{
string pathname=_pathname_field.text();
string::size_type f=pathname.rfind('.');
if (f==string::npos) f=0; else ++f;
return pathname.substr(f);
}
 
bool save_dbox::selection_button_present() const
{
return _selection_button.parent();
}
 
bool save_dbox::selection_button_enabled() const
{
return _selection_button.enabled();
}
 
bool save_dbox::selection_button_state() const
{
return _selection_button.selected();
}
 
save_dbox& save_dbox::filetype(unsigned int filetype)
{
_filetype=filetype;
_filetype_icon.sprite_name(sprite_name(_filetype,_sprname));
return *this;
}
 
save_dbox& save_dbox::spritename(const string& sprname)
{
_sprname=sprname;
_filetype_icon.sprite_name(sprite_name(_filetype,_sprname));
return *this;
}
 
save_dbox& save_dbox::pathname(const string& pathname)
{
_pathname_field.text(pathname);
return *this;
}
 
save_dbox& save_dbox::selection_button_present(bool value)
{
if (value)
{
_column.add(_selection_button,2);
}
else
{
_selection_button.remove();
}
return *this;
}
 
save_dbox& save_dbox::selection_button_enabled(bool value)
{
_selection_button.enabled(value);
return *this;
}
 
save_dbox& save_dbox::selection_button_state(bool value)
{
_selection_button.selected(value);
return *this;
}
 
save_dbox& save_dbox::attach_save(transfer::save& saveop)
{
_saveop=&saveop;
return *this;
}
 
save_dbox& save_dbox::detach_save()
{
_saveop=0;
return *this;
}
 
void save_dbox::handle_save()
{
string pathname=_pathname_field.text();
string::size_type f=pathname.find_first_of(".:<");
if (f!=string::npos)
{
component* target=_saveop;
if (!target) target=this;
events::save_to_file ev(*target,_pathname_field.text(),
_selection_button.selected());
ev.post();
}
else
{
application* app=parent_application();
const char* message="To save, drag the icon to a directory display";
const char* title=(app)?app->name().c_str():"Unknown";
os::Wimp_ReportError(0,message,title,0,0);
}
}
 
void save_dbox::handle_cancel()
{
remove();
}
 
}; /* namespace desktop */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/absolute_layout.cc
New file
0,0 → 1,200
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include <algorithm>
 
#include "rtk/graphics/gcontext.h"
#include "rtk/desktop/absolute_layout.h"
 
namespace rtk {
namespace desktop {
 
absolute_layout::absolute_layout()
{
xbaseline(xbaseline_left);
ybaseline(ybaseline_top);
}
 
absolute_layout::~absolute_layout()
{
while (_components.size())
_components.back()->remove();
remove();
}
 
box absolute_layout::auto_bbox() const
{
box abbox;
vector<component*>::const_iterator i=_components.begin();
if (i!=_components.end())
{
component* c=*i++;
abbox=(c->min_bbox()+c->origin());
}
while (i!=_components.end())
{
component* c=*i++;
abbox|=(c->min_bbox()+c->origin());
}
 
// Add margin.
abbox|=_margin;
 
// Ensure that bounding box is compatible with baselines.
switch (xbaseline())
{
case xbaseline_left:
abbox.xmin(0);
break;
case xbaseline_right:
abbox.xmax(0);
break;
case xbaseline_centre:
{
int xsize=max(-abbox.xmin(),abbox.xmax());
abbox.xmin(-xsize);
abbox.xmax(xsize);
}
break;
default:
/* no action. */
break;
}
switch (ybaseline())
{
case ybaseline_top:
abbox.ymax(0);
break;
case ybaseline_bottom:
abbox.ymin(0);
break;
case ybaseline_centre:
{
int ysize=max(-abbox.ymin(),abbox.ymax());
abbox.ymin(-ysize);
abbox.ymax(ysize);
}
break;
default:
/* no action. */
break;
}
 
return abbox;
}
 
component* absolute_layout::find(const point& p) const
{
for (vector<component*>::const_iterator i=_components.begin();
i!=_components.end();++i)
{
component* c=*i;
if (p<=c->bbox()+c->origin()) return c;
}
return 0;
}
 
box absolute_layout::bbox() const
{
return _bbox;
}
 
void absolute_layout::resize() const
{
for (vector<component*>::const_iterator i=_components.begin();
i!=_components.end();++i)
{
component* c=*i;
c->resize();
}
inherited::resize();
}
 
void absolute_layout::reformat(const point& origin,const box& pbbox)
{
// Fit bounding box to parent.
box bbox=fit(pbbox);
 
// Update origin and bounding box of this component, force redraw
// if necessary. (This must happen before reformat() is called for
// any children.)
bool moved=(origin!=this->origin())||(bbox!=this->bbox());
if (moved) force_redraw(true);
_bbox=bbox;
inherited::reformat(origin,bbox);
if (moved) force_redraw(true);
 
// Place children.
for (vector<component*>::const_iterator i=_components.begin();
i!=_components.end();++i)
{
component* c=*i;
c->reformat(c->origin(),c->min_bbox());
}
}
 
void absolute_layout::unformat()
{
for (vector<component*>::iterator i=_components.begin();
i!=_components.end();++i)
{
component* c=*i;
c->unformat();
}
}
 
void absolute_layout::redraw(gcontext& context,const box& clip)
{
for (vector<component*>::iterator i=_components.begin();
i!=_components.end();++i)
{
if (component* c=*i)
{
point cpos=c->origin();
context+=cpos;
c->redraw(context,clip-cpos);
context-=cpos;
}
}
inherited::redraw(context,clip);
}
 
void absolute_layout::remove_notify(component& c)
{
vector<component*>::iterator f=
std::find(_components.begin(),_components.end(),&c);
if (f!=_components.end())
{
_components.erase(f);
invalidate();
}
}
 
absolute_layout& absolute_layout::add(component& c,const point& p)
{
c.remove();
c.origin(p);
_components.push_back(&c);
link_child(c);
invalidate();
return *this;
}
 
absolute_layout& absolute_layout::margin(const box& margin)
{
_margin=margin;
invalidate();
return *this;
}
 
absolute_layout& absolute_layout::margin(int margin)
{
_margin=box(-margin,-margin,margin,margin);
invalidate();
return *this;
}
 
}; /* namespace desktop */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/virtual_row_layout.h
New file
0,0 → 1,171
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_DESKTOP_VIRTUAL_ROW_LAYOUT
#define _RTK_DESKTOP_VIRTUAL_ROW_LAYOUT
 
#include <vector>
 
#include "rtk/desktop/sizeable_component.h"
 
namespace rtk {
namespace desktop {
 
/** A layout class for arranging cells in a row.
* This class produces the same visual appearance as a row_layout,
* without the need for the members of the row to exist as components.
*/
class virtual_row_layout:
public sizeable_component
{
private:
/** The class from which this one is derived. */
typedef sizeable_component inherited;
public:
/** A type for representing cell counts or indices. */
typedef unsigned int size_type;
 
/** A null value for use in place of a cell index. */
static const size_type npos=static_cast<size_type>(-1);
private:
/** The number of cells. */
size_type _xcells;
 
/** A vector containing the position of the left edge of each cell
* with respect to origin of layout. The position of the right
* edge is obtained by subtracting _xgap from the left edge of the
* following cell. A hypothetical value for _xmin[xcells()] is
* included in the vector so that the position of the right edge
* of the last cell can be determined. */
vector<int> _xmin;
 
/** The cached y-baseline set for the layout. */
mutable ybaseline_set _ybs;
 
/** The size of gap to be placed between cells. */
int _xgap;
 
/** The margin to be placed around the whole layout. */
box _margin;
 
/** The current bounding box. */
box _bbox;
public:
/** Construct virtual row layout.
* @param xcells the required number of cells (defaults to 0)
*/
virtual_row_layout(size_type xcells=0);
 
/** Destroy virtual row layout. */
virtual ~virtual_row_layout();
 
virtual box auto_bbox() const;
virtual box bbox() const;
virtual void reformat(const point& origin,const box& pbbox);
virtual void redraw(gcontext& context,const box& clip);
public:
/** Get number of cells.
* @return the number of cells
*/
size_type xcells() const
{ return _xcells; }
 
/** Set number of cells.
* @param xcells the required number of cells
* @return a reference to this
*/
virtual_row_layout& cells(size_type xcells);
 
/** Get size of gap between cells.
* @return the size of gap between cells
*/
int xgap() const
{ return _xgap; }
 
/** Set size of gap between cells.
* @param xgap the required gap between cells
* @return a reference to this
*/
virtual_row_layout& xgap(int xgap);
 
/** Get margin around layout.
* @return a box indicating the margin width for each side of the layout
*/
box margin() const
{ return _margin; }
 
/** Set margin around layout.
* @param margin a box specifying the required margin width for each
* side of the layout
* @return a reference to this
*/
virtual_row_layout& margin(const box& margin);
 
/** Set margin around layout.
* @param margin an integer specifying the required margin width for
* all sides of the layout
* @return a reference to this
*/
virtual_row_layout& margin(int margin);
 
/** Get minimum bounding box for cell.
* This function is equivalent to get_bbox() but acts on a virtual
* child instead of a real component.
* @param x the x-index of the cell
*/
virtual box cell_min_bbox(size_type x) const=0;
 
/** Get vertical baseline for cell.
* This function is equivalent to xbaseline() but acts on a virtual
* child instead of a real component. By default it returns
* xbaseline_text.
* @param x the x-index of the cell
*/
virtual xbaseline_type cell_xbaseline(size_type x) const;
 
/** Get horizontal baseline for cell.
* This function is equivalent to ybaseline() but acts on a virtual
* child instead of a real component. By default it returns
* ybaseline_text.
* @param x the x-index of the cell
*/
virtual ybaseline_type cell_ybaseline(size_type x) const;
 
/** Reformat cell to fit within specified bounding box.
* This function is equivalent to reformat() but acts on a virtual
* child instead of a real component. By default it does nothing.
* @param x the x-index of the cell
* @param origin the new origin of this cell, with respect to
* its parent
* @param bbox the available bounding box for this cell, with
* respect to its own origin
*/
virtual void cell_reformat(size_type x,const point& origin,
const box &bbox);
 
/** Redraw call.
* This function is equivalent to redraw() but acts on a virtual
* child instead of a real component.
* @param x the x-index of the cell
* @param context the graphics context within which the
* redraw should take place
* @param clip the bounding box of the region to be redrawn,
* with respect to the origin of the cell
*/
virtual void cell_redraw(size_type x,gcontext& context,const box& clip)=0;
 
/** Get x-index of cell containing point.
* @param p the point to find, with respect to the origin of this
* component.
* @return the x-index of the cell containing p, or npos if there is
* no such cell.
*/
size_type find_x(const point& p);
};
 
}; /* namespace desktop */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/writable_field.cc
New file
0,0 → 1,26
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/desktop/writable_field.h"
 
namespace rtk {
namespace desktop {
 
writable_field::writable_field()
{
validation("Ktar;Pptr_write");
border(true);
fill(true);
hcentre(true).vcentre(true);
fcolour(7).bcolour(0);
button(14);
yfit(false);
xbaseline(xbaseline_text);
ybaseline(ybaseline_text);
min_bbox(box(0,0,16,0));
}
 
}; /* namespace desktop */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/absolute_layout.h
New file
0,0 → 1,87
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_DESKTOP_ABSOLUTE_LAYOUT
#define _RTK_DESKTOP_ABSOLUTE_LAYOUT
 
#include <vector>
 
#include "rtk/desktop/sizeable_component.h"
 
namespace rtk {
namespace desktop {
 
/** A layout class for arranging components by specifying their coordinates.
* This class is provided for use when the required layout does not have a
* logical structure, or where the structure is too complex to be represented
* using other layout classes (such as rows, columns and grids).
*/
class absolute_layout:
public sizeable_component
{
private:
/** The class from which this one is derived. */
typedef sizeable_component inherited;
 
/** A vector containing a pointer to each child. */
vector<component*> _components;
 
/** The margin to be placed around the whole layout. */
box _margin;
 
/** The current bounding box. */
box _bbox;
public:
/** Construct absolute layout.
* By default, the origin of an absolute layout is in the top
* left-hand corner.
*/
absolute_layout();
 
/** Destroy absolute layout. */
virtual ~absolute_layout();
 
virtual box auto_bbox() const;
virtual component* find(const point& p) const;
virtual box bbox() const;
virtual void resize() const;
virtual void reformat(const point& origin,const box& pbbox);
virtual void unformat();
virtual void redraw(gcontext& context,const box& clip);
protected:
virtual void remove_notify(component& c);
public:
/** Add component to layout.
* @param c the component to be added
* @param p the required initial origin
* @return a reference to this
*/
absolute_layout& add(component& c,const point& p);
 
/** Get margin around layout.
* @return a box indicating the margin width for each side of the layout
*/
const box& margin() const
{ return _margin; }
 
/** Set margin around layout.
* @param margin a box specifying the required margin width for each
* side of the layout
* @return a reference to this
*/
absolute_layout& margin(const box& margin);
 
/** Set margin around layout.
* @param margin an integer specifying the required margin width for
* all sides of the layout
* @return a reference to this
*/
absolute_layout& margin(int margin);
};
 
}; /* namespace desktop */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/label.cc
New file
0,0 → 1,65
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include "rtk/graphics/gcontext.h"
#include "rtk/os/wimp.h"
#include "rtk/desktop/label.h"
 
namespace rtk {
namespace desktop {
 
label::label()
{
xbaseline(xbaseline_text);
ybaseline(ybaseline_text);
}
 
label::label(const string& text):
_text(text)
{
xbaseline(xbaseline_text);
ybaseline(ybaseline_text);
}
 
label::~label()
{
remove();
}
 
box label::min_bbox() const
{
box bbox=internal_bbox();
bbox-=external_origin(bbox,xbaseline_text,ybaseline_text);
return bbox;
}
 
void label::redraw(gcontext& context,const box& clip)
{
box ibox=internal_bbox();
point offset=external_origin(ibox,xbaseline_text,ybaseline_text);
context.fcolour(7);
context.bcolour(0);
context.draw(_text.c_str(),-offset);
}
 
label& label::text(const string& text)
{
force_redraw();
_text=text;
reformat(origin(),box());
force_redraw();
invalidate();
return *this;
}
 
box label::internal_bbox() const
{
int width;
os::Wimp_TextOp1(_text.c_str(),0,&width);
return box(0,-8,width,24);
}
 
}; /* namespace desktop */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/label.h
New file
0,0 → 1,62
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_DESKTOP_LABEL
#define _RTK_DESKTOP_LABEL
 
#include <string>
 
#include "rtk/desktop/component.h"
 
namespace rtk {
namespace desktop {
 
/** A class to represent a line of text.
* The text is displayed using the default desktop font.
*/
class label:
public component
{
private:
/** The label text. */
string _text;
public:
/** Construct empty label. */
label();
 
/** Construct label with specified text.
* @param text the required label text
*/
label(const string& text);
 
/** Destroy label. */
virtual ~label();
 
virtual box min_bbox() const;
virtual void redraw(gcontext& context,const box& clip);
 
/** Get label text.
* @return the label text
*/
const string& text() const
{ return _text; }
 
/** Set label text.
* @param text the required label text
* @return a reference to this
*/
label& text(const string& text);
private:
/** Get bounding box with respect to internal baselines.
* The internal baselines are xbaseline_text and ybaseline_text.
* @return the bounding box with respect to internal baselines
*/
box internal_bbox() const;
};
 
}; /* namespace desktop */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/sizeable_component.h
New file
0,0 → 1,61
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_SIZEABLE_COMPONENT
#define _RTK_SIZEABLE_COMPONENT
 
#include "rtk/desktop/component.h"
 
namespace rtk {
namespace desktop {
 
/** An abstract class from which RTK components may be derived if it is
* possible to explicitly specify the required minimum bounding box.
*/
class sizeable_component:
public component
{
private:
/** The class from which this one is derived. */
typedef component inherited;
public:
using component::xauto;
using component::yauto;
private:
using component::set_xauto;
using component::set_yauto;
/** The minimum bounding box. */
mutable box _min_bbox;
public:
/** Construct sizeable component.
* @param origin the initial origin of the component, with respect
* to its parent
*/
sizeable_component(const point& origin=point());
 
/** Destroy sizeable component. */
virtual ~sizeable_component();
 
virtual box min_bbox() const;
virtual void resize() const;
 
/** Set minimum bounding box.
* If the specified width is zero then the width of the minimum bounding
* box will be varied automatically to fit the content of the component.
* Similarly for the height.
* @param min_bbox the required minimum bounding box
*/
sizeable_component& min_bbox(const box& min_bbox);
 
/** Get bounding box needed to fit content.
* @return the bounding box needed to fit the content of this component
*/
virtual box auto_bbox() const=0;
};
 
}; /* namespace desktop */
}; /* namespace rtk */
 
#endif
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/grid_layout.cc
New file
0,0 → 1,385
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#include <algorithm>
#include <functional>
 
#include "rtk/util/divider.h"
#include "rtk/graphics/gcontext.h"
#include "rtk/desktop/grid_layout.h"
 
namespace rtk {
namespace desktop {
 
using rtk::util::divider;
 
grid_layout::grid_layout(size_type xcells,size_type ycells):
_xcells(xcells),
_ycells(ycells),
_components(xcells*ycells,0),
_xmin(xcells+1,0),
_ymax(ycells+1,0),
_xbs(xcells),
_ybs(ycells),
_xgap(0),
_ygap(0)
{}
 
grid_layout::~grid_layout()
{
for (vector<component*>::iterator i=_components.begin();
i!=_components.end();++i)
{
if (component* c=*i) c->remove();
}
remove();
}
 
box grid_layout::auto_bbox() const
{
// Reset baseline sets.
for (size_type x=0;x!=_xcells;++x) _xbs[x]=xbaseline_set();
for (size_type y=0;y!=_ycells;++y) _ybs[y]=ybaseline_set();
 
// Request min_bbox for each cell. Incorporate into appropriate
// x-baseline and y-baseline set.
vector<component*>::const_iterator i=_components.begin();
for (size_type y=0;y!=_ycells;++y)
{
for (size_type x=0;x!=_xcells;++x)
{
if (component* c=*i++)
{
box mcbbox=c->min_bbox();
_xbs[x].add(mcbbox,c->xbaseline());
_ybs[y].add(mcbbox,c->ybaseline());
}
}
}
 
// Calculate total width and height.
int xsize=0;
int ysize=0;
for (size_type x=0;x!=_xcells;++x)
xsize+=_xbs[x].xsize();
for (size_type y=0;y!=_ycells;++y)
ysize+=_ybs[y].ysize();
 
// Add gaps to width and height.
if (_xcells) xsize+=(_xcells-1)*_xgap;
if (_ycells) ysize+=(_ycells-1)*_ygap;
 
// Add margin to width and height
xsize+=_margin.xsize();
ysize+=_margin.ysize();
 
// Construct minimum bounding box, with respect to top left-hand
// corner of layout.
box abbox(0,-ysize,xsize,0);
 
// Translate to external origin and return.
abbox-=external_origin(abbox,xbaseline_left,ybaseline_top);
return abbox;
}
 
component* grid_layout::find(const point& p) const
{
vector<int>::const_iterator xf=
lower_bound(_xmin.begin(),_xmin.end(),p.x()+1,less<int>());
vector<int>::const_iterator yf=
lower_bound(_ymax.begin(),_ymax.end(),p.y()-1,greater<int>());
if (xf==_xmin.begin()) return 0;
if (yf==_ymax.begin()) return 0;
size_type x=(xf-_xmin.begin())-1;
size_type y=(yf-_ymax.begin())-1;
component* c=_components[y*_xcells+x];
if (!c) return 0;
box cbbox=c->bbox()+c->origin();
if (!(p<=cbbox)) return 0;
return c;
}
 
box grid_layout::bbox() const
{
return _bbox;
}
 
void grid_layout::resize() const
{
for (vector<component*>::const_iterator i=_components.begin();
i!=_components.end();++i)
{
if (component* c=*i) c->resize();
}
inherited::resize();
}
 
void grid_layout::reformat(const point& origin,const box& pbbox)
{
// Fit bounding box to parent.
box bbox=fit(pbbox);
 
// Update origin and bounding box of this component, force redraw
// if necessary. (This must happen before reformat() is called for
// any children.)
bool moved=(origin!=this->origin())||(bbox!=this->bbox());
if (moved) force_redraw(true);
_bbox=bbox;
inherited::reformat(origin,bbox);
if (moved) force_redraw(true);
 
// Remove margin.
box ibox(_bbox-_margin);
 
// Get bounding box before adding excess.
box abbox=auto_bbox();
 
// Calculate excess in x-direction.
int xexcess=_bbox.xsize()-abbox.xsize();
if (xexcess<0) xexcess=0;
int xspread=abbox.xsize();
xspread-=_margin.xsize();
if (_xcells) xspread-=(_xcells-1)*_xgap;
if (xspread<0) xspread=0;
divider xdiv(xexcess,xspread);
 
// Set minimum x-coordinate for each column.
int xpos=ibox.xmin();
_xmin[0]=xpos;
for (size_type x=0;x!=_xcells;++x)
{
int xsize=_xbs[x].xsize();
xpos+=xsize+xdiv(xsize);
xpos+=_xgap;
_xmin[x+1]=xpos;
}
 
// Calculate excess in y-direction.
int yexcess=_bbox.ysize()-abbox.ysize();
if (yexcess<0) yexcess=0;
int yspread=abbox.ysize();
yspread-=_margin.ysize();
if (_ycells) yspread-=(_ycells-1)*_ygap;
if (yspread<0) yspread=0;
divider ydiv(yexcess,yspread);
 
// Set minimum and maximum y-coordinates for each row.
int ypos=ibox.ymax();
_ymax[0]=ypos;
for (size_type y=0;y!=_ycells;++y)
{
int ysize=_ybs[y].ysize();
ypos-=ysize+ydiv(ysize);
ypos-=_ygap;
_ymax[y+1]=ypos;
}
 
// Place children.
vector<component*>::iterator i=_components.begin();
for (size_type y=0;y!=_ycells;++y)
{
for (size_type x=0;x!=_xcells;++x)
{
if (component* c=*i++)
{
// Construct bounding box for cell with respect to
// origin of layout.
box cbbox(_xmin[x],_ymax[y+1]+_ygap,_xmin[x+1]-_xgap,_ymax[y]);
 
// Calculate offset from top left-hand corner of cell
// to origin of child.
int xoffset=_xbs[x].offset(xbaseline_left,c->xbaseline(),
cbbox.xsize());
int yoffset=_ybs[y].offset(ybaseline_bottom,c->ybaseline(),
cbbox.ysize());
point coffset(xoffset,yoffset);
 
// Calculate origin of cell with respect to origin of
// layout.
point cpos(cbbox.xminymin()+coffset);
 
// Reformat child.
c->reformat(cpos,cbbox-cpos);
}
}
}
}
 
void grid_layout::unformat()
{
for (vector<component*>::iterator i=_components.begin();
i!=_components.end();++i)
{
if (component* c=*i) c->unformat();
}
}
 
void grid_layout::redraw(gcontext& context,const box& clip)
{
// Look for the first column with a right edge which overlaps (or is to
// the right of) the clip box: _xmin[x0+1] -_xgap > clip.xmin().
vector<int>::iterator xf0=upper_bound(
_xmin.begin(),_xmin.end(),clip.xmin()+_xgap,less<int>());
size_type x0=xf0-_xmin.begin();
if (x0) --x0;
 
// Look for the first column with a left edge which is to the right of
// the clip box: _xmin[x1] >= clip.xmax().
vector<int>::iterator xf1=lower_bound(
_xmin.begin(),_xmin.end(),clip.xmax(),less<int>());
size_type x1=xf1-_xmin.begin();
if (x1>_xcells) x1=_xcells;
 
// Look for the first row with a lower edge which overlaps (or is
// below) the clip box: _ymax[y0+1] + _ygap < clip.ymax().
vector<int>::iterator yf0=upper_bound(
_ymax.begin(),_ymax.end(),clip.ymax()-_ygap,greater<int>());
size_type y0=yf0-_ymax.begin();
if (y0) --y0;
 
// Look for the first row with an upper edge which is below the
// clip box: _ymax[y1] <= clip.ymin().
vector<int>::iterator yf1=lower_bound(
_ymax.begin(),_ymax.end(),clip.ymin(),greater<int>());
size_type y1=yf1-_ymax.begin();
if (y1>_ycells) y1=_ycells;
 
// Redraw children.
// For safety, use inequalities in the for-loops.
vector<component*>::iterator i=_components.begin()+y0*_xcells;
for (size_type y=y0;y<y1;++y)
{
vector<component*>::iterator j=i+x0;
for (size_type x=x0;x<x1;++x)
{
if (component* c=*j++)
{
point cpos(c->origin());
context+=cpos;
c->redraw(context,clip-cpos);
context-=cpos;
}
}
i+=_xcells;
}
inherited::redraw(context,clip);
}
 
void grid_layout::remove_notify(component& c)
{
vector<component*>::iterator f=
std::find(_components.begin(),_components.end(),&c);
if (f!=_components.end())
{
*f=0;
invalidate();
}
}
 
grid_layout& grid_layout::cells(size_type xcells,size_type ycells)
{
// Create new child array.
vector<component*> components(xcells*ycells);
 
// Initialise source and destination iterators.
vector<component*>::iterator src=_components.begin();
vector<component*>::iterator dst=components.begin();
 
// Calculate number of columns and number of rows to be copied
// from source to destination.
size_type xcopy=min(_xcells,xcells);
size_type ycopy=min(_ycells,ycells);
 
// Handle rows that exist in source and destination.
for (size_type y=0;y!=ycopy;++y)
{
// Handle columns that exist in source and destination (copy).
for (size_type x=0;x!=xcopy;++x)
*dst++=*src++;
// Handle columns that do not exist in destination (discard).
for (size_type x=xcopy;x!=_xcells;++x)
if (component* c=*src++) c->remove();
// Handle columns that do not exist in source (zero).
for (size_type x=xcopy;x!=xcells;++x)
*dst++=0;
}
// Handle rows that do not exist in destination (discard).
for (size_type y=ycopy;y!=_ycells;++y)
{
for (size_type x=0;x!=_xcells;++x)
if (component* c=*src++) c->remove();
}
// Handle rows that do not exist in source (zero).
for (size_type y=ycopy;y!=ycells;++y)
{
for (size_type x=0;x!=xcells;++x)
*dst++=0;
}
 
// Replace existing child array.
_xcells=xcells;
_ycells=ycells;
_components.swap(components);
 
// Resize auxiliary data structures.
_xmin.resize(xcells+1,0);
_ymax.resize(ycells+1,0);
_xbs.resize(xcells);
_ybs.resize(ycells);
 
// Invalidate component and return.
invalidate();
return *this;
}
 
grid_layout& grid_layout::add(component& c,size_type x,size_type y)
{
// If cell does not exist then resize grid.
if ((x>=_xcells)||(y>=_ycells))
cells(max(_xcells,x+1),max(_ycells,y+1));
 
// If cell is occupied then remove content.
if (component* c=_components[y*_xcells+x])
c->remove();
 
// Link from parent to child and child to parent.
_components[y*_xcells+x]=&c;
link_child(c);
 
// Invalidate component and return.
invalidate();
return *this;
}
 
grid_layout& grid_layout::xgap(int xgap)
{
_xgap=xgap;
invalidate();
return *this;
}
 
grid_layout& grid_layout::ygap(int ygap)
{
_ygap=ygap;
invalidate();
return *this;
}
 
grid_layout& grid_layout::margin(const box& margin)
{
_margin=margin;
invalidate();
return *this;
}
 
grid_layout& grid_layout::margin(int margin)
{
_margin=box(-margin,-margin,margin,margin);
invalidate();
return *this;
}
 
}; /* namespace desktop */
}; /* namespace rtk */
Property changes:
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
/tags/v0_5_0-2/!RTK/rtk/desktop/menu_item.h
New file
0,0 → 1,209
// This file is part of the RISC OS Toolkit (RTK).
// Copyright © 2003 Graham Shaw.
// Distribution and use are subject to the GNU Lesser General Public License,
// a copy of which may be found in the file !RTK.Copyright.
 
#ifndef _RTK_DESKTOP_MENU_ITEM
#define _RTK_DESKTOP_MENU_ITEM
 
#include "rtk/desktop/icon.h"
 
namespace rtk {
namespace desktop {
 
class window;
class menu;
 
/** A class to represent a RISC OS menu item. */
class menu_item:
public icon
{
private:
/** The class from which this one is derived. */
typedef icon inherited;
 
/** A union used to hold an attached menu or dialogue box. */
union
{
/** The menu that is currently attached to this component, if any.
* This variable is meaningful if _has_menu is true.
*/
menu* _submenu;
/** The dialogue box that is currently attached to this component,
* if any. This variable is meaningful if _has_dbox is true.
*/
window* _dbox;
};
 
/** The has-submenu flag.
* True if _submenu points to a menu that is currently attached to
* this menu item. (The submenu is not a child, so can be attached to
* any number of menu items.)
*/
bool _has_submenu:1;
 
/** The has-dbox flag.
* True if _dbox points to a dialogue box window that is currently
* attached to this menu item. (The dialogue box is not a child,
* so can be attached to any number of menu items.)
*/
bool _has_dbox:1;
 
/** The tick flag.
* True if this menu item is ticked, otherwise false.
*/
bool _tick:1;
 
/** The separator flag.
* True if this menu item is followed by a separator, otherwise false.
*/
bool _separator:1;
public:
/** Construct menu item.
* By default, a menu item:
* - has a background colour of 0;
* - is not followed by a separator; and
* - keeps the menu tree open if clicked with adjust.
*
* Other default attributes are as for an icon.
*/
menu_item();
 
/** Destroy menu item. */
virtual ~menu_item();
public:
/** Get submenu attached to this menu item.
* @return the attached submenu, or 0 if there is none
*/
menu* submenu();
 
/** Attach submenu.
* Any existing submenu or dialogue box is detached.
* Attaching a submenu does not make it a child of this menu item.
* It becomes a child of the application when it is opened by the
* user, and ceases to be a child when it is closed. This behaviour
* allows one submenu to be shared by several menu items.
* @param submenu the submenu to be attached
* @return a reference to this
*/
menu_item& attach_submenu(menu& submenu);
 
/** Detach submenu.
* If there is no attached submenu then no action is taken.
* @return a reference to this
*/
menu_item& detach_submenu();
 
/** Get dialogue box attached to this menu item.
* @return the attached dialogue box, or 0 is there is none
*/
window* dbox();
 
/** Attach dialogue box.
* Any existing submenu or dialogue box is detached.
* Attaching a dialogue box does not make it a child of this menu
* item. It becomes a child of the application when it is opened
* by the user, and ceases to be a child when it is closed. This
* behaviour allows one dialogue box to be shared between several
* menu items.
* @param dbox the dialogue box to be attached
* @return a reference to this
*/
menu_item& attach_dbox(window& dbox);
 
/** Detach dialogue box.