GLUEscript - The manual - 0.1.07 Glueing Libraries Using EcmaScript Franky Braem GLUEscript - The manual - 0.1.07: Glueing Libraries Using EcmaScript Franky Braem
Publication date Copyright © 2002 - 2011 Franky Braem Table of Contents
1. Introduction ...... 1 What's GLUEscript? ...... 1 History ...... 1 Glue ...... 1 Configuration ...... 1 glue.runtimeSize ...... 2 glue.contextSize ...... 2 glue.contextPoolSize ...... 2 2. Building GLUE ...... 3 Prerequisites ...... 3 Premake ...... 3 POCO ...... 3 wxWidgets ...... 3 Linux ...... 3 NSPR ...... 3 Premake ...... 3 PocoJavaScript ...... 4 GLUEscript ...... 4 Install ...... 5 glue.properties ...... 6 3. Apache ...... 7 Introduction ...... 7 Configure Apache ...... 7 4. core ...... 8 Introduction ...... 8 Reference ...... 8 5. curl ...... 13 Introduction ...... 13 Setting Options ...... 13 curl.Auth ...... 15 curl.Easy ...... 16 curl.Form ...... 36 curl.FTPAuth ...... 37 curl.FTPMethod ...... 38 curl.FTPSSL ...... 39 curl.Http ...... 40 curl.Info ...... 41 curl.IPResolve ...... 43 curl.Multi ...... 44 Curl ...... 45 curl.Netrc ...... 46 curl.Option ...... 47 curl.Protocol ...... 51 curl.ProxyType ...... 52 curl.SSHAuth ...... 53 curl.SSLVersion ...... 54 curl.UseSSL ...... 55 6. Data ...... 56 Introduction ...... 56 Reference ...... 56 7. expat ...... 62
iii GLUEscript - The manual - 0.1.07
Introduction ...... 62 Reference ...... 62 8. fcgi ...... 67 Introduction ...... 67 Example ...... 67 Class Reference ...... 67 9. gd ...... 69 Introduction ...... 69 Examples ...... 69 Drawing a pixel ...... 69 Drawing a line ...... 69 Drawing a dashed line ...... 70 Drawing a triangle ...... 71 Drawing a rectangle ...... 71 Drawing a filled polygon ...... 72 Drawing a partial ellipse ...... 72 Drawing a filled partial ellipse ...... 73 Alpha Blending ...... 73 Reference ...... 74 10. memcache ...... 101 Introduction ...... 101 memcached in JavaScript ...... 101 Reference ...... 101 11. mysql ...... 105 Introduction ...... 105 Database ...... 105 Executing SQL statements ...... 105 Class Reference ...... 105 12. net ...... 122 Introduction ...... 122 Handling Form Input ...... 122 Naming the elements ...... 122 Uploading files ...... 123 Class Reference ...... 124 13. sqlite ...... 182 Introduction ...... 182 Database ...... 182 Executing SQL statements ...... 182 Class Reference ...... 182 14. system ...... 191 Introduction ...... 191 Reference ...... 191 15. tpl ...... 217 Introduction ...... 217 Template files ...... 217 A template example ...... 217 Class Reference ...... 218 16. wx ...... 221 Introduction ...... 221 wxTheApp ...... 221 Event Handling ...... 221 Class Reference ...... 222 Index ...... 583
iv List of Tables
5.1. Constants of curl.Auth ...... 15 5.2. Constants of curl.FTPAuth ...... 37 5.3. Constants of curl.FTPMethod ...... 38 5.4. Constants of curl.FTPSSL ...... 39 5.5. Constants of curl.Http ...... 40 5.6. Constants of curl.Info ...... 41 5.7. Constants of curl.IPResolve ...... 43 5.8. Constants of curl.Netrc ...... 46 5.9. Constants of curl.Option ...... 47 5.10. Constants of curl.Protocol ...... 51 5.11. Constants of curl.ProxyType ...... 52 5.12. Constants of curl.SSHAuth ...... 53 5.13. Constants of curl.SSLVersion ...... 54 5.14. Constants of curl.UseSSL ...... 55 7.1. Constants of expat.Parser ...... 63 10.1. Constants of memcache.Client ...... 102 11.1. Constants of mysql.Database ...... 106 12.1. Constants of net.Family ...... 129 12.2. Constants of net.HTTPResponse ...... 141 12.3. Constants of net.MailRecipient ...... 154 13.1. Constants of sqlite.Database ...... 183 14.1. Constants of system.InputStream ...... 198 14.2. Constants of system.OutputStream ...... 200 14.3. Constants of system.Path ...... 202 16.1. Constants of wx.AcceleratorEntry ...... 226 16.2. Constants of wx.Alignment ...... 231 16.3. Constants of wx.Animation ...... 232 16.4. Constants of wx.AnimationCtrl ...... 234 16.5. Constants of wx.AuiManagerDock ...... 241 16.6. Constants of wx.AuiManagerOption ...... 242 16.7. Constants of wx.AuiNotebook ...... 243 16.8. Constants of wx.AuiPaneInsertLevel ...... 255 16.9. Constants of wx.BitmapType ...... 263 16.10. Constants of wx.BookCtrlBase ...... 265 16.11. Constants of wx.BookHittest ...... 271 16.12. Constants of wx.Border ...... 272 16.13. Constants of wx.Button ...... 274 16.14. Constants of wx.CalendarCtrl ...... 277 16.15. Constants of wx.CalendarDateBorder ...... 283 16.16. Constants of wx.CheckBox ...... 287 16.17. Constants of wx.CheckBoxState ...... 290 16.18. Constants of wx.Choicebook ...... 294 16.19. Constants of wx.CollapsiblePane ...... 299 16.20. Constants of wx.ColourPickerCtrl ...... 307 16.21. Constants of wx.ComboBox ...... 310 16.22. Constants of wx.Dialog ...... 322 16.23. Constants of wx.Direction ...... 326 16.24. Constants of wx.FileDialog ...... 328 16.25. Constants of wx.Filter ...... 330 16.26. Constants of wx.FindReplaceData ...... 332 16.27. Constants of wx.FindReplaceDialog ...... 333
v GLUEscript - The manual - 0.1.07
16.28. Constants of wx.Font ...... 337 16.29. Constants of wx.FontEncoding ...... 342 16.30. Constants of wx.Frame ...... 347 16.31. Constants of wx.FullScreen ...... 350 16.32. Constants of wx.Gauge ...... 351 16.33. Constants of wx.HtmlWindow ...... 359 16.34. Constants of wx.Id ...... 366 16.35. Constants of wx.ItemKind ...... 380 16.36. Constants of wx.KeyCode ...... 383 16.37. Constants of wx.LayoutAlignment ...... 390 16.38. Constants of wx.LayoutOrientation ...... 391 16.39. Constants of wx.ListAlign ...... 392 16.40. Constants of wx.Listbook ...... 393 16.41. Constants of wx.ListBox ...... 396 16.42. Constants of wx.ListColumnFormat ...... 398 16.43. Constants of wx.ListCtrl ...... 402 16.44. Constants of wx.ListFind ...... 414 16.45. Constants of wx.ListMask ...... 419 16.46. Constants of wx.ListNext ...... 420 16.47. Constants of wx.ListRect ...... 421 16.48. Constants of wx.ListState ...... 422 16.49. Constants of wx.MenuBar ...... 428 16.50. Constants of wx.Menu ...... 432 16.51. Constants of global ...... 446 16.52. Constants of wx.Notebook ...... 447 16.53. Constants of wx.NotebookHittest ...... 450 16.54. Constants of wx.Orientation ...... 452 16.55. Constants of wx.PickerBase ...... 456 16.56. Constants of wx.RadioBox ...... 461 16.57. Constants of wx.RadioButton ...... 465 16.58. Constants of wx.SashDragStatus ...... 469 16.59. Constants of wx.SashEdgePosition ...... 470 16.60. Constants of wx.SashWindow ...... 474 16.61. Constants of wx.Slider ...... 499 16.62. Constants of wx.SpinButton ...... 503 16.63. Constants of wx.SpinCtrl ...... 505 16.64. Constants of wx.SplitMode ...... 508 16.65. Constants of wx.SplitterWindow ...... 510 16.66. Constants of wx.StaticText ...... 516 16.67. Constants of wx.StatusBar ...... 518 16.68. Constants of wx.Stretch ...... 521 16.69. Constants of wx.SystemSettings ...... 523 16.70. Constants of wx.TextCtrl ...... 527 16.71. Constants of wx.ToolBar ...... 536 16.72. Constants of wx.TreeCtrl ...... 550 16.73. Constants of wx.TreeItemIcon ...... 567 16.74. Constants of wx.Window ...... 570
vi Chapter 1. Introduction What's GLUEscript?
GLUE stands for Glueing Libraries Using EcmaScript. With GLUEscript, EcmaScript (better known as JavaScript) can be used as a general purpose language. It allows you to write desktop applications, dynamic web pages, system scripts ... with JavaScript.
GLUEscript uses SpiderMonkey, the JavaScript engine used in FireFox.
The interpreter can be run as a console program, a FastCGI program or as an Apache module. History
GLUEscript is the successor of wxJavaScript. wxJavaScript was a port of wxWidgets, a portable GUI framework. But wxJavaScript wasn't only wxWidgets. It also ported MySQL, SQLite, memcached, cURL, ... After several years of developing wxJavaScript, it was decided to create an interpreter which didn't depend on wxWidgets. Instead of wxWidgets, the POCO framework is used for writing portable C ++ code. You can still write GUI applications with the wxWidgets ported classes, but for system scripts, dynamic webpages, ... which don't need wxWidgets, you can run GLUEscript without the wxWidgets binaries. Glue
A port of a C/C++ library is called a "glue". A glue is a dynamic linked library which ports the C/C++ library to JavaScript. The following glues are available in GLUEscript:
• curl
• expat
• gd
• memcached
• mysql
• net
• system
• sqlite
• wx Configuration
GLUEscript is configured using a property file. GLUEscript will search for a file with the name glue.properties in the application directory. For the console application this directory is the directory where the executable is stored. For the Apache environment this is the file specified with AddPocoConfig in httpd.conf.
1 Introduction
The configuration of the console application, FastCGI program and Apache can be done in the same property file. A property for the console program starts with glue.console. For FastCGI glue.fcgi is used and for Apache the name of the host is used: glue.localhost. When a property is valid for all programs, only glue. is used. An example:
glue.runtimeSize = 1M glue.localhost.runtimeSize = 2M
In this example the runtime size will be 1 MB. Except for Apache, where 2 MB will be used for localhost.
glue.modules.URI is the only property that can't be overruled by Apache, FCGI, ... glue.runtimeSize
Defines the maximum number of allocated bytes after which garbage collection is run. You can use the suffix M for MB and K for KB. glue.contextSize
Defines the size, in bytes, of each "stack chunk". This is a memory management tuning parameter which most users should not adjust. 8192 is a good default value. You can use the suffix M for MB and K for KB. glue.contextPoolSize
Contexts are pooled. This parameter defines the size of the pool. glue.modules.URI
A URI where the dynamic libraries are stored. When this is not set the folder 'modules' is searched in the application directory (where glue.exe is)
2 Chapter 2. Building GLUE Prerequisites
Before you can start building GLUEscript, you need to follow some steps. Premake
GLUEscript uses Premake [http://industriousone.com/premake] for generating make files. Premake uses LUA-scripts for generating these files. Installing Premake is easy. Just get the right executable (version 4.2) for your operating system. POCO
The POCO [http://poco.appinf.com/] library is used for writing portable C++ code. So download the POCO library and install it. Build POCO as shared libraries. When you want to build POCO on Windows with MinGW then you can download some Premake scripts from here [http://gluescript.svn.sourceforge.net/ viewvc/gluescript/src/poco.zip] to build it with CodeLite or Code::Blocks. wxWidgets
When you want to use the GUI classes you need to build wxWidgets. You can get more information about it on their website [http://www.wxwidgets.org]. Linux NSPR
To build GLUEscript on Linux, a prebuild NSPR library is needed. Get the latest version from NSPR [http://www.mozilla.org/projects/nspr] and install NSPR. Premake
Open a terminal and move to the source folder of GLUEscript and run premake. When you also want to compile/build the WX glue, specify --with-wx as first argument to premake4. For example:
bronx@ubuntu:~$ cd dev* bronx@ubuntu:~/development$ cd glue* bronx@ubuntu:~/development/gluescript$ cd src bronx@ubuntu:~/development/gluescript/src$ premake4 --with-wx gmake
When everythings goes right, you should see something like this:
Poco Include Directory: /usr/local/include Poco Library Directory: /usr/local/lib NSPR Include Directory: /usr/local/include/nspr
3 Building GLUE
NSPR Library Directory: /usr/local/lib Using the zlib library which is part of GLUEscript Using the png library which is part of GLUEscript Using the jpg library which is part of GLUEscript Building configurations... Running action 'gmake'... Generating ../build/gmake/PocoJavaScript.make... Generating ../build/gmake/ApacheConnector.make... Generating ../build/gmake/Script.make... Generating ../build/gmake/SpiderMonkey.make... Generating ../build/gmake/GLUE.make... Generating ../build/gmake/zlib.make... Generating ../build/gmake/png.make... Generating ../build/gmake/jpg.make... Generating ../build/gmake/Common.make... Generating ../build/gmake/Core.make... Generating ../build/gmake/glue.make... Generating ../build/gmake/Data.make... Generating ../build/gmake/Expat.make... Generating ../build/gmake/SQLite.make... Generating ../build/gmake/Tpl.make... Generating ../build/gmake/MySQL.make... Generating ../build/gmake/GD.make... Generating ../build/gmake/MemCached.make... Generating ../build/gmake/Curl.make... Generating ../build/gmake/FCGI.make... Generating ../build/gmake/Net.make... Generating ../build/gmake/System.make... Generating ../build/gmake/WX.make... Generating ../build/gmake/Apache.make... Done.
The action gmake will generate common makefiles. With premake it's also possible to generate workspaces for Codelite and Code::Blocks. All makefiles will be generated in the build folder. For each different action of premake you find a folder. For example, You can find the common makefiles in the gmake folder. PocoJavaScript
The Poco JavaScript framework, which is donated by GLUEscript to Poco, must be build before you can start building GLUEscript. PocoJavaScript also contains the Poco Script framework and the Poco Apache Connector. The following is an example on building this framework in release mode on a 64-bit operating system (Ubuntu).
make -f PocoJavaScript.make config=release64
GLUEscript Now it's possible to build GLUEscript:
make -f GLUEscript.make config=release64
4 Building GLUE
Install
At the moment there's no install script. By default the glue program searches for modules in the 'modules' subdirectory of the program. So move them to this directory. You also have to remove the 'lib' prefix. Make it look like this:
drwxr-xr-x 4 bronx bronx 4096 2010-05-04 19:03 .. -rwxr-xr-x 1 bronx bronx 165840 2010-05-04 20:38 libmod_poco.so -rwxr-xr-x 1 bronx bronx 51992 2010-05-04 20:38 libPocoScript.so -rwxr-xr-x 1 bronx bronx 2078752 2010-05-04 20:41 libPocoSpiderMonkey.so -rwxr-xr-x 1 bronx bronx 139288 2010-05-04 21:01 glue -rwxr-xr-x 1 bronx bronx 402944 2010-05-04 21:57 libglue_data.so -rwxr-xr-x 1 bronx bronx 228616 2010-05-05 22:16 libglue_apache.so -rwxr-xr-x 1 bronx bronx 218112 2010-05-06 19:03 glue_fcgi drwxr-xr-x 3 bronx bronx 4096 2010-05-06 21:05 . drwxr-xr-x 2 bronx bronx 4096 2010-05-06 21:06 modules bronx@ubuntu:~/development/gluescript/bin/Release$ cd modules bronx@ubuntu:~/development/gluescript/bin/Release/modules$ ls -lart total 15416 -rwxr-xr-x 1 bronx bronx 591752 2010-05-04 21:26 glue_core.so -rwxr-xr-x 1 bronx bronx 529232 2010-05-04 21:57 glue_expat.so -rwxr-xr-x 1 bronx bronx 1049472 2010-05-04 21:57 glue_sqlite.so -rwxr-xr-x 1 bronx bronx 720032 2010-05-04 21:58 glue_mysql.so -rwxr-xr-x 1 bronx bronx 262136 2010-05-04 22:15 glue_tpl.so -rwxr-xr-x 1 bronx bronx 2150184 2010-05-04 22:15 glue_gd.so -rwxr-xr-x 1 bronx bronx 395152 2010-05-04 22:19 glue_memcache.so -rwxr-xr-x 1 bronx bronx 1034360 2010-05-04 22:54 glue_system.so -rwxr-xr-x 1 bronx bronx 921280 2010-05-05 21:24 glue_net.so -rwxr-xr-x 1 bronx bronx 7402224 2010-05-05 22:16 glue_wx.so -rwxr-xr-x 1 bronx bronx 649432 2010-05-06 19:05 glue_curl.so drwxr-xr-x 3 bronx bronx 4096 2010-05-06 21:05 .. drwxr-xr-x 2 bronx bronx 4096 2010-05-06 21:06 .
When you run glue, you problably see this error:
bronx@ubuntu:~/development/gluescript/bin/Release$ ./glue ./glue: error while loading shared libraries: libPocoSpiderMonkey.so: cannot open shared object file: No such file or directory
Fixing this problem is easy. Simply add the directory to your /etc/ld.so.conf file, and then -- as root -- run the ldconfig program so it rebuilds /etc/ld.so.cache.
Now run glue:
glue runs in interactive mode. Each line will be executed. Enter an empty line to end glue. > print("Hello World\n"); Hello World >
5 Building GLUE
glue.properties
glue.properties is a file that configures GLUEscript. Use it to define which modules must be loaded. An example:
glue.uri=file:///c:/development/gluescript/bin/release/modules glue.modules.core=${glue.uri}/glue_core.dll glue.modules.wx=${glue.uri}/glue_wx.dll glue.modules.system=${glue.uri}/glue_system.dll glue.modules.net=${glue.uri}/glue_net.dll glue.modules.curl=${glue.uri}/glue_curl.dll glue.modules.memcache=${glue.uri}/glue_memcache.dll glue.modules.sqlite=${glue.uri}/glue_sqlite.dll glue.modules.mysql=${glue.uri}/glue_mysql.dll glue.modules.tpl=${glue.uri}/glue_tpl.dll glue.modules.expat=${glue.uri}/glue_expat.dll glue.modules.gd=${glue.uri}/glue_gd.dll
Note The core module is important! Without it GLUEscript can't load other modules.
6 Chapter 3. Apache Introduction
GLUEscript can be used to create dynamic webpages with Apache. Configure Apache
Internally GLUEscript uses the ApacheConnector of the POCO framework. To run JavaScript you need to use the POCO configuration tags. This is an example:
LoadModule poco_module c:/GLUEscript/bin/mod_pocod.dll AddPocoRequestHandler GLUERequestHandlerFactory c:/GLUEscript/bin/glue_apache.dll /hello AddPocoRequestHandler GLUERequestHandlerFactory c:/GLUEscript/bin/glue_apache.dll /book AddPocoConfig c:/GLUEscript/glue.properties
This example will redirect all URI's that start with hello and book to GLUEscript. GLUEscript is configured in the glue.properties file. In this file you need to attach a script for each request handler.
glue.localhost.controller.hello = c:/GLUEscript/samples/apache/echo.js glue.localhost.controller.book = c:/GLUEscript/samples/apache/book.js
When a script is called, a request and response object is automatically available. request is a net.HTTPServerRequest and response is a net.HTTPServerResponse.
7 Chapter 4. core Introduction
The core glue contains classes that are used by several glues. It defines classes like Binary, BinaryString, Encoding, ... This glue is always loaded automatically by the GLUEscript engine. Reference
8 core
Name core.Binary — Prototype for Binary classes
Properties length
Integer length ;
Returns the length of the Binary Methods concat
core.BinaryString concat(core.Binary Buffer);
core.BinaryString concat(Array Buffer);
core.BinaryString concat(Integer Buffer);
Returns a new binary comprised of this binary joined with other binary, array or integer value(s). Multiple arguments can be specified. byteAt
core.BinaryString byteAt(Integer Offset);
Return the byte at offset as a core.BinaryString decodeToString
String decodeToString(String Encoding);
Converts the binary into a String with the given encoding get
Integer get(Integer Offset);
Return the byte as Integer
9 core
Name core.BinaryString
Constructor
BinaryString(String Str, String Encoding= UTF-8);
BinaryString(core.Binary Buffer);
BinaryString(Array Arr);
BinaryString();
Constructs a new BinaryString class
10 core
Name core.Encoding — class for text encodings like UTF-8 or ISO 8859-1.
All the available encodings are defined as class properties. Retrieve as follows:
Encoding["UTF-16-BE"]
The following encodings are available: ASCII, ISO-8859-1, ISO-8859-15, UTF-8, UTF-16, UTF-16-LE, UTF-16-BE and CP1252.
11 core
Name core.Version — Represents a version number
Properties major
Integer major ;
Returns the major number minor
Integer minor ;
Returns the minor number release
Integer release ;
Returns the release number description
String description ;
Returns the description
12 Chapter 5. curl Introduction
The curl glue ports cURL [http://curl.haxx.se] to JavaScript. libcurl is a free and easy-to-use client-side URL transfer library, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS and FILE. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos4), file transfer resume, http proxy tunneling and more! Warning
When you use the prebuild cURL from the binary distribution of GLUEscript on Windows you need to install OpenSSL. Download the OpenSSL binaries from Shining Light Productions [http://www.slproweb.com/products/Win32OpenSSL.html]. Setting Options
There are 3 ways in JavaScript to set cURL options. Use setopt
With setopt options are set as in the C/C++ version. All available options are defined as constants in curl.Option.
var curl = require("curl"); var c = new curl.Easy(); c.setopt(curl.Option.VERBOSE, true); c.setopt(curl.Option.URL, "http://gluescript.sf.net");
Use setopt with an object
An object can be used. Use the constants as array index for the option. This can be handy, when you want to use a separate script for setting the options (a configuration script for example) or to store the options in JSON format.
var curl = require("curl"); var options = new Object(); options[curl.Option.VERBOSE] = true; options[curl.Option.URL] = "http://gluescript.sf.net";
var c = new curl.Easy(); c.setopt(options);
13 curl
Use properties
All options are also properties of curl.Easy.
var curl = require("curl"); var c = new curl.Easy(); c.url = "http://gluescript.sf.net"; c.verbose = true;
14 curl
Name curl.Auth — Defines constants for httpAuth
This class defines constants for setting the property httpAuth Constants
Table 5.1. Constants of curl.Auth
Name Description ANY ANYSAFE BASIC DIGEST GSSNEGOTIATE NTLM
15 curl
Name curl.Easy — The easy interface
Use this class to create a libcurl easy session. Class Methods strerror
String strerror(Integer Code);
Return string describing error code Constructor
Easy();
This creates a new libcurl easy session. It is automatically cleaned up. Properties append
Boolean append ;
Tells the library to append to the remote file instead of overwrite it. This is only useful when uploading to an ftp site. autoReferer
Boolean autoReferer ;
Set to true to enable this. When enabled, libcurl will automatically set the Referer: field in requests where it follows a Location: redirect. cookie
String cookie ;
It will be used to set a cookie in the http request. The format of the string should be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie should contain.
If you need to set multiple cookies, you need to set them all using a single option and thus you need to concatenate them all in one single string. Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.
16 curl cookieFile
String cookieFile ;
The name of a file holding cookie data to read. The cookie data may be in Netscape / Mozilla cookie data format or just regular HTTP-style headers dumped to a file.
Given an empty or non-existing file or by passing the empty string, this option will enable cookies for this curl handle, making it understand and parse received cookies and then use matching cookies in future request.
If you set this property multiple times, you just add more files to read. Subsequent files will add more cookies. cookieJar
String cookieJar ;
This will make curl write all internally known cookies to the specified file when curl is destroyed. If no cookies are known, no file will be created. Specify "-" to instead have the cookies written to stdout. Using this option also enables cookies for this session, so if you for example follow a location it will make matching cookies get sent accordingly. cookieList
String cookieList ;
Cookie can be either in Netscape / Mozilla format or just regular HTTP-style header (Set-Cookie: ...) format. If cURL cookie engine was not enabled it will enable its cookie engine. Passing a magic string "ALL" will erase all cookies known by cURL. (Added in 7.14.1) Passing the special string "SESS" will only erase all session cookies known by cURL. (Added in 7.15.4) Passing the special string "FLUSH" will write all cookies known by cURL to the file specified by cookieJar. cookieSession
Boolean cookieSession ;
It will force libcurl to ignore all cookies it is about to load that are "session cookies" from the previous session. By default, libcurl always stores and loads all cookies, independent if they are session cookies are not. Session cookies are cookies without expiry date and they are meant to be alive and existing for this "session" only. crlf
Boolean crlf ;
Convert Unix newlines to CRLF newlines on transfers. customRequest
17 curl
String customRequest ;
This will be used instead of GET or HEAD when doing an HTTP request, or instead of LIST or NLST when doing an ftp directory listing. This is useful for doing DELETE or other more or less obscure HTTP requests. Don't do this at will, make sure your server supports the command first. dirListOnly
Boolean dirListOnly ;
A true value tells the library to just list the names of files in a directory, instead of doing a full directory listing that would include file sizes, dates etc. This works for FTP and SFTP URLs. dnsCacheTimeout
Integer dnsCacheTimeout ;
This sets the timeout in seconds. Name resolves will be kept in memory for this number of seconds. Set to zero (0) to completely disable caching, or set to -1 to make the cached entries remain forever. By default, libcurl caches this info for 60 seconds. This is the same as calling setopt with Option.DNS_CACHE_TIMEOUT. effectiveUrl
String effectiveUrl ;
Returns the last used effective URL. encoding
String encoding ;
Sets the contents of the Accept-Encoding: header sent in an HTTP request. error
String error ;
Returns the last error as a String filetime
Boolean filetime ;
When true, libcurl will attempt to get the modification date of the remote document in this operation. followLocation
Boolean followLocation ;
18 curl
True tells the library to follow any Location: header that the server sends as part of an HTTP header. ftpAccount
String ftpAccount ;
When an FTP server asks for "account data" after user name and password has been provided, this data is sent off using the ACCT command. ftpAlternativeToUser
String ftpAlternativeToUser ;
A string which will be used to authenticate if the usual FTP "USER user" and "PASS password" negotiation fails ftpCreateMissingDirs
Boolean ftpCreateMissingDirs ;
curl will attempt to create any remote directory that it fails to CWD into. CWD is the command that changes working directory. ftpFileMethod
Integer ftpFileMethod ;
This option controls what method libcurl should use to reach a file on a FTP(S) server. See curl.FTPMethod. ftpPort
String ftpPort ;
This will be used to get the IP address to use for the ftp PORT instruction. The PORT instruction tells the remote server to connect to our specified IP address. The string may be a plain IP address, a host name, an network interface name (under Unix) or just a '-' letter to let the library use your systems default IP address. Default FTP operations are passive, and thus won't use PORT. ftpResponseTimeout
Integer ftpResponseTimeout ;
Causes curl to set a timeout period (in seconds) on the amount of time that the server is allowed to take in order to generate a response message for a command before the session is considered hung. ftpSkipPasvIp
19 curl
Boolean ftpSkipPasvIp ;
If set to a true value, it instructs libcurl to not use the IP address the server suggests in its 227-response to libcurl's PASV command when libcurl connects the data connection. Instead libcurl will re-use the same IP address it already uses for the control connection. But it will use the port number from the 227-response. ftpSSLAuth
Integer ftpSSLAuth ;
See curl.FTPAuth ftpSSLCCC
Integer ftpSSLCCC ;
See curl.FTPSSL. If enabled, this option makes libcurl use CCC (Clear Command Channel). It shuts down the SSL/TLS layer after authenticating. The rest of the control channel communication will be unencrypted. This allows NAT routers to follow the FTP transaction. ftpUseEPRT
Boolean ftpUseEPRT ;
Tells curl to use the EPRT (and LPRT) command when doing active FTP downloads. ftpUseEPSV
Boolean ftpUseEPSV ;
Tells curl to use the EPSV command when doing passive FTP downloads. header
Boolean header ;
Set this to true tells the library to include the header in the body output. This is the same as calling setopt with Option.HEADER when set. http200Aliases
Array http200Aliases ;
Pass an array with aliases to be treated as valid HTTP 200 responses. Some servers respond with a custom header response line. For example, IceCast servers respond with "ICY 200 OK". By including this string in your list of aliases, the response will be treated as a valid HTTP header line such as "HTTP/1.0 200 OK". httpAuth
20 curl
Integer httpAuth ;
Tell libcurl what authentication method(s) to use. See curl.Auth HttpContentDecoding
Boolean HttpContentDecoding ;
If set to false, content decoding will be disabled. If set to true it is enabled. Note however that libcurl has no default content decoding but requires you to use encoding for that. httpGet
Boolean httpGet ;
When true, this forces the HTTP request to get back to GET. usable if a POST, HEAD, PUT or a custom request have been used previously using the same curl handle.
When setting httpGet to true, it will automatically set noBody. httpVersion
Integer httpVersion ;
This forces libcurl to use the specific HTTP versions. This is not sensible to do unless you have a good reason. See curl.Http httpHeader
Array httpHeader ;
An array with String elements which are HTTP headers to pass to the server in your HTTP request. If you add a header that is otherwise generated and used by libcurl internally, your added one will be used instead. If you add a header with no contents as in 'Accept:' (no data on the right side of the colon), the internally used header will get disabled. Thus, using this option you can add new headers, replace internal headers and remove internal headers. To add a header with no contents, make the contents be two quotes: "". The headers included in the array must not be CRLF-terminated, because curl adds CRLF after each header item. Failure to comply with this will result in strange bugs because the server will most likely ignore part of the headers you specified. httpPost
curl.Form httpPost ;
A multipart/formdata HTTP POST. httpProxyTunnel
Boolean httpProxyTunnel ;
21 curl
Set the parameter to true to get the library to tunnel all operations through a given HTTP proxy. This is the same as calling setopt with Option.HTTPPROXYTUNNEL. httpTransferDecoding
Boolean httpTransferDecoding ;
If set to false, transfer decoding will be disabled, if set to true it is enabled (default). libcurl does chunked transfer decoding by default unless this option is set to zero. ignoreContentLength
Boolean ignoreContentLength ;
Ignore the Content-Length header. This is useful for Apache 1.x (and similar servers) which will report incorrect content length for files over 2 gigabytes. If this option is used, curl will not be able to accurately report progress, and will simply stop the download when the server ends the connection. inFileSize
Integer inFileSize ;
When uploading a file to a remote site, this option should be used to tell libcurl what the expected size of the infile is. interface
String interface ;
This sets the interface name to use as outgoing network interface. The name can be an interface name, an IP address or a host name. This is the same as calling setopt with Option.INTERFACE. localPort
Integer localPort ;
This sets the local port number of the socket used for connection. This is the same as calling setopt with Option.LOCALPORT. localPortRange
Integer localPortRange ;
This is the number of attempts libcurl should do to find a working local port number. It starts with the given localPort and adds one to the number for each retry. Setting this value to 1 or below will make libcurl do only one try for exact port number. Note that port numbers by nature is a scarce resource that will be busy at times so setting this value to something too low might cause unnecessary connection setup failures. This is the same as calling setopt with Option.LOCALPORTRANGE.
22 curl maxFileSize
Integer maxFileSize ;
This allows you to specify the maximum size (in bytes) of a file to download. If the file requested is larger than this value, the transfer will not start and Error.FILESIZE_EXCEEDED will be returned. maxRedirs
Integer maxRedirs ;
The redirection limit. netrc
Integer netrc ;
This parameter controls the preference of libcurl between using user names and passwords from your ~/.netrc file, relative to user names and passwords in the URL supplied with url. See netrc for values. netrcFile
String netrcFile ;
Contains the full path name to the file you want libcurl to use as .netrc file. If this option is omitted, and netrc is set, libcurl will attempt to find the a .netrc file in the current user's home directory. noBody
Boolean noBody ;
Tells the library to not include the body-part in the output. noProgress
Boolean noProgress ;
Set this to true tells the library to shut off the built-in progress meter completely. This is the same as calling setopt with Option.NOPROGRESS when set. port
Integer port ;
Set the remote port number to connect to, instead of the one specified in the URL or the default port for the used protocol. This is the same as calling setopt with Option.PORT.
23 curl post
Boolean post ;
Tells the library to do a regular HTTP post. postFields
core.Binary postFields ;
A buffer with the full data to post in an HTTP POST operation. Make sure that the data is formatted the way you want the server to receive it. libcurl will not convert or encode it for you. Most web servers will assume this data to be url-encoded. The buffer is not copied by the library: as a consequence, they must be preserved by the calling application until the transfer finishes. postQuote
Array postQuote ;
An array with FTP or SFTP commands to pass to the server after your ftp transfer request. preQuote
Array preQuote ;
An array with FTP commands to pass to the server after the transfer type is set. protocols
Integer protocols ;
Pass a long that holds a bitmask of curl.Protocol constants. If used, this bitmask limits what protocols libcurl may use in the transfer. This allows you to have a libcurl built to support a wide range of protocols but still limit specific transfers to only be allowed to use a subset of them. By default libcurl will accept all protocols it supports. See also redirProtocols. proxy
String proxy ;
Set HTTP proxy to use. This is the same as calling setopt with Option.PROXY. proxyAuth
Integer proxyAuth ;
Tells libcurl what authentication method(s) to use for the proxy authentication.
24 curl proxyPort
Integer proxyPort ;
Set the proxy port to connect to unless it is specified in the proxy string. This is the same as calling setopt with Option.PROXYPORT. proxyUserPwd
String proxyUserPwd ; quote
Array quote ;
An array with FTP or SFTP commands to pass to the server prior to your ftp request. This will be done before any other commands are issued (even before the CWD command for FTP). range
String range ;
A property which should contain the specified range you want. It should be in the format "X-Y", where X or Y may be left out. HTTP transfers also support several intervals, separated with commas as in "X-Y,N- M". Using this kind of multiple intervals will cause the HTTP server to send the response document in pieces (using standard MIME separation techniques). Pass a null to this option to disable the use of ranges. redirProtocols
Integer redirProtocols ;
Pass a long that holds a bitmask of curl.Protocol constants. If used, this bitmask limits what protocols libcurl may use in a transfer that it follows to in a redirect when followLocation is enabled. This allows you to limit specific transfers to only be allowed to use a subset of protocols in redirections. By default libcurl will allow all protocols except for FILE and SCP. referer
String referer ;
This will be used to set the Referer: header in the http request sent to the remote server. This can be used to fool servers or scripts. resumeFrom
Integer resumeFrom ;
25 curl
It contains the offset in number of bytes that you want the transfer to start from. Set this option to 0 to make the transfer start from the beginning (effectively disabling resume). For FTP, set this option to -1 to make the transfer start from the end of the target file (useful to continue an interrupted upload). tcpNoDelay
Boolean tcpNoDelay ;
Setting this option to true will disable TCP's Nagle algorithm. The purpose of this algorithm is to try to minimize the number of small packets on the network (where "small packets" means TCP segments less than the Maximum Segment Size (MSS) for the network). This is the same as calling setopt with Option.TCP_NODELAY timeCondition
Integer timeCondition ; timeout
Integer timeout ;
The maximum time in seconds that you allow the libcurl transfer operation to take. Normally, name lookups can take a considerable time and limiting operations to less than a few minutes risk aborting perfectly normal operations. This option will cause curl to use the SIGALRM to enable time-outing system calls. timeoutMs
Double timeoutMs ;
Like timeout but takes number of milliseconds instead. timeValue
Double timeValue ; transferText
Boolean transferText ;
When true, it tells the library to use ASCII mode for ftp transfers, instead of the default binary transfer. For win32 systems it does not set the stdout to binary mode. unrestrictedAuth
Boolean unrestrictedAuth ;
26 curl
True tells the library it can continue to send authentication (user+password) when following locations, even when hostname changed. upload
Boolean upload ;
When true, it tells the library to prepare for an upload. url
String url ;
The actual URL to deal with. This is the same as calling setopt with Option.URL. useragent
String useragent ;
This will be used to set the User-Agent: header in the http request sent to the remote server. This can be used to fool servers or scripts. username
String username ;
Sets the user name to be used in protocol authentication. You should not use this option together with the (older) userPwd. password
String password ;
Set a password to use for the transfer. proxyUsername
String proxyUsername ;
Sets user name to use for the transfer while connecting to Proxy. proxyPassword
String proxyPassword ;
Set a password to use for connecting to the proxy.
27 curl useSSL
Integer useSSL ; userPwd
String userPwd ;
A string which should be [user name]:[password] to use for the connection. verbose
Boolean verbose ;
Set this to true to get the library to display a lot of verbose information about its operations. This is the same as calling setopt with Option.VERBOSE. bufferSize
Integer bufferSize ;
Set the preferred size (in bytes) for the receive buffer in libcurl. The main point of this would be that the write callback gets called more often and with smaller chunks. This is the same as calling setopt with Option.BUFFERSIZE. lowSpeedLimit
Integer lowSpeedLimit ;
It contains the transfer speed in bytes per second that the transfer should be below during lowSpeedTime seconds for the library to consider it too slow and abort. lowSpeedTime
Integer lowSpeedTime ;
It contains the time in seconds that the transfer should be below the lowSpeedLimit for the library to consider it too slow and abort. maxSendSpeed
Double maxSendSpeed ;
If an upload exceeds this speed on cumulative average during the transfer, the transfer will pause to keep the average rate less than or equal to this property.
28 curl maxRecvSpeed
Double maxRecvSpeed ;
If a download exceeds this speed on cumulative average during the transfer, the transfer will pause to keep the average rate less than or equal to the property value. maxConnects
Integer maxConnects ;
The set number will be the persistent connection cache size. The set amount will be the maximum amount of simultaneously open connections that libcurl may cache in this easy handle. Default is 5, and there isn't much point in changing this value unless you are perfectly aware of how this work and changes libcurl's behaviour. This concerns connection using any of the protocols that support persistent connections.
When reaching the maximum limit, curl closes the oldest one in the cache to prevent the number of open connections to increase. freshConnect
Boolean freshConnect ;
Set to true to make the next transfer use a new (fresh) connection by force. If the connection cache is full before this connection, one of the existing connections will be closed as according to the selected or default policy. forbidReuse
Boolean forbidReuse ;
Set to true to make the next transfer explicitly close the connection when done. Normally, libcurl keep all connections alive when done with one transfer in case there comes a succeeding one that can re-use them. connectTimeout
Integer connectTimeout ;
This should contain the maximum time in seconds that you allow the connection to the server to take. This only limits the connection phase, once it has connected, this option is of no more use. connectTimeoutMS
Double connectTimeoutMS ;
Like connectTimeout but takes number of milliseconds instead. ipResolve
29 curl
Integer ipResolve ;
Allows an application to select what kind of IP addresses to use when resolving host names. This is only interesting when using host names that resolve addresses using more than one version of IP. connectOnly
Boolean connectOnly ;
A true value tells the library to perform any required proxy authentication and connection setup, but no data transfer. sslCert
String sslCert ;
The string should be the file name of a certificate. sslCertType
String sslCertType ;
The string should be the format of the certificate. Supported formats are "PEM" and "DER" sslKey
String sslKey ;
The string should be the file name of a private key. The default format is "PEM" and can be changed with sslKeyType. sslKeyType
String sslKeyType ;
The string should be the format of the private key. Supported formats are "PEM", "DER" and "ENG". keyPasswd
String keyPasswd ;
It will be used as the password required to use the sslKey or sshPrivateKeyFile private key. sslEngine
String sslEngine ;
It will be used as the identifier for the crypto engine you want to use for your private key.
30 curl sslEngineDefault
String sslEngineDefault ;
Sets the actual crypto engine as the default for (asymmetric) crypto operations. sslVersion
Integer sslVersion ;
Control what version of SSL/TLS to attempt to use. See curl.SSLVersion sslVerifyPeer
Boolean sslVerifyPeer ;
This property determines whether curl verifies the authenticity of the peer's certificate. A true value means curl verifies. cainfo
String cainfo ;
A String naming a file holding one or more certificates to verify the peer with. capath
String capath ;
A String naming a directory holding multiple CA certificates to verify the peer with. randomFile
String randomFile ;
The file will be used to read from to seed the random engine for SSL. The more random the specified file is, the more secure the SSL connection will become. egdSocket
String egdSocket ;
Path name to the Entropy Gathering Daemon socket. It will be used to seed the random engine for SSL. sslVerifyHost
Integer sslVerifyHost ;
31 curl
This option determines whether libcurl verifies that the server cert is for the server it is known as. sslCipherList
String sslCipherList ;
A String holding the list of ciphers to use for the SSL connection. The list must be syntactically correct, it consists of one or more cipher strings separated by colons. Commas or spaces are also acceptable separators but colons are normally used, !, - and + can be used as operators. sslSessionIdCache
Boolean sslSessionIdCache ;
False disables libcurl's use of SSL session-ID caching. Set this to true to enable it. krbLevel
String krbLevel ;
Set the kerberos security level for FTP; this also enables kerberos awareness. This is a string, 'clear', 'safe', 'confidential' or 'private'. If the string is set but doesn't match one of these, 'private' will be used. Set the property to null to disable kerberos support for FTP. sshAuthTypes
Integer sshAuthTypes ;
See curl.SSHAuth. sshHostPublicKeyMD5
String sshHostPublicKeyMD5 ;
A string containing 32 hexadecimal digits. The string should be the 128 bit MD5 cheksum of the remote host's public key, and libcurl will reject the connection to the host unless the md5sums match. This option is only for SCP and SFTP transfers. sshPublicKeyFile
String sshPublicKeyFile ;
A file name for the public key. sshPrivateKeyFile
String sshPrivateKeyFile ;
32 curl
A file name for the private key. newFilePerms
Integer newFilePerms ;
Permissions that will be assigned to newly created files on the remote server. The default value is 0644, but any valid value can be used. newDirectory
Integer newDirectory ;
Permissions that will be assigned to newly created directories on the remote server. The default value is 0755, but any valid value can be used. telnetOptions
Array telnetOptions ;
The elements should be in the format
Integer proxyType ;
Set the type of the proxy. Use constants of the class curl.ProxyType. Methods cleanup
cleanup();
Destroys the CURL handle. When you call this, you can't use this object anymore. escape
String escape(String Str);
URL encodes the given string. This function converts the given input string to an URL encoded string and returns that as a new string. All input characters that are not a-z, A-Z or 0-9 are converted to their "URL escaped" version (%NN where NN is a two-digit hexadecimal number). unescape
33 curl
String unescape(String Str);
This function converts the given URL encoded input string to a plain string duphandle
Easy duphandle();
This function will return a new Easy curl object, a duplicate, using all the options of this object. The new object will not inherit any state information, no connections, no SSL sessions and no cookies. reset
reset();
Re-initializes all options previously set on a specified CURL object to the default values.
It does not change the following information kept in the object: live connections, the Session ID cache, the DNS cache, the cookies and shares. getinfo
Mixed getinfo(Integer info);
Request internal information from the curl session with this function. setopt
Integer setopt(Integer opt, Mixed parameter);
Integer setopt(Object Options);
Set options for curl. You can set properties using an object or by calling setopt several times.
var curl = require("curl"); var options = new Object(); options[curl.Option.URL] = "http://www.sitepoint.com"; options[curl.Option.HEADER] = 1;
var c = new curl.Easy(); c.setopt(options);
is the same as
var curl = require("curl"); var c = new curl.Easy();
34 curl
c.setopt(curl.Option.URL, "http://www.sitepoint.com"); c.setopt(curl.Option.HEADER, 1); perform
Integer perform();
This function is called after all the setopt calls are made, and will perform the transfer as described in the options. You can do any amount of calls to perform while using the same object. If you intend to transfer more than one file, you are even encouraged to do so. libcurl will then attempt to re-use the same connection for the following transfers, thus making the operations faster, less CPU intense and using less network resources. Just note that you will have to use setopt between the invokes to set options for the following perform.
You must never call this function simultaneously from two places using the same object. Let the function return first before invoking it another time. If you want parallel transfers, you must use several curl objects. Events onWrite
The function is called as soon as there is data received that needs to be saved. The data is passed as a core.Binary. The return value should be the number of bytes actually used from the buffer. When this amount differs from the size of the buffer, curl will report an error and will abort the transfer. onRead
This function gets called by libcurl as soon as it needs to read data in order to send it to the peer. This function must return a core.Binary which contains the data. Return 'null' to stop the transfer. onProgress
This function gets called by curl instead of its internal equivalent with a frequent interval during operation (roughly once per second) no matter if data is being transfered or not. Unknown/unused argument values passed to the callback will be set to zero (like if you only download data, the upload size will remain 0). Returning a non-zero value from this callback will cause libcurl to abort the transfer. Arguments are: download total, download now, upload total, upload now.
35 curl
Name curl.Form — Building a multipart/formdata HTTP POST
This class can be used for building a multipart/formdata HTTP POST. Constructor
Form();
Creates a new Form Methods addName
Integer addName(String Name, String Content);
Appens a new section addFile
Integer addFile(String Name, String File, String ContentType);
Adds a file
36 curl
Name curl.FTPAuth — Defines constants for ftpSSLAuth
This class defines constants for setting the property ftpSSLAuth. Constants
Table 5.2. Constants of curl.FTPAuth
Name Description DEFAULT SSL TLS
37 curl
Name curl.FTPMethod — Defines constants for ftpFileMethod
This class defines constants for setting the property ftpFileMethod. Constants
Table 5.3. Constants of curl.FTPMethod
Name Description MULTICWD NOCWD SINGLECWD
38 curl
Name curl.FTPSSL — Defines constants for ftpSSLCCC
This class defines constants for setting the property ftpSSLCCC Constants
Table 5.4. Constants of curl.FTPSSL
Name Description CCC_ACTIVE CCC_NONE CCC_PASSIVE
39 curl
Name curl.Http — Defines constants for httpVersion
Use the constants of this class for setting httpVersion Constants
Table 5.5. Constants of curl.Http
Name Description VERSION_1_0 VERSION_1_1 VERSION_NONE
40 curl
Name curl.Info — Defines constants for use with getinfo
Use the constants in the method getinfo to request internal information from the curl session. Look at libcurl website [http://curl.haxx.se/libcurl/c] for more information about all these constants. Constants
Table 5.6. Constants of curl.Info
Name Description APPCONNECT_TIME Get the time, in seconds, it took from the start until the SSL/SSH connect/handshake to the remote host was completed CERTINFO Not implemented yet! CONDITION_UNMET Get 1 if the condition provided in the previous request didn't match CONNECT_TIME Get the time, in seconds, it took from the start until the connect to the remote host (or proxy) was completed CONTENT_LENGTH_DOWNLOAD Get the content-length of the download. CONTENT_LENGTH_UPLOAD Get the specified size of the upload. CONTENT_TYPE Get the content-type of the downloaded object. This is the value read from the Content-Type: field. COOKIELIST Get a list of all cookies cURL knows EFFECTIVE_URL Get the last used effective URL. FILETIME Get the remote time of the retrieved document (in number of seconds since 1 jan 1970 in the GMT/ UTC time zone). FTP_ENTRY_PATH Get a string holding the path of the entry path. HEADER_SIZE Get the total size of all the headers received. Measured in number of bytes. HTTPAUTH_AVAIL Get a bitmask indicating the authentication method(s) available. HTTP_CONNECTCODE Get the last received proxy response code to a CONNECT request LASTSOCKET Get the last socket used by this curl session. NAMELOOKUP_TIME Get the time, in seconds, it took from the start until the name resolving was completed. NUM_CONNECTS Get how many new connections libcurl had to create to achieve the previous transfer. OS_ERRNO Get the errno variable from a connect failure. PRETRANSFER_TIME Get the time, in seconds, it took from the start until the file transfer is just about to begin
41 curl
Name Description PRIMARY_IP Get a string holding the IP address of the most recent connection done with this curl handle. PROXYAUTH_AVAIL Get a bitmask indicating the authentication method(s) available for your proxy authentication. REDIRECT_COUNT Get the total number of redirections that were actually followed. REDIRECT_TIME Get the total time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before final transaction was started. REQUEST_SIZE Get the total size of the issued requests. RESPONSE_CODE Get the last received HTTP or FTP code. SIZE_DOWNLOAD Get the total amount of bytes that were downloaded. SIZE_UPLOAD Get the total amount of bytes that were uploaded. SPEED_DOWNLOAD Get the average download speed that curl measured for the complete download. SPEED_UPLOAD Get the average upload speed that curl measured for the complete upload. SSL_ENGINES SSL_VERIFYRESULT Get the result of the certification verification that was requested. STARTTRANSFER_TIME Get the time, in seconds, it took from the start until the first byte is just about to be transferred. TOTAL_TIME Get the total time in seconds for the previous transfer, including name resolving, TCP connect etc.
42 curl
Name curl.IPResolve — Defines constants for ipResolve
Use the constants of this class for setting ipResolve Constants
Table 5.7. Constants of curl.IPResolve
Name Description V4 Resolve to IPv4 addresses. V6 Resolve to IPv6 addresses. WHATEVER Default, resolves addresses to all IP versions that your system allows.
43 curl
Name curl.Multi — A class to create a libcurl multi session
Class Methods strerror
String strerror(Integer Code); Constructor
Multi();
This creates a new libcurl multi session. It is automatically cleaned up. Methods addHandle
Integer addHandle(curl.Easy Curl); removeHandle
Integer removeHandle(curl.Easy Curl); perform
Integer perform();
44 curl
Name Curl
45 curl
Name curl.Netrc — Defines constants for netrc
Use the constants of this class to set netrc Constants
Table 5.8. Constants of curl.Netrc
Name Description IGNORED The library will ignore the file and use only the information in the URL. This is the default. OPTIONAL The use of your ~/.netrc file is optional, and information in the URL is to be preferred. The file will be scanned for the host and user name (to find the password only) or for the host only, to find the first user name and password after that machine, which ever information is not specified in the URL. REQUIRED This value tells the library that use of the file is required, to ignore the information in the URL, and to search the file for the host only.
46 curl
Name curl.Option — Contains constants for setopt method
Use the constants of this class to set options:
var curl = require("curl"); var options = new Object(); options[curl.Option.VERBOSE] = true; options[curl.Option.URL] = "http://gluescript.sf.net"; var c = new curl.Easy(); c.setopt(options);
For more information about all these options, look at curl_easy_setopt [http://curl.haxx.se/libcurl/c/ curl_easy_setopt.html] api documentation and the documentation of curl.Easy (all these options are also properties of this class). Constants
Table 5.9. Constants of curl.Option
Name Description APPEND AUTOREFERER BUFFERSIZE CAINFO CAPATH CONNECTTIMEOUT CONNECTTIMEOUT_MS COOKIE COOKIEFILE COOKIEJAR COOKIELIST COOKIESESSION CRLF CUSTOMREQUEST DIRLISTONLY DNS_CACHE_TIMEOUT EGDSOCKET ENCODING FAILONERROR FILETIME FOLLOWLOCATION
47 curl
Name Description FORBID_REUSE FRESH_CONNECT FTPPORT FTPSSLAUTH FTP_ACCOUNT FTP_ALTERNATIVE_TO_USER FTP_CREATE_MISSING_DIRS FTP_FILEMETHOD FTP_RESPONSE_TIMEOUT FTP_SKIP_PASV_IP FTP_SSL_CCC FTP_USE_EPRT FTP_USE_EPSV HEADER HTTP200ALIASES HTTPAUTH HTTPGET HTTPHEADER HTTPPOST HTTPPROXYTUNNEL HTTP_CONTENT_DECODING HTTP_TRANSFER_DECODING HTTP_VERSION IGNORE_CONTENT_LENGTH INFILESIZE INFILESIZE_LARGE INTERFACE IPRESOLVE KEYPASSWD KRBLEVEL LOCALPORT LOCALPORTRANGE LOW_SPEED_LIMIT LOW_SPEED_TIME MAXCONNECTS MAXFILESIZE MAXFILESIZE_LARGE MAXREDIRS
48 curl
Name Description MAX_RECV_SPEED_LARGE MAX_SEND_SPEED_LARGE NETRC NETRC_FILE NEW_DIRECTORY_PERMS NEW_FILE_PERMS NOBODY NOPROGRESS NOSIGNAL PASSWORD PORT POST POSTFIELDS POSTFIELDSIZE POSTFIELDSIZE_LARGE POSTQUOTE PREQUOTE PROTOCOLS PROXY PROXYAUTH PROXYPASSWORD PROXYPORT PROXYTYPE PROXYUSERNAME PROXYUSERPWD PUT QUOTE RANDOM_FILE RANGE REDIR_PROTOCOLS REFERER RESUME_FROM RESUME_FROM_LARGE SSH_AUTH_TYPES SSH_PRIVATE_KEYFILE SSH_PUBLIC_KEYFILE SSLCERT SSLCERTTYPE
49 curl
Name Description SSLENGINE SSLENGINE_DEFAULT SSLKEY SSLKEYTYPE SSLVERSION SSL_CIPHER_LIST SSL_SESSIONID_CACHE SSL_VERIFYHOST SSL_VERIFYPEER STDERR TCP_NODELAY TELNETOPTIONS TIMECONDITION TIMEOUT TIMEOUT_MS TIMEVALUE TRANSFERTEXT UNRESTRICTED_AUTH UPLOAD URL USERAGENT USERNAME USERPWD USE_SSL VERBOSE
50 curl
Name curl.Protocol — Defines constants for protocols and redirProtocols
Use the constants of this class to set protocols and redirProtocols. Constants
Table 5.10. Constants of curl.Protocol
Name Description DICT FILE FTP FTPS HTTP HTTPS LDAP SCP SFTP TELNET TFTP VERBOSE
51 curl
Name curl.ProxyType — Defines constants for proxyType
Use the constants of this class to set the property proxyType Constants
Table 5.11. Constants of curl.ProxyType
Name Description HTTP Default use HTTP/1.1 HTTP_1_0 Use HTTP/1.0 SOCKS4 SOCKS4A SOCKS5 SOCKS5_HOSTNAME
52 curl
Name curl.SSHAuth — Defines constants for sshAuthTypes
This class defines constants for setting the property sshAuthTypes. Constants
Table 5.12. Constants of curl.SSHAuth
Name Description ANY HOST KEYBOARD PASSWORD PUBLICKEY
53 curl
Name curl.SSLVersion — Defines constants for sslVersion
Use the constants for setting the property sslVersion. Constants
Table 5.13. Constants of curl.SSLVersion
Name Description DEFAULT SSLv2 SSLv3 TLSv1
54 curl
Name curl.UseSSL — Defines constants for useSSL
Use the constants of this class to set the property useSSL Constants
Table 5.14. Constants of curl.UseSSL
Name Description ALL CONTROL NONE TRY
55 Chapter 6. Data Introduction
The data glue is a common database framework based on Poco Data. Poco Data is an abstraction layer which allows users to easily send/retrieve data to/from various different SQL databases. At the moment the following databases are supported: "SQLite", "ODBC" and "MySQL". To use them, use these name as argument to the constructor of data.Session The data glue is still in early development. Also note that only string, numbers and boolean can be used in the bind method of Statement for the moment. Reference
56 Data
Name data.Session — A Session holds a connection to a database and creates Statement objects.
Constructor
Session(String Connector, String Connection);
Creates a new session, using the given connector (MySQL, SQLite or ODBC), and connectionString. Properties connected
Boolean connected ;
Returns true if the session is connected transaction
Boolean transaction ;
Returns true when a transaction is in progress. Methods begin
begin();
Starts a transaction. close
close();
Closes the session. This is automatically done when the Session object is garbage collected. commit
commit();
Commits and ends a transaction. execute
57 Data
execute(String SQL);
Executes a SQL statement getFeature
Boolean getFeature(String Name);
Look up the state of a feature. getProperty
Any getProperty(String Name);
Look up the value of a property. prepare
data.Statement prepare(String SQL);
Prepares a data.Statement. rollback
rollback();
Rolls back and ends a transaction. setFeature
setFeature(String Name, Boolean State);
Set the state of a feature. setProperty
setProperty(String Name, Any Value);
Set the value of a property.
58 Data
Name data.Statement — A Statement is used to execute SQL statements.
Properties done
Boolean done ;
Returns if the statement was completely executed or if a previously set limit stopped it and there is more work to do. When no limit is set, it will always - after calling execute() - return true. Methods bind
bind();
Binds a value. At this time, only numeric, boolean and string values are allowed! execute
Integer execute(); toString
String toString();
Creates a string from the accumulated SQL statement
59 Data
Name data.RecordSet — RecordSet provides access to data returned from a query.
Recordset provides navigation methods to iterate through the recordset, retrieval methods to extract data, and methods to get metadata (type, etc.) about columns. To work with a RecordSet, first create a data.Statement, execute it, and create the RecordSet from the Statement, as follows:
var stmt = session.prepare("SELECT * FROM Person"); stmt.execute(); var rs = new RecordSet(stmt);
Constructor
RecordSet(data.Statement Statement);
Creates a new RecordSet object Properties columnCount
Integer columnCount ;
Returns the number of columns rowCount
Integer rowCount ;
Returns the number of rows Methods columnLength
columnLength(Integer Pos);
columnLength(String Name);
Returns the maximum length of the column. columnName
columnName(Integer Pos);
60 Data
Returns the name of the column. columnType
columnType(Integer Pos);
columnType(String Name);
Returns the type of the column. columnPrecision
columnPrecision(); moveFirst
Boolean moveFirst();
Moves the row cursor to the first row. Returns true if there is at least one row in the RecordSet, false otherwise. moveLast
Boolean moveLast();
Moves the row cursor to the last row. Returns true if there is at least one row in the RecordSet, false otherwise. moveNext
Boolean moveNext();
Moves the row cursor to the next row. Returns true if the row is available, or false if the end of the record set has been reached and no more rows are available. movePrevious
Boolean movePrevious();
Moves the row cursor to the previous row. Returns true if the row is available, or false if there are no more rows available. value
value();
61 Chapter 7. expat Introduction
The expat glue ports the expat [http://expat.sourceforge.net] XML parser to JavaScript. expat is a stream- oriented parser in which an application registers handlers for things the parser might find in the XML document (like start tags). Reference
62 expat
Name expat.Parser — Parse XML with the expat parser
Parser implements the expat [http://expat.sourceforge.net] XML parser. Constants
Table 7.1. Constants of expat.Parser
Name Description XML_STATUS_ERROR XML_STATUS_OK Constructor
Parser(String Encoding= null);
Constructs a new parser. Properties characters
String characters ;
When the onCharacter callback is not used, XMLParser will collect the characters in this property. It will be cleared when a start tag is read and it will be complete when an end tag is read. onCharacter
Function onCharacter ;
This function is called when contiguous text free of tags is found. Note that this function can be called more then ounce for the same tag. The function gets one argument: the received data. onComment
Function onComment ;
Set a handler for comments. This function gets one argument: all text inside the comment delimiters. onDefault
Function onDefault ;
The function hase one argument: any characters in the document which wouldn't otherwise be handled. This includes both data for which no handlers can be set (like some kinds of DTD declarations) and data
63 expat
which could be reported but which currently has no handler set. The characters are passed exactly as they were present in the XML document except that they will be encoded in UTF-8. Line boundaries are not normalized. Note that a byte order mark character is not passed to the default handler. There are no guarantees about how characters are divided between calls to the default handler: for example, a comment might be split between multiple calls. Setting this handler has the side effect of turning off expansion of references to internally defined general entities. Instead these references are passed to the default handler. onDefaultExpand
Function onDefaultExpand ;
This sets a default handler, but doesn't inhibit the expansion of internal entity references. The entity reference will not be passed to the default handler. The function has one argument: any characters in the document which wouldn't otherwise handled. onEndCData
Function onEndCData ;
This function is called at the end of a CDATA section. onEndElement
Function onEndElement ;
This function will be called everytime when a tag is ended (also for empty tags). The functions gets one argument: the name of the element. onEndNamespaceDecl
Function onEndNamespaceDecl ; onExternalEntityRef
Function onExternalEntityRef ;
Set an external entity reference handler. This handler is also called for processing an external DTD subset if parameter entity parsing is in effect. This function gets 5 arguments: XMLParser, context, base, systemId and publicId. The function must return an integer value: non-zero for success, zero for failure. onProcessing
Function onProcessing ;
This function will be called for processing instructions. It gets two arguments: target and data. A target is the first word in the processing instruction. The data is the rest of the characters in it after skipping all whitespace after the initial word. onSkippedEntity
64 expat
Function onSkippedEntity ;
The function has two arguments: the entity name and a boolean which will be true the entity is a parameter entity and false for general entity. This function is called in two situations:
• An entity reference is encountered for which no declaration has been read and this is not an error.
• An internal entity reference is read, but not expanded, because the onDefault handler has been called. onStartCData
Function onStartCData ;
This function is called at the beginning of a CDATA section. onStartElement
Function onStartElement ;
This function will be called everytime when a tag is started (also for empty tags). The functions get two arguments: the name of the element and an object with contains properties which you can access with the name of the attribute. Methods reset
Boolean reset();
Clean up the memory structures maintained by the parser so that it may be used again. After this has been called, parser is ready to start parsing a new document. parse
Integer parse(String Content, Boolean Final);
Parse some more of the document. Returns XML_STATUS_ERROR or XML_STATUS_OK.
The following example shows how easy it is to create a simple DOM structure in JavaScript.
var expat = require("expat");
// Constructor for a XMLElement object function XMLElement(parent, name, attrs) { this.parent = parent; if ( parent != null ) parent.elements[parent.elements.length + 1] = this; this.name = name; this.attrs = attrs;
65 expat
this.elements = new Array(); } var p = new expat.Parser(); p.currentElement = null; p.onStartElement = function(element, attrs) { this.currentElement = new XMLElement(this.currentElement, element, attrs); } p.onEndElement = function(element) { this.currentElement.data = this.characters;
if ( this.currentElement.parent != null ) this.currentElement = this.currentElement.parent; } p.parse('
66 Chapter 8. fcgi Introduction
glue_fcgi is a FastCGI process. Use this to create dynamic webpages with JavaScript, E4X, ... on a webserver that supports FastCGI.
Download mod_fastcgi from FastCGI [], install it and configure it as follows:
LoadModule fastcgi_module modules/mod_fastcgi.dll FastCGIExternalServer "c:/xampp/htdocs/fcgi" -host localhost:9000
Before requesting pages, you need to start glue_fastcgi (no need to pass the port argument, because 9000 is the default). Example
Each request is run in its own context. The following objects are constructed before the script is run: fcgi which is a FCGI. This example is a simple echo program:
fcgi.write("Content-type: text/html; charset=iso-8859-1\r\n\r\n"); // cgi response: http://www.ietf.org/rfc/rfc3875 var params = fcgi.getParam(); for(i in params) { fcgi.write(""); fcgi.write(i); fcgi.write(""); fcgi.write(params[i]); fcgi.write("
"); }
Save this program in c:/xampp/htdocs/fcgi. Class Reference
67 fcgi
Name FCGI — Implements FastCGI
Methods getParam
Object getParam();
String getParam(String Param);
An object is returned containing all parameters as properties of the object, or a String is returned when a certain parameter is asked. read
String read(Integer Len);
Reads up to Len consecutive bytes from the input stream. When an empty string is returned, the end of the input has been reached. write
Integer write(String Data);
Integer write(core.Binary Buffer);
Writes a string or buffer into the output stream. The number of characters (or bytes) written are returned. flush
Integer flush(); writeError
Integer writeError(String Data);
68 Chapter 9. gd Introduction
gd ports the GD library [http://www.libgd.org] to JavaScript. GD is a graphics library. It allows your code to quickly draw images complete with lines, arcs, text, multiple colors, cut and paste from other images, and flood fills, and write out the result as a PNG or JPEG file. This is particularly useful in World Wide Web applications, where PNG and JPEG are two of the formats accepted for inline images by most browsers. Examples Drawing a pixel
A white pixel will be drawn in the middle of a black square using setPixel.
var gd = require("gd"); var img = new gd.Image({ width : 100, height: 100 }); // Background colour first var black = img.colorAllocate( { red: 0, green: 0, blue: 0 }); var white = img.colorAllocate( { red: 255, green : 255, blue: 255 });
img.setPixel({ x : 50, y: 50 }, white);
var jpeg = new gd.ImageJPEG(img); jpeg.write("c:\\temp\\pixel.jpg");
Drawing a line
A white line is drawn from the upper left corner to the bottom right corner using line
69 gd
var gd = require("gd"); var img = new gd.Image({ width : 100, height: 100 }); // Background colour first var black = img.colorAllocate( { red: 0, green: 0, blue: 0 }); var white = img.colorAllocate( { red: 255, green : 255, blue: 255 });
img.line({ x : 0, y : 0 }, { x : 99, y : 99 }, white);
var jpeg = new gd.ImageJPEG(img); jpeg.write("c:\\temp\\line.jpg");
Drawing a dashed line
This example shows how to draw a dashed line. A dashed white line is drawn from the upper left corner to the bottom right corner using setStyle and line
var gd = require("gd"); var img = new gd.Image({ width : 100, height: 100 }); // Background colour first var black = img.colorAllocate( { red: 0, green: 0, blue: 0 }); var white = img.colorAllocate( { red: 255, green : 255, blue: 255 });
var style = new Array(white, white, white, gd.transparent, gd.transparent, gd.transparent); img.setStyle(style); img.line({ x : 0, y : 0 }, { x : 99, y : 99 }, gd.styled);
var jpeg = new gd.ImageJPEG(img); jpeg.write("c:\\temp\\dashed.jpg")
70 gd
Drawing a triangle
A triangle is drawn using the polygon functions. This example will draw a white triangle on a black background. For a filled triangle, use filledPolygon.
var gd = require("gd"); var img = new gd.Image({ width : 100, height: 100 }); // Background colour first var black = img.colorAllocate( { red: 0, green: 0, blue: 0 }); var white = img.colorAllocate( { red: 255, green : 255, blue: 255 });
var points = new Array( { x : 50, y : 0 }, { x : 99, y : 99 }, { x : 0, y : 99 }); img.polygon(points, white);
var jpeg = new gd.ImageJPEG(img); jpeg.write("c:\\temp\\polygon.jpg");
Drawing a rectangle
A rectangle is drawn with rectangle.
var gd = require("gd"); var img = new gd.Image({ width: 100, height: 100 }); // Background colour first var black = img.colorAllocate( { red: 0, green: 0, blue: 0 }); var white = img.colorAllocate( { red: 255, green : 255, blue: 255 });
// Note that wxRect should be created with wxPoint to get the same // result as the example on the GD website. img.rectangle(25, 25, 74, 74, white);
71 gd
var jpeg = new gd.ImageJPEG(img); jpeg.write("c:\\temp\\rect.jpg");
Drawing a filled polygon
A filled polygon is created with filledPolygon.
var img = new gd.Image({ width: 100, height: 100 }); // Background colour first var black = img.colorAllocate({ red: 0, green: 0, blue: 0 }); var white = img.colorAllocate({ red: 255, green: 255, blue: 255 }); var red = img.colorAllocate({ red: 255, green: 0, blue: 0 });
var points = new Array({ x : 50, y : 0 }, { x : 99, y : 99 }, { x : 0, y : 99 }); img.filledPolygon(points, white); /* Outline it in red; must be done second */ img.polygon(points, red);
var jpeg = new gd.ImageJPEG(img); jpeg.write("c:\\temp\\filledpolygon.jpg");
Drawing a partial ellipse
arc is used to draw a partial ellipse centered at the given point, with the specified size in pixels.
var gd = require("gd"); var img = new gd.Image({width: 100, height: 50 }); // Background colour first var black = img.colorAllocate({ red: 0, green: 0, blue: 0 }); var white = img.colorAllocate({ red: 255, green: 255, blue: 255 });
img.arc({ x: 50, y : 25 }, { width: 98, height: 48}, 0, 360, white); var jpeg = new gd.ImageJPEG(img); jpeg.write("c:\\temp\\arc.jpg");
72 gd
Drawing a filled partial ellipse
filledArc is used to draw a partial ellipse centered at the given point, with the specified size in pixels.
var gd = require("gd"); var img = new gd.Image({width: 100, height: 50 }); // Background colour first var black = img.colorAllocate({ red: 0, green: 0, blue: 0 }); var white = img.colorAllocate({ red: 255, green: 255, blue: 255 });
img.filledArc({ x: 50, y : }, { width: 98, height: 48 }, 0, 360, white, gd.arc); var jpeg = new gd.ImageJPEG(img); jpeg.write("c:\\temp\\filledarc.jpg");
Alpha Blending
The alphaBlending function allows for two different modes of drawing on truecolor images. In blending mode, which is on by default, the alpha channel component of the color supplied to all drawing functions, such as setPixel , determines how much of the underlying color should be allowed to shine through. As a result, gd automatically blends the existing color at that point with the drawing color, and stores the result in the image. The resulting pixel is opaque. In non-blending mode, the drawing color is copied literally with its alpha channel information, replacing the destination pixel. Blending mode is not available when drawing on palette images.
var red, blue; var img = new gd.Image({ width : 100, height: 100}, true);
/* Background color */ red = gd.trueColor({ red: 255, green: 0, blue: 0 }); img.filledRectangle(0, 0, 100, 100, red);
/* Drawing color. Full transparency would be an alpha channel value of 127 (gd has a 7 bit alpha chnanel). 0 is opaque, 127 is transparent. So cut gdAlphaTransparent in half to get
73 gd
50% blending. */ blue = gd.trueColorAlpha( { red: 0, green: 0, blue: 255 }, gd.alphaTransparent / 2);
/* Draw with blending. Result will be 50% red, 50% blue: yellow (emitted light, remember, not reflected light. What you learned in Kindergarten is wrong here). */ img.alphaBlending(1); img.filledRectangle(0, 0, 25, 25, blue);
/* Draw without blending. Result will be 50% blue, 50% the background color of the image viewer or web browser used; results in browsers that don't support semi-transparent pixels are unpredictable! */ img.alphaBlending(0); img.filledRectangle(75, 75, 25, 25, blue);
var png = new gd.ImagePNG(img); png.write("c:\\temp\\alphablend.png");
Reference
74 gd
Name gd.Font — A wrapper class for the gd fonts
Following fonts are defined: gd.Font.small, gd.Font.large, gd.Font.mediumBold, gd.Font.giant and gd.Font.tiny. Properties w
Integer w ;
Returns the character width h
Integer h ;
Returns the character height size
Integer size ;
Returns the character size
75 gd
Name gd.ImageGIF — A class for reading or writing a GIF image.
Use this class to read a GIF image or to create a GIF image Constructor
ImageGIF(String Filename);
Creates an image from the given file. When the filename is relative the path will be resolved to the path of the active script.
ImageGIF(core.Binary Buffer);
Creates an image with the data from the buffer
ImageGIF(gd.Image Image);
Converts the given image into a GIF image.
This constructor can also be called as a function (without the new keyword) to convert an image to a GIF image. This example will create "test.gif" from img.
var gd = require("gd"); ... gd.ImageGif(img, "test.gif");
Methods write
Boolean write(String Filename);
Writes the image to a file. Returns false when the file can't be opened. writeToBuffer
core.BinaryString writeToBuffer();
Writes the image to a buffer.
76 gd
Name gd.Image — ports all image functions of the GD library
The Image class. Constructor
Image(Object size, Boolean trueColor= false);
Creates a new Image object. The object must have a width and height property.
Image(Integer width, Integer height, Boolean trueColor= false);
Creates a new Image object. Properties tile
gd.Image tile ; colorsTotal
Integer colorsTotal ;
Returns the number of colors currently allocated in a palette image. For truecolor images, the result of the property is undefined and should not be used. interlace
Integer interlace ;
interlace is used to determine whether an image should be stored in a linear fashion, in which lines will appear on the display from first to last, or in an interlaced fashion, in which the image will "fade in" over several passes. By default, images are not interlaced. (When writing JPEG images, interlacing implies generating progressive JPEG files, which are represented as a series of scans of increasing quality. Noninterlaced gd images result in regular [sequential] JPEG data streams.)
A nonzero value for interlace turns on interlace; a zero value turns it off. Note that interlace has no effect on other functions, and has no meaning unless you save the image in PNG or JPEG format; the gd and xbm formats do not support interlace.
When a PNG is loaded or a JPEG is loaded, interlace will be set according to the setting in the PNG or JPEG file.
77 gd
Note that many PNG and JPEG viewers and web browsers do not support interlace or the incremental display of progressive JPEGs. However, the interlaced PNG or progressive JPEG should still display; it will simply appear all at once, just as other images do. transparent
Integer transparent ;
Returns the current transparent color index in the image. If there is no transparent color, returns -1
Sets the transparent color index for the specified image to the specified index. To indicate that there should be no transparent color, use a color index of -1. Note that JPEG images do not support transparency, so this setting has no effect when writing JPEG images.
The color index used should be an index allocated by colorAllocate, whether explicitly invoked by your code or implicitly invoked by loading an image. In order to ensure that your image has a reasonable appearance when viewed by users who do not have transparent background capabilities (or when you are writing a JPEG-format file, which does not support transparency), be sure to give reasonable RGB values to the color you allocate for use as a transparent color, even though it will be transparent on systems that support PNG transparency. width
Integer width ;
Returns the width of the image. height
Integer height ;
Returns the height of the image. size
Object size ;
Returns an object with a width and height property trueColour
Boolean trueColour ;
Returns true if the image is a truecolour image clip
Object clip ;
Establishes a clipping rectangle. Once clip has been set, all future drawing operations will remain within the specified clipping area, until a new clip is set. For instance, if a clipping rectangle of 25, 25, 75, 75 has
78 gd
been set within a 100x100 image, a diagonal line from 0,0 to 99,99 will appear only between 25,25 and 75,75. When set the object must contain the following properties: x, y, width, height
If clip is never set, the clipping area will be the entire image. Methods colorAllocate
colorAllocate(Object Colour);
The object must contain a red, green and blue property
colorAllocate(Integer Red, Integer Green, Integer Blue);
colorAllocate finds the first available color index in the image, sets its RGB values to those requested, and returns the index of the new color table entry, or an RGBA value in the case of a truecolor image; in either case you can then use the returned value as a parameter to drawing functions. When creating a new palette- based image, the first time you invoke this function, you are setting the background color for that image.
In the event that all colors (256) have already been allocated, colorAllocate will return -1 to indicate failure. (This is not uncommon when working with existing PNG files that already use 256 colors.) Note that colorAllocate does not check for existing colors that match your request; see colorExact, colorClosest and colorClosestHWB for ways to locate existing colors that approximate the color desired in situations where a new color is not available. Also see colorResolve. colorDeallocate
colorDeallocate(Integer C);
colorDeallocate marks the specified color as being available for reuse. It does not attempt to determine whether the color index is still in use in the image. After a call to this function, the next call to colorAllocate for the same image will set new RGB values for that color index, changing the color of any pixels which have that index as a result. If multiple calls to colorDeallocate are made consecutively, the lowest- numbered index among them will be reused by the next colorAllocate call. colorAllocateAlpha
Integer colorAllocateAlpha(Object Colour, Integer A);
The object must contain a red, green and blue property
Integer colorAllocateAlpha(Integer Red, Integer Green, Integer Blue, Integer A);
colorAllocateAlpha finds the first available color index in the image specified, sets its RGBA values to those requested, and returns the index of the new color table entry, or an RGBA value in the case of a
79 gd
truecolor image; in either case you can then use the returned value as a parameter to drawing functions. When creating a new palette-based image, the first time you invoke this function, you are setting the background color for that image.
In the event that all colors (256) have already been allocated, colorAllocateAlpha will return -1 to indicate failure. (This is not uncommon when working with existing PNG files that already use 256 colors.) Note that colorAllocateAlpha does not check for existing colors that match your request; see colorExact, colorClosest and colorClosestHWB for ways to locate existing colors that approximate the color desired in situations where a new color is not available. Also see colorResolve colorClosest
colorClosest(Object Colour);
The object must contain a red, green and blue property
Integer colorClosest(Integer Red, Integer Green, Integer Blue);
colorClosest searches the colors which have been defined thus far in the image specified and returns the index of the color with RGB values closest to those of the request. (Closeness is determined by Euclidian distance, which is used to determine the distance in three-dimensional color space between colors.)
If no colors have yet been allocated in the image, colorClosest returns -1.
When applied to a truecolor image, this function always succeeds in returning the desired color.
This function is most useful as a backup method for choosing a drawing color when an image already contains 256 colors and no more can be allocated. (This is not uncommon when working with existing PNG files that already use many colors.) See colorExact for a method of locating exact matches only. colorClosestAlpha
Integer colorClosestAlpha(Object Colour, Integer A);
The object must contain a red, green and blue property
Integer colorClosestAlpha(Integer Red, Integer Green, Integer Blue, Integer A);
colorClosestAlpha searches the colors which have been defined thus far in the image specified and returns the index of the color with RGBA values closest to those of the request. (Closeness is determined by Euclidian distance, which is used to determine the distance in four-dimensional color/alpha space between colors.)
If no colors have yet been allocated in the image, colorClosestAlpha returns -1.
When applied to a truecolor image, this function always succeeds in returning the desired color.
80 gd
This function is most useful as a backup method for choosing a drawing color when a palette-based image already contains 256 colors and no more can be allocated. (This is not uncommon when working with existing palette-based PNG files that already use many colors.) See colorExactAlpha for a method of locating exact matches only. colorClosestHWB
Integer colorClosestHWB(Object Colour);
The object must contain a red, green and blue property
Integer colorClosestHWB(Integer Red, Integer Green, Integer Blue);
colorClosestHWB searches the colors which have been defined thus far in the image specified and returns the index of the color with hue, whiteness and blackness closest to the requested color. This scheme is typically superior to the Euclidian distance scheme used by colorClosest.
If no colors have yet been allocated in the image, colorClosestHWB returns -1.
When applied to a truecolor image, this function always succeeds in returning the desired color.
This function is most useful as a backup method for choosing a drawing color when a palette-based image already contains 256 colors and no more can be allocated. (This is not uncommon when working with existing palette-based PNG files that already use many colors.) See colorExact for a method of locating exact matches only. colorExact
Integer colorExact(Object Colour);
The object must contain a red, green and blue property
Integer colorExact(Integer Red, Integer Green, Integer Blue);
colorExact searches the colors which have been defined thus far in the image specified and returns the index of the first color with RGB values which exactly match those of the request. If no allocated color matches the request precisely, colorExact returns -1. See colorClosest for a way to find the color closest to the color requested.
When applied to a truecolor image, this function always succeeds in returning the desired color. colorExactAlpha
Integer colorExactAlpha(Object Colour, Integer A);
The object must contain a red, green and blue property
81 gd
Integer colorExactAlpha(Integer Red, Integer Green, Integer Blue, Integer A);
The same as colorClosestAlpha but returns an exact match only. colorResolve
Integer colorResolve(Object Colour);
The object must contain a red, green and blue property
Integer colorResolve(Integer Red, Integer Green, Integer Blue);
colorResolve searches the colors which have been defined thus far in the image specified and returns the index of the first color with RGB values which exactly match those of the request. If no allocated color matches the request precisely, then colorResolve tries to allocate the exact color. If there is no space left in the color table then colorResolve returns the closest color (as in colorClosest). This function always returns an index of a color.
When applied to a truecolor image, this function always succeeds in returning the desired color. colorResolveAlpha
Integer colorResolveAlpha(Object Colour, Integer A);
The object must contain a red, green and blue property
Integer colorResolveAlpha(Integer Red, Integer Green, Integer Blue, Integer A);
colorResolveAlpha searches the colors which have been defined thus far in the image specified and returns the index of the first color with RGB values which exactly match those of the request. If no allocated color matches the request precisely, then colorResolveAlpha tries to allocate the exact color. If there is no space left in the color table then colorResolveAlpha returns the closest color (as in colorClosestAlpha). This function always returns an index of a color.
When applied to a truecolor image, this function always succeeds in returning the desired color. red
red(Integer C);
Returns the red portion of the specified color in the image. green
82 gd
green(Integer C);
Returns the green portion of the specified color in the image. blue
blue(Integer C);
Returns the blue portion of the specified color in the image. setPixel
setPixel(Object Point, Integer ColourIndex);
setPixel(Integer X, Integer Y, Integer ColourIndex);
Sets a pixel to a particular color. line
line(Object From, Object To, Integer ColourIndex);
line(Integer X1, Integer Y1, Integer X2, Integer Y2, Integer ColourIndex);
line is used to draw a line between two endpoints (X1,Y1 and X2, Y2). The line is drawn using the color index specified. Note that the color index can be an actual color returned by colorAllocate or one of gd.Styled, gd.Brushed or gd.StyledBrushed.
When an object is passed, it must have a x and y property. For example:
var black = img.colorAllocate( { red: 0, green: 0, blue: 0 }); img.line({x : 0, y : 0}, {x : 99, y : 99 }, black);
polygon
polygon(Array Points, Integer ColourIndex);
polygon is used to draw a polygon with the verticies (at least 3) specified, using the color index specified. The array must contain objects with a x and y property.
83 gd openPolygon
openPolygon(Array Points, Integer ColourIndex);
openPolygon is used to draw a polygon with the verticies (at least 3) specified, using the color index specified. Unlike polygon the enpoints of the line sequence are not connected to a closed polygon. The array must contain objects with a x and y property. rectangle
rectangle(Object Rect, Integer ColourIndex);
Rect must contain a x, y, width and height property
rectangle(Integer X1, Integer Y1, Integer X2, Integer Y2, Integer ColourIndex);
rectangle is used to draw a rectangle using the color index specified. filledPolygon
filledPolygon(Array Points, Integer ColourIndex);
filledPolygon is used to fill a polygon with the verticies (at least 3) specified, using the color index specified. The array must contain objects with a x, y property filledRectangle
filledRectangle(Object Rect, Integer ColourIndex);
Rect must contain an x, y, width and height property
filledRectangle(Integer X1, Integer Y1, Integer X2, Integer Y2, Integer ColourIndex);
filledRectangle is used to draw a solid rectangle with the two corners (upper left first, then lower right) specified, using the color index specified. arc
84 gd
arc(Object Center, Object Size, Integer S, Integer E, Integer ColourIndex);
arc(Integer X, Integer Y, Integer Width, Integer Height, Integer S, Integer E, Integer ColourIndex);
arc is used to draw a partial ellipse centered at the given point, with the specified width and height in pixels. The arc begins at the position in degrees specified by S and ends at the position specified by E. The arc is drawn in the color specified by the last argument. A circle can be drawn by beginning from 0 degrees and ending at 360 degrees, with width and height being equal. E must be greater than S. Values greater than 360 are interpreted modulo 360. filledArc
filledArc(Object Center, Object Size, Integer S, Integer E, Integer ColourIndex, Integer Style);
filledArc(Integer X, Integer Y, Integer Width, Integer Height, Integer S, Integer E, Integer ColourIndex, Integer Style);
filledArc is used to draw a partial ellipse centered at the given point, with the specified width and height in pixels. The arc begins at the position in degrees specified by S and ends at the position specified by E. The arc is filled in the color specified by the second to last argument. A circle can be drawn by beginning from 0 degrees and ending at 360 degrees, with width and height being equal. E must be greater than S. Values greater than 360 are interpreted modulo 360. The last argument is a bitwise OR of the following possibilities: gd.arc, gd.chord, gd.pie (synonym for gd.chord), gd.noFill, and gd.edged. gd.arc and gd.chord are mutually exclusive; gd.chord just connects the starting and ending angles with a straight line, while gd.arc produces a rounded edge. gd.pie is a synonym for gd.arc. gd.noFill indicates that the arc or chord should be outlined, not filled. gd.edged, used together with gd.noFill, indicates that the beginning and ending angles should be connected to the center; this is a good way to outline (rather than fill) a 'pie slice'. filledEllipse
filledEllipse(Object Center,
85 gd
Object Size, Integer ColourIndex);
filledEllipse(Integer X, Integer Y, Integer Width, Integer Height, Integer ColourIndex);
filledEllipse is used to draw an ellipse centered at the given point, with the specified width and height in pixels. The ellipse is filled in the color specified by the last argument. fillToBorder
fillToBorder(Object Point, Integer BorderColorIndex, Integer ColourIndex);
fillToBorder(Integer X, Integer Y, Integer BorderColorIndex, Integer ColourIndex);
fillToBorder floods a portion of the image with the specified color, beginning at the specified point and stopping at the specified border color. For a way of flooding an area defined by the color of the starting point, see fill. The border color cannot be a special color such as gd.Tiled; it must be a proper solid color. fill
fill(Object Point, Integer ColourIndex);
fill(Integer X, Integer Y, Integer ColourIndex);
fill floods a portion of the image with the specified color, beginning at the specified point and flooding the surrounding region of the same color as the starting point. For a way of flooding a region defined by a specific border color rather than by its interior color, see fillToBorder. setAntiAliased
setAntiAliased(Integer ColourIndex);
"Antialiasing" is a process by which jagged edges associated with line drawing can be reduced by blending the foreground color with an appropriate percentage of the background, depending on how much of the pixel in question is actually within the boundaries of the line being drawn. All line-drawing functions, such as line, openPolygon and polygon, will draw antialiased lines if the special "color" gd.AntiAliased is used when calling them.
86 gd
setAntiAliased is used to specify the actual foreground color to be used when drawing antialiased lines.
Antialiased lines can be drawn on both truecolor and palette-based images. However, attempts to draw antialiased lines on highly complex palette-based backgrounds may not give satisfactory results, due to the limited number of colors available in the palette. Antialiased line-drawing on simple backgrounds should work well with palette-based images; otherwise create or fetch a truecolor image instead. setAntiAliasedDontBlend
setAntiAliasedDontBlend(Integer ColourIndex, Integer DontBlend);
Normally, when drawing lines with the special gd.AntiAliased "color," blending with the background to reduce jagged edges is the desired behavior. However, when it is desired that lines not be blended with one particular color when it is encountered in the background, the setAntiAliasedDontBlend function can be used to indicate the special color that the foreground should stand out more clearly against. setBrush
setBrush(gd.Image Brush);
Just as a paintbrush is not a single point, a brush image need not be a single pixel. Any gd image can be used as a brush, and by setting the transparent color index of the brush image with transparent, a brush of any shape can be created. All line-drawing functions, such as line, openPolygon and polygon, will use the current brush if the special "color" gd.Brushed or gd.StyledBrushed is used when calling them.
setBrush is used to specify the brush to be used in a particular image. You can set any image to be the brush. If the brush image does not have the same color map as the first image, any colors missing from the first image will be allocated. If not enough colors can be allocated, the closest colors already available will be used. This allows arbitrary PNGs to be used as brush images. It also means, however, that you should not set a brush unless you will actually use it; if you set a rapid succession of different brush images, you can quickly fill your color map, and the results will not be optimal. setTile
setTile(gd.Image Tile);
Any gd image can be used as a tile, and by setting the transparent color index of the tile image with transparent, a tile that allows certain parts of the underlying area to shine through can be created. All region- filling functions, such as fill and filledPolygon, will use the current tile if the special "color" gd.Tiled is used when calling them. setStyle
setStyle(Array Style);
It is often desirable to draw dashed lines, dotted lines, and other variations on a broken line. setStyle can be used to set any desired series of colors, including a special color that leaves the background intact, to be repeated during the drawing of a line.
To draw a line using the style, use the normal line function with the special color value gd.Styled.
87 gd
Style is an array of integers with the desired series of color values to be repeated. You can assign the special color value gd.Transparent to indicate that the existing color should be left unchanged for that particular pixel (allowing a dashed line to be attractively drawn over an existing image). boundsSafe
Boolean boundsSafe(Object Point);
Boolean boundsSafe(Integer X, Integer Y);
boundsSafe returns true if the specified point is within the current clipping rectangle, false if not. The clipping rectangle is set by clip and defaults to the entire image. getPixel
Integer getPixel(Object point);
Integer getPixel(Integer X, Integer Y);
getPixel retrieves the color index of a particular pixel. setThickness
setThickness(Integer thickness);
Sets the width of lines drawn by the gd.Image#line, gd.Image#polygon, gd.Image#openPolygon and related functions, in pixels. string
string(gd.Font Font, Object Point, String Str, Integer Colour);
string(gd.Font Font, Integer X, Integer Y, String Str, Integer Colour);
string is used to draw a string on the image. stringUp
stringUp(gd.Font Font, Object Point,
88 gd
String Str, Integer Colour);
stringUp(gd.Font Font, Integer X, Integer Y, String Str, Integer Colour);
stringUp is used to draw multiple characters on the image, rotated 90 degrees stringFT
Array stringFT(Integer Fg, String FontName, Double PointSize, Double Angle, Object Point, String Text);
Array stringFT(Integer Fg, String FontName, Double PointSize, Double Angle, Integer X, Integer Y, String Text);
stringFT draws a string of anti-aliased characters on the image using the FreeType library to render user- supplied TrueType fonts. We do not provide TrueType fonts (.ttf and .ttc files). Obtaining them is entirely up to you. The string is anti-aliased, meaning that there should be fewer "jaggies" visible. The fontname is the full pathname to a TrueType font file, or a font face name if the GDFONTPATH environment variable has been set. In the absence of a full path, the font face name may be presented with or without extension.
The string may be arbitrarily scaled (ptsize) and rotated (angle in radians). The direction of rotation is counter-clockwise, with 0 radians (0 degrees) at 3 o'clock and PI/2 radians (90 degrees) at 12 o'clock.
This method returns an array with 2 elements: one with a possible error message and one with another array containing the bounding rectangle (the smallest rectangle that completely surrounds the rendered string and does not intersect any pixel of the rendered string). This array contains the following elements: 0 = lower left corner, X position, 1 = lower left corner, Y position, 2 = lower right corner, X position, 3 = lower right corner, Y position, 4 = upper right corner, X position, 5 = upper right corner, Y position, 6 = upper left corner, X position, 7 = upper left corner, Y position
The points are relative to the text regardless of the angle, so "upper left" means in the top left-hand corner seeing the text horizontally.
Use gd.stringFT to get the bounding rectangle without rendering. This is a relatively cheap operation if followed by a rendering of the same string, because of the caching of the partial rendering during bounding rectangle calculation.
The string is rendered in the color indicated by the Fg color index. Use the negative of the desired color index to disable anti-aliasing.
89 gd
An example:
var err, rect; var font = "C:\\WINDOWS\\Fonts\\Times.ttf"; [err, rect] = gd.stringFT(0, font, 40, 0, 0, 0, "Hello."); var img = new gd.Image(rect[2] - rect[6] + 6, rect[3] - rect[7] + 6);
var white = img.colorResolve(0, 0, 0); var black = img.colorResolve(255, 255, 255);
var x = 3 - rect[6]; var y = 3 - rect[7]; print("x = ", x, "\n"); print("y = ", y, "\n"); [err, rect] = img.stringFT(black, font, 40, 0, x, y, "Hello."); print(err, "\n");
var jpg = new gd.ImageJPEG(img); jpg.write("c:\\temp\\ttf.jpg");
stringFTCircle
String stringFTCircle(Object Center, Double Radius, Double TextRadius, Double FillPortion, String Font, Double Points, String Top, String Bottom, Index Fg);
String stringFTCircle(Integer X, Integer Y, Double Radius, Double TextRadius, Double FillPortion, String Font, Double Points, String Top, String Bottom, Index Fg);
Draws the text strings specified by Top and Bottom on image, curved along the edge of a circle of radius Radius, with its center at Center. Top is written clockwise along the top; Bottom is written counterclockwise along the bottom. TextRadius determines the "height" of each character; if textRadius is 1/2 of Radius, characters extend halfway from the edge to the center. FillPortion varies from 0 to 1.0, with useful values from about 0.4 to 0.9, and determines how much of the 180 degrees of arc assigned to each section of text is actually occupied by text; 0.9 looks better than 1.0 which is rather crowded. Font is a freetype font; stringFT. Points is passed to the freetype engine and has an effect on hinting; although
90 gd
the size of the text is determined by Radius, TextRadius, and FillPortion, you should pass a point size that "hints" appropriately -- if you know the text will be large, pass a large point size such as 24.0 to get the best results. Fg can be any color, and may have an alpha component, do blending, etc. copy
copy(gd.Image Source, Object DestPoint, Object SourceRect);
copy(gd.Image Source, Integer X, Integer Y, Integer SX, Integer SY, Integer Width, Integer Height);
copy is used to copy a rectangular portion of one image to this image. (For a way of stretching or shrinking the image in the process, see copyResized) The Source argument is the source image from which the region is copied. The DestPoint specifies the point in the image to which the region will be copied. The SourceRect specifies the region in the source image.
When you copy a region from one location in an image to another location in the same image, copy will perform as expected unless the regions overlap, in which case the result is unpredictable.
colorExactcolorAllocatecolorClosest copyResized
copyResized(gd.Image Source, Object DestRect, Object SourceRect);
copyResized(gd.Image Source, Integer X, Integer Y, Integer SX, Integer SY, Integer Width, Integer Height, Integer SWidth, Integer SHeight);
copyResized is used to copy a rectangular portion of one image to this image. The X and Y dimensions of the original region and the destination region can vary, resulting in stretching or shrinking of the region as appropriate. (For a simpler version of this function which does not deal with resizing, see copy) The Source argument is the source image from which the region is copied. The DestRect specifies the point in the image to which the region will be copied. The SourceRect specifies the region in the source image. The width and height of the source region can differ from the destination region, allowing a region to be scaled during the copying process.
91 gd
When you copy a region from one location in an image to another location in the same image, copyResized will perform as expected unless the regions overlap, in which case the result is unpredictable. Note Important note on copying between images: since different images do not necessarily have the same color tables, pixels are not simply set to the same color index values to copy them. copy will attempt to find an identical RGB value in the destination image for each pixel in the copied portion of the source image by invoking colorExact. If such a value is not found, copy will attempt to allocate colors as needed using colorAllocate. If both of these methods fail, copy will invoke colorClosest to find the color in the destination image which most closely approximates the color of the pixel being copied. copyResampled
copyResampled(gd.Image Source, Object DestRect, Object SourceRect);
copyResampled(gd.Image Source, Integer X, Integer Y, Integer SX, Integer SY, Integer Width, Integer Height, Integer SWidth, Integer SHeight);
copyResampled is used to copy a rectangular portion of one image to this image, smoothly interpolating pixel values so that, in particular, reducing the size of an image still retains a great deal of clarity. The X and Y dimensions of the original region and the destination region can vary, resulting in stretching or shrinking of the region as appropriate. (For a simpler version of this function which does not deal with resizing, see copy. For a version which does not interpolate pixel values, see copyResized.)
The Source argument is the source image from which the region is copied. The DestRect specifies the point in the image to which the region will be copied. The SourceRect specifies the region in the source image. The width and height of the source region can differ from the destination region, allowing a region to be scaled during the copying process.
When you copy a region from one location in an image to another location in the same image, copyResized will perform as expected unless the regions overlap, in which case the result is unpredictable. Note Important note on copying between images: since different images do not necessarily have the same color tables, pixels are not simply set to the same color index values to copy them. copy will attempt to find an identical RGB value in the destination image for each pixel in the copied portion of the source image by invoking colorExact. If such a value is not found, copy will attempt to allocate colors as needed using colorAllocate. If both of these methods fail, copy will invoke colorClosest to find the color in the destination image which most closely approximates the color of the pixel being copied. copyRotated
92 gd
copyRotated(gd.Image Source, Object DestPoint, Object SourceRect, Integer Angle);
copyRotated(gd.Image Source, Integer X, Integer Y, Integer SX, Integer SY, Integer Width, Integer Height, Integer Angle);
copyRotated is used to copy a rectangular portion of one image to this image, or to another region of the same image. The SourceRect specifies the source area. The DestX and dstY coordinates specify the CENTER of the destination area. This important distinction is made because the rotated rectangle may or may not be parallel to the X and Y axes. The destination coordinates may be floating point, as the center of the desired destination area may lie at the center of a pixel (0.5 pixels) rather than its upper left corner. The angle specified is an integer number of degrees, between 0 and 360, with 0 degrees causing no change, and counterclockwise rotation as the angle increases.
When you copy a region from one location in an image to another location in the same image, copyRotated will perform as expected unless the regions overlap, in which case the result is unpredictable. If this presents a problem, create a scratch image in which to keep intermediate results. Note Important note on copying between images: since palette-based images do not necessarily have the same color tables, pixels are not simply set to the same color index values to copy them. If the destination image is not a truecolor image, colorResolveAlpha is used to choose the destination pixel. copyMerge
copyMerge(gd.Image Source, Object DestPoint, Object SourceRect, Integer Angle, Integer Pct);
copyMerge(gd.Image Source, Integer X, Integer Y, Integer SX, Integer SY, Integer Width, Integer Height, Integer Angle, Integer Pct);
copyMerge is almost identical to copy, except that it 'merges' the two images by an amount specified in the last parameter. If the last parameter is 100, then it will function identically to copy - the source image replaces the pixels in this image.
93 gd
If, however, the Pct parameter is less than 100, then the two images are merged. With Pct = 0, no action is taken. copyMergeGray
copyMergeGray(gd.Image Source, Object DestPoint, Object SourceRect, Integer Angle, Integer Pct);
copyMergeGray(gd.Image Source, Integer X, Integer Y, Integer SX, Integer SY, Integer Width, Integer Height, Integer Angle, Integer Pct);
copyMergeGray is almost identical to copyMerge, except that when merging images it preserves the hue of the source by converting the destination pixels to grey scale before the copy operation. paletteCopy
paletteCopy(gd.Image Source);
Copies a palette from one image to this image, attempting to match the colors in this image to the colors in the source palette. squareToCircle
squareToCircle(Integer Radius);
The image MUST be square, but can have any size. Creates a new image of width and height radius * 2, in which the X axis of the original has been remapped to theta (angle) and the Y axis of the original has been remapped to rho (distance from center). This is known as a "polar coordinate transform." See also stringFTCircle, which uses this function internally. sharpen
sharpen(Integer Pct);
Sharpens the specified image. Pct is a sharpening percentage, and can be greater than 100. Silently does nothing to non-truecolor images. Silently does nothing for Pct < 0. Transparency/alpha channel are not altered. alphaBlending
94 gd
alphaBlending(Integer Blending);
The alphaBlending function allows for two different modes of drawing on truecolor images. In blending mode, which is on by default, the alpha channel component of the color supplied to all drawing functions, such as setPixel, determines how much of the underlying color should be allowed to shine through. As a result, gd automatically blends the existing color at that point with the drawing color, and stores the result in the image. The resulting pixel is opaque. In non-blending mode, the drawing color is copied literally with its alpha channel information, replacing the destination pixel. Blending mode is not available when drawing on palette images. saveAlpha
saveAlpha(Integer Switch);
95 gd
Name gd.ImageJPEG — A class for reading or writing a JPEG image.
Use this class to read a JPEG image or to create a JPEG image. Constructor
ImageJPEG(String Filename);
Creates an image from the given file. When the filename is relative the path will be resolved to the path of the active script.
ImageJPEG(core.Binary Buffer);
Creates an image with the data from the buffer
ImageJPEG(gd.Image Image);
Converts the given image into a JPEG image.
This constructor can also be called as a function (without the new keyword) to convert an image to a JPEG image. This example will create "test.jpg" from img.
var gd = require("gd"); ... gd.ImageJPEG(img, "test.jpg");
Methods write
Boolean write(String Filename, Integer Quality= 100);
Writes the image to a file. Returns false when the file can't be opened. When the filename is relative the path will be resolved to the path of the active script.
The file may be a file URI or a path to a file (the path is converted to a URI internally). writeToBuffer
core.BinaryString writeToBuffer(Integer Quality= 100);
Writes the image to a buffer.
96 gd
Name gd.ImagePNG — A class for reading or writing a PNG image.
Use this class to read a PNG image or to create a PNG image. Constructor
ImagePNG(String Filename);
ImagePNG(core.Binary Buffer);
ImagePNG(gd.Image Image);
This constructor can also be called as a function (without the new keyword) to convert an image to a PNG image. This example will create "test.png" from img.
var gd = require("gd"); ... gd.ImagePNG(img, "test.png");
Methods write
Boolean write(String Filename, Integer Level= -1);
Writes the image to a file. Returns false when the file can't be opened. A compression level of 0 means "no compression." A compression level of 1 means "compressed, but as quickly as possible." A compression level of 9 means "compressed as much as possible to produce the smallest possible file." A compression level of -1 will use the default compression level at the time zlib was compiled on your system.
When the filename is relative the path will be resolved to the path of the active script. writeToBuffer
core.BinaryString writeToBuffer();
Writes the image to a buffer.
97 gd
Name gd
Class Methods useFontConfig
Boolean useFontConfig(Boolean Switch);
GD 2.0.29 introduced the ability to use fontconfig patterns rather than font file names as parameters to stringFT and stringFTCircle. For backwards compatibility reasons, the fontlist parameter to those functions is still expected to be a full or partial font file path name or list thereof by default. However, as a convenience, a single call to gd.useFontConfig with a nonzero parameter configures gd to expect the fontlist parameter to be a fontconfig pattern. Regardless of whether the flag argument is nonzero, this function returns true when the fontconfig library is available and false when it is not. When fontconfig is not available, the fontlist parameter always behaves as in previous versions of GD. trueColor
Integer trueColor(Object Color);
Integer trueColor(Integer Red, Integer Green, Integer Blue);
gd.trueColor returns an RGBA color value for use when drawing on a truecolor image. This method should not be used with palette-based images. If you need to write code which is compatible with both palette- based and truecolor images, use colorResolve. trueColorAlpha
Integer trueColorAlpha(Object Color, Integer Alpha);
gd.trueColor returns an RGBA color value for use when drawing on a truecolor image. This method should not be used with palette-based images. If you need to write code which is compatible with both palette- based and truecolor images, use colorResolve. Properties antiAliased
antiAliased ;
Used in place of a color when invoking a line-drawing function such as line or rectangle. When gd.AntiAliased is used as the color, the foreground color set with setAntiAliased is used, with antialiasing mechanisms to minimize any "jagged" appearance. For more information, see setAntiAliased.
98 gd brushed
brushed ;
Used in place of a color when invoking a line-drawing function such as line or rectangle. When gd.Brushed is used as the color, the brush image set with setBrush is drawn in place of each pixel of the line (the brush is usually larger than one pixel, creating the effect of a wide paintbrush). See also styledBrushed for a way to draw broken lines with a series of distinct copies of an image. maxColors
maxColors ;
The constant 256. This is the maximum number of colors in a palette-based PNG file according to the PNG standard, and is also the maximum number of colors in a palette-based gd image. This of course does not apply to truecolor images. styled
styled ;
Used in place of a color when invoking a line-drawing function such as line or rectangle. When gd.Styled is used as the color, the colors of the pixels are drawn successively from the style that has been set with setStyle. If the color of a pixel is equal to gd.Transparent, that pixel is not altered. (This mechanism is completely unrelated to the "transparent color" of the image itself; see transparent for that mechanism.) See also gd.StyledBrushed. styledBrushed
styledBrushed ;
Used in place of a color when invoking a line-drawing function such as line or rectangle. When gd.StyledBrushed is used as the color, the brush image set with setBrush is drawn at each pixel of the line, providing that the style set with setStyle contains a nonzero value (OR gd.Transparent, which does not equal zero but is supported for consistency) for the current pixel. (Pixels are drawn successively from the style as the line is drawn, returning to the beginning when the available pixels in the style are exhausted.) Note that this differs from the behavior of gd.Styled, in which the values in the style are used as actual pixel colors, except for gd.Transparent. tiled
tiled ;
Used in place of a normal color in filledRectangle, filledPolygon, fill, and fillToBorder. gd.Tiled selects a pixel from the tile image set with setTile in such a way as to ensure that the filled area will be tiled with copies of the tile image. See the discussions of fill and fillToBorder for special restrictions regarding those functions. transparent
99 gd
transparent ;
Used in place of a normal color in a style to be set with setStyle. gd.Transparent is not the transparent color index of the image; for that functionality please see transparent.
100 Chapter 10. memcache Introduction
The module MemCache provides a client api to a memcached server. memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. GLUEscript uses the memcached client from Jellycan Code [http://code.jellycan.com].
How memcached works can be read at the memcached website [http://www.danga.com/memcached/]. memcached in JavaScript
Using memcached in GLUEscript is easy. Create a memcache.Client object and add a memcached server. When you set properties to the client object, a value will be stored in the cache. When you retrieve properties, a value will be retrieved from the cache. The key used to get the value, is the name of the property.
var memcache = require("memcache"); var client = new memcache.Client(); client.addServer("127.0.0.1:11211"); client.username = "franky"; print(client.username, "\n");
It is not possible to store a JavaScript object directly into the cache. The object will always be converted to a String. Instead JSON [http://www.json.org] can be a good alternative to store an object into the cache. Reference
101 memcache
Name memcache.Client — A JavaScript client for memcached
This is a client for memcached. You can set variables (only primitive values and strings are allowed) as properties to this class. For example:
var client = new memcache.Client(); client.addServer("127.0.0.1:11211"); client.user = "Franky";
The code above sets the username into the cache with key 'user'. Constants
Table 10.1. Constants of memcache.Client
Name Description NOREPLY NOSERVER NOTFOUND NOTSTORED OK
Constructor
Client();
Creates a new client. Methods addServer
Boolean addServer(String Server= localhost);
Add a server to the client. This method will fail only if the address is not a valid IP address or PORT. It will not fail if the server cannot be contacted but will instead continue to occasionally attempt connections to that server. The server is a string specified as IP[:PORT]. The port will default to 11211 if not supplied. add
Array add(String Key, Any Value);
102 memcache
Add an item to the cache. This will fail if the item already exists at the server. An array with two elements is returned: first element contains the result, second element contains the number of items with a successful result. append
Array append(String Key, Any Value);
Append data to an existing item in the cache. An array with two elements is returned: first element contains the number of items with a successful result. The second element is another array containing all result codes when an array is passed, or an integer element that contains the result code. clearServers
clearServers();
Disconnect from and remove all servers. prepend
Integer prepend(String Key, Any Value);
Prepend data to an existing item in the cache. set
Array set(String Key, Any Value, Integer TimeOut= 0);
Array set(Object KeyPairValue, Integer TimeOut= 0);
Sets the key in the cache. When you use the second form, each property of the object will be the key and the property value is the value which is cached. When you want to store complex objects, it is recommended to use JSON to generate a String value. Specify a timeout in seconds for the data to live on the server.
var memcache = require("memcache"); var client = new memcache.Client(); client.addServer("127.0.0.1:11211"); var [n, rc] = client.set({ FirstName : "Franky", LastName : "Braem" }); print("Number of keys added: ", n, "\n"); print("The return code for each key:\n"); for(i in rc) {
103 memcache
print("Rc: " + rc[i], "\n"); } print("FirstName: ", client.FirstName, "\n"); print("LastName: ", client.LastName, "\n");
get
String get(String Key);
Gets the value associated to this key in the cache and returns it as a string. 'null' is returned when the key is not found. replace
Array replace(String Key, Any Value, Integer TimeOut= 0);
Array replace(Object KeyPairValue, Integer TimeOut= 0);
Replace an item in the cache. This will fail if the item does not already exist at the server. The timeout is a time in seconds for the data to live on the server. removeServer
Boolean removeServer(String Server);
Delete a server from the client. The server should be specified as documented in addServer. increment
Array increment(String Key, Integer Diff, Boolean Reply= true);
Increment a value at the server. When a reply is requested (which is the default), an array with two values is returned: the return code and the new value of the key. decrement
Array decrement(String Key, Integer Diff, Boolean Reply= true);
Decrement a value at the server. When a reply is requested (which is the default), an array with two values is returned: the return code and the new value of the key.
104 Chapter 11. mysql Introduction
The MySQL glue makes the MySQL [http://www.mysql.com] database available in JavaScript. This module has been tested with MySQL version 5.0. If you use another version, and you encounter problems, you can try to rebuild this module with your MySQL version. Database
mysql.Database represents a database. Before you can use a database, you have to connect to it.
var mysql = require("mysql"); var db = new mysql.Database(); if ( db.connect("localhost", "root", "password", "dbname") ) { }
Executing SQL statements
SQL statements can be executed with query or prepare. With prepare you can bind JavaScript variables to the SQL statement.
db.query("CREATE TABLE person(name VARCHAR(30), nr INTEGER)");
var stmt = db.prepare("SELECT * FROM person WHERE nr = ?"); stmt.bind(0, 1); var row; while(row = stmt.fetchObject()) { print(row.name); print(row.nr); }
Class Reference
105 mysql
Name mysql.Database — Represents a MySQL database
The class is used for accessing a MySQL database. More information about the MySQL database server can be found at MySQL [http://www.mysql.com]. Constants
Table 11.1. Constants of mysql.Database
Name Description INIT_COMMAND Command to execute when connecting to the MySQL server. Will automatically be re-executed when reconnecting. OPTION_MULTI_STATEMENTS_OFF Disable multiple-statement support. OPTION_MULTI_STATEMENTS_ON Enable multiple-statement support OPT_COMPRESS Use the compressed client/server protocol. OPT_CONNECT_TIMEOUT Connect timeout in seconds. OPT_GUESS_CONNECTION For an application linked against libmysqld, this allows the library to guess whether to use the embedded server or a remote server. “Guess” means that if the hostname is set and is not localhost, it uses a remote server. This behavior is the default. MYSQL_OPT_USE_EMBEDDED_CONNECTION and MYSQL_OPT_USE_REMOTE_CONNECTION can be used to override it. This option is ignored for applications linked against libmysqlclient. OPT_LOCAL_INFILE If no pointer is given or if pointer points to an unsigned int != 0 the command LOAD LOCAL INFILE is enabled. OPT_NAMED_PIPE Use named pipes to connect to a MySQL server on NT. OPT_PROTOCOL Type of protocol to use. Should be one of the enum values of mysql_protocol_type defined in mysql.h. OPT_READ_TIMEOUT Timeout for reads from server (works only for TCP/ IP connections, and only for Windows prior to MySQL 5.0.25). You can this option so that a lost connection can be detected earlier than the TCP/IP Close_Wait_Timeout value of 10 minutes. OPT_RECONNECT Enable or disable automatic reconnection to the server if the connection is found to have been lost. Reconnect has been off by default since MySQL 5.0.3; this option is new in 5.0.13 and provides a way to set reconnection behavior explicitly. OPT_SSL_VERIFY_SERVER_CERT Enable or disable verification of the server's Common Name value in its certificate against the
106 mysql
Name Description hostname used when connecting to the server. The connection is rejected if there is a mismatch. This feature can be used to prevent man-in-the-middle attacks. Verification is disabled by default. Added in MySQL 5.0.23. OPT_USE_EMBEDDED_CONNECTION For an application linked against libmysqld, this forces the use of the embedded server for the connection. This option is ignored for applications linked against libmysqlclient. OPT_USE_REMOTE_CONNECTION For an application linked against libmysqld, this forces the use of a remote server for the connection. This option is ignored for applications linked against libmysqlclient. OPT_USE_RESULT This option is unused. OPT_WRITE_TIMEOUT Timeout for writes to server (works currently only on Windows on TCP/IP connections). READ_DEFAULT_FILE Read options from the named option file instead of from my.cnf. READ_DEFAULT_GROUP Read options from the named group from my.cnf or the file specified with MYSQL_READ_DEFAULT_FILE. REFRESH_GRANT Refresh the grant tables, like FLUSH PRIVILEGES. REFRESH_HOSTS Flush the host cache, like FLUSH HOSTS. REFRESH_LOG Flush the logs, like FLUSH LOGS. REFRESH_MASTER On a master replication server, remove the binary log files listed in the binary log index and truncate the index file, like RESET MASTER REFRESH_SLAVE On a slave replication server, reset the master server information and restart the slave, like RESET SLAVE. REFRESH_STATUS Reset status variables, like FLUSH STATUS. REFRESH_TABLES Flush the table cache, like FLUSH TABLES REFRESH_THREADS Flush the thread cache. REPORT_DATA_TRUNCATION Enable or disable reporting of data truncation errors for prepared statements via MYSQL_BIND.error. (Default: enabled) Added in 5.0.3. SECURE_AUTH Whether to connect to a server that does not support the password hashing used in MySQL 4.1.1 and later. SET_CHARSET_DIR The pathname to the directory that contains character set definition files. SET_CHARSET_NAME The name of the character set to use as the default character set.
107 mysql
Name Description SHARED_MEMORY_BASE_NAME Named of shared-memory object for communication to server. Should be same as the option --shared-memory-base-name used for the mysqld server you want to connect to.
Class Properties clientInfo
String clientInfo ; clientVersion
Integer clientVersion ; Constructor
Database();
Constructs a new Database object Properties affectedRows
Integer affectedRows ;
Returns the number of rows changed by the last UPDATE, deleted by the last DELETE or inserted by the last INSERT statement. May be called immediately after query for UPDATE, DELETE, or INSERT statements. For SELECT statements, affectedRows works like numRows characterSet
String characterSet ;
The character set used by GLUEscript errno
Integer errno ;
Returns the error number for the most recently invoked Database function. error
String error ;
108 mysql
A string containing the error message for the most recently invoked Database function that failed. If a function didn't fail, the return value may be the previous error or an empty string to indicate no error. fieldCount
Integer fieldCount ;
Returns the number of columns for the most recent query on the connection. hostInfo
String hostInfo ;
Returns a string describing the type of connection in use, including the server hostname. info
String info ;
Retrieves a string providing information about the most recently executed query. insertId
Integer insertId ;
Returns the value generated for an AUTO_INCREMENT column by the previous INSERT or UPDATE statement. Use this property after you have performed an INSERT statement into a table that contains an AUTO_INCREMENT field. Note that insertId returns 0 if the previous statement does not use an AUTO_INCREMENT value. If you need to save the value for later, be sure to store the value of insertId in a variable. moreResults
Boolean moreResults ;
This property is used when you execute multiple statements specified as a single statement string, or when you execute CALL statements, which can return multiple result sets.
moreResults returns true if more results exist from the currently executed statement, in which case the application must call next protoInfo
Integer protoInfo ;
Returns the protocol version used by current connection. serverInfo
109 mysql
String serverInfo ;
Returns the version number of the server as a String. serverVersion
Integer serverVersion ;
Returns the version number of the server as an integer. sqlState
String sqlState ;
Returns a string containing the SQLSTATE error code for the most recently executed SQL statement. stat
String stat ;
Returns a string containing information similar to that provided by the mysqladmin status command. This includes uptime in seconds and the number of running threads, questions, reloads, and open tables. warningCount
Integer warningCount ;
Returns the number of warnings generated during execution of the previous SQL statement. Methods autocommit
Boolean autocommit(Boolean Mode);
Sets autocommit mode on if mode is true, off if mode is false. changeUser
Boolean changeUser(String User, String Passwd= null, String Db= null);
Changes the user and causes the database specified by Db to become the default (current) database. In subsequent queries, this database is the default for table references that do not include an explicit database specifier.
changeUser fails if the connected user cannot be authenticated or doesn't have permission to use the database. In this case, the user and database are not changed.
110 mysql
The db parameter may be set to null if you don't want to have a default database.
This command always performs a ROLLBACK of any active transactions, closes all temporary tables, unlocks all locked tables and resets the state as if one had done a new connect. This happens even if the user didn't change. commit
Boolean commit();
Commits the current transaction. connect
Boolean connect(String Host= "", String User= "", String Passwd= "", String Db= "", Integer Port= 0, String UnixSocket= "");
Boolean connect(Object );
Connects to a Database database. When an object is passed, it must contain a host, user, password, database and port property. listDbs
mysql.Result listDbs(String Wild= "");
Returns a result set consisting of database names on the server that match the simple regular expression specified by the Wild parameter. Wild may contain the wildcard characters "%" or "_" or may be an empty string to match all databases listFields
mysql.Result listFields(String Table, String Wild= "");
Returns a result set consisting of field names in the given table that match the simple regular expression specified by the wild parameter. Wild may contain the wildcard characters "%" or "_", or may be an empty string to match all fields listProcesses
mysql.Result listProcesses();
Returns a result set describing the current server threads. This is the same kind of information as that reported by mysqladmin processlist or a SHOW PROCESSLIST query.
111 mysql listTables
mysql.Result listTables(String Wild= "");
Returns a result set consisting of field names in the given table that match the simple regular expression specified by the wild parameter. Wild may contain the wildcard characters "%" or "_", or may be an empty string to match all fields options
Integer options(Integer Option, Any Value);
Can be used to set extra connect options and affect behavior for a connection. This function may be called multiple times to set several options. ping
Integer ping();
Checks whether the connection to the server is working. If the connection has gone down, an automatic reconnection is attempted.
This function can be used by clients that remain idle for a long while, to check whether the server has closed the connection and reconnect if necessary.
Return Values: Zero if the connection to the server is alive. Non-zero if an error occurred. A non-zero return does not indicate whether the MySQL server itself is down; the connection might be broken for other reasons such as network problems. prepare
mysql.Statement prepare(String SQL);
Prepares an SQL statement. The application can include one or more parameter markers in the SQL statement by embedding question mark ("?") characters into the SQL string at the appropriate positions.
The markers are legal only in certain places in SQL statements. For example, they are allowed in the VALUES() list of an INSERT statement (to specify column values for a row), or in a comparison with a column in a WHERE clause to specify a comparison value. However, they are not allowed for identifiers (such as table or column names), or to specify both operands of a binary operator such as the = equal sign. The latter restriction is necessary because it would be impossible to determine the parameter type. In general, parameters are legal only in Data Manipulation Language (DML) statements, and not in Data Definition Language (DDL) statements.
The parameter markers must be bound to application variables using bind before executing the statement.
On failure null is returned. query
mysql.Result query();
112 mysql
Executes the SQL statement. When a statement returns rows, mysql.Result object is returned. Otherwise null is returned. null is also returned on failure. You can use fieldCount to get the number of returned fields in a row. refresh
Integer refresh(Integer Options);
This functions flushes tables or caches, or resets replication server information. The connected user must have the RELOAD privilege.
The options argument is a bit mask composed from any combination of the following values. Multiple values can be OR'ed together to perform multiple operations with a single call.
Returns zero for success, non-zero if an error occurred. rollback
Integer rollback();
Rolls back the current transaction. selectDb
Integer selectDb(String Database);
Causes the database specified by Database to become the default (current) database on the connection specified by mysql. In subsequent queries, this database is the default for table references that do not include an explicit database specifier.
selectDb fails unless the connected user can be authenticated as having permission to use the database. setServerOption
Integer setServerOption(Integer Option);
Enables or disables an option for the connection. option can have one of the following values: mysql.Database.OPTION_MULTI_STATEMENTS_ON or mysql.Database.OPTION_MULTI_STATEMENTS_OFF sslSet
Integer sslSet(String Key, String Cert, String Ca, String CaPath, String Cipher);
Key is the pathname to the key file. Cert is the pathname to the certificate file. Ca is the pathname to the certificate authority file. CaPath is the pathname to a directory that contains trusted SSL CA certificates in pem format. Cipher is a list of allowable ciphers to use for SSL encryption.
113 mysql
Name mysql.Field — Represents a field retrieved from a mysql.Result.
Properties autoIncrement
Boolean autoIncrement ;
When true, the field has the AUTO_INCREMENT attribute. binary
Boolean binary ;
When true, the field has the BINARY attribute. catalog
String catalog ;
The catalog name. This value is always "def". db
String db ;
The name of the database that the field comes from. If the field is a calculated field, db is an empty string. def
String def ;
The default value of this field, as a null-terminated string. This is set only if you use listFields. length
Integer length ;
The width of the field, as specified in the table definition. maxLength
Integer maxLength ;
The maximum width of the field for the result set (the length of the longest field value for the rows actually in the result set.
114 mysql multipleKey
Boolean multipleKey ;
When true, the field is part of a non-unique key. name
String name ;
The name of the field. If the field was given an alias with an AS clause, the value of name is the alias. notNull
Boolean notNull ;
When true, field can't be null. orgName
String orgName ;
The name of the field. Aliases are ignored. orgTable
String orgTable ;
The name of the table. Aliases are ignored. primaryKey
Boolean primaryKey ;
When true, the field is part of the primary key. table
String table ;
The name of the table containing this field, if it isn't a calculated field. For calculated fields, the table value is an empty string. If the table was given an alias with an AS clause, the value of table is the alias. uniqueKey
Boolean uniqueKey ;
When true, the field is part of a unique key.
115 mysql unsigned
Boolean unsigned ;
When true, the field has the UNSIGNED attribute. zeroFill
Boolean zeroFill ;
When true, the field has the ZEROFILL attribute.
116 mysql
Name MySQL
117 mysql
Name mysql.Result — Keeps the result of a query.
Properties fieldTell
Integer fieldTell ;
The current offset of the field cursor. numFields
Integer numFields ;
Returns the number of columns in a result set. numRows
Integer numRows ;
Returns the number of rows in the result set. numRows is intended for use with statements that return a result set, such as SELECT. For statements such as INSERT, UPDATE, or DELETE, the number of affected rows can be obtained with affectedRows. Methods dataSeek
dataSeek(Integer Offset);
Seeks to an arbitrary row in a query result set. The offset value is a row number and should be in the range from 0 to numRows.
This function requires that the result set structure contains the entire result of the query, so dataSeek may be used only in conjunction with query. fetchField
mysql.Field fetchField();
Returns the definition of one column of a result. Call this function repeatedly to retrieve information about all columns in the result set. fetchField returns null when no more fields are left. fetchFieldDirect
mysql.Field fetchFieldDirect(Integer FieldNr);
118 mysql
Given a field number FieldNr (between 0 and (numFields - 1)) for a column within a result set, returns that column's field definition as a mysql.Field object. You may use this function to retrieve the definition for an arbitrary column fetchFields
Array fetchFields();
Returns an array of all fields for a result set. Each element represents one column of the result set. When an error occurs or no fields are found, a null is returned. fetchLengths
Array fetchLengths();
Returns an array with integer elements containing the size of each field value. The length for empty columns and for columns containing NULL values is zero. When an error occurs or no fields are found, a null is returned. fetchObject
Object fetchObject();
Returns an array with each field value as element. When an error occurs or there are no fields available a null is returned. fetchRow
Array fetchRow();
Returns an array with each field value as element. When an error occurs or there are no fields available a null is returned. next
Integer next();
This function is used when you execute multiple statements specified as a single statement string, or when you execute CALL statements, which can return multiple result sets.
If more statement results exist, next() reads the next statement result and returns the status back to the application. The result object is ready for retrieving the contents.
119 mysql
Name mysql.Statement — A class for handling a query.
Properties affectedRows
Integer affectedRows ;
Returns the total number of rows changed, deleted, or inserted by the last executed statement. errno
Integer errno ;
Returns the error code for the most recently invoked statement. error
String error ;
Returns a string containing the error message for the most recently invoked statement. insertId
Integer insertId ;
Returns the value generated for an AUTO_INCREMENT column by the previous INSERT or UPDATE statement. Use this property after you have performed an INSERT statement into a table that contains an AUTO_INCREMENT field. Note that insertId returns 0 if the previous statement does not use an AUTO_INCREMENT value. If you need to save the value for later, be sure to store the value of insertId in a variable. paramCount
Integer paramCount ;
Returns the number of parameters in the prepared statement sqlState
String sqlState ;
Returns a string containing the SQLSTATE error code for the most recently executed SQL statement. Methods bind
120 mysql
bind(Array Bindings);
bind(Integer Pos, Mixed Value);
The method bind is used to bind input data for the parameter markers in the SQL statement that was passed to prepare.
The array must contain one element for each "?" parameter marker that is present in the query. execute
Boolean execute();
Executes the prepared statement fetchArray
Array fetchArray();
Returns the next row as an array. fetchObject
Object fetchObject();
Returns the next row as an object. The name of the field is used as name of the property.
121 Chapter 12. net Introduction
net glues the POCO Net classes to JavaScript. These classes are also used by the Apache glue. Handling Form Input
Input elements of an HTML form can be retrieved with the getObject property of the net.HTMLForm class. Create a net.HTMLForm and pass the request as argument. Naming the elements
The name of the element is important. The getObject property will return an object with properties that are based on the name. You can use simple names as shown below:
Now you can reach the elements as follows:
var form = new net.HTMLForm(request); var elements = form.getObject(); response.print("Firstname: " + elements.firstname + "\n"); response.print("Lastname: " + elements.lastname + "\n");
It's also possible to create objects. Use a dot between names and the object tree will be created automatically.
These elements can be reached as follows:
var form = new net.HTMLForm(request); var customer = form.getObject().customer; response.print("Firstname: " + customer.firstname + "\n"); response.print("Lastname: " + customer.lastname + "\n");
122 net
When elements with the same name are used, you can retrieve them as arrays. Use [] in the name of the element.
Use the following code to retrieve the elements:
var form = new net.HTMLForm(request); response.print("Firstname: " + form.getObject().name[0] + "\n"); response.print("Lastname: " + form.getObject().name[1] + "\n");
Arrays and objects can be combined:
Note An array operator without an index can only be used on the last part of the name! Uploading files
HTMLForm is also used to handle file uploads. Use a net.PartHandler when constructing an HTMLForm:
var form = new net.HTMLForm(request, fileHandler);
fileHandler must be an object of type net.PartHandler. This type has a function that is called automatically when a file is uploaded. The function gets header information and a stream to read the body as arguments. This is a sample implementation:
var fileHandler = new net.PartHandler(); fileHandler.handlePart = function(header, stream) { var type = header.get("Content-Type", "(unspecified)"); if (header.has("Content-Disposition")) { var disp, params; [disp, params] = net.MessageHeader.splitParameters(header.get("Content-Disposition"), disp, params); var formElementname = params.get("name", "(unnamed)"); var fileName = params.get("filename", "(unnamed)");
123 net
var newFileName = "c:\\temp\\" + fileName; var fos = new system.FileOutputStream(newFileName); if ( fos ) { while(! stream.eof) { var buffer = stream.read(1024 * 1024); fos.write(buffer); response.print("write 1024 characters
"); } fos.close(); } else { response.print("can't create file: ", newFileName, "
"); } } } Class Reference
124 net
Name net.DatagramSocket — This class provides an interface to an UDP stream socket.
Prototype: net.Socket
Constructor
DatagramSocket();
DatagramSocket(Integer Family);
DatagramSocket(net.Socket Socket);
DatagramSocket(net.SocketAddress SocketAddress, Boolean ReuseAddress= false);
Creates a new DatagramSocket Properties broadcast
Boolean broadcast ;
Returns the IP address and port number of the peer socket. Methods bind
bind(net.SocketAddress Address, Boolean ReuseAddress= false);
Bind a local address to the socket. This is usually only done when establishing a server socket. If ReuseAddress is true, sets the SO_REUSEADDR socket option. Cannot be used together with connect. connect
connect(net.SocketAddress Address);
Restricts incoming and outgoing packets to the specified address. receiveBytes
Integer receiveBytes(core.Binary Buffer,
125 net
Integer Flags= 0);
Receives data from the socket and stores it in buffer. Up to length bytes are received. Returns the number of bytes received. receiveFrom
Integer receiveFrom(core.Binary Buffer, net.SocketAddress Address, Integer Flags= 0);
Receives data from the socket and stores it in buffer. Up to length bytes are received. Stores the address of the sender in address. Returns the number of bytes received. sendBytes
Integer sendBytes(core.Binary Buffer, Integer Flags= 0);
Sends the contents of the given buffer through the socket. Returns the number of bytes sent, which may be less than the number of bytes specified. sendTo
Integer sendTo(core.Binary Buffer, net.SocketAddress Address, Integer Flags= 0);
Sends the contents of the given buffer through the socket to the given address. Returns the number of bytes sent, which may be less than the number of bytes specified.
126 net
Name net.DialogSocket — This class provides an interface to an UDP stream socket.
Prototype: net.StreamSocket
Constructor
DialogSocket();
DialogSocket(net.Socket Socket);
DialogSocket(net.SocketAddress SocketAddress);
Creates a new StreamSocket Methods get
Integer get();
Reads one character from the connection. Returns -1 if no more characters are available. peek
Integer peek();
Returns the character that would be returned by the next call to get, without actually extracting the character from the buffer. Returns -1 if no more characters are available. receiveMessage
Array receiveMessage();
Returns an array with two elements: A boolean which is true when the message is read or false if the connection has been closed by the peer. The second element is the received string, delimited by CR-LF. receiveStatusMessage
Array receiveStatusMessage();
Returns an array with two elements. Receives a single-line or multi-line response from the socket connection. The format must be according to one of the response formats specified in the FTP (RFC 959) or SMTP (RFC 2821) specifications. The first line starts with a 3-digit status code. Following the status code is either a space character (' ' ) (in case of a single-line response) or a minus character ('-') in case
127 net
of a multi-line response. The following lines can have a three-digit status code followed by a minus-sign and some text, or some arbitrary text only. The last line again begins with a three-digit status code (which must be the same as the one in the first line), followed by a space and some arbitrary text. All lines must be terminated by a CR-LF sequence. The response contains all response lines, separated by a newline character, including the status code. The status code is returned as the first element of the array. If the response line does not contain a status code, 0 is returned. sendByte
sendByte();
Sends a single byte over the socket connection. sendMessage
sendMessage(String Message);
sendMessage(String Message, String Arg);
sendMessage(String Message, String Arg1, String Arg2);
Appends a CR-LF sequence to the message and sends it over the socket connection. sendString
sendString(String Str);
Sends the given string over the socket connection. sendTelnetCommand
sendTelnetCommand(Byte Command);
sendTelnetCommand(Byte Command, Byte Arg);
Sends a TELNET command sequence. synch
synch();
Sends a TELNET SYNCH signal over the connection.
128 net
Name net.Family — Defines constants for net.IPAddress
Constants
Table 12.1. Constants of net.Family
Name Description IPv4 IPv6
129 net
Name net.FilePartSource — An implementation of net.PartSource for plain files.
Prototype: net.PartSource
Constructor
FilePartSource(String Path);
FilePartSource(String Path, String MediaType);
FilePartSource(String Path, String Filename, String MediaType);
Constructs a new FilePartSource object. Returns null when the file can't be found. When no MediaType is given, The MIME type is set to application/octet-stream.
130 net
Name net.HTMLForm — HTMLForm is a helper class for working with HTML forms, both on the client and on the server side.
Prototype: net.NameValueCollection
Use HTMLForm to process the input of a HTTP request you received in the Apache module or use it to send a HTML form to a server. Constructor
HTMLForm();
Creates an empty HTMLForm and sets the encoding to "application/x-www-form-urlencoded".
HTMLForm(String Encoding);
Creates an empty HTMLForm that uses the given encoding. Encoding must be either "application/x-www- form-urlencoded" (which is the default) or "multipart/form-data".
HTMLForm(net.HTTPRequest Request);
Use this to create a HTMLForm for processing the GET or POST requests.
HTMLForm(net.HTTPRequest Request, net.PartHandler PartHandler);
Use this to create a HTMLForm for processing a POST request with files. The uploaded files are passed to the given net.PartHandler. Properties boundary
String boundary ;
Returns the MIME boundary used for writing multipart form data. encoding
String encoding ;
the encoding used for posting the form Methods prepareSubmit
131 net
prepareSubmit(net.HTTPRequest Request);
Fills out the request object for submitting the form.
If the request method is GET, the encoded form is appended to the request URI as query string. Otherwise (the method is POST), the form's content type is set to the form's encoding. The form's parameters must be written to the request body separately, with a call to write. If the request's HTTP version is HTTP/1.0:
• persistent connections are disabled
• the content transfer encoding is set to identity encoding
Otherwise, if the request's HTTP version is HTTP/1.1:
• the request's persistent connection state is left unchanged
• the content transfer encoding is set to chunked
132 net
Name net.Cookie — Represents a cookie
A cookie is a small amount of information sent by a Web server to a Web browser, saved by the browser, and later sent back to the server. A cookie's value can uniquely identify a client, so cookies are commonly used for session management.
A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number. This class supports both the Version 0 (by Netscape) and Version 1 (by RFC 2109) cookie specifications. By default, cookies are created using Version 0 to ensure the best interoperability. Class Methods escape
String escape(String Str);
Escapes the given string by replacing all non-alphanumeric characters with escape sequences in the form %xx, where xx is the hexadecimal character code. The following characters will be replaced with escape sequences:
• percent sign %
• less-than and greater-than < and >
• curly brackets { and }
• square brackets [ and ]
• parenthesis ( and )
• solidus /
• vertical line |
• reverse solidus (backslash /)
• quotation mark "
• apostrophe '
• circumflex accent ^
• grave accent `
• comma and semicolon , and ;
• whitespace and control characters unescape
133 net
String unescape(String Str);
Unescapes the given string by replacing all escape sequences in the form %xx with the respective characters. Constructor
Cookie(String Name, String Value);
Constructs a new net.Cookie object. Properties comment
String comment ;
The comment of the cookie. domain
String domain ;
The domain of the cookie. httpOnly
Boolean httpOnly ;
The domain of the cookie. maxAge
Integer maxAge ;
The maximum age in seconds for the cookie. name
String name ;
The name of the cookie. path
String path ;
The path of the cookie.
134 net secure
String secure ;
The value of the secure flag for the cookie. value
String value ;
The value of the cookie. version
String version ;
The version of the cookie 0 (denoting a Netscape cookie) or 1 (denoting a RFC 2109 cookie). Methods toString
String toString();
Returns a string representation of the cookie, suitable for use in a Set-Cookie header.
135 net
Name net.HTTPMessage — The prototype for net.HTTPRequest and net.HTTPResponse .
Prototype: net.MessageHeader
Defines the common properties of all HTTP messages. These are version, content length, content type and transfer encoding. Also methods for HTTP headers are part of this class. Properties chunckedTransferEncoding
Boolean chunckedTransferEncoding ;
Sets the Transfer-Encoding header to chunked. Otherwise, removes the Transfer-Encoding header. contentLength
Integer contentLength ;
The content length contentType
String contentType ;
Get/Set the content type
KeepAlive
Boolean KeepAlive ;
Sets the value of the Connection header field. The value is set to "Keep-Alive" if keepAlive is true, or to "Close" otherwise. version
String version ;
Get/Set HTTP version
136 net
Name net.HTTPRequest — This class is used for representing an HTTP request
Prototype: net.HTTPMessage Important When used with the Apache module, a request object is automatically created and can be reached as 'request'. Constructor
HTTPRequest();
Creates a GET / HTTP/1.0 HTTP request.
HTTPRequest(String Version);
Creates a GET / HTTP/1.x request with the given version (HTTP/1.0 or HTTP/1.1).
HTTPRequest(String Method, String URI);
Creates a HTTP/1.0 request with the given method and URI.
HTTPRequest(String Method, String URI, String Version);
Creates a HTTP request with the given method, URI and version. Properties cookies
net.NameValueCollection cookies ;
Returns the cookies. credentials
Array credentials ;
Returns the authentication scheme and additional authentication information as an array (scheme is the first element, the authentication information is the second element) contained in this request. host
137 net
String host ;
Set/Get the value of the Host header field. method
String method ;
Get/Set the HTTP method path
String path ;
Returns the path of the URI query
String query ;
Returns the query part. uri
String uri ;
Get/Set the requested URI.
138 net
Name net.HTTPRequestHandler
Create an object of this class in the createRequestHandler function of the class net.HTTPRequestHandlerFactory. When a request is handled, the function handleRequest will be called. handleRequest has two arguments: net.HTTPServerRequest and a net.HTTPServerResponse Constructor
HTTPRequestHandler();
Constructs a new HTTPRequestHandler object
139 net
Name net.HTTPRequestHandlerFactory — A factory for net.HTTPRequestHandler objects.
You must set createRequestHandler to a function that receives a net.HTTPServerRequest as argument and that returns a net.HTTPRequestHandler . Constructor
HTTPRequestHandlerFactory();
Constructs a new HTTPRequestHandlerFactory object
140 net
Name net.HTTPResponse — This class encapsulates an HTTP response
Prototype: net.HTTPMessage Important When used with the Apache module, a response object is automatically created and can be reached as 'response'. Constants
Table 12.2. Constants of net.HTTPResponse
Name Description ACCEPTED BAD_GATEWAY BAD_REQUEST CONFLICT CONTINUE CREATED EXPECTATION_FAILED FORBIDDEN FOUND GATEWAY_TIMEOUT GONE INTERNAL_SERVER_ERROR LENGTH_REQUIRED METHOD_NOT_ALLOWED MOVED_PERMANENTLY MULTIPLE_CHOICES NONAUTHORITATIVE NOT_ACCEPTABLE NOT_FOUND NOT_IMPLEMENTED NOT_MODIFIED NO_CONTENT OK PARTIAL_CONTENT PAYMENT_REQUIRED PRECONDITION_FAILED PROXY_AUTHENTICATION_REQUIRED
141 net
Name Description REQUESTED_RANGE_NOT_SATISFIABLE REQUESTENTITYTOOLARGE REQUESTURITOOLONG REQUEST_TIMEOUT RESET_CONTENT SEE_OTHER SERVICE_UNAVAILABLE SWITCHING_PROTOCOLS TEMPORARY_REDIRECT UNAUTHORIZED UNSUPPORTEDMEDIATYPE USEPROXY VERSION_NOT_SUPPORTED Constructor
HTTPResponse();
HTTPResponse(Integer Status);
HTTPResponse(Integer Status, String Reason);
HTTPResponse(String Version, Integer Status);
HTTPResponse(String Version, Integer Status, String Reason);
Constructs a new HTTPResponse. Properties cookies
Array cookies ;
Returns an array with all the cookies set in the response header. date
Date date ;
142 net
Get/Set the Date header status
Integer status ;
Get/Set the HTTP status code. reason
String reason ;
Get/Set the HTTP reason phrase. Methods addCookie
addCookie(net.Cookie Cookie);
143 net
Name net.HTTPServer — A subclass of net.TCPServer that implements a full-featured multithreaded HTTP server.
Prototype: net.TCPServer
A net.HTTPRequestHandlerFactory must be supplied. The net.ServerSocket must be bound and in listening state. To configure various aspects of the server, a net.HTTPServerParams object can be passed to the constructor. The server supports:
• HTTP/1.0 and HTTP/1.1
• automatic handling of persistent connections.
• automatic decoding/encoding of request/response message bodies using chunked transfer encoding.
var net = require("net");
var factory = new net.HTTPRequestHandlerFactory(); factory.createRequestHandler = function(request) { var handler = new net.HTTPRequestHandler(); handler.handleRequest = function(request, response) { response.print("It works!"); }
return handler; }
var httpServer = new net.HTTPServer(factory, new net.ServerSocket(50001), new net.HTTPServerParams()); httpServer.start();
Constructor
HTTPServer(net.HTTPRequestHandlerFactory Factory, net.ServerSocket ServerSocket, net.HTTPServerParams Params);
Constructs a new HTTPServer object
144 net
Name net.HTTPServerParams
Constructor
HTTPServerParams();
Constructs a new HTTPServerParams object Properties keepAlive
Boolean keepAlive ;
Returns true if and only if persistent connections are enabled. keepAliveTimeout
Integer keepAliveTimeout ;
Returns the connection timeout for HTTP connections. maxKeepAliveRequests
Integer maxKeepAliveRequests ;
The maximum number of requests allowed during a persistent connection, or 0 if unlimited connections are allowed. serverName
String serverName ;
The name and port (name:port) that the server uses to identify itself. softwareVersion
String softwareVersion ;
The server software name and version that the server uses to identify itself. timeout
Integer timeout ;
145 net
Returns the connection timeout for HTTP connections.
146 net
Name net.HTTPServerRequest — This class is used for representing an server-side HTTP request
Prototype: net.HTTPRequest
Properties clientAddress
net.SocketAddress clientAddress ;
Returns client's address. expectContinue
Boolean expectContinue ;
Returns true if the client expects a 100 Continue response. serverAddress
net.SocketAddress serverAddress ;
Returns server's address.
147 net
Name net.HTTPServerResponse — This class is used for representing server-side HTTP responses.
Prototype: net.HTTPResponse
Properties sent
Boolean sent ;
Returns true when the headers are already sent. Methods print
print(); sendFile
Boolean sendFile(String File, String Type); redirect
redirect(String URI); sendBuffer
sendBuffer(core.Binary Buffer); requireAuthentication
requireAuthentication(String Realm);
148 net
Name net.IPAddress — This class represents an internet (IP) host address
This class represents an internet (IP) host address. The address can belong either to the IPv4 or the IPv6 address family. See also net.Family. Constructor
IPAddress();
IPAddress(net.IPAddress Address);
IPAddress(Integer Family);
IPAddress(String Address);
IPAddress(String Address, Integer Family); Properties family
Integer family ;
Returns the address family (IPv4 or IPv6) of the address. broadcast
Boolean broadcast ;
Returns true if and only if the address is a broadcast address. globalMC
Boolean globalMC ;
Returns true if and only if the address is a global multicast address. ipv4Compatible
Boolean ipv4Compatible ;
Returns true if and only if the address is IPv4 compatible.
149 net ipv4Mapped
Boolean ipv4Mapped ;
Returns true if and only if the address is an IPv4 mapped IPv6 address. linkLocal
Boolean linkLocal ;
Returns true if and only if the address is a link local unicast address. linkLocalMC
Boolean linkLocalMC ;
Returns true if and only if the address is a link-local multicast address. loopback
Boolean loopback ;
Returns true if and only if the address is a loopback address. multicast
Boolean multicast ;
Returns true if and only if the address is a multicast address. nodeLocalMC
Boolean nodeLocalMC ;
Returns true if and only if the address is a node-local multicast address. orgLocalMC
Boolean orgLocalMC ;
Returns true if and only if the address is a organization-local multicast address. siteLocal
Boolean siteLocal ;
Returns true if and only if the address is a site local unicast address.
150 net siteLocalMC
Boolean siteLocalMC ;
Returns true if and only if the address is a site-local multicast address. unicast
Boolean unicast ;
Returns true if and only if the address is a unicast address. wellKnownMC
Boolean wellKnownMC ;
Returns true if and only if the address is a well-known multicast address. wildcard
Boolean wildcard ;
Returns true if and only if the address is a wildcard (all zero) address.
151 net
Name net.MailMessage — This class represents an e-mail message.
Prototype: net.MessageHeader
MailMessage supports both old-style plain text messages, as well as MIME multipart mail messages with attachments. Constructor
MailMessage();
Constructs a new MailMessage object Properties content
String content ; contentType
String contentType ; date
Date date ; sender
String sender ; subject
String subject ; recipients
Array recipients ;
152 net
Methods addAttachment
addAttachment(String Name, net.PartSource Source);
Adds an attachment to the mail message. Note The MailMessage object will take ownership of the Source object. This means that when this object is garbage collected, the Source object can't be used anymore! addContent
addContent(net.PartSource Source);
Adds a part to the mail message. Note The MailMessage object will take ownership of the Source object. This means that when this object is garbage collected, the Source object can't be used anymore! addRecipient
addRecipient(net.MailRecipient Recipient);
addRecipient(Object Recipient);
addRecipient(Integer Type, String Address);
addRecipient(Integer Type, String Address, String RealName);
Adds a recipient.
153 net
Name net.MailRecipient
Constants
Table 12.3. Constants of net.MailRecipient
Name Description BCC Blind-carbon-copy recipient CC Carbon-copy recipient PRIMARY Primary recipient
Constructor
MailRecipient(Integer Type, String Address);
MailRecipient(Integer Type, String Address, String RealName);
Constructs a new MailRecipient object Properties address
String address ;
Get/Set the address of the recipient. realName
String realName ;
Get/Set the real name of the recipient. type
Integer type ;
Get/Set type of the recipient. Use one of the constants.
154 net
Name net.MessageHeader
Prototype: net.NameValueCollection
A collection of name-value pairs that are used in various internet protocols like HTTP and SMTP. The name is case-insensitive. There can be more than one name-value pair with the same name. Class Methods splitElements
Array splitElements(String Str, Boolean IgnoreEmpty= true);
Splits the given string into separate elements. Elements are expected to be separated by commas. For example, the string
text/plain; q=0.5, text/html, text/x-dvi; q=0.8
is split into the elements
text/plain; q=0.5 text/html text/x-dvi; q=0.8
Commas enclosed in double quotes do not split elements. If ignoreEmpty is true, empty elements are not returned. splitParameters
Array splitParameters(String Str);
Splits the given string into a value and a collection of parameters. The value is returned as first element of the returned array. The parameters are stored in a net.NameValueCollection and can retrieved from the second element of the returned array. Parameters are expected to be separated by semicolons. Enclosing quotes of parameter values are removed. For example, the string
multipart/mixed; boundary="MIME_boundary_01234567"
is split into the value
multipart/mixed
and the parameter
boundary -> MIME_boundary_01234567 Constructor
155 net
MessageHeader();
Creates a new MessageHeader object Methods write
write(system.OutputStream OutputStream);
Writes the message header to the given output stream. The format is one name-value pair per line, with name and value separated by a colon and lines delimited by a carriage return and a linefeed character. See RFC 2822 for details.
156 net
Name net.MulticastSocket — A MulticastSocket is a special net.DatagramSocket that can be used to send packets to and receive packets from multicast groups.
Prototype: net.DatagramSocket
Constructor
MulticastSocket();
MulticastSocket(Integer Family);
MulticastSocket(net.Socket Socket);
MulticastSocket(net.SocketAddress SocketAddress, Boolean ReuseAddress= false);
Creates a new MulticastSocket Properties interface
net.NetworkInterface interface ;
Returns the interface used for sending multicast packets. loopback
Boolean loopback ;
Returns true if and only if loopback for multicast packets is enabled, false otherwise. timeToLive
Integer timeToLive ;
Returns the TTL/hop limit for outgoing packets. Methods joinGroup
joinGroup(net.IPAddress GroupAddress);
157 net
joinGroup(net.IPAddress GroupAddress, net.NetworkInterface Interface);
Joins the specified multicast group at the given interface or the default interface. leaveGroup
leaveGroup(net.IPAddress GroupAddress);
leaveGroup(net.IPAddress GroupAddress, net.NetworkInterface Interface);
Leaves the specified multicast group at the default interface or at the given interface.
158 net
Name Net
159 net
Name net.NameValueCollection — A collection of name-value pairs that are used in various internet protocols like HTTP and SMTP.
This class is a prototype of several classes like net.HTMLForm, net.HTTPMessage, net.HTTPResponse, net.HTTPServerRequest, net.HTTPServerResponse, net.MailMessage and net.MessageHeader. The name is case-insensitive. There can be more than one name-value pair with the same name. Properties empty
Boolean empty ;
Returns true if and only if the header does not have any content. size
Integer size ;
Returns the number of name-value pairs in the collection. Methods add
add(String Name, String Value);
Adds a new name-value pair with the given name and value. clear
clear();
Removes all name-value pairs and their values. erase
erase(String Name);
Removes all name-value pairs with the given name. get
String get(String Name, String Default= null);
160 net
Returns the value of the first name-value pair with the given name. When no value with the given name has been found, the defaultValue is returned. getArray
Array getArray(String Name);
Returns all values with the given name as array. An empty array is returned, when the name-value pair doesn't exist. getObject
Object getObject();
Returns all parameters as one object. For example: when the collection contains values for names 'firstname' and 'lastname' an object will be returned with 'firstname' and 'lastname' as property. Names that contains a [] are transfered to an array. See Naming the elements for more examples. has
Boolean has(String Name);
Returns true if there is at least one name-value pair with the given name. set
set(String Name, String Value);
Sets the value of the (first) name-value pair with the given name.
161 net
Name net.NetworkInterface — This class represents a network interface
NetworkInterface is used with net.MulticastSocket to specify multicast interfaces for sending and receiving multicast messages. Class Methods forAddress
forAddress(net.IPAddress Address);
Returns the NetworkInterface for the given IP address. forIndex
forIndex(Integer Index);
Returns the NetworkInterface for the given interface index. If an index of 0 is specified, a NetworkInterface instance representing the default interface (empty name and wildcard address) is returned. forName
forName(String Name);
Returns the NetworkInterface for the given name. If requireIPv6 is false, an IPv4 interface is returned. Otherwise, an IPv6 interface is returned. list
list();
Returns a list with all network interfaces on the system. Constructor
NetworkInterface();
Creates a network interface Properties address
net.IPAddress address ;
Returns the IP address bound to the interface.
162 net broadcastAddress
net.IPAddress broadcastAddress ;
Returns the IPv4 broadcast address for this network interface. displayName
String displayName ;
Returns the interface display name. index
Integer index ;
Returns the interface index. Only supported if IPv6 is available.
Name
String Name ;
Returns the interface name. subnetMask
net.IPAddress subnetMask ;
Returns the IPv4 subnet mask for this network interface. supportsIPv4
Boolean supportsIPv4 ;
Returns true if the interface supports IPv4. supportsIPv6
Boolean supportsIPv6 ;
Returns true if the interface supports IPv6.
163 net
Name net.PartSource — Prototype for net.FilePartSource and net.StringPartSource.
Properties filename
String filename ;
Returns the filename for the part or attachment. mediatype
String mediatype ;
Returns the MIME media type for this part or attachment.
164 net
Name net.PartHandler — The base class for all part or attachment handlers.
Part handlers are used for handling email parts and attachments in MIME multipart messages, as well as file uploads via HTML forms. A function handlePart will be called to process the file, part, ... For an example see: Uploading files. Constructor
PartHandler();
Creates a new part handeler
165 net
Name net.ServerSocket — This class provides an interface to a TCP server socket.
Constructor
ServerSocket();
ServerSocket(net.SocketAddress Address, Integer Backlog= 64);
ServerSocket(Integer Port, Integer Backlog= 64);
Constructs a new ServerSocket object Methods acceptConnection
net.StreamSocket acceptConnection();
Get the next completed connection from the socket's completed connection queue. If the queue is empty, waits until a connection request completes. Returns a new TCP socket for the connection with the client. bind
bind(net.SocketAddress Address, Boolean Reuse= false);
bind(Integer Port, Boolean Reuse= false);
Bind a local port to the socket. This is usually only done when establishing a server socket. If Reuse is true, sets the SO_REUSEADDR socket option. listen
listen(Integer Backlog= 64);
Puts the socket into listening state. The socket becomes a passive socket that can accept incoming connection requests. The backlog argument specifies the maximum number of connections that can be queued for this socket.
166 net
Name net.SMTPClientSession — This class implements an Simple Mail Transfer Procotol (SMTP, RFC 2821) client for sending e-mail messages.
With this class you can connect to an SMTP server to send mails. As an example I've configured Mercury/32 to listen to the port 2525 and use the SMTP server of my ISP to send the message (Mercury SMTP Client - relay version).
var smtp = new net.SMTPClientSession("localhost", 2525); smtp.login();
Use the class net.MailMessage to create an e-mail and add a recipient using the net.MailRecipient.
mail.addRecipient(net.MailRecipient.PRIMARY, "[email protected]"); mail.sender = "[email protected]"; // Important to set this!
Make sure you set the name of the sender and that it's allowed by your ISP (if you don't use your own SMTP server). For a simple text e-mail use content and send the message with sendMessage.
mail.content = "Hello world"; smtp.sendMessage(mail);
When you want to send attachments, you need to use addAttachment and addContent methods to build the message. Text content is added with net.StringPartSource, while an attachment is added with net.FilePartSource.
mail.addContent(new net.StringPartSource("Hello World")); var attachment = new net.FilePartSource("c:\\text.txt"); mail.addAttachment("text.txt", attachment);
Constructor
SMTPClientSession(String Host, Integer Port= 25);
Constructs a new SMTPClientSession object Properties timeout
Integer timeout ;
167 net
Get/Sets the timeout for socket read operations. Methods close
Boolean close();
Sends a QUIT command and closes the connection to the server. On error an exception is thrown. login
login();
login(Integer Method, String Username, String Password);
Logs in to the SMTP server using the given authentication method and the given credentials. open
open();
Reads the initial response from the SMTP server. Usually called implicitly through login(), but can also be called explicitly to implement different forms of SMTP authentication. Does nothing if called more than once. sendCommand
Object sendCommand(String Command, String Arg= null);
Sends the given command verbatim to the server and waits for a response. An object with two properties is returned: state and response. sendMessage
sendMessage(net.MailMessage Message);
Sends the given mail message by sending a MAIL FROM command, a RCPT TO command for every recipient, and a DATA command with the message headers and content.
168 net
Name net.SocketAddress — This class represents an internet (IP) endpoint/socket address.
This class represents an internet (IP) endpoint/socket address. The address can belong either to the IPv4 or the IPv6 address family and consists of a host address and a port number. Constructor
SocketAddress();
SocketAddress(net.SocketAddress Address);
SocketAddress(net.IPAddress Address, Integer Port);
SocketAddress(String Host, Integer Port);
SocketAddress(String HostAndPort);
The constructor without arguments creates a wildcard (all zero) IPv4 socket address. When only a string is passed, it creates a SocketAddress from an IP address or host name and a port number/service name. Host name/address and port number must be separated by a colon. In case of an IPv6 address, the address part must be enclosed in brackets. Properties family
Integer family ;
Returns the address family of the host's address. host
net.IPAddress host ;
Returns the host IP address. port
Integer port ;
Returns the port number.
169 net
Methods toString
String toString();
Returns a string representation of the address.
170 net
Name net.Socket — Socket is the prototype for net.StreamSocket, net.ServerSocket, net.DatagramSocket and other socket classes.
Class Properties supportsIPV4
Boolean supportsIPV4 ; supportsIPV6
Boolean supportsIPV6 ; Properties address
net.SocketAddress address ;
Returns the IP address and port number of the socket. available
Integer available ;
Returns the number of bytes available that can be read without causing the socket to block. blocking
Boolean blocking ;
Get/Set the blocking mode. keepAlive
Boolean keepAlive ;
Get/Set the value of the SO_KEEPALIVE socket option. linger
Object linger ;
Get/Set the value of the SO_LINGER socket option. The object must have a on and seconds property.
171 net noDelay
Boolean noDelay ;
Get/Set the value of the TCP_NODELAY socket option.
OOBInline
Boolean OOBInline ;
Get/Set the value of the SO_OOBINLINE socket option. receiveBufferSize
Integer receiveBufferSize ;
Get/Set the size of the receive buffer. receiveTimeout
Integer receiveTimeout ;
Get/Set the timeout in milliseconds. reuseAddress
Boolean reuseAddress ;
Get/Set the value of the SO_REUSEADDR socket option. reusePort
Boolean reusePort ;
Get/Set the value of the SO_REUSEPORT socket option. sendBufferSize
Integer sendBufferSize ;
Get/Set the size of the send buffer. sendTimeout
Integer sendTimeout ;
Get/Set the timeout in milliseconds.
172 net peerAddress
net.SocketAddress peerAddress ;
Returns the IP address and port number of the peer socket. Methods close
close();
Closes the socket. poll
Boolean poll(Integer TimeOut, Integer Mode);
Determines the status of the socket, using a call to select().
173 net
Name net.StreamSocket — This class provides an interface to an UDP stream socket.
Prototype: net.StreamSocket
Constructor
StreamSocket();
StreamSocket(Integer Family);
StreamSocket(net.StreamSocket Socket);
StreamSocket(net.SocketAddress SocketAddress);
Creates a new StreamSocket Methods connect
connect(net.SocketAddress Address);
connect(net.SocketAddress Address, Integer Timeout);
Initializes the socket and establishes a connection to the TCP server at the given address. connectNB
connectNB(net.SocketAddress Address);
Initializes the socket and establishes a connection to the TCP server at the given address. Prior to opening the connection the socket is set to nonblocking mode. receiveBytes
Integer receiveBytes(core.Binary Buffer, Integer Flags= 0);
Receives data from the socket and stores it in buffer. Up to length bytes are received. Returns the number of bytes received. sendBytes
174 net
Integer sendBytes(core.Binary Buffer, Integer Flags= 0);
Sends the contents of the given buffer through the socket. Returns the number of bytes sent, which may be less than the number of bytes specified. sendUrgent
Integer sendUrgent(Integer Char);
Sends one byte of urgent data through the socket. shutdown
shutdown();
Shuts down both the receiving and the sending part of the socket connection. shutdownReceive
shutdownReceive();
Shuts down the receiving part of the socket connection. shutdownSend
shutdownSend();
Shuts down the sending part of the socket connection.
175 net
Name net.StringPartSource — An implementation of net.PartSource for strings.
Prototype: net.PartSource
Constructor
StringPartSource(String Str);
StringPartSource(String Str, String MediaType);
StringPartSource(String Str, String MediaType, String Filename);
Constructs a new StringPartSource object. The MIME type is set to text/plain when MediaType is not given.
176 net
Name net.TCPServer — This class implements a multithreaded TCP server.
Constructor
TCPServer(net.TCPServerConnectionFactory Factory, net.ServerSocket ServerSocket, net.TCPServerParams Params= null);
Constructs a new TCPServer object Properties currentConnections
Integer currentConnections ;
Returns the number of currently handled connections. currentThreads
Integer currentThreads ;
Returns the number of currently used connection threads. maxConcurrentConnections
Integer maxConcurrentConnections ;
Returns the maximum number of concurrently handled connections. port
Integer port ;
Returns the port the server socket listens to. queuedConnections
Integer queuedConnections ;
Returns the number of queued connections. refusedConnections
177 net
Integer refusedConnections ;
Returns the number of refused connections. Methods start
start(); stop
stop();
178 net
Name net.TCPServerConnection
Constructor
TCPServerConnection(net.StreamSocket Socket);
Constructs a new TCPServerConnection object Properties socket
net.StreamSocket socket ;
Returns the underlying socket
179 net
Name net.TCPServerConnectionFactory
Constructor
TCPServerConnectionFactory();
Constructs a new TCPServerConnectionFactory object
180 net
Name net.TCPServerParams
Constructor
TCPServerParams();
Constructs a new TCPServerParams object Properties maxQueued
Integer maxQueued ;
The maximum number of queued connections. maxThreads
Integer maxThreads ;
The maximum number of simultaneous threads available. threadIdleTime
Integer threadIdleTime ;
The maximum thread idle time in milliseconds. threadPriority
Integer threadPriority ;
The priority of TCP server threads
181 Chapter 13. sqlite Introduction
The sqlite glue makes the SQLite [http://www.sqlite.org] database available in JavaScript. Database
sqlite.Database represents a database. When the database doens't exist, the database will be created.
var sqlite = require("sqlite"); var db = new sqlite.Database("person.db");
Executing SQL statements
SQL statements can be executed with exec or prepare. Use exec when you don't need information from the database:
db.exec("CREATE TABLE person(name TEXT, nr INTEGER)");
Use prepare when you need information from the database. prepare will return a sqlite.Statement object. sqlite.Statement allows you to iterate the results of the SQL statements.
var stmt = db.prepare("SELECT * FROM person"); var row; while(row = stmt.fetchObject()) { print(row.name); print(row.nr); }
Class Reference
182 sqlite
Name sqlite.Database — Implements a SQLite database
Constants
Table 13.1. Constants of sqlite.Database
Name Description ABORT Callback routine requested an abort AUTH Authorization denied BUSY The database file is locked CANTOPEN Unable to open the database file CONSTRAINT Abort due to constraint violation CORRUPT The database disk image is malformed DELETE DENY DONE step has finished executing EMPTY (Internal Only) Database table is empty ERROR SQL error or missing database FULL Insertion failed because database is full INSERT INTERNAL An internal logic error in SQLite INTERRUPT Operation terminated by sqlite_interrupt() IOERR Some kind of disk I/O error occurred LOCKED A table in the database is locked MISMATCH Data type mismatch MISUSE Library used incorrectly NOLFS Uses OS features not supported on host NOMEM A malloc() failed NOTFOUND (Internal Only) Table or record not found OK Successful result PERM Access permission denied PROTOCOL Database lock protocol error READONLY Attempt to write a readonly database ROW step has another row ready SCHEMA The database schema changed TOOBIG Too much data for one row of a table UPDATE
183 sqlite
Class Methods complete
Boolean complete(String SQL);
This function returns true if the given input string comprises one or more complete SQL statements. Constructor
Database(String Filename);
Constructs a new Database object.
When the filename is relative the path will be resolved to the path of the active script. Properties autocommit
Boolean autocommit ;
Test to see whether or not the database connection is in autocommit mode. Return TRUE if it is and FALSE if not. Autocommit mode is on by default. Autocommit is disabled by a BEGIN statement and reenabled by the next COMMIT or ROLLBACK. changes
Integer changes ;
This property returns the number of database rows that were changed (or inserted or deleted) by the most recently completed INSERT, UPDATE, or DELETE statement. Only changes that are directly specified by the INSERT, UPDATE, or DELETE statement are counted. Auxiliary changes caused by triggers are not counted. See totalChanges lastInsertRowID
Double lastInsertRowID ;
Each entry in an SQLite table has a unique integer key called the "rowid". The rowid is always available as an undeclared column named ROWID, OID, or _ROWID_. If the table has a column of type INTEGER PRIMARY KEY then that column is another an alias for the rowid.
This property returns the rowid of the most recent INSERT into the database from the database connection. If no inserts have ever occurred on this database connection, zero is returned.
If an INSERT occurs within a trigger, then the rowid of the inserted row is returned by this routine as long as the trigger is running. But once the trigger terminates, the value returned by this routine reverts to the last value inserted before the trigger fired.
184 sqlite errMsg
String errMsg ;
Returns the error message from the most recent sqlite method call. errNo
Integer errNo ;
Returns the error number from the most recent sqlite method call. onCommit
Function onCommit ;
Register a callback function to be invoked whenever a new transaction is committed. If the callback function returns non-zero, then the commit is converted into a rollback. onTrace
Function onTrace ;
Register a function that is called each time an SQL statement is evaluated. The function receives the SQL statement as argument. onRollback
Function onRollback ;
Register a callback to be invoked whenever a transaction is rolled back. onUpdate
Function onUpdate ;
Register a callback function with the database to be invoked whenever a row is updated, inserted or deleted.
The function gets 4 arguments: The first argument is one of Database.INSERT, Database.DELETE or Database.UPDATE, depending on the operation that caused the callback to be invoked. The second and third arguments to the callback contains the database and table name from the affected row. The final callback parameter is the rowid of the row. In the case of an update, this is the rowid after the update takes place. opened
Boolean opened ;
Returns true when the database was successfully opened
185 sqlite totalChanges
Integer totalChanges ;
Use this property to find the total number of changes including changes caused by triggers. See changes Methods exec
Integer exec(String SQL);
Executes an SQL statement immediately. prepare
sqlite.Statement prepare(String SQL);
To execute an SQL query, it must first be compiled into a byte-code program using prepare.
186 sqlite
Name SQLite
187 sqlite
Name sqlite.Statement — Implements an sqlite statement.
Use the prepare method to create a SQLite SQL statement. Properties columnCount
Integer columnCount ;
Return the number of columns in the result set returned by the prepared SQL statement. Methods bind
Integer bind(Integer Parameter, Mixed Value);
Integer bind(String Parameter, Mixed Value);
In the SQL strings input to prepare, one or more literals can be replace by a parameter "?" or ":AAA" or "$VVV" where AAA is an alphanumeric identifier and VVV is a variable name according to the syntax rules of the TCL programming language. The values of these parameters (also called "host parameter names") can be set using bind.
The first argument to bind is the index or the name of the parameter to be set. The first parameter has an index of 1.
The second argument is the value to bind to the parameter.
bind must be called after prepare or reset and before sqlite.Statement.method.step. Bindings are not cleared by the reset. Unbound parameters are interpreted as NULL.
bind returns Database.OK on success or an error code if anything goes wrong. Database.RANGE is returned if the parameter index is out of range. Database.NOMEM is returned if malloc fails. Database.MISUSE is returned if these routines are called on a virtual machine that is the wrong state or which has already been finalized.
Blobs are supported. Use a core.Binary instance as value. columnDeclType
String columnDeclType(Integer Column);
The declared type of the table column is returned. If the column of the result set is not a table column, then null is returned. For example, in the database schema:
188 sqlite
CREATE TABLE t1(c1 INTEGER);
And the following statement compiled:
SELECT c1 + 1, c1 FROM t1;
Then this method would return the string "INTEGER" for the second result column (Column==1), and nullL for the first result column (Column==0).
If the following statements were compiled then this method would return "INTEGER" for the first (only) result column.
SELECT (SELECT c1) FROM t1; SELECT (SELECT c1 FROM t1); SELECT c1 FROM (SELECT c1 FROM t1); SELECT * FROM (SELECT c1 FROM t1); SELECT * FROM (SELECT * FROM t1); columnName
String columnName(Integer Column);
This function returns the column heading for the column of this statement, columnOriginalName
String columnOriginalName(Integer Column);
If the column returned by the statement is a column reference, this function may be used to access the schema name of the referenced column in the database schema. If the column is not a column reference, NULL is returned. columnTableName
String columnTableName(Integer Column);
If the column returned by the statement is a column reference, this function may be used to access the name of the table that contains the column. If the column is not a column reference, null is returned. fetchArray
Array fetchArray();
This method calls step and returns the row in an array. An empty array will be returned when no rows are available anymore. fetchObject
Object fetchObject();
189 sqlite
This method calls step and returns the row as a JavaScript object. null will be returned when no rows are available anymore. step
Integer step();
After an SQL query has been prepared with a call to either prepare, then this method must be called one or more times to execute the statement. The return value will be either Database.BUSY, Database.DONE, Database.ROW, Database.ERROR, or Database.MISUSE.
• Database.BUSY means that the database engine attempted to open a locked database and there is no busy callback registered. Call step again to retry the open.
• Database.DONE means that the statement has finished executing successfully. step should not be called again on this virtual machine without first calling reset to reset the virtual machine back to its initial state.
• If the SQL statement being executed returns any data, then Database.ROW is returned each time a new row of data is ready for processing by the caller. Call step again to retrieve the next row of data.
• Database.ERROR means that a run-time error (such as a constraint violation) has occurred. step should not be called again on the VM. More information may be found in the property errMsg.
• Database.MISUSE means that the this routine was called inappropriately. Perhaps it was called on a virtual machine that had already been finalized or on one that had previously returned sqlite.ERROR or Database.DONE. Or it could be the case that a database connection is being used by a different thread than the one it was created it.
Database.MISUSE is also returned when the associated Database object is not available anymore. This can occur when the database is finalized (when the variable gets out of scope for example). Make sure the database object is still referenced somewhere by a local or global variable. reset
Integer reset();
The reset function is called to reset a prepared SQL statement obtained by a previous call to prepare back to it's initial state, ready to be re-executed.
190 Chapter 14. system Introduction
system provides classes for accessing the filesystem, the enviroment, processes, .... Reference
191 system
Name Global Functions — global functions
Methods glob
Array glob(String Pattern, Integer Options);
Creates a set of files that match the given pathPattern. The path may be give in either Unix, Windows or VMS syntax and is automatically expanded by calling expand. The pattern may contain wildcard expressions even in intermediate directory names. Note that, for obvious reasons, escaping characters in a pattern with a backslash does not work in Windows-style paths. Directories that for whatever reason cannot be traversed are ignored.
The available options are defined as properties on this function: CASELESS, DEFAULT, DOT_SPECIAL and FOLLOWING_SYMLINKS. An example:
var system = require("system"); var files = system.glob("/development/*.cpp", system.glob.CASELESS);
192 system
Name system.File — The File class provides methods for working with a file.
Constructor
File(system.Path Path);
File(String Path);
Creates a new File object. Properties canExecute
Boolean canExecute ;
Makes the file executable (if flag is true), or non-executable (if flag is false) by setting the file's permission bits accordingly. canRead
Boolean canRead ;
Makes the file non-writeable (if flag is true), or writeable (if flag is false) by setting the file's flags in the filesystem accordingly. canWrite
Boolean canWrite ;
Makes the file writeable (if flag is true), or non-writeable (if flag is false) by setting the file's flags in the filesystem accordingly. created
Date created ;
Returns the creation date of the file. Not all platforms or filesystems (e.g. Linux and most Unix platforms with the exception of FreeBSD and Mac OS X) maintain the creation date of a file. On such platforms, created returns the time of the last inode modification. directory
Boolean directory ;
193 system
Returns true when the file is a directory. exists
Boolean exists ;
Returns true when the file exists file
Boolean file ;
Returns true when the file is a regular file. hidden
Boolean hidden ;
Returns true if the file is hidden. On Windows platforms, the file's hidden attribute is set for this to be true. On Unix platforms, the file name must begin with a period for this to be true. lastModified
Boolean lastModified ;
Gets/Sets the modification date of the file. link
Boolean link ;
Returns true if the file is a symbolic link. size
Integer size ;
Gets/Sets the size of the file path
String path ;
Returns the path Methods copyTo
194 system
Boolean copyTo(String Path);
Copies the file (or directory) to the given path. The target path can be a directory. createDirectories
Boolean createDirectories();
Creates a directory (and all parent directories if necessary). createDirectory
Boolean createDirectory();
Creates a directory. Returns true if the directory has been created and false if it already exists or an error occurs. createFile
Boolean createFile();
Creates a new, empty file in an atomic operation. Returns true if the file has been created and false if the file already exists or when an error occurs. list
Array list();
Returns the names of all files in the directory. moveTo
Boolean moveTo(String Path);
Move the file (or directory) to the given path. The target path can be a directory. remove
Boolean remove(Boolean Recursive= false);
Deletes the file. If recursive is true and the file is a directory, recursively deletes all files in the directory. renameTo
Boolean renameTo(String Path);
Renames the file to the new name.
195 system
Name system.FileInputStream — An input stream for reading from a file.
Prototype: system.InputStream
Files are always opened in binary mode. When you need to handle text you need to use system.TextInputStream Note A stream is automatically closed when the object is garbage collected. When this is to late, you need to call the close method. Constructor
FileInputStream(String Filename);
Creates a new FileInputStream object. When the file doesn't exist null is returned. Methods close
close();
Closes the stream.
196 system
Name system.FileOutputStream — An output stream for writing data to a file.
Prototype: system.OutputStream
Files are always opened in binary mode. When you need to handle text you need to use system.TextOutputStream Note A stream is automatically closed when the object is garbage collected. When this is to late, you need to call the close method. Constructor
FileOutputStream(String Filename, Boolean Truncate= true);
Creates a new FileOutputStream object. When the file doesn't exist null is returned. When Truncate is true (which is the default), the file will be truncated. Methods close
close();
Closes the stream.
197 system
Name system.InputStream — Base class for all input streams.
Constants
Table 14.1. Constants of system.InputStream
Name Description SEEK_BEG SEEK_CUR SEEK_END
Properties count
Integer count ;
Get number of characters extracted by last unformatted input operation eof
Boolean eof ;
Returns true when the end of the file is reached. pos
Integer pos ;
Returns the absolute position of the get pointer. The get pointer determines the next location in the input sequence to be read by the next input operation. Methods ignore
ignore(Integer Size= 1);
Extracts characters from the input sequence and discards them. peek
Integer peek();
198 system
Reads and returns the next character without extracting it, i.e. leaving it as the next character to be extracted from the stream. read
core.BinaryString read(Integer Size);
Reads a block of data. seek
Boolean seek(Integer Pos);
Boolean seek(Integer Offset, Integer Direction);
Sets the position of the get pointer to the given position. False is returned on failure. unget
unget();
Decrements the internal get pointer by one, making the last character extracted from the input sequence available again as the next character to be read from the stream.
199 system
Name system.OutputStream — Base class for all output streams.
Constants
Table 14.2. Constants of system.OutputStream
Name Description SEEK_BEG SEEK_CUR SEEK_END
Properties pos
Integer pos ;
Returns the absolute position of the put pointer. The put pointer determines the next location in the output sequence where the next output operation is going to take place. Methods write
write(core.Binary Buffer);
write(String Buffer);
Writes a block of data. seek
Boolean seek(Integer Pos);
Boolean seek(Integer Offset, Integer Direction);
Sets the position of the get pointer to the given position. False is returned on failure. flush
flush();
200 system
Synchronizes the buffer associated with the stream to its controlled output sequence. This effectively means that all unwritten characters in the buffer are written to its controlled output sequence as soon as possible ("flushed").
201 system
Name system.Path — This class represents filesystem paths (including filenames) in a platform-independent manner
Unix, Windows and OpenVMS all use a different syntax for filesystem paths. This class can work with all three formats. A path is made up of an optional node name (only Windows and OpenVMS), an optional device name (also only Windows and OpenVMS), a list of directory names and an optional filename. Constants
Table 14.3. Constants of system.Path
Name Description GUESS NATIVE UNIX VMS WINDOWS
Class Properties current
String current ; home
String home ; roots
String roots ; null
String null ; pathSeparator
String pathSeparator ; separator
String separator ;
202 system temp
String temp ; Class Methods expand
String expand(String Path);
Expands all environment variables contained in the path. On Unix, a tilde as first character in the path is replaced with the path to user's home directory. find
Array find(String PathList, String Name);
Searches the file with the given name in the locations (paths) specified in pathList. The paths in pathList must be delimited by the platform's path separator (see pathSeparator()). A relative path may be given in name. If the file is found in one of the locations, the complete path of the file is stored in the path given as argument and true is returned. Otherwise false is returned and the path argument remains unchanged.
This method returns an array with two elements: the first element is a boolean indicating success or failure. The second element is a os.Path object. forDirectory
system.Path forDirectory(String Path);
Creates a path referring to a directory. Constructor
Path(Boolean Absolute);
Creates an empty absolute or relative path.
Path(String Path);
Creates a path from a string.
Path(String Path, Integer Style);
Creates a path from a string.
Path(String Path,
203 system
Integer Style);
Creates a path from a parent path and a relative path. The parent path is expected to reference a directory. The relative path is appended to the parent path.
Path(String Path, system.Path Relative);
Creates a path from a parent path and a relative path. The parent path is expected to reference a directory. The relative path is appended to the parent path.
Creates a new Path object. Properties basename
String basename ;
Set/Gets the basename (the filename sans extension) of the path. depth
Integer depth ;
Returns the number of directories. device
String device ;
Gets/Sets the device name. Setting a non-empty device automatically makes the path an absolute one. directoryName
String directoryName ;
Gets the directory name of the path (it's the same as calling directories with depth - 1) extension
String extension ;
Gets/Sets the file extension. filename
String filename ;
Gets/Sets the filename.
204 system node
String node ;
Gets/Sets the node name. isAbsolute
Boolean isAbsolute ;
Returns true when the path is absolute. isDirectory
Boolean isDirectory ;
Returns true when the path is a directory. isFile
Boolean isFile ;
Returns true when the path is a file. isRelative
Boolean isRelative ;
Returns true when the path is relative. parent
system.Path parent ;
Returns a path referring to the path's directory. Methods absolute
system.Path absolute();
system.Path absolute(system.Path Path);
Makes the path absolute taking the given path as base.
system.Path absolute(String Path);
205 system
Makes the path absolute taking the given path as base.
Makes the path absolute taking the current path as base. append
system.Path append(system.Path Path);
system.Path append(String Path);
Appends the given path assign
system.Path assign(system.Path Path);
Assigns the given path.
sytem.Path assign(String Path);
Assigns a string containing a path in native format.
system.Path assign(String Path, Integer Style);
Assigns a string containing a path. clear
clear();
Clears all components. directory
String directory(Integer N);
Returns the N'th directory in the directory list. If N == depth(), returns the filename. makeAbsolute
system.Path makeAbsolute();
Makes the path absolute if it is relative. The current working directory is taken as base directory.
system.Path makeAbsolute(system.Path Path);
Makes the path absolute if it is relative. The given path is taken as base.
206 system makeDirectory
system.Path makeDirectory();
If the path contains a filename, the filename is appended to the directory list and cleared. Thus the resulting path always refers to a directory. makeFile
system.Path makeFile();
If the path contains no filename, the last directory becomes the filename. makeParent
system.Path makeParent();
Makes the path refer to its parent. parseDirectory
system.Path parseDirectory(String Path);
system.Path parseDirectory(String Path, Integer Style);
The resulting path always refers to a directory and the filename part is empty. popDirectory
popDirectory();
Removes the last directory from the directory list. pushDirectory
pushDirectory(String Path);
Adds a directory to the directory list. resolve
system.Path resolve(system.Path Path);
Resolves the given path agains the current one. If the given path is absolute, it replaces the current one. Otherwise, the relative path is appended to the current path. toString
207 system
String toString();
Returns a string containing the path in native format.
208 system
Name system.Pipe — This class implements an anonymous pipe.
Pipes are a common method of inter-process communication - on Unix, pipes are the oldest form of IPC.
A pipe is a half-duplex communication channel, which means that data only flows in one direction. Pipes have a read-end and a write-end. One process writes to the pipe and another process reads the data written by its peer. Read and write operations are always synchronous. A read will block until data is available and a write will block until the reader reads the data.
Pipes are used through a system.PipeOutputStream or system.PipeInputStream. Constructor
Pipe();
Creates a new Pipe object.
209 system
Name system.PipeInputStream — An input stream for reading from a Pipe.
Prototype: system.InputStream
Constructor
PipeInputStream(system.Pipe Pipe);
Creates the PipeInputStream with the given Pipe.
210 system
Name system.PipeOutputStream — An output stream for writing to a Pipe.
Prototype: system.OutputStream
Constructor
PipeOutputStream(system.Pipe Pipe);
Creates the PipeOutputStream with the given Pipe.
211 system
Name system.Process — This class provides methods for working with processes.
Constructor
Process(String Command, Array Args, system.Pipe inPipe= null, system.Pipe outPipe= null, system.Pipe errPipe= null);
Creates a new Process object. The given arguments are passed to the command on the command line.
If inPipe, outPipe or errPipe is non-null, the corresponding standard input, standard output or standard error stream of the launched process is redirected to the system.Pipe. os.PipeInputStream.class or system.PipeOutputStream can be used to send receive data from, or send data to the process.
The same system.Pipe can be used for both outPipe and errPipe. After a system.Pipe has been passed as inPipe, only write operations are valid. After a system.Pipe has been passed as outPipe or errPipe, only read operations are valid. Important It is forbidden to pass the same pipe as inPipe and outPipe or errPipe. Properties pid
Integer pid ;
Returns the process id Methods wait
Integer wait();
Waits for the process to terminate and returns the exit code of the process.
212 system
Name system.TemporaryFile — The TemporaryFile class helps with the handling of temporary files.
Prototype: system.File
A unique name for the temporary file is automatically chosen and the file is placed in the directory reserved for temporary files (see temp). Obtain the path by calling the path() method (inherited from File).
The TemporaryFile class does not actually create the file - this is up to the application. The class does, however, delete the temporary file - either in the garbage collector, or immediately before the scripts terminates. Class Properties tempName
String tempName ; Constructor
TemporaryFile();
Creates a new system.TemporaryFile object. Methods keep
keep();
Disables automatic deletion of the file when the object is garbage collected. keepUntilExit
keepUntilExit();
The file will be deleted when the script ends. collected.
213 system
Name system.TextInputStream — An input stream for reading text from a file.
Prototype: system.FileInputStream
Unlike system.FileInputStream which opens a file in binary mode, TextInputStream can handle line endings and files with different encodings. GLUEscript uses UTF-8 internally. Note A stream is automatically closed when the object is garbage collected. When this is to late, you need to call the close method. Note Because this class uses a conversion stream internally, it's not possible to use seek and pos. Constructor
TextInputStream(String Filename, String LineEnding, core.Encoding Encoding= null);
Creates a new TextInputStream object. When the file doesn't exist null is returned. When no LineEnding argument is passed, the default of the operating system is used. When no encoding is specified, TextInputStream will try to detect the encoding based on the BOM. When a BOM is in the file, TextInputStream will discard it. Note Be carefull when a BOM is in the file: don't use seek to set the pointer to the beginning of the file, because when you start reading again you will read the BOM characters. Methods close
close();
Closes the stream. readAll
String readAll();
Reads all text. readLine
String readLine();
214 system
Returns the next line from the stream. The new line characters are not included.
215 system
Name system.TextOutputStream — An output stream for writing text to a file.
Prototype: system.FileOutputStream
Unlike system.FileOutputStream which opens a file in binary mode, TextOutputStream can handle line endings and can convert the file to another encoding. (GLUEscript uses internally UTF-8). Note A stream is automatically closed when the object is garbage collected. When this is to late, you need to call the close method. Note Because this class uses a conversion stream internally, it's not possible to use seek and pos. Constructor
TextOutputStream(String Filename, String LineEnding, core.Encoding Encoding= null, Boolean Truncate= true);
Creates a new TextOutputStream object. When no LineEnding argument is passed, the default of the operating system is used. When Truncate is true (default), the file will be truncated. Methods close
close();
Closes the stream writeLine
writeLine(String Text);
Writes the text to the file and appends a new line.
216 Chapter 15. tpl Introduction
TPL is a template engine for generating (X)HTML, XML, text, ... It is based on libtemplate [http:// www.lazarusid.com/libtemplate.shtml].
A template engine allows you to separate the logic of your application from the view. A template consists of literal text and elements. An element will be replaced by a value set in the template engine. When a template is parsed, the elements are replaced with their set values, and the parsed template is stored in an new element. The developer has the option of replacing any existing value for the template, or appending to the existing value. Template files
A template file can contain multiple templates. Each template must be enclosed between and tags. It has a mandatory name attribute. Quotes arround the attribute value is mandatory. Within a template, there is literal text, which will be unchanged by the parsing process, and elements. Parsing will replace the element with the values assigned in the template engine. Elements without assigned values will not appear in the parsed result.
An element is enclosed in curly braces, and may contain letters, numbers and punctuation marks. Whitespace between curly braces will cause it to be interpreted as literal text rather than an element. This convention allows the use of javascript functions in templates. A template example
Base Square Cube ------{rows} ------
The quotes "{empty}" should be empty.
{base} {square} {cube}
This script uses the template:
var tpl = require("tpl"); var engine = new tpl.Engine(); var n = 1;
// Load the template file engine.load("cube.tpl");
217 tpl
for(n = 1;n <= 10; n++) { engine.base = n; engine.square = n * n; engine.cube = n * n * n; // Parse the template 'row' and add the result to element 'rows' engine.parse("row", "rows", true); }
engine.parse("grid", "main", false);
print(engine.main);
Class Reference
218 tpl
Name tpl.Engine — A class used for generating output using templates
A class used for generating output using templates (based on LibTemplate). Template variables are dynamic properties. This means that adding a property to this class, adds a template variable. The following is an example on using this class:
var engine = new tpl.Engine(); var n = 1;
// Load the template file engine.load("test.tpl"); for(n = 1;n <= 10; n++) { engine.base = n; engine.square = n * n; engine.cube = n * n * n; // Parse the template 'row' and add the result to element 'rows' engine.parse("row", "rows", true); }
engine.parse("grid", "main", false); var output = engine.main;
The template file 'test.tpl' looks like this:
Base Square Cube ------{rows} ------
The quotes "{empty}" should be empty.
{base} {square} {cube}
Use this class to separate the HTML code (View) from the JavaScript code (Model and Controller). Note It's not allowed to put text before or after a template-tag on the same line!. Constructor
Engine(String Path= "");
219 tpl
Constructs a new EngineClass Methods load
load(String Filename, core.Encoding Encoding= null);
Loads a template file and appends the templates to the engine. When no encoding is passed, UTF8 will be used. On Windows an absolute filepath will be translated to a file URI.
Currently only the file scheme is supported! parse
boolean parse(String name, String newname, Boolean append= true);
Substitute the element values for their tags in the compiled template.
220 Chapter 16. wx Introduction
wx ports the GUI classes of wxWidgets [http://www.wxwidgets.org] to JavaScript. With this glue, it's possible to write desktop applications in JavaScript. wxTheApp
Unlike wxWidgets, there's no application class that derives from App. When glue_wx is loaded it instantiates an object of the type App and stores it in the global variable TheApp. The application can be initialized assigning a function to the onInit event (Allthough it can also be initialized without this function). This function must create a top-level window and make that window visible. When the return value of this function is false, or there is no top-level window created, or the top-level window is invisible, the main loop will exit immediately. A simple example:
var wx = require("wx"); wx.TheApp.onInit = function() { var frame = new wx.Frame(null, -1, "An App example"); // Don't forget to show the frame by setting // the visible property to true! frame.visible = true; this.topWindow = frame; return true; }
Event Handling
Event handling is simple in JavaScript. The only thing that is needed, is assigning a function to a predefined event property. For example: onKeyDown can be used to react on a pressed key:
text.onKeyDown = function(e) { if (e.keyCode == 13) { frame.setStatusText("Enter is not allowed"); e.skip = false; } e.skip = true; }
An event handler gets one argument of type Event. The scope of this argument is restricted to the handler. Outside the handler the argument will always return null when you retrieve properties.
Removing an event handler, can be done by deleting the event property.
221 wx
// Delete the event: delete text.onKeyDown;
Class Reference
222 wx
Name wx.AboutDialogInfo — wx.AboutDialogInfo contains information shown in the standard About dialog displayed by the wx.AboutBox() function.
This class contains the general information about the program, such as its name, version, copyright and so on, as well as lists of the program developers, documentation writers, artists and translators. The simple properties from the former group are represented as a string with the exception of the program icon and the program web site, while the lists from the latter group are stored as an Array and can be either set entirely at once using the corresponding property or built one by one using addDeveloper etc. Constructor
AboutDialogInfo();
Constructs a new AboutDialogInfo Class. Properties name
String name ;
Name of the program. When this property is not set, appName will be used instead. version
String version ;
The version of the program. The version is in free format, i.e. not necessarily in the x.y.z form but it shouldn't contain the "version" word. description
String description ;
A brief, but possibly multiline, description of the program. copyright
String copyright ;
Set the short string containing the program copyright information. Notice that any occurrences of "(C)" in copyright will be replaced by the copyright symbol (circled C) automatically. license
String license ;
223 wx
A long, multiline string containing the text of the program license. icon
wx.Icon icon ;
The icon to be shown in the dialog. By default the icon of the main frame will be shown if the native about dialog supports custom icons. website
String website ;
The web site for the program. websiteDescription
String websiteDescription ;
The web site description for the program. developers
Array developers ;
An array with the names of the developers of this program. docWriters
Array docWriters ;
An array with the names of the documentation authors. artists
Array artists ;
An array with the names of the artists of this program. translators
Array translators ;
An array with the names of the translators of this program. Methods addArtist
224 wx
addArtist(String Artist);
Add an artist. addDeveloper
addDeveloper(String Developer);
Add a developer addDocWriter
addDocWriter(String DocWriter);
Add a documentation author addTranslator
addTranslator(String Translator);
Add a translator
225 wx
Name wx.AcceleratorEntry — An Object used by an application wishing to create an accelerator table.
See wx.AcceleratorTable, wxMenuItem accel property. Constants
Table 16.1. Constants of wx.AcceleratorEntry Name Description ALT CTRL NORMAL SHIFT Constructor
AcceleratorEntry();
AcceleratorEntry(Integer Flags= 0, Integer Keycode= 0, Integer Command= 0);
Constructs a new AcceleratorEntry Class. Properties flags
Integer flags ; keyCode
Integer keyCode ;
See wx.KeyCode command
Integer command ;
The menu or control command identifier. Methods set
226 wx set(Integer Flags, Integer Keycode= 0, Integer Command= 0);
227 wx
Name wx.AcceleratorTable — An accelerator table allows the application to specify a table of keyboard shortcuts for menus or other commands.
On Windows, menu or button commands are supported; on GTK, only menu commands are supported. The following example adds an accelerator to a frame. When CTRL-F1 is pressed the menu action associated with id 1 is executed.
var wx = require("wx"); wx.theApp.onInit = init;
function init() { var frame = new wx.Frame(null, -1, "Accelerator Test"); var menuBar = new wx.MenuBar(); var menu = new wx.Menu(); var idInfoAbout = 1;
menu = new wx.Menu(); menu.append(idInfoAbout, "About"); menu.actions[idInfoAbout] = infoAboutMenu; menuBar.append(menu, "Info");
frame.menuBar = menuBar;
var entries = new Array(); entries[0] = new wx.AcceleratorEntry(wx.AcceleratorEntry.CTRL, wx.KeyCode.F1, idInfoAbout); frame.acceleratorTable = new wx.AcceleratorTable(entries);
menu.getItem(idInfoAbout).accel = entries[0];
topWindow = frame; frame.visible = true;
return true; }
function infoAboutMenu(event) { wx.MessageBox("Accelerator Test Version 1.0"); }
Constructor
AcceleratorTable(Array Entries);
Constructs a new AcceleratorTable Class. The array must contain elements of type wx.AcceleratorEntry.
228 wx
Properties ok
Boolean ok ;
Returns true when the accelerator table is valid
229 wx
Name wx.ActivateEvent — This object is passed to a function that handles an activate event.
Prototype: wx.Event
Handle this event by setting the onActivate property on a wx.Window object. Properties active
Boolean active ;
Returns true when the control is active, false when it's not.
230 wx
Name wx.Alignment
Constants
Table 16.2. Constants of wx.Alignment
Name Description BOTTOM CENTER CENTER_HORIZONTAL CENTER_VERTICAL CENTRE CENTRE_HORIZONTAL CENTRE_VERTICAL LEFT NOT RIGHT TOP
231 wx
Name wx.Animation — This class encapsulates the concept of a platform-dependent animation.
An animation is a sequence of frames of the same size. Sound is not supported by Animation. Constants
Table 16.3. Constants of wx.Animation
Name Description TYPE_ANI TYPE_ANY TYPE_GIF
Constructor
Animation();
Constructor Properties frameCount
Integer frameCount ;
Returns the number of frames for this animation. ok
Boolean ok ;
Returns true if animation data is present. size
wx.Size size ;
Returns the size of the animation. Methods getDelay
Integer getDelay(Integer Frame);
232 wx
Returns the delay for the i-th frame in milliseconds. If -1 is returned the frame is to be displayed forever. getFrame
wx.Image getFrame(Integer Frame);
Returns the i-th frame as a wxImage. loadFile
Boolean loadFile(String Name, Integer Type= wx.Animation.TYPE_ANY);
Loads an animation from a file.
233 wx
Name wx.AnimationCtrl
Prototype: wx.Control
This is a static control which displays an animation. See also wx.Animation Constants
Table 16.4. Constants of wx.AnimationCtrl
Name Description DEFAULT_STYLE NO_AUTORESIZE By default, the control will adjust its size to exactly fit to the size of the animation when animation is set. If this style flag is given, the control will not change its size.
Constructor
AnimationCtrl();
AnimationCtrl(wx.Window Parent, Integer Id, wx.Animation Animation, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Constructs a new AnimationCtrl Class. Properties animation
wx.Animation animation ;
Get/Set the animation associated with this control. inactiveBitmap
wx.Bitmap inactiveBitmap ;
The bitmap to show on the control when it's not playing an animation. If you set it to null (which is the default), then the first frame of the animation is instead shown when the control is inactive; in this case, if there's no valid animation associated with the control (see animation), then the background colour of the window is shown.
234 wx playing
Boolean playing ;
Returns true if the animation is being played. Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Animation Animation, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Constructs a new AnimationCtrl Class. play
Boolean play();
Starts playing the animation. The animation is always played in loop mode (unless the last frame of the animation has an infinite delay time) and always start from the first frame (even if you stopped it while some other frame was displayed). stop
stop();
Stops playing the animation. The control will show the first frame of the animation, a custom static image or the window's background colour as specified by setting inactiveBitmap. loadFile
loadFile(String Name, Integer Type= wx.Animation.TYPE_ANY);
Loads an animation from a file.
235 wx
Name wx.App — App represents the application.
An Object of this class is automatically instantiated and can be accessed as follows:
var wx = require("wx"); wx.TheApp
You can assign a function to the onInit event. This function is called before the main message loop is entered. It's not mandatory to use onInit, because the console application will check if a top-level window is created and shown before entering the main loop. Unlike previous versions of GLUEscript, where you needed to call mainLoop, the console application will enter the main loop automatically. Properties appName
String appName ;
Get/Set the application name className
String className ;
Get/Set the classname topWindow
wx.Window topWindow ;
Get/Set the top window of your application. vendorName
String vendorName ;
Get/Set the vendor name argv
Array argv ;
Returns the arguments passed to the script
236 wx
Name wx.AuiManager — AuiManager is the central class of the wxAUI class framework.
Constructor
AuiManager();
AuiManager(wx.Window ManagedWindow, Integer Option= wx.AuiManagerOption.DEFAULT);
Constructs a new wxAuiManager. Properties allPanes
Array allPanes ;
Array with all pane info (see wx.AuiPaneInfo). dockSizeConstraint
Array dockSizeConstraint ;
When a user creates a new dock by dragging a window into a docked position, often times the large size of the window will create a dock that is unwieldly large. wxAuiManager by default limits the size of any new dock to 1/3 of the window size. For horizontal docks, this would be 1/3 of the window height. For vertical docks, 1/3 of the width. Setting this property will adjust this constraint value. The numbers must be between 0.0 and 1.0. For instance, setting dockSizeContraint to [0.5, 0.5] will cause new docks to be limited to half of the size of the entire managed window. flags
Integer flags ; managedWindow
wx.Window managedWindow ;
Get/Set the frame or window which is to be managed by wxAuiManager. Methods addPane
237 wx
Boolean addPane(wx.Window Window, wx.AuiPaneInfo PaneInfo);
Boolean addPane(wx.Window Window, Integer Direction= wxDirection.LEFT, String Caption= "");
Boolean addPane(wx.Window Window, wx.AuiPaneInfo PaneInfo, wx.Point Pos);
addPane() tells the frame manager to start managing a child window. There are several versions of this function. The first version allows the full spectrum of pane parameter possibilities. The second version is used for simpler user interfaces which do not require as much configuration. The last version allows a drop position to be specified, which will determine where the pane will be added. detachPane
Boolean detachPane(wx.Window Window);
Tells the wx.AuiManager to stop managing the pane specified by window. The window, if in a floated frame, is reparented to the frame managed by wx.AuiManager. getPane
wx.AuiPaneInfo getPane(wx.Window Window);
wx.AuiPaneInfo getPane(String Name);
getPane is used to lookup a wx.AuiPaneInfo object either by window or by pane name, which acts as a unique id for a window pane. The returned wx.AuiPaneInfo object may then be modified to change a pane's look, state or position. After one or more modifications to wx.AuiPaneInfo, update should be called to commit the changes to the user interface. If the lookup failed (meaning the pane could not be found in the manager), ok will return false. hideHint
hideHint();
Hides any docking hint that may be visible. insertPane
Boolean insertPane(wx.Window Window, wx.AuiPaneInfo InsertLocation, Integer InsertLevel= wx.AuiPaneInsertLevel.PANE);
This method is used to insert either a previously unmanaged pane window into the frame manager, or to insert a currently managed pane somewhere else. insertPane will push all panes, rows, or docks aside and insert the window into the position specified by InsertLocation. Because InsertLocation can
238 wx
specify either a pane, dock row, or dock layer, the InsertLevel parameter is used to disambiguate this. The parameter InsertLevel can take a value of wx.AuiPaneInsertLevel.PANE, wx.AuiPaneInsertLevel.ROW or wx.AuiPaneInsertLevel.DOCK. loadPaneInfo
loadPaneInfo(String PanePart, wx.AuiPaneInfo Pane);
loadPaneInfo is similar to to loadPerspective, with the exception that it only loads information about a single pane. It is used in combination with savePaneInfo. loadPerspective
Boolean loadPerspective(String Perspective, Boolean Update= true);
Loads a saved perspective. If Update is true, update is automatically invoked, thus realizing the saved perspective on screen. savePaneInfo
String savePaneInfo(wx.AuiPaneInfo Pane);
savePaneInfo is similar to savePerspective, with the exception that it only saves information about a single pane. It is used in combination with loadPaneInfo. savePerspective
String savePerspective();
Saves the entire user interface layout into an encoded String, which can then be stored by the application. When a perspective is restored using loadPerspective, the entire user interface will return to the state it was when the perspective was saved. showHint
showHint(wx.Rect Rect); unInit
unInit();
Uninitializes the framework and should be called before a managed frame or window is destroyed. update
update();
239 wx
This method is called after any number of changes are made to any of the managed panes. Update must be invoked after addPane or insertPane are called in order to "realize" or "commit" the changes. In addition, any number of changes may be made to wx.AuiPaneInfo structures (retrieved with getPane), but to realize the changes, update must be called. This construction allows pane flicker to be avoided by updating the whole layout at one time.
240 wx
Name wx.AuiManagerDock — Defines constants for wx.AuiManager
Constants
Table 16.5. Constants of wx.AuiManagerDock
Name Description BOTTOM CENTER CENTRE LEFT NONE RIGHT TOP
241 wx
Name wx.AuiManagerOption — Defines constants for wx.AuiManager
Constants
Table 16.6. Constants of wx.AuiManagerOption
Name Description ALLOW_ACTIVE_PANE ALLOW_FLOATING DEFAULT HINT_FADE NO_VENETIAN_BLINDS_FADE RECTANGLE_HINT TRANSPARENT_DRAG TRANSPARENT_HINT VENETIAN_BLINDS_HINT
242 wx
Name wx.AuiNotebook
Prototype: wx.Control
wxAuiNotebook is a notebook control which implements many features common in applications with dockable panes. Specifically, wxAuiNotebook implements functionality which allows the user to rearrange tab order via drag-and-drop, split the tab window into many different splitter configurations, and toggle through different themes to customize the control's look and feel. Constants
Table 16.7. Constants of wx.AuiNotebook
Name Description BOTTOM With this style, tabs are drawn along the bottom of the notebook. CLOSE_BUTTON With this style, a close button is available on the tab bar. CLOSE_ON_ACTIVE_TAB With this style, the close button is visible on the active tab. CLOSE_ON_ALL_TABS With this style, the close button is visible on all tabs. DEFAULT_STYLE Defined as TOP | TAB_SPLIT | TAB_MOVE | SCROLL_BUTTONS | CLOSE_ON_ACTIVE_TAB SCROLL_BUTTONS With this style, left and right scroll buttons are displayed. TAB_EXTERNAL_MOVE Allows a tab to be moved to another tab control. TAB_FIXED_WIDTH With this style, all tabs have the same width. TAB_MOVE Allows a tab to be moved horizontally by dragging. TAB_SPLIT Allows the tab control to be split by dragging a tab. TOP With this style, tabs are drawn along the top of the notebook. WINDOWLIST_BUTTON With this style, a drop-down list of windows is available.
Constructor
AuiNotebook();
AuiNotebook(wx.Window Parent, Integer Id= wx.ID.ANY);
Constructs a new AuiNotebook.
243 wx
Properties pageCount
Integer pageCount ;
Returns the number of pages. selection
Integer selection ;
Get/Set the index of the active page. tabCtrlHeight
Integer tabCtrlHeight ;
Get/Set the height of the tab control. Methods create
Boolean create(wx.Window Parent, Integer Id= wx.ID.ANY, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Creates the notebook window. addPage
Boolean addPage(wx.Window Win, String Caption, Boolean Select= false, wx.Bitmap Bitmap= null);
Adds a page. If the Select parameter is true, calling this will generate a page change event. advanceSelection
advanceSelection(Boolean Forward= true);
Sets the selection to the next or previous page. deletePage
244 wx
Boolean deletePage(Integer Page);
Deletes a page at the given index. Calling this method will generate a page change event. getHeightForPageHeight
Integer getHeightForPageHeight(Integer PageHeight);
Returns the desired height of the notebook for the given page height. Use this to fit the notebook to a given page size. getPage
wx.Window getPage(Integer Index);
Returns the page specified by the given index. getPageBitmap
wx.Bitmap getPageBitmap(Integer Index);
Returns the tab bitmap for the page. getPageIndex
Integer getPageIndex(wx.Window Win);
Returns the page index for the specified window. If the window is not found in the notebook, -1 is returned. getPageText
String getPageText(Integer Index);
Returns the tab label for the page. insertPage
Boolean insertPage(Integer Index, wx.Window Win, String Caption, Boolean Select= false, wx.Bitmap Bitmap= null);
insertPage is similar to addPage, but allows the ability to specify the insert location. If the Select parameter is true, calling this will generate a page change event. removePage
Boolean removePage(Integer Page);
245 wx
Removes a page at the given index. setFont
Boolean setFont(wx.Font Font);
Sets the font for drawing the tab labels, using a bold version of the font for selected tab labels. setSelectedFont
setSelectedFont(wx.Font Font);
Sets the font for drawing selected tab labels. setMeasuringFont
setMeasuringFont(wx.Font Font);
Sets the font for measuring tab labels. setNormalFont
setNormalFont(wx.Font Font);
Sets the font for drawing unselected tab labels. setPageBitmap
Boolean setPageBitmap(Integer Page, wx.Bitmap Bitmap);
Sets the bitmap for the page. To remove a bitmap from the tab caption, pass null. setPageText
Boolean setPageText(Integer Page, String Text);
Sets the tab label. setUniformBitmapSize
setUniformBitmapSize(wx.Size Size);
setUniformBitmapSize ensures that all tabs will have the same height, even if some tabs don't have bitmaps. Passing wx.DefaultSize to this function will instruct the control to use dynamic tab height, which is the default behaviour. Under the default behaviour, when a tab with a large bitmap is added, the tab control's height will automatically increase to accommodate the larger bitmap.
246 wx split
split(Integer Page, Integer Direction);
split performs a split operation programmatically. The argument page indicates the page that will be split off. This page will also become the active page after the split. The direction argument specifies where the pane should go, it should be one of the following: wx.Direction.TOP, wx.Direction.BOTTOM, wx.Direction.LEFT, or wx.Direction.RIGHT. showWindowMenu
Boolean showWindowMenu();
Shows the window menu for the active tab control associated with this notebook, and returns true if a selection was made.
247 wx
Name wx.AuiNotebookEvent — This object is passed to a function that is set to a wx.AuiNotebook event property.
Prototype: wx.NotifyEvent Properties selection
Integer selection ;
Get the current selection oldSelection
Integer oldSelection ;
Get the old selection
248 wx
Name wx.AuiPaneInfo
Constructor
AuiPaneInfo();
AuiPaneInfo(wx.Window ManagedWindow, Integer Option= wx.AuiManagerOption.DEFAULT);
Constructs a new wx.AuiManager. Properties bestSize
wx.Size bestSize ;
Get/Sets the ideal size for the pane. bottomDockable
Boolean bottomDockable ;
Indicates whether a pane can be docked at the bottom of the frame caption
String caption ;
Get/Set the caption of the pane. captionVisible
Boolean captionVisible ;
Indicates that a pane caption should be visible. If false, no pane caption is drawn. closeButton
Boolean closeButton ;
Indicates that a close button should be drawn for the pane. destroyOnClose
249 wx
Boolean destroyOnClose ;
Indicates whether a pane should be destroyed when it is closed. Normally a pane is simply hidden when the close button is clicked. Setting destroyOnClose to true will cause the window to be destroyed when the user clicks the pane's close button. direction
Integer direction ;
Get/Set the direction of the docked pane. dockFixed
Boolean dockFixed ;
Causes the containing dock to have no resize sash. This is useful for creating panes that span the entire width or height of a dock, but should not be resizable in the other direction. dockable
Boolean dockable ;
Specifies whether a frame can be docked or not. fixed
Boolean fixed ;
Forces a pane to be fixed size so that it cannot be resized floatable
Boolean floatable ;
Sets whether the user will be able to undock a pane and turn it into a floating window. floatingSize
wx.Size floatingSize ;
Get/Sets the size of the floating pane. floatingPosition
wx.Point floatingPosition ;
Get/Sets the position of the floating pane.
250 wx gripper
Boolean gripper ;
Indicates that a gripper should be drawn for the pane. gripperTop
Boolean gripperTop ;
Indicates that a gripper should be drawn at the top of the pane paneBorder
Boolean paneBorder ;
Indicates that a border should be drawn for the pane. maximizeButton
Boolean maximizeButton ;
Indicates that a maximize button should be drawn for the pane. minimizeButton
Boolean minimizeButton ;
Indicates that a minimize button should be drawn for the pane. pinButton
Boolean pinButton ;
Indicates that a pin button should be drawn for the pane. docked
Boolean docked ;
Is the pane docked? floating
Boolean floating ;
Is the pane floating?
251 wx ok
Boolean ok ;
Returns true if the wx.AuiPaneInfo object is valid. A pane is valid if it has an associated window. resizeable
Boolean resizeable ;
Allows a pane to be resized if the property is true, and forces it to be a fixed size if the property is false. toolbar
Boolean toolbar ;
Returns true if the pane contains a toolbar. moveable
Boolean moveable ;
Is the frame movable? name
String name ;
Gets/Sets the name of the pane so it can be referenced in lookup functions. If a name is not specified by the user, a random name is assigned to the pane when it is added to the manager. position
Integer position ;
The position of the docked pane. row
Integer row ;
The row of the docked pane. Methods bottom
wx.AuiPaneInfo bottom();
252 wx
Sets the pane dock position to the bottom side of the frame. center
wx.AuiPaneInfo center();
Sets the pane dock position to the left side of the frame. The center pane is the space in the middle after all border panes (left, top, right, bottom) are subtracted from the layout. Can also be called as centre. centerPane
wx.AuiPaneInfo centerPane();
centerPane specifies that the pane should adopt the default center pane settings. Center panes usually do not have caption bars. This function provides an easy way of preparing a pane to be displayed in the center dock position. Can also be called as centrePane. defaultPane
wx.AuiPaneInfo defaultPane();
Specifies that the pane should adopt the default pane settings. dock
wx.AuiPaneInfo dock();
indicates that a pane should be docked. float
wx.AuiPaneInfo float();
indicates that a pane should be docked. show
wx.AuiPaneInfo show(Boolean Sw= true);
Show/hide the pane hide
wx.AuiPaneInfo hide();
Hide the pane layer
253 wx
wx.AuiPaneInfo layer(Integer Layer);
Determines the layer of the docked pane. The dock layer is similar to an onion, the inner-most layer being layer 0. Each shell moving in the outward direction has a higher layer number. This allows for more complex docking layout formation. left
wx.AuiPaneInfo left();
Sets the pane dock position to the left side of the frame. right
wx.AuiPaneInfo right();
Sets the pane dock position to the right side of the frame. top
wx.AuiPaneInfo top();
Sets the pane dock position to the top side of the frame.
254 wx
Name wx.AuiPaneInsertLevel — Defines constants for wx.AuiManager
Constants
Table 16.8. Constants of wx.AuiPaneInsertLevel
Name Description DOCK PANE ROW
255 wx
Name wx.AutomationObject — The AutomationObject class represents an OLE automation object containing a single data member, an IDispatch pointer.
It contains a number of functions that make it easy to perform automation operations, and set and get properties. The wxVariant class is not ported, because GLUEscript translates every type to the corresponding JavaScript type. This class is only available on a Windows platform. Constructor
AutomationObject();
Constructs a new AutomationObject object. Unlike wxWidgets, this constructor can't take an IDispatch pointer because this type can't be used in JavaScript. Methods callMethod
Any callMethod(String Method, ... Arg1);
Calls an automation method for this object. When the method returns a value it is not returned as a wxVariant but it is converted to its corresponding JavaScript type.
The following example opens a workbook into Microsoft Excel:
var objExcel = new wx.AutomationObject();
if ( objExcel.createInstance("Excel.Application") ) { objExcel.putProperty("visible", true); var objBooks = new wx.AutomationObject(); objExcel.getObject(objBooks, "workbooks"); objBooks.callMethod("open", "c:\\temp\\glue.xls"); }
The name of the method can contain dot-separated property names, to save the application needing to call getProperty several times using several temporary objects. For example:
objExcel.callMethod("workbooks.open", "c:\\temp\\glue.xls"); createInstance
Boolean createInstance(String classId);
Creates a new object based on the class id, returning true if the object was successfully created, or false if not.
256 wx
The following example starts Microsoft Excel:
var obj = new wx.AutomationObject(); if ( obj.createInstance("Excel.Application") ) { // Excel object is created }
getInstance
Boolean getInstance(String classId);
Retrieves the current object associated with a class id, and attaches the IDispatch pointer to this object. Returns true if a pointer was successfully retrieved, false otherwise. putProperty
Boolean putProperty(String Property, ... Arg1);
Puts a property value into this object. The following example starts Microsoft Excel and makes it visible.
var obj = new wx.AutomationObject(); if ( obj.createInstance("Excel.Application") ) { obj.putProperty("visible", true); }
The name of the property can contain dot-separated property names, to save the application needing to call getProperty several times using several temporary objects. getProperty
Any getProperty(String Property, ... Arg1);
Gets a property from this object. The return type depends on the type of the property. Use getObject when the property is an object. The name of the method can contain dot-separated property names, to save the application needing to call getProperty several times using several temporary objects. getObject
Boolean getObject(wx.AutomationObject Object, String Property, ... Arg1);
Gets a property from this object. The type of the property is also an object. The following example retrieves the object Workbooks from an Excel application:
257 wx
var objExcel = new wx.AutomationObject(); if ( objExcel.createInstance("Excel.Application") ) { objExcel.putProperty("visible", true); var objBooks = new wx.AutomationObject(); objExcel.getObject(objBooks, "workbooks"); }
The name of the method can contain dot-separated property names, to save the application needing to call getProperty several times using several temporary objects.
258 wx
Name wx.BitmapButton — A button that contains a bitmap.
Prototype: wx.Button Constructor
BitmapButton();
BitmapButton(wx.Window Parent, Integer Id, wx.Bitmap Bitmap, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Button.AUTO_DRAW);
Constructs a new wx.BitmapButton object. Properties bitmapDisabled
wx.Bitmap bitmapDisabled ;
Bitmap to show when the button is disabled. bitmapFocus
wx.Bitmap bitmapFocus ;
Bitmap to show when the button has the focus. bitmapLabel
wx.Bitmap bitmapLabel ;
The default bitmap. bitmapSelected
wx.Bitmap bitmapSelected ;
Bitmap to show when the button is selected. Methods create
259 wx
Boolean create(wx.Window Parent, Integer Id, wx.Bitmap Bitmap, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Button.AUTO_DRAW);
Creates a bitmap button.
260 wx
Name wx.Bitmap — This class encapsulates the concept of a platform-dependent bitmap, either monochrome or colour.
See wx.Icon and wx.BitmapType Constructor
Bitmap();
Bitmap(String FileName, Integer Type);
Bitmap(wx.Image Image, Integer ColourDepth= -1);
Constructs a new Bitmap Class. Properties depth
Integer depth ;
Get/Set the colour depth of the bitmap. A value of 1 indicates a monochrome bitmap. height
Integer height ;
Get/Set the height of the bitmap in pixels. ok
Boolean ok ;
Returns true when the bitmap data is available. width
Integer width ;
Get/Set the width of the bitmap in pixels. Methods create
261 wx
Boolean create(Integer Width, Integer Height, Integer Depth= -1);
Creates a fresh bitmap. loadFile
Boolean loadFile(String Name, Integer Type);
Loads a bitmap from a file.
262 wx
Name wx.BitmapType
Constants
Table 16.9. Constants of wx.BitmapType
Name Description ANY BMP BMP_RESOURCE CUR CUR_RESOURCE GIF GIF_RESOURCE ICO ICON ICON_RESOURCE ICO_RESOURCE INVALID JPEG JPEG_RESOURCE MACCURSOR MACCURSOR_RESOURCE PCX PCX_RESOURCE PICT PICT_RESOURCE PNG PNG_RESOURCE PNM PNM_RESOURCE RESOURCE TIF TIF_RESOURCE XBM XBM_DATA XPM XPM_DATA
263 wx
Name wx.BMPHandler — Image handler for bitmaps.
Prototype: wx.ImageHandler
264 wx
Name wx.BookCtrlBase — Prototype for all book controls like wx.Notebook, wx.Choicebook.
Prototype: wx.Control Constants
Table 16.10. Constants of wx.BookCtrlBase
Name Description ALIGN_MASK BOTTOM DEFAULT LEFT RIGHT TOP
Properties currentPage
wx.Window currentPage ;
The current page. pageCount
Integer pageCount ;
Returns the number of pages in the control. selection
Integer selection ;
Get/Set the selected page. imagelist
wx.ImageList imagelist ;
Get/Set the associated image list. internalBorder
265 wx
Integer internalBorder ;
Get/Set size of area between book control area and page area. controlMargin
Integer controlMargin ;
Get/Set the margin around the controller. controlSizer
wx.Sizer controlSizer ;
Get the sizer containing the control. vertical
Boolean vertical ;
Returns true if we have wxBookCtrlBase.TOP or wxBookCtrlBase.BOTTOM style fitToCurrentPage
Boolean fitToCurrentPage ;
Get/Set option to shrink to fit current page. Methods getPage
wx.Window getPage(Integer Index);
Returns the page specified by the given index. getPageText
String getPageText(Integer Index);
Returns the tab label for the page. setPageText
Boolean setPageText(Integer Page, String Text);
Sets the tab label.
266 wx getPageImage
Integer getPageImage(Integer Index);
Returns the item's image index in the current image list. setPageImage
Boolean setPageImage(Integer Page, Integer ImageId);
Sets the item's image index in the current image list. setPageSize
setPageSize(wx.Size Size);
Resize the notebook so that all pages will have the specified size addPage
Boolean addPage(wx.Window Win, String Caption, Boolean Select= false, Integer ImageId= -1);
Add a new page. insertPage
Boolean insertPage(Integer Index, wx.Window Win, String Caption, Boolean Select= false, Integer Image= -1);
insertPage is similar to addPage, but allows the ability to specify the insert location. If the Select parameter is true, calling this will generate a page change event. deletePage
Boolean deletePage(Integer Page);
Deletes a page at the given index. Calling this method will generate a page change event. deleteAllPages
Boolean deleteAllPages();
267 wx
Delete all pages. removePage
Boolean removePage(Integer Page);
Removes a page at the given index. changeSelection
Integer changeSelection(Integer Page);
Set Selection but does not generate events. advanceSelection
advanceSelection(Boolean Forward= true);
Sets the selection to the next or previous page. hitTest
Array hitTest(wx.Point Pos);
Returns an array with two elements: the page which is hit and a flag where it is it(icon, label).
268 wx
Name wx.BookCtrlBaseEvent
Prototype: wx.NotifyEvent Properties selection
Integer selection ;
Get the current selection oldSelection
Integer oldSelection ;
Get the old selection
269 wx
Name wx.BookCtrlEvent — This object is passed to a function that is set to a wx.BookCtrlBase event property.
Prototype: wx.BookCtrlBaseEvent
270 wx
Name wx.BookHittest
Constants
Table 16.11. Constants of wx.BookHittest
Name Description NOWHERE There was no tab under this point. ONICON The point was over an icon (currently wxMSW only). ONITEM The point was over an item, but not on the label or icon. ONLABEL The point was over a label (currently wxMSW only). ONPAGE The point was over a currently selected page, not over any tab. Note that this flag is present only if -1 is returned.
271 wx
Name wx.Border
Constants
Table 16.12. Constants of wx.Border
Name Description DEFAULT DOUBLE MASK NONE RAISED SIMPLE STATIC SUNKEN
272 wx
Name wx.BoxSizer — The basic idea behind a box sizer is that windows will most often be laid out in rather simple basic geometry, typically in a row or a column or several hierarchies of either.
Prototype: wx.Sizer Constructor
BoxSizer(Integer orientation);
Creates a new BoxSizer object. See wx.Orientation Properties orientation
Integer orientation ;
Gets the orientation. See wx.Orientation
273 wx
Name wx.Button — A button is a control that contains a text string
Prototype: wx.Control
It's one of the commonest elements of a GUI. It may be placed on a dialog box or panel, or indeed almost any other window. An example:
// dlg is a wx.Dialog var button = new wx.Button(dlg, -1, "Click me"); button.onClicked = function(event) { wx.messageBox("You've clicked me"); }
Constants
Table 16.13. Constants of wx.Button
Name Description AUTODRAW If this is specified, the button will be drawn automatically using the label bitmap only, providing a 3D-look border. If this style is not specified, the button will be drawn without borders and using all provided bitmaps. WIN32 only. BOTTOM Aligns the label to the bottom of the button. Windows and GTK+ only. EXACTFIT Creates the button as small as possible instead of making it of the standard size (which is the default behaviour ). LEFT Left-justifies the label. Windows and GTK+ only. NO_BORDER Creates a flat button. Windows and GTK+ only. RIGHT Right-justifies the bitmap label. Windows and GTK + only. TOP Aligns the label to the top of the button. Windows and GTK+ only.
Class Properties defaultSize
Integer defaultSize ; Constructor
274 wx
Button();
Button(wx.Window Parent, Integer Id, String Text, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Button.AUTODRAW, wx.Validator Validator= wx.DefaultValidator);
Constructs a new wx.Button object. Properties label
String label ;
Get/Set the label of the button. Methods create
Boolean create(wx.Window Parent, Integer Id, String Text, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Button.AUTODRAW, wx.Validator Validator= wx.DefaultValidator);
Creates a button. setDefault
setDefault();
This sets the button to be the default item for the panel or dialog box. see defaultItem. Events onClicked Called when the button is clicked. The type of the argument that your handler receives is wx.CommandEvent.
275 wx
Name wx.CalculateLayoutEvent — This event is sent by wx.LayoutAlgorithm to calculate the amount of the remaining client area that the window should occupy.
Prototype: wx.Event Properties flags
Integer flags ;
Get/Set the flags associated with this event. Not currently used. rect
wx.Rect rect ;
Before the event handler is entered, returns the remaining parent client area that the window could occupy. When the event handler returns, this should contain the remaining parent client rectangle, after the event handler has subtracted the area that its window occupies.
276 wx
Name wx.CalendarCtrl — The calendar control allows the user to pick a date.
Prototype: wx.Control
For this, it displays a window containing several parts: a control at the top to pick the month and the year (either or both of them may be disabled), and a month area below them which shows all the days in the month. The user can move the current selection using the keyboard and select the date (generating onCalendar event) by pressing return or double clicking it.
It has advanced possibilities for the customization of its display. All global settings (such as colours and fonts used) can, of course, be changed. But also, the display style for each day in the month can be set independently using wx.CalendarDateAttr. Constants
Table 16.14. Constants of wx.CalendarCtrl
Name Description MONDAY_FIRST Show Monday as the first day in the week NO_MONTH_CHANGE Disable the month (and, implicitly, the year) changing NO_YEAR_CHANGE Disable the year changing SEQUENTIAL_MONTH_SELECTION Use alternative, more compact, style for the month and year selection controls. SHOW_HOLIDAYS Highlight holidays in the calendar SHOW_SURROUNDING_WEEKS Show the neighbouring weeks in the previous and next months SUNDAY_FIRST Show Sunday as the first day in the week
Constructor
CalendarCtrl();
CalendarCtrl(wx.Window Parent, Integer Id, Date DefaultDate, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.CalendarCtrl.SHOW_HOLIDAYS);
Constructs a new CalendarCtrl object. Properties attr
277 wx
Array attr ;
Get the attributes of a day. The array index must be between 1 and 31. date
Date date ;
Get/Set the current date enableHolidayDisplay
Boolean enableHolidayDisplay ;
Show/hide holidays (write only) enableMonthChange
Boolean enableMonthChange ;
Enable/Disable month changing (write only) enableYearChange
Boolean enableYearChange ;
Enable/Disable year changing (write only) headerColourBg
wx.Colour headerColourBg ;
Get/Set the background colour of the header. See setHeaderColours and headerColourFg headerColourFg
wx.Colour headerColourFg ;
Get/Set the foreground colour of the header. See setHeaderColours and headerColourBg highlightColourBg
wx.Colour highlightColourBg ;
Get/Set the background colour of the selected date. See setHighlightColours and highlightColourFg highlightColourFg
wx.Colour highlightColourFg ;
278 wx
Get/Set the foreground colour of the selected date. See setHighlightColours and highlightColourBg holidayColourBg
wx.Colour holidayColourBg ;
Get/Set the background colour of a holiday. See setHolidayColours and holidayColourFg holidayColourFg
wx.Colour holidayColourFg ;
Get/Set the foreground colour of a holiday. See setHolidayColours and holidayColourBg lowerDateLimit
Date lowerDateLimit ;
Get/Set the lower date limit in which selection might occur. Set to null to remove the lower limit. See upperDateLimit and setDateRange upperDateLimit
Date upperDateLimit ;
Get/Set the upper date limit in which selection might occur. Set to null to remove the upper limit. See lowerDateLimit and setDateRange Methods create
Boolean create(wx.Window Parent, Integer Id, Date DefaultDate, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.CalendarCtrl.SHOW_HOLIDAYS);
Creates a calendar control. setDateRange
setDateRange(Date LowerLimit= null, Date UpperLimit= null);
Set the range in which selection can occur. setHeaderColours
279 wx
setHeaderColours(wx.Colour ForegroundColour, wx.Colour BackgroundColour);
Sets the colours of the header. setHighlightColours
setHighlightColours(wx.Colour ForegroundColour, wx.Colour BackgroundColour);
Sets the colours of the highlighted date. setHolidayColours
setHolidayColours(wx.Colour ForegroundColour, wx.Colour BackgroundColour);
Sets the colours of a holiday. Events onCalendar A day is double clicked. The function gets a wx.CalendarEvent as argument. onCalendarSelChanged The selected date is changed. The function gets a wx.CalendarEvent as argument. onCalendarDay The selected day is changed. The function gets a wx.CalendarEvent as argument. onCalendarMonth The selected month is changed. The function gets a wx.CalendarEvent as argument. onCalendarYear The selected year is changed. The function gets a wx.CalendarEvent as argument. onCalendarWeekDayClicked The user clicked on the week day header. The function gets a wx.CalendarEvent as argument.
280 wx
Name wx.CalendarDateAttr
Constructor
CalendarDateAttr();
CalendarDateAttr(wx.Colour TextColour, wx.Colour BackgroundColour= null, wx.Colour BorderColour= null, wx.Font Font= null, Integer Border= 0);
CalendarDateAttr(Integer Border, wx.Colour BorderColour);
Constructs a new CalendarDateAttr object. Properties backgroundColour
wx.Colour backgroundColour ;
The background colour border
Integer border ;
Type of the border. See wx.CalendarDateBorder. borderColour
wx.Colour borderColour ;
The colour of the border. font
wx.Font font ;
The font of the text. holiday
281 wx
boolean holiday ;
Is the day a holiday? textColour
wx.Colour textColour ;
The colour of the text
282 wx
Name wx.CalendarDateBorder
Constants
Table 16.15. Constants of wx.CalendarDateBorder
Name Description NONE ROUND SQUARE
283 wx
Name wx.CalendarEvent — This object is passed to a function that is set to a wx.CalendarCtrl event property.
Prototype: wx.Event Properties date
Date date ;
Returns the date. weekDay
Integer weekDay ;
Returns the weekday
284 wx
Name wx.Caret — A caret is a blinking cursor showing the position where the typed text will appear.
The text controls usually have a caret but wxCaret class also allows to use a caret in other windows. Class Properties blinkTime
Integer blinkTime ; Constructor
Caret();
Caret(wx.Window Window, Integer Width, Integer Height);
Caret(wx.Window Window, wx.Size Size);
Constructs a new Caret object. Properties position
wx.Point position ;
The caret position in pixels size
wx.Size size ;
Get/Set the caret size window
wx.Window window ;
Get the window the caret is associated with. ok
285 wx
Boolean ok ;
Returns true if the caret was created successfully. visible
Boolean visible ;
Returns true if the caret is visible and false if it is permanently hidden (if it is is blinking and not shown currently but will be after the next blink, this property still returns true). Methods create
Boolean create(wx.Window Window, Integer Width, Integer Height);
Boolean create(wx.Window Window, wx.Size Size);
Creates a new Caret object. hide
hide(); move
move(wx.Point Point);
Move the caret to given position. show
show(Boolean Sw= true);
Show/hide the caret
286 wx
Name wx.CheckBox — A checkbox is a labeled box which is either on (checkmark is visible) or off (no checkmark)
Prototype: wx.Control
An example:
var wx = require("wx"); ... // dlg is a Dialog ... var chkbox = new wx.CheckBox(dlg, -1, "Check me"); chkbox.onCheckBox = function(event) { if ( event.checked ) wx.messageBox("Checked"); else wx.messageBox("Unchecked"); }
Note Because JavaScript doesn't allow to create properties which begin with a number, the styles wxCHK_3STATE and wxCHK_2STATE are ported as THREE_STATE and TWO_STATE. Constants
Table 16.16. Constants of wx.CheckBox
Name Description ALIGN_RIGHT ALLOW_3RD_STATE_FOR_USER THREE_STATE TWO_STATE
Constructor
CheckBox();
CheckBox(wx.Window Parent, Integer Id, String Text, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0,
287 wx
wx.Validator Validator= null);
Constructs a new CheckBox object. Properties checked
Boolean checked ;
Returns true when the checkbox is checked value
Boolean value ;
Checks/Unchecks the checkbox. threeState
Boolean threeState ;
Returns whether or not the checkbox is a 3-state checkbox. threeStateValue
Integer threeStateValue ;
Sets the checkbox to the given state. thirdStateAllowedForUser
Boolean thirdStateAllowedForUser ;
Returns whether or not the user can set the checkbox to the third state. Methods create
Boolean create(wx.Window Parent, Integer Id, String Text, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0, wx.Validator Validator= null);
Constructs a new CheckBox object.
288 wx
Events onCheckBox Called when the checkbox is clicked. The type of the argument that your handler receives is wx.CommandEvent.
289 wx
Name wx.CheckBoxState
Constants
Table 16.17. Constants of wx.CheckBoxState
Name Description CHECKED UNCHECKED UNDETERMINED
290 wx
Name wx.CheckListBox — A checklistbox is like a listbox, but allows items to be checked or unchecked.
Prototype: wx.ListBox Constructor
CheckListBox();
CheckListBox(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wxSize Size= wx.DefaultSize, Array Items= null, Integer Style= 0, wx.Validator Validator= null);
Constructs a new CheckListBox object. Properties checked
Array checked ;
Array with wx.CheckListBoxItem elements. Use it to check/uncheck a specific item. Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wxSize Size= wx.DefaultSize, Array Items= null, Integer Style= 0, wx.Validator Validator= null);
Creates CheckListBox. check
check(Index Index, Boolean Check= true);
Returns true when the item with the given index is checked
291 wx isChecked
Boolean isChecked(Index Index);
Returns true when the item with the given index is checked Events onCheckListBox Called when an item is checked or unchecked. The function that is called gets a wx.CommandEvent object.
292 wx
Name wx.CheckListBoxItem — CheckListBoxItem is a helper class used by GLUEscript to provide the use of an array to check or uncheck an item of a wx.CheckListBox.
The following sample shows a wx.CheckListBox with the first item checked.
dlg = new wx.Dialog(null, -1, "Test", new wx.Point(0, 0), new wx.Size(200, 200)); items = new Array(); items[0] = "item 1"; items[1] = "item 2"; items[2] = "item 3"; choice = new wx.CheckListBox(dlg, -1, wx.DefaultPosition, new wx.Size(150, 150), items); choice.checked[0] = true; dlg.showModal();
293 wx
Name wx.Choicebook
Prototype: wx.BookCtrlBase Constants
Table 16.18. Constants of wx.Choicebook
Name Description BOTTOM DEFAULT LEFT RIGHT TOP Constructor
Choicebook();
Choicebook(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Constructs a new Choicebook. Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Creates a wx.Choicebook. Events onPageChanged onPageChanging
294 wx
Name wx.ChoicebookEvent — This object is passed to a function that is set to a wx.Choicebook event property.
Prototype: wx.BookCtrlBaseEvent
295 wx
Name wx.Choice — A choice item is used to select one of a list of strings.
Prototype: wx.ControlWithItems
Unlike a listbox, only the selection is visible until the user pulls down the menu of choices. An example:
var items = new Array(); items[0] = "Opel"; items[1] = "Ford"; items[2] = "BMW"; // dlg is a wx.Dialog var choice = new wx.Choice(dlg, -1, wx.DefaultPosition, wx.DefaultSize, items);
Constructor
Choice();
Choice(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Array Items= null, Integer Style= 0, wx.Validator Validator= null);
Constructs a new Choice object. Properties columns
Integer columns ;
Gets/Sets the number of columns currentSelection
Integer currentSelection ;
Unlike selection which only returns the accepted selection value, i.e. the selection in the control once the user closes the dropdown list, this property returns the current selection. That is, while the dropdown list is shown, it returns the currently selected item in it. When it is not shown, its result is the same as for the other property. Methods create
296 wx
Boolean create(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Array Items= null, Integer Style= 0, wx.Validator Validator= null);
Creates a Choice Events onChoice Called when an item is selected. The type of the argument that your handler receives is wx.CommandEvent.
297 wx
Name wx.CloseEvent — This object is passed to a function that is set to an onClose property of a wx.Frame or wx.Dialog.
Prototype: wx.Event
The following example vetoes the close event because the text control was changed.
frame.onclose = close;
function close(closeEvent) { if ( closeEvent.canVeto ) { if ( textCtrl.modified ) { wx.MessageBox("Can't close because you didn't save the contents"); closeEvent.veto = true; } } }
Properties canVeto
Boolean canVeto ;
Returns true when the close event can be vetoed. loggingOff
Boolean loggingOff ;
Returns true when the user is logging off. veto
Boolean veto ;
Set this to true when you don't want to close the window.
298 wx
Name wx.CollapsiblePane — A collapsible pane is a container with an embedded button-like control which can be used by the user to collapse or expand the pane's contents.
Prototype: wx.Control
Once constructed you should use the pane property to access the pane and add your controls inside it (i.e. use the pane property as parent for the controls which must go in the pane, NOT the wx.CollapsiblePane itself!).
Note that because of its nature of control which can dynamically (and drastically) change its size at run- time under user-input, when putting wxCollapsiblePane inside a wxSizer you should be careful to add it with a proportion value of zero; this is because otherwise all other windows with non-null proportion values would automatically get resized each time the user expands or collapse the pane window resulting usually in a weird, flickering effect.
var wx = require("wx"); var collpane = new wx.CollapsiblePane(dlg, wx.Id.ANY, "Details:");
// add the pane with a zero proportion value to the 'sz' sizer which contains it sz.add(collpane, 0, wx.Stretch.GROW | wx.Direction.ALL, 5);
// now add a test label in the collapsible pane using a sizer to layout it: var win = collpane.pane; var paneSz = new wx.BoxSizer(wx.Orientation.VERTICAL); paneSz.add(new wx.StaticText(win, wx.Id.ANY, "test!", 1, wx.Stretch.GROW | wx.Direction.ALL, 2); win.sizer = paneSz; paneSz.setSizeHints(win);
Constants
Table 16.19. Constants of wx.CollapsiblePane
Name Description DEFAULT_STYLE
Constructor
CollapsiblePane();
CollapsiblePane(wx.Window Parent, Integer Id, String Label, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.CollapsiblePane.DEFAULT_STYLE, wx.Validator Validator= wx.DefaultValidator);
299 wx
Constructs a new wx.CollapsiblePane object. Properties pane
wx.Window pane ;
Returns the pane window. Add controls to the returned wx.Window to make them collapsible. collapsed
Boolean collapsed ;
Get/Set collapsed. expanded
Boolean expanded ;
Get/Set expanded. Methods create
Boolean create(wx.Window Parent, Integer Id, String Label, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.CollapsiblePane.DEFAULT_STYLE, wx.Validator Validator= wx.DefaultValidator);
Creates a new wx.CollapsiblePane object. Events onChanged The user showed or hidden the collapsible pane. The type of the argument that your handler receives is wx.CollapsiblePaneEvent.
300 wx
Name wx.CollapsiblePaneEvent — This event class is used for the events generated by wx.CollapsiblePane.
Prototype: wx.CommandEvent Properties collapsed
Boolean collapsed ;
301 wx
Name wx.Colour — A colour is an Object representing a combination of Red, Green, and Blue (RGB) intensity values.
This is a list of predefined colour Classs: wx.BLACK, wx.WHITE, wx.RED, wx.BLUE, wx.GREEN, wx.CYAN, wx.LIGHT_GREY and wx.nullColour (assuming you assigned glue_wx to the wx variable). Constructor
Colour(Integer Red, Integer Green, Integer Blue, Integer Alpha= 255);
Colour(Object Object);
Colour(String ColourName);
Constructs a new Colour Class. When a simple Object is used, the Object must have the following properties: red, blue and green. Properties alpha
Integer alpha ;
Returns the alpha value. blue
Integer blue ;
Gets the Blue value green
Integer green ;
Gets the Green value ok
Boolean ok ;
Returns true when the colour is valid
302 wx red
Integer red ;
Gets the Red value Methods set
set(Integer Red, Integer Green, Integer Blue);
Sets the RGB values.
303 wx
Name wx.ColourDatabase
wxWidgets maintains a database of standard RGB colours for a predefined set of named colours (such as "BLACK", "LIGHT GREY"). ColourDatabase is a singleton and is instantiated when the application starts: TheColourDatabase. An example:
var wx = require("wx"); var colour = wx.TheColourDatabase.findColour("RED");
Methods addColour
addColour(String Name, wx.Colour Colour);
Adds a colour to the database. If a colour with the same name already exists, it is replaced. find
wxColour find(String Name);
Returns the colour with the given name. undefined is returned when the colour does not exist. findName
String findName(wx.Colour Colour);
Returns the name of the colour. undefined is returned when the colour has no name.
304 wx
Name wx.ColourData — This class holds a variety of information related to colour dialogs.
See wx.ColourDialog Constructor
ColourData();
Constructs a new wx.ColourData object. The selected colour is black and chooseFull is true. Properties chooseFull
Boolean chooseFull ;
Under Windows, determines whether the Windows colour dialog will display the full dialog with custom colour selection controls. Has no meaning under other platforms. colour
wx.Colour colour ;
Get/Set the current colour associated with the colour dialog. customColour
Array customColour ;
Get/Set the ith custom colour associated with the colour dialog. The index must be between 0 and 15. The element is a wx.Colour.
305 wx
Name wx.ColourDialog — The wxColourDialog presents a colour selector to the user.
Prototype: wx.Dialog
See also wx.ColourData. The following sample shows this dialog:
var wx = require("wx"); wx.TheApp.onInit = function() { clrData = new wx.ColourData(); // Set the selected colour clrData.colour = new wx.Colour(0, 0, 0);
// Set a custom colour clrData.customColour[0] = wxRED;
dlg = new wx.ColourDialog(null, clrData); dlg.title = "Select a colour"; dlg.showModal();
return false; }
Constructor
ColourDialog(wx.Window Parent, wx.ColourData ColourData);
Constructs a new wx.ColourDialog object Properties colourData
wx.ColourData colourData ;
Gets the colour data.
306 wx
Name wx.ColourPickerCtrl — This control allows the user to select a colour.
Prototype: wx.PickerBase
The generic implementation is a button which brings up a wx.ColourDialog when clicked. Native implementation may differ but this is usually a (small) widget which give access to the colour-chooser dialog. Constants
Table 16.20. Constants of wx.ColourPickerCtrl
Name Description DEFAULT_STYLE SHOW_LABEL USE_TEXTCTRL
Constructor
ColourPickerCtrl();
ColourPickerCtrl(wx.Window Parent, Integer Id, wx.Colour Colour= wxBLACK, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.ColourPickerCtrl.DEFAULT_STYLE, wx.Validator Validator= null);
Constructs a new colour picker. Properties colour
wx.Colour colour ;
Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Colour Colour= wxBLACK,
307 wx
wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wxColourPickerCtrl.DEFAULT_STYLE, wx.Validator Validator= null);
Creates a colour picker control.
308 wx
Name wx.ColourPickerEvent — This event class is used for the events generated by wx.ColourPickerCtrl
Prototype: wx.CommandEvent Properties colour
wx.Colour colour ;
Retrieve the colour the user has just selected.
309 wx
Name wx.ComboBox — A combobox is like a combination of an edit control and a listbox.
Prototype: wx.ControlWithItems
It can be displayed as static list with editable or read-only text field; or a drop-down list with text field; or a drop-down list without a text field. Constants
Table 16.21. Constants of wx.ComboBox
Name Description SIMPLE DROPDOWN READONLY SORT
Constructor
ComboBox();
ComboBox(wx.Window Parent, Integer Id, String Text= "", wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Array Items= null, Integer Style= 0, wx.Validator Validator= null);
Constructs a new ComboBox object Properties canCopy
Boolean canCopy ;
Returns true if the combobox is editable and there is a text selection to copy to the clipboard. Only available on Windows. canCut
Boolean canCut ;
310 wx
Returns true if the combobox is editable and there is a text selection to cut to the clipboard. Only available on Windows. canPaste
Boolean canPaste ;
Returns true if the combobox is editable and there is text to paste from the clipboard. Only available on Windows. canRedo
Boolean canRedo ;
Returns true if the combobox is editable and the last undo can be redone. Only available on Windows. canUndo
Boolean canUndo ;
Returns true if the combobox is editable and the last edit can be undone. Only available on Windows. value
String value ;
Gets/Sets the text field insertionPoint
Integer insertionPoint ;
Gets/Sets the insertion point of the text field lastPosition
Integer lastPosition ;
Gets the last position of the text field Methods create
create(wx.Window Parent, Integer Id, String Text= "", wx.Point Position= wx.DefaultPosition,
311 wx
wx.Size Size= wx.DefaultSize, Array Items= null, Integer Style= 0, wx.Validator Validator= null);
Creates a ComboBox copy
copy();
Copies the selected text to the clipboard cut
cut();
Copies the selected text to the clipboard and removes the selected text paste
paste();
Pastes the content of the clipboard in the text field. redo
redo();
Redoes the last undo in the text field. Windows only. remove
remove(Integer From, Integer To);
Removes the text between From and To replace
replace(Integer From, Integer To, String Text);
Replaces the text between From and To with the given text undo
undo();
312 wx
Undoes the last edit in the text field. Windows only. Events onText Called when the text of the textfield is changed. The type of the argument that your handler receives is wx.CommandEvent. onComboBox Called when an item is selected. The type of the argument that your handler receives is wx.CommandEvent.
313 wx
Name wx.CommandEvent — This event class contains information about command events, which originate from a variety of simple controls.
Prototype: wx.Event Properties integer
Integer integer ;
Returns the integer identifier corresponding to a listbox, choice or radiobox selection (only if the event was a selection, not a deselection) , or a boolean value representing the value of a checkbox. checked
Boolean checked ;
This can be used for menus or checkboxes to check if they are checked or not selection
Integer selection ;
This can be used to know which item is selected in a wx.ListBox or wx.Choice control string
String string ;
This can be used to know the string of the item selected in a wx.ListBox or wx.Choice control.
314 wx
Name wx.ContextHelpButton
Prototype: wx.BitmapButton
Instances of this class may be used to add a question mark button that when pressed, puts the application into context-help mode. It does this by creating a wx.ContextHelp object which itself generates a wx.HelpEvent event when the user clicks on a window. Constructor
ContextHelpButton(wx.Window Parent);
Constructs a new ContextHelpButton object.
315 wx
Name wx.ContextHelp — This class changes the cursor to a query and puts the application into a 'context- sensitive help mode'.
When the user left-clicks on a window within the specified window, a EVT_HELP event is sent to that control, and the application may respond to it by popping up some help. Constructor
ContextHelp(wx.Window Window= null, Boolean Now= true);
Constructs a new ContextHelp object. Methods beginContextHelp
Boolean beginContextHelp(wx.Window Window= null);
Puts the application into context-sensitive help mode. Returns true, when the application was put successfully into context-sensitive help mode. This function only returns when the event loop has finished. endContextHelp
Boolean endContextHelp();
Ends context-sensitive help mode. Not normally called by the application.
316 wx
Name wx.Control — This is the prototype for a control or 'widget'.
Prototype: wx.Window
A control is generally a small window which processes user input and/or displays one or more item of data. Properties label
String label ;
Get/Set the label
317 wx
Name wx.ControlItem — ControlItem represents an item in a wx.ControlWithItems control.
Note This class is a helper class to make it possible to use the items of a wx.ControlWithItems as an array. It has no corresponding class in wxWidgets. Properties value
String value ;
Get/Set the value of the item. Methods remove
remove();
removes the item from the control. select
select();
Selects/unselects the item.
318 wx
Name wx.ControlWithItems — This class is a prototype for some wxWidgets controls which contain several items, such as wx.ListBox, wx.CheckListBox, wx.Choice and wx.ComboBox.
Prototype: wx.Control
It defines the methods for accessing the controls items. Properties count
Integer count ;
The number of items empty
Boolean empty ;
Returns true when the control has no items item
wx.ControlItem item ;
This is an 'array' property. This means that you have to specify an index to retrieve the actual item. An example: choice.item[0].value = "BMW"; selection
Integer selection ;
Get/Set the selected item stringSelection
String stringSelection ;
Get the label of the selected item or an empty string when no item is selected. Or select the item with the given string. Methods append
Integer append(String Item);
319 wx
append(Array Items);
Adds the item or all elements of the array to the end of the control. When only one item is appended, the return value is the index of the newly added item. clear
clear();
Removes all items from the control. deleteItem
deleteItem(Integer Index);
Removes the item with the given index (zero-based). findString
Integer findString(String Search);
Returns the zero-based index of the item with the given search text. -1 is returned when the string was not found. insert
Integer insert(String Item, Integer Pos);
Inserts the item into the list before pos. Not valid for wxListBox.SORT or wxComboBox.SORT styles, use Append instead. The returned value is the index of the new inserted item.
320 wx
Name wx.Cursor — A cursor is a small bitmap usually used for denoting where the mouse pointer is, with a picture that might indicate the interpretation of a mouse click.
Prototype: wx.Bitmap
As with icons, cursors in X and MS Windows are created in a different manner. Therefore, separate cursors will be created for the different environments. Platform-specific methods for creating a wxCursor object are catered for, and this is an occasion where conditional compilation will probably be required (see wx.Icon for an example). Constructor
Cursor();
Cursor(String Name, Integer Type, Integer HotSpotX= 0, Integer HotSpotY= 0);
Cursor(Integer Id);
Cursor(wx.Image Image);
Creates a new Cursor object. The second form is not available on wxGTK.
321 wx
Name wx.Dialog — A dialog box is a window with a title bar and sometimes a system menu, which can be moved around the screen. It can contain controls and other windows.
Prototype: wx.TopLevelWindow
The following sample shows a simple dialog:
var wx = require("wx"); wx.TheApp.onInit = function() { dlg = new wx.Dialog(null, -1, "test");
dlg.button = new wx.Button(dlg, 1, "Ok");
dlg.button.onClicked = function() { endModal(1); }
dlg.showModal();
// Return false, will end the main loop return false; }
Constants
Table 16.22. Constants of wx.Dialog
Name Description CAPTION DEFAULT_DIALOG_STYLE DIALOG_EX_CONTEXTHELP DIALOG_MODAL NO_3D RESIZE_BORDER STAY_ON_TOP SYSTEM_MENU THICK_FRAME
Constructor
Dialog();
322 wx
Dialog(wx.Window Parent, Integer Id, String title, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Dialog.DEFAULT_DIALOG_STYLE);
Creates a dialog Properties returnCode
Integer returnCode ;
The returncode of the modal dialog modal
Boolean modal ;
Returns true when the dialog is a modal dialog Methods create
Boolean create(wx.Window Parent, Integer Id, String title, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Dialog.DEFAULT_DIALOG_STYLE);
Creates a dialog. endModal
endModal(Integer ReturnCode);
Ends a modal dialog. The ReturnCode is the value to be returned from showModal showModal
Integer showModal();
Shows a modal dialog. The value returned is the return code set by endModal. Events onClose Called when the dialog is closed. The type of the argument that your handler receives is wx.CloseEvent.
323 wx onInitDialog This event is sent as a dialog or panel is being initialised. Handlers for this event can transfer data to the window. The function gets a wx.InitDialogEvent as argument
324 wx
Name wx.DirDialog — This class represents the directory chooser dialog.
Prototype: wx.Dialog Constructor
DirDialog(wx.Window Parent, String Message= 'Choose a directory', String DefaultPath= "", Integer Style= wx.DirDialog.DEFAULT_STYLE, wx.Point Position= wx.DefaultPosition);
Constructs a new DirDialog object Properties message
String message ;
Get/Set the message of the dialog path
String path ;
Get/Set the full path of the selected file
325 wx
Name wx.Direction
Constants
Table 16.23. Constants of wx.Direction
Name Description ALL BOTTOM DOWN EAST LEFT NORTH RIGHT SOUTH TOP TOP UP WEST
326 wx
Name wx.Event — Event is the prototype for the following event objects.
Properties id
Integer id ;
The identifier of the associated window skip
Boolean skip ;
Set this to true when you want to tell the system to skip the current event handler and to use the next valid handler.
327 wx
Name wx.FileDialog — A dialog for saving or opening a file.
Prototype: wx.Dialog
The following shows a save dialog:
var wx = require("wx"); var dlg = new wx.FileDialog(frame, "Save a file"); dlg.style = wx.FileDialog.SAVE; dlg.showModal();
Constants
Table 16.24. Constants of wx.FileDialog
Name Description CHANGE_DIR DEFAULT_STYLE FILE_MUST_EXIST MULTIPLE OPEN OVERWRITE_PROMPT PREVIEW SAVE Constructor
FileDialog(wx.Window Parent, String Message= 'Choose a file', String DefaultDir= '', String DefaultFile= '', String WildCard= '*.*', Integer Style= wx.FileDialog.DEFAULT_STYLE, wx.Point Position= wx.DefaultPosition);
Constructs a new FileDialog object Properties directory
String directory ;
Get/Set the default directory
328 wx filename
String filename ;
Get/Set the default filename filenames
Array filenames ;
Get an array of the selected file names filterIndex
Integer filterIndex ;
Get/Set the filter index (wildcards) message
String message ;
Get/Set the message of the dialog path
String path ;
Get/Set the full path of the selected file paths
Array paths ;
Gets the full path of all selected files wildcard
String wildcard ;
Gets/Sets the wildcard such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
329 wx
Name wx.Filter
Constants
Table 16.25. Constants of wx.Filter
Name Description ALPHA Non-alpha characters are filtered out. ALPHANUMERIC Non-alphanumeric characters are filtered out. ASCII Non-ASCII characters are filtered out. EXCLUDE_CHAR_LIST Use an include list. The validator checks if each input character is in the list (one character per list element), complaining if it is. EXCLUDE_LIST Use an exclude list. The validator checks if the user input is on the list, complaining if it is. INCLUDE_CHAR_LIST Use an include list. The validator checks if each input character is in the list (one character per list element), complaining if not. INCLUDE_LIST Use an include list. The validator checks if the user input is on the list, complaining if not. NONE No filtering NUMERIC Non-numeric characters are filtered out.
330 wx
Name wx.FindDialogEvent — This event class contains the information about all wx.FindReplaceDialog events
Prototype: wx.Event Properties findString
String findString ; flags
Integer flags ; replaceString
String replaceString ;
331 wx
Name wx.FindReplaceData — FindReplaceData holds the data for wx.FindReplaceDialog.
It is used to initialize the dialog with the default values and will keep the last values from the dialog when it is closed. It is also updated each time a wx.FindDialogEvent is generated so instead of using the wx.FindDialogEvent methods you can also directly query this object. Constants
Table 16.26. Constants of wx.FindReplaceData
Name Description DOWN MATCHCASE WHOLEWORD
Constructor
FindReplaceData(Integer Flags= 0);
Constructs a new FindReplaceData object. Properties findString
String findString ;
Get/Set the string to find flags
Integer flags ;
Get/Set the flags. replaceString
String replaceString ;
Get/Set the replacement string
332 wx
Name wx.FindReplaceDialog — wx.FindReplaceDialog is a standard modeless dialog which is used to allow the user to search for some text (and possible replace it with something else).
Prototype: wx.Dialog
The actual searching is supposed to be done in the owner window which is the parent of this dialog. Note that it means that unlike for the other standard dialogs this one must have a parent window. Also note that there is no way to use this dialog in a modal way, it is always, by design and implementation, modeless. Constants
Table 16.27. Constants of wx.FindReplaceDialog
Name Description NOMACTHCASE NOUPDOWN NOWHOLEWORD REPLACEDIALOG
Constructor
FindReplaceDialog(wx.Window Parent, wx.FindReplaceData Data, String Title, Integer Style= 0);
FindReplaceDialog();
Constructs a new FindReplaceDialog object Properties data
wx.FindReplaceData data ;
Get/Set the data Methods create
Boolean create(wx.Window Parent, wx.FindReplaceData Data, String Title,
333 wx
Integer Style= 0);
Creates a FindReplaceDialog. Events onFind The find button was pressed. The argument passed to the function is a wx.FindDialogEvent onFindNext The find next button was pressed. The argument passed to the function is a wx.FindDialogEvent onFindReplace The replace button was pressed. The argument passed to the function is a wx.FindDialogEvent onFindReplaceAll The replace all button was pressed. The argument passed to the function is a wx.FindDialogEvent onFindClose The dialog is being destroyed. The argument passed to the function is a wx.FindDialogEvent
334 wx
Name wx.FlexGridSizer — A flex grid sizer is a sizer which lays out its children in a two-dimensional table with all table fields in one row having the same height and all fields in one column having the same width.
Prototype: wx.GridSizer Constructor
FlexGridSizer( Rows, Cols, Vgap, Hgap);
FlexGridSizer( Cols, Integer Vgap= 0, Integer Hgap= 0);
Constructs a new FlexGridSizer object.
335 wx
Name wx.FocusEvent — A focus event is sent when a window's focus changes.
Prototype: wx.Event
See onSetFocus and onKillFocus.
336 wx
Name wx.Font — A font is an Object which determines the appearance of text. Fonts are used for drawing text to a device context, and setting the appearance of a window's text.
Constants
Table 16.28. Constants of wx.Font
Name Description BOLD DECORATIVE DEFAULT ITALIC LIGHT MODERN NORMAL ROMAN SCRIPT SLANT SWISS Class Properties defaultEncoding
Integer defaultEncoding ; Constructor
Font();
Font(Integer PointSize, Integer Family, Integer Style, Integer Weight, Boolean Underline, String FaceName= "", wx.FontEncoding Encoding= wx.FontEncoding.DEFAULT);
Constructs a new Font Class. Properties encoding
337 wx
Integer encoding ; faceName
String faceName ;
Get/Set the actual typeface to be used. family
Integer family ;
Font family, a generic way of referring to fonts without specifying an actual facename. ok
Boolean ok ;
Returns true when the font is ok. pointSize
Integer pointSize ;
Get/Set size in points style
Integer style ;
Get/Set the font style underlined
Boolean underlined ;
Get/Set underline. weight
Integer weight ;
Get/Set the weight of the font
338 wx
Name wx.FontData — This class holds a variety of information related to font dialogs.
See wx.FontDialog Constructor
FontData();
Constructs a new FontData object. Properties allowSymbols
Boolean allowSymbols ;
Under MS Windows, get/set a flag determining whether symbol fonts can be selected. Has no effect on other platforms enableEffects
Boolean enableEffects ;
Get whether 'effects' are enabled under Windows. This refers to the controls for manipulating colour, strikeout and underline properties. chosenFont
wx.Font chosenFont ;
Get the selected font colour
wx.Colour colour ; initialFont
wx.Font initialFont ;
Get/Set the font that will be initially used by the font dialog showHelp
339 wx
boolean showHelp ;
Show the help button? Windows only.
340 wx
Name wx.FontDialog — The wxFontDialog presents a Font selector to the user.
Prototype: wx.Dialog Constructor
FontDialog(wx.Window Parent, wx.FontData FontData);
Constructs a new FontDialog object Properties
FontData
wx.FontData FontData ;
Gets the Font data.
341 wx
Name wx.FontEncoding
Constants
Table 16.29. Constants of wx.FontEncoding
Name Description ALTERNATIVE same as MS-DOS CP866 BULGARIAN used under Linux in Bulgaria CP1250 WinLatin2 CP1251 WinCyrillic CP1252 WinLatin1 CP1253 WinGreek (8859-7) CP1254 WinTurkish CP1255 WinHebrew CP1256 WinArabic CP1257 WinBaltic (same as Latin 7) CP12_MAX CP437 original MS-DOS codepage CP850 CP437 merged with Latin1 CP852 CP437 merged with Latin2 CP855 another cyrillic encoding CP866 and another one and for Windows CP874 WinThai CP932 Japanese (shift-JIS) CP936 Chinese simplified (GB) CP949 Korean (Hangul charset) CP950 Chinese (traditional - Big5) DEFAULT current default encoding ISO8859_1 West European (Latin1) ISO8859_10 Variation of Latin4 (Latin6) ISO8859_11 Thai ISO8859_12 Doesn't exist currently, but put it here anyhow to make all ISO8859 consecutive numbers ISO8859_13 Baltic (Latin7) ISO8859_14 Latin8 ISO8859_15 Latin9 (a.k.a. Latin0, includes euro) ISO8859_2 Central and East European (Latin2)
342 wx
Name Description ISO8859_3 Esperanto (Latin3) ISO8859_4 Baltic (old) (Latin4) ISO8859_5 Cyrillic ISO8859_6 Arabic ISO8859_7 Greek ISO8859_8 Hebrew ISO8859_9 Turkish (Latin5) ISO8859_MAX KOI8 We don't support any of KOI8 variants MAX SYSTEM system default UNICODE Unicode - currently used only by wx.EncodingConverter class UTF7 UTF-7 Unicode encoding UTF8 UTF-8 Unicode encoding
343 wx
Name wx.FontEnumerator — Use wxFontEnumerator to enumerate all available fonts.
See wx.Font, wx.FontEncoding
The following example shows a dialog which contains a listbox with the names of all the available fonts.
var dlg = new wx.Dialog(null, -1, "Font Enumerating example");
// Create a FontEnumerator var enumerator = new wx.FontEnumerator(); // Set a funtion to onFacename. To get all available fonts return true. // No arguments need to be specified, because they are not used.
enumerator.onFacename = function() { return true; };
// Use enumerateFaceNames to start the enumeration. enumerator.enumerateFacenames();
// Now the property facenames contains all the font names. var listbox = new wx.ListBox(dlg, -1, wx.DefaultPosition, wx.DefaultSize, enumerator.facenames);
Class Properties encodings
Array encodings ; facenames
Array facenames ; onFontEncoding
Function onFontEncoding ; onFacename
Function onFacename ; Constructor
344 wx
FontEnumerator();
Creates a FontEnumerator object. Methods enumerateFaceNames
Boolean enumerateFaceNames(Integer FontEncoding= wx.FontEncoding.SYSTEM, Boolean FixedWidthOnly= false);
This will call the function which is set to the onFacename property for each font which supports the given encoding. When this function returns true for the the given font, it will be added to facenames. When no function is specified, all fonts will be added to facenames. See also wx.FontEncoding, facenames, onFacename enumerateEncodings
Boolean enumerateEncodings(String Font= "");
The function set on the onFontEncoding is called for each encoding supported by the given font. When no function is set all encodings are reported. See onFontEncoding, encodings
345 wx
Name wx.FontList — A font list is a list containing all fonts which have been created.
There is only one instance of this class: fontList. Use this object to search for a previously created font of the desired type and create it if not already found. In some windowing systems, the font may be a scarce resource, so it is best to reuse old resources if possible. When an application finishes, all fonts will be deleted and their resources freed, eliminating the possibility of 'memory leaks'. See wx.Font, wx.FontEncoding and wx.FontEnumerator Methods findOrCreateFont
wx.Font findOrCreateFont(Integer PointSize, Integer Family, Integer Style, Integer Weight, Boolean Underline= false, String FaceName= "", wx.FontEncoding Encoding= wxFontEncoding.DEFAULT);
Finds a font of the given specification, or creates one and adds it to the list. The following code shows an example:
var font = wx.theFontList.findOrCreateFont(10, wx.Font.DEFAULT, wx.Font.NORMAL, wx.Font.NORMAL);
346 wx
Name wx.Frame — A frame is a window whose size and position can (usually) be changed by the user.
Prototype: wx.TopLevelWindow
It usually has thick borders and a title bar, and can optionally contain a menu bar, toolbar and status bar. A frame can contain any window that is not a frame or dialog. Constants
Table 16.30. Constants of wx.Frame
Name Description CAPTION CLOSE_BOX DEFAULT_FRAME_STYLE FRAME_EX_CONTEXTHELP FRAME_FLOAT_ON_PARENT FRAME_NO_TASKBAR FRAME_TOOL_WINDOW ICONIZE MAXIMIZE MAXIMIZE_BOX MINIMIZE MINIMIZE_BOX RESIZE_BORDER SIMPLE_BORDER STAY_ON_TOP SYSTEM_MENU
Constructor
Frame();
Frame(wx.Window Parent, Integer Id, String Title, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Creates a new Frame object
347 wx
Properties menuBar
wx.MenuBar menuBar ;
Set/Get the menubar statusBar
wx.StatusBar statusBar ;
Set/Get the statusbar statusBarFields
Integer statusBarFields ;
Set/Get the number of statusbar fields. A statusbar is created when there isn't a statusbar created yet. statusBarPane
Integer statusBarPane ;
Set/Get the pane used to display menu and toolbar help. -1 disables help display. toolBar
wx.ToolBar toolBar ;
Set/Get the toolbar Methods create
Boolean create(wx.Window Parent, Integer Id, String Title, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Creates a new Frame object processCommand
processCommand(Integer Id);
348 wx
Simulates a menu command. createStatusBar
wx.StatusBar createStatusBar(Integer Field= 1, Integer Style= 0, Integer Id= -1);
Creates a status bar at the bottom of the frame. Note The width of the status bar is the whole width of the frame (adjusted automatically when resizing), and the height and text size are chosen by the host windowing system createToolBar
wx.ToolBar createToolBar(Integer Style= wx.Border.NONE | wx.ToolBar.HORIZONTAL, Integer Id= -1);
Creates a toolbar at the top or left of the frame. setStatusText
setStatusText(String Text, Integer Field= 0);
Sets the text of the given status field. When no field is specified, the first one is used. setStatusWidths
setStatusWidths(Array Widths);
Sets the widths of the fields in the status bar. When the array contains more elements then fields, those elements are discarded. See also statusWidths. Events onClose Called when the frame is closed. The type of the argument that your handler receives is wx.CloseEvent. onIconize An event being sent when the frame is iconized (minimized). Currently only wxMSW and wxGTK generate such events. The type of the argument that your handler receives is wx.IconizeEvent. When you handle this event, don't forget to set skip to true. Otherwise the frame will not be iconized. onMaximize An event being sent when the frame is maximized. The type of the argument that your handler receives is wx.MaximizeEvent. When you handle this event, don't forget to set skip to true. Otherwise the frame will not be maximized.
349 wx
Name wx.FullScreen
Constants
Table 16.31. Constants of wx.FullScreen
Name Description ALL NOBORDER NOCAPTION NOMENUBAR NOSTATUSBAR NOTOOLBAR
350 wx
Name wx.Gauge — A gauge is a horizontal or vertical bar which shows a quantity (often time)
Prototype: wx.Control Constants
Table 16.32. Constants of wx.Gauge
Name Description HORIZONTAL PROGRESSBAR SMOOTH VERTICAL Constructor
Gauge();
Gauge(wx.Window Parent, Integer Id, Integer Range, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Gauge.HORIZONTAL, wx.Validator Validator= null);
Constructs a new Gauge object. Properties bezelFace
Integer bezelFace ;
Get/Set the width of the 3D bezel face. Windows only range
Integer range ;
Get/Set the maximum position of the gauge. shadowWidth
Integer shadowWidth ;
351 wx
Get/Set the 3D shadow margin width. Windows only value
Integer value ;
Get/Set the current value of the gauge. vertical
Boolean vertical ;
Returns true if the gauge is vertical (has Gauge.VERTICAL style) and false otherwise. Methods create
Boolean create(wx.Window Parent, Integer Id, Integer Range, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= Gauge.HORIZONTAL, wx.Validator Validator= null);
Creates a Gauge pulse
pulse();
Switch the gauge to indeterminate mode (if required) and makes the gauge move a bit to indicate the user that some progress has been made. Note that after calling this function the value property is undefined and thus you need to explicitely set value if you want to restore the determinate mode.
352 wx
Name wx.GenericValidator — GenericValidator performs data transfer (but not validation or filtering) for the following basic controls: wx.Button, wx.CheckBox , wx.ListBox , wx.StaticText , wx.RadioButton , wx.RadioBox, wx.Choice, wx.ComboBox, wx.Gauge, wx.Slider , wx.SpinButton , wx.TextCtrl , wx.CheckListBox
Prototype: wx.Validator
There's a difference between the wxWidgets implementation and the GLUEscript implementation: wxWidgets automatically transfer the data to the given pointer variable when validation succeeds. In JavaScript this is not possible. GLUEscript solves this with the value property. This property returns the value of the control. The type of this value is the same as the type of the argument of the constructor. The following example shows how to use this class:
var wx = require("wx"); var user = "Demo"; var pwd = "";
function Application() { var dlg = new wx.Dialog(null, -1, "Validator Example", wx.DefaultPosition, new wx.Size(200, 150));
var userText = new wx.TextCtrl(dlg, -1); var pwdText = new wx.TextCtrl(dlg, -1); var okButton = new wx.Button(dlg, wx.Id.OK, "Ok"); var cancelButton = new wx.Button(dlg, wx.Id.CANCEL, "Cancel");
dlg.sizer = new wx.FlexGridSizer(4, 2, 10, 10); dlg.sizer.add(new wx.StaticText(dlg, -1, "Username")); dlg.sizer.add(userText); dlg.sizer.add(new wx.StaticText(dlg, -1, "Password")); dlg.sizer.add(pwdText); dlg.sizer.add(okButton); dlg.sizer.add(cancelButton);
// Create validator var validator = new wx.GenericValidator(user);
validator.validate = function() { if ( this.window.value.length == 0 ) { wx.MessageBox("Please give a username"); return false; } return true; } userText.validator = validator;
dlg.autoLayout = true;
353 wx
dlg.layout(); dlg.showModal();
user = validator.value;
return false; }
wx.TheApp.onInit = Application;
Constructor
GenericValidator(Any Value);
Constructs a new wxGenericValidator object Value is used to transfer to the control. The type of value is important. Boolean is used for wx.CheckBox and wx.RadioBox . String is used for wx.Button, wx.ComboBox, wx.StaticText and wx.TextCtrl. Integer is used for wx.Gauge, wx.RadioBox, wx.SpinButton and wx.Choice. Array of Integers is used for wx.ListBox and wx.CheckListBox. Properties value
Any value ;
Gets the value. The same type as the argument of the constructor of wx.GenericValidator. validate
Function validate ;
Assign a function to this property that checks the content of the associated window. The function can have one argument: the parent of the associated window. This function should return false when the content is invalid, true when it is valid. To get the associated window, use this.window.
354 wx
Name wx.GIFHandler — Image handler for bitmaps.
Prototype: wx.ImageHandler
355 wx
Name wx.GridSizer — A grid sizer is a sizer which lays out its children in a two-dimensional table with all table fields having the same size, i.e. the width of each field is the width of the widest child, the height of each field is the height of the tallest child.
Prototype: wx.Sizer Constructor
GridSizer(Integer Rows, Integer Cols, Integer Vgap, Integer Hgap);
GridSizer(Integer Cols, Integer Vgap, Integer Hgap);
Constructs a new GridSizer object.
356 wx
Name wx.HelpEvent — A help event is sent when the user has requested context-sensitive help.
Prototype: wx.Event
This can either be caused by the application requesting context-sensitive help mode via wx.ContextHelp, or (on MS Windows) by the system generating a WM_HELP message when the user pressed F1 or clicked on the query button in a dialog caption.
A help event is sent to the window that the user clicked on, and is propagated up the window hierarchy until the event is processed or there are no more event handlers. The application should use id to check the identity of the clicked-on window, and then either show some suitable help or set skip to true if the identifier is unrecognised. Setting skip to true is important because it allows wxWidgets to generate further events for ancestors of the clicked-on window. Otherwise it would be impossible to show help for container windows, since processing would stop after the first window found.
See onHelp, wx.ContextHelp and wx.ContextHelpButton Properties position
wx.Point position ;
Get/Set the left-click position of the mouse in screen-coordinates. This helps the application to position the help appropriately.
357 wx
Name wx.HtmlLinkEvent — This event class is used for the events generated by wx.HtmlWindow.
Prototype: wx.Event Properties href
String href ;
Return HREF value of the tag. target
String target ;
Return TARGET value of the tag.
358 wx
Name wx.HtmlWindow — The purpose of this class is to display HTML pages (either local file or downloaded via HTTP protocol) in a window.
Prototype: wx.ScrolledWindow Constants
Table 16.33. Constants of wx.HtmlWindow
Name Description DEFAULT_STYLE NO_SELECTION Don't allow the user to select text. SCROLLBAR_AUTO Display scrollbars only if page's size exceeds window's size. SCROLLBAR_NEVER Never display scrollbars, not even when the page is larger than the window.
Constructor
HtmlWindow();
HtmlWindow(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.HtmlWindow.DEFAULT_STYLE);
Constructs a new HtmlWindow object. See also create. Properties historyCanBack
String historyCanBack ;
Returns true if it is possible to go back in the history (i.e. historyBack won't fail). historyCanForward
String historyCanForward ;
Returns true if it is possible to go forward in the history (i.e. historyForward won't fail). openedAnchor
359 wx
String openedAnchor ;
Returns anchor within currently opened page (see openedPage). If no page is opened or if the displayed page wasn't produced by call to loadPage, empty string is returned. openedPage
String openedPage ;
Returns full location of the opened page. If no page is opened or if the displayed page wasn't produced by call to loadPage, empty string is returned. openedPageTitle
String openedPageTitle ;
Returns title of the opened page or wxEmptyString if current page does not contain
wx.Frame relatedFrame ;
Gets/Sets the frame in which page title will be displayed. text
String text ;
Returns content of currently displayed page as plain text. Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.HtmlWindow.DEFAULT_STYLE);
Creates an HTML window. appendToPage
Boolean appendToPage(String Source);
Appends HTML fragment to currently displayed text and refreshes the window. False is returned on failure. historyBack
360 wx
Boolean historyBack();
Moves back to the previous page. (each page displayed using loadPage is stored in history list.) historyClear
historyClear();
Clears the history. historyForward
Boolean historyForward();
Moves forward to the next page. (each page displayed using loadPage is stored in history list.) loadFile
Boolean loadFile(String filename);
Loads HTML page from file and displays it. Returns false on failure. loadPage
Boolean loadPage(String Location);
Unlike setPage this function first loads HTML page from location and then displays it. selectAll
selectAll();
Selects all text in the window. selectLine
selectLine(wx.Point Pos);
Selects the line of text that pos points at. Note that pos is relative to the top of displayed page, not to window's origin, use calcUnscrolledPosition to convert physical coordinate. selectWord
selectWord(wx.Point Pos);
Selects the word at position pos. Note that pos is relative to the top of displayed page, not to window's origin, use calcUnscrolledPosition to convert physical coordinate. setBorders
361 wx
setBorders(Integer Border);
This function sets the space between border of window and HTML contents. setFonts
setFonts(String NormalFace, String FixedFace, Array Sizes= null);
This function sets font sizes and faces setPage
Boolean setPage(String Source);
Sets HTML page and display it. This won't load the page!! It will display the source setRelatedFrame
setRelatedFrame(wx.Frame Frame, String Format);
Sets the frame in which page title will be displayed. format is format of frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s. This %s is substituted with HTML page title. setRelatedStatusBar
setRelatedStatusBar(Integer Bar= -1);
After calling setRelatedFrame, this sets statusbar slot where messages will be displayed. (Default is -1 = no messages.) Events onLinkClicked This event is triggered when a hyperlinck is clicked. The function receives a wx.HtmlLinkEvent as argument.
362 wx
Name wx.ICOHandler — Image handler for bitmaps.
Prototype: wx.ImageHandler
363 wx
Name wx.Icon — An icon is a small rectangular bitmap usually used for denoting a minimized application.
Prototype: wx.Bitmap
It differs from a wx.Bitmap in always having a mask associated with it for transparent drawing. On some platforms, icons and bitmaps are implemented identically, since there is no real distinction between a Bitmap with a mask and an icon; and there is no specific icon format on some platforms (X-based applications usually standardize on XPMs for small bitmaps and icons). However, some platforms (such as Windows) make the distinction, so a separate class is provided. See wx.Bitmap, wx.TopLevelWindow icon property and wx.BitmapType Constructor
Icon();
Icon(String Name, Integer Type, Integer DesiredWidth= -1, Integer DesiredHeight= -1);
Constructs a new Icon Class. The first constructor creates an icon without data. Use loadFile to load an icon. When the filename is relative, it will be resolved against the path of the script. Methods loadFile
Boolean loadFile(String Name, Integer Type);
Loads an icon from a file. When the filename is relative, it will be resolved against the path of the script.
364 wx
Name wx.IconizeEvent — An event being sent when the frame is iconized (minimized) or restored. Currently only Windows and GTK generate such events.
Prototype: wx.Event
See wx.Frame Properties iconized
Boolean iconized ;
Returns true when the frame is iconized, false when it's not.
365 wx
Name wx.Id
Constants
Table 16.34. Constants of wx.Id
Name Description ABORT ABOUT ANY APPLY BACKWARD CANCEL CLEAR CLOSE CONTEXT_HELP COPY CUT DEFAULT DUPLICATE EXIT FILE1 FILE2 FILE3 FILE4 FILE5 FILE6 FILE7 FILE8 FILE9 FIND FORWARD HELP HELP_COMMANDS HELP_CONTENTS HELP_CONTEXT HELP_PROCEDURES HIGHEST
366 wx
Name Description IGNORE LOWEST MORE NEW NO NOTOALL OK OPEN PASTE PREVIEW PRINT PRINT_SETUP REDO RESET RETRY REVERT SAVE SAVEAS SELECTALL SEPARATOR SETUP STATIC UNDO YES YESTOALL
367 wx
Name wx.Image — This class encapsulates a platform-independent image.
An image can be loaded from a file in a variety of formats. Class Properties handlers
Array handlers ; Class Methods addHandler
addHandler(wx.ImageHandler Handler);
Adds a handler to the end of the static list of format handlers. There is usually only one instance of a given handler class in an application session. canRead
Boolean canRead(String Name);
Returns true when the file can be read. cleanUpHandlers
cleanUpHandlers();
Removes all handlers. Is called automatically by wxWidgets. findHandler
wx.ImageHandler findHandler(String Name);
wx.ImageHandler findHandler(String Extension, Integer Type);
wx.ImageHandler findHandler(Integer Type);
Searches a handler findHandlerMime
368 wx
wx.ImageHandler findHandlerMime(String Type);
Finds the handler associated with the given MIME type. removeHandler
Boolean removeHandler(String Name);
Remove the given handler. insertHandler
insertHandler(wx.ImageHandler Handler);
Adds a handler at the start of the static list of format handlers. There is usually only one instance of a given handler class in an application session. Constructor
Image();
Image(Integer Width, Integer Height);
Image(wx.Size size);
Image(String Name, Integer Type= wx.BitmapType.ANY);
Image(String Name, String MimeType);
Image(core.Binary Buffer, Integer Type= wx.BitmapType.ANY); Properties height
Integer height ;
Gets the height of the image in pixels. mask
Boolean mask ;
369 wx
Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour. maskBlue
Integer maskBlue ;
Returns the blue value of the mask colour. maskGreen
Integer maskGreen ;
Returns the green value of the mask colour. maskRed
Integer maskRed ;
Returns the red value of the mask colour. ok
Boolean ok ;
Returns true when the image data is available. width
Integer width ;
Returns the width of the image in pixels. Methods create
create(Integer Width, Integer Height);
create(wx.Size Size);
Creates a fresh image with the given size. destroy
destroy();
Destroys the image data.
370 wx copy
wx.Image copy();
Returns an identical copy of image. getSubImage
wx.Image getSubImage(wx.Rect Rect);
Returns a sub image of the current one as long as the rect belongs entirely to the image. paste
paste(wx.Image Image, Integer X, Integer Y);
Pastes image into this instance and takes care of the mask colour and out of bounds problems. scale
wx.Image scale(Integer Width, Integer Height);
wx.Image scale(wx.Size Size);
Returns a scaled version of the image with size Width * Height. rescale
wx.Image rescale(Integer Width, Integer Height);
wx.Image rescale(wx.Size Size);
Changes the size of the image in-place: after a call to this function, the image will have the given width and height. Returns the (modified) image itself. rotate
wx.Image rotate(Double Angle, wx.Point Center, Boolean InterPol= true, wx.Point Offset= null);
Rotates the image about the given point, by angle radians. Passing true for interpolating results in better image quality, but is slower. If the image has a mask, then the mask colour is used for the uncovered
371 wx
pixels in the rotated image background. Else, black will be used. Returns the rotated image, leaving this image intact. rotate90
wx.Image rotate90(Boolean ClockWise= true);
Returns a copy of the image rotated 90 degrees in the direction indicated by clockwise. mirror
wx.Image mirror(Boolean Horizontally= Y);
Returns a mirrored copy of the image. The parameter horizontally indicates the orientation. replace
replace(Integer R1, Integer G1, Integer B1, Integer R2, Integer G2, Integer B2);
replace(wx.Colour Colour1, wx.Colour Colour2);
Replaces the colour with another colour. convertToMono
wx.Image convertToMono(Integer R, Integer G, Integer B);
wx.Image convertToMono(wx.Colour Colour);
Converts to a monochrome image. The returned image has white colour where the original has (r,g,b) colour and black colour everywhere else. setRGB
setRGB(Integer X, Integer Y, Integer R, Integer G, Integer B);
setRGB(Integer X,
372 wx
Integer Y, wx.Colour Colour);
setRGB(wx.Point Point, wx.Colour Colour);
Sets the colour of the pixel at the given coordinate. This routine performs bounds-checks for the coordinate so it can be considered a safe way to manipulate the data, but in some cases this might be too slow. getRed
Integer getRed(Integer X, Integer Y);
Integer getRed(wx.Point Point);
Returns the red intensity at the given coordinate. getGreen
Integer getGreen(Integer X, Integer Y);
Integer getGreen(wx.Point Point);
Returns the green intensity at the given coordinate. getBlue
Integer getBlue(Integer X, Integer Y);
Integer getBlue(wx.Point Point);
Returns the blue intensity at the given coordinate. getColour
wx.Colour getColour(Integer X, Integer Y);
Integer getColour(wx.Point Point);
Returns the colour of the given coordinate. findFirstUnusedColour
Boolean findFirstUnusedColour(wx.Colour StartColour);
373 wx
Finds the first colour that is never used in the image. The search begins at given start colour and continues by increasing R, G and B components (in this order) by 1 until an unused colour is found or the colour space exhausted. This method returns an array with 1 or 4 elements: the first element is a boolean indicating success. When this is true, 3 elements follow with the r, g, b values of the colour. setMaskFromImage
Boolean setMaskFromImage(wx.Image Image, Integer R, Integer G, Integer B);
Boolean setMaskFromImage(wx.Image Image, wx.Colour Colour);
Sets image's mask so that the pixels that have RGB value of r,g,b (or colour) in mask will be masked in the image. This is done by first finding an unused colour in the image, setting this colour as the mask colour and then using this colour to draw all pixels in the image whose corresponding pixel in mask has given RGB value. Returns false if mask does not have same dimensions as the image or if there is no unused colour left. Returns true if the mask was successfully applied. loadFile
Boolean loadFile(String Name, Integer Type= wx.BitmapType.ANY);
Boolean loadFile(String Name, String MimeType= wx.BitmapType.ANY);
Loads an image from a file. saveFile
Boolean saveFile(String Name, Integer Type= wx.BitmapType.ANY);
Boolean saveFile(String Name, String MimeType= wx.BitmapType.ANY);
Saves an image to a file. setMaskColour
setMaskColour(Integer R, Integer G, Integer B);
setMaskColour(wx.Colour Colour);
374 wx
Sets the mask colour for this image (and tells the image to use the mask). setOption
setOption(String Name, String Value);
setOption(String Name, Integer Value);
Sets a user-defined option. The function is case-insensitive to name. For example, when saving as a JPEG file, the option quality is used, which is a number between 0 and 100 (0 is terrible, 100 is very good). See getOption, getOptionInt, hasOption. getOption
String getOption(String Name);
Gets a user-defined option. The function is case-insensitive to name. See setOption, getOptionInt, hasOption getOptionInt
Integer getOptionInt(String Name);
Gets a user-defined option. The function is case-insensitive to name. See setOption, getOption, hasOption hasOption
Boolean hasOption(String Name);
Returns true if the given option is present. The function is case-insensitive to name. See setOption, getOptionInt, hasOption
375 wx
Name wx.ImageHandler — ImageHandler is the prototype for several image handlers.
Properties extension
String extension ;
Get/Set the handler extension. mimeType
String mimeType ;
Get/Set the handler MIME type. name
String name ;
Get/Set the handler name. type
Integer type ;
Get/Set the handler type. Methods getImageCount
Integer getImageCount(String Filename);
If the image file contains more than one image and the image handler is capable of retrieving these individually, this function will return the number of available images. Most imagehandlers return 1. Unlike wxWidgets this method expects a filename instead of an inputstream. loadFile
Boolean loadFile(wx.Image Image, String File, Boolean Verbose= true, Integer Index= 0);
Loads a image from a file, putting the resulting data into image. If the image file contains more than one image and the image handler is capable of retrieving these individually, index indicates which image
376 wx
to read from the stream. Returns true when successful, false otherwise. Unlike wxWidgets this method expects a filename instead of an inputstream. saveFile
Boolean saveFile(wx.Image Image, String Filename, Boolean Verbose= true);
Saves a image to a file. Returns true on success, false otherwise. Unlike wxWidgets this method expects a filename instead of an inputstream.
377 wx
Name wx.ImageList — An ImageList contains a list of images, which are stored in an unspecified form.
Images can have masks for transparent drawing, and can be made from a variety of sources including bitmaps and icons. ImageList is used principally in conjunction with wx.TreeCtrl and wx.ListCtrl classes. Constructor
ImageList();
ImageList(Integer Width, Integer Height, Boolean Mask= true, Integer Count= 1);
Constructs a new ImageList object. Properties imageCount
Integer imageCount ;
Returns the number of the images. Methods create
create(Integer Width, Integer Height, Boolean Mask= true, Integer Count= 1);
Creates an image list. Width and Height specify the size of the images in the list (all the same). Mask specifies whether the images have masks or not. Count is the initial number of images to reserve. add
Integer add(wx.Bitmap Bitmap, Integer Mask);
Integer add(wx.Bitmap Bitmap, wx.Colour Colour);
Integer add(wx.Icon Icon);
378 wx
Adds a new image using a bitmap and an optional mask bitmap or adds a new image using a bitmap and a mask colour or adds a new image using an icon. Returns the new zero-based index of the image. getSize
Array getSize(Integer Index= 0);
This method returns an array with 3 elements. The first element is a boolean indicating success or failure. The second element contains the width and the third element contains the height. Because an array is returned you can use the multiple return value as such:
[rc, width, height] = imgList.getSize();
remove
Boolean remove(Integer Index);
Removes the image with the given index. Returns true on success. removeAll
Boolean removeAll();
Removes all images. Returns true on success. replace
Boolean replace(Integer Index, wx.Bitmap Bitmap, wx.Bitmap Mask);
Boolean replace(Integer Index, wx.Icon Icon);
Replaces the image at the given index with a new image.
379 wx
Name wx.ItemKind
Constants
Table 16.35. Constants of wx.ItemKind
Name Description CHECK MAX NORMAL RADIO SEPARATOR
380 wx
Name wx.InitDialogEvent — An InitDialogEvent is sent as a dialog or panel is being initialised. Handlers for this event can transfer data to the window.
Prototype: wx.Event
See onInitDialog.
381 wx
Name wx.JPEGHandler — Image handler for JPEG images.
Prototype: wx.ImageHandler
382 wx
Name wx.KeyCode
Constants
Table 16.36. Constants of wx.KeyCode
Name Description ADD ALT BACK CANCEL CAPITAL CLEAR CONTROL DECIMAL DELETE DIVIDE DOWN END ESCAPE EXECUTE F1 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F2 F20 F21 F22 F23 F24
383 wx
Name Description F3 F4 F5 F6 F7 F8 F9 HELP HOME INSERT LBUTTON LEFT MBUTTON MENU MULTIPLY NEXT NUMLOCK NUMPAD0 NUMPAD1 NUMPAD2 NUMPAD3 NUMPAD4 NUMPAD5 NUMPAD6 NUMPAD7 NUMPAD8 NUMPAD9 NUMPAD_ADD NUMPAD_BEGIN NUMPAD_DECIMAL NUMPAD_DELETE NUMPAD_DIVIDE NUMPAD_DOWN NUMPAD_END NUMPAD_ENTER NUMPAD_EQUAL NUMPAD_F1 NUMPAD_F2
384 wx
Name Description NUMPAD_F3 NUMPAD_F4 NUMPAD_HOME NUMPAD_INSERT NUMPAD_LEFT NUMPAD_MULTIPLY NUMPAD_NEXT NUMPAD_PAGEDOWN NUMPAD_PAGEUP NUMPAD_PRIOR NUMPAD_RIGHT NUMPAD_SEPARATOR NUMPAD_SPACE NUMPAD_SUBTRACT NUMPAD_TAB NUMPAD_UP PAGEDOWN PAGEUP PAUSE PRINT PRIOR RBUTTON RETURN RIGHT SCROLL SELECT SEPARATOR SHIFT SNAPSHOT SPACE START SUBTRACT TAB UP
385 wx
Name wx.KeyEvent — This event class contains information about keypress (character) events.
Prototype: wx.Event
Look at onChar for an example. See onChar, onCharHook, onKeyDown, onKeyUp. Properties altDown
Boolean altDown ;
True when the ALT key was pressed at the time of the event. controlDown
Boolean controlDown ;
True when the CTRL key was pressed at the time of the event. hasModifiers
Boolean hasModifiers ;
True when META, CTRL or ALT key was down at the time of the event. keyCode
Integer keyCode ;
The code of the key. See wx.KeyCode metaDown
Boolean metaDown ;
True when the META key was down at the time of the event. shiftDown
Boolean shiftDown ;
True when the SHIFT key was down at the time of the event. x
386 wx
Integer x ;
The x position of the event y
Integer y ;
The y position of the event
387 wx
Name wx.LayoutAlgorithm — LayoutAlgorithm implements layout of subwindows in MDI or SDI frames.
It sends a wx.CalculateLayoutEvent event to children of the frame, asking them for information about their size. For MDI parent frames, the algorithm allocates the remaining space to the MDI client window (which contains the MDI child frames). For SDI (normal) frames, a 'main' window is specified as taking up the remaining space.
Because the event system is used, this technique can be applied to any windows, which are not necessarily 'aware' of the layout classes (no virtual functions in wx.Window refer to wxLayoutAlgorithm or its events). However, you may wish to use wx.SashLayoutWindow for your subwindows since this class provides handlers for the required events, and accessors to specify the desired size of the window. The sash behaviour in the base class can be used, optionally, to make the windows user-resizable.
LayoutAlgorithm is typically used in IDE (integrated development environment) applications, where there are several resizable windows in addition to the MDI client window, or other primary editing window. Resizable windows might include toolbars, a project window, and a window for displaying error and warning messages.
When a window receives an onCalculateLayout event, it should call SetRect in the given event object, to be the old supplied rectangle minus whatever space the window takes up. It should also set its own size accordingly. onCalculateLayout generates an onQueryLayoutInfo event which it sends to itself to determine the orientation, alignment and size of the window, which it gets from internal member variables set by the application.
The algorithm works by starting off with a rectangle equal to the whole frame client area. It iterates through the frame children, generating onCalculateLayout events which subtract the window size and return the remaining rectangle for the next window to process. It is assumed (by onCalculateLayout) that a window stretches the full dimension of the frame client, according to the orientation it specifies. For example, a horizontal window will stretch the full width of the remaining portion of the frame client area. In the other orientation, the window will be fixed to whatever size was specified by onQueryLayoutInfo. An alignment setting will make the window 'stick' to the left, top, right or bottom of the remaining client area. This scheme implies that order of window creation is important. Say you wish to have an extra toolbar at the top of the frame, a project window to the left of the MDI client window, and an output window above the status bar. You should therefore create the windows in this order: toolbar, output window, project window. This ensures that the toolbar and output window take up space at the top and bottom, and then the remaining height in-between is used for the project window.
LayoutAlgorithm is quite independent of the way in which onCalculateLayout chooses to interpret a window's size and alignment. Therefore you could implement a different window class with a new onCalculateLayout event handler, that has a more sophisticated way of laying out the windows. It might allow specification of whether stretching occurs in the specified orientation, for example, rather than always assuming stretching. (This could, and probably should, be added to the existing implementation). Constructor
LayoutAlgorithm();
Constructs a new LayoutAlgorithm object.
388 wx
Methods layoutFrame
Boolean layoutFrame(wx.Frame Frame, wx.Window MainWindow= null);
Lays out the children of a normal frame. MainWindow is set to occupy the remaining space. layoutMDIFrame
Boolean layoutMDIFrame(wx.MDIParentFrame Frame, wx.Rect Rect= null);
Lays out the children of an MDI parent frame. If rect is non-null, the given rectangle will be used as a starting point instead of the frame's client area. layoutWindow
Boolean layoutWindow(wx.Window Window, wx.Window MainWindow= null);
389 wx
Name wx.LayoutAlignment
Constants
Table 16.37. Constants of wx.LayoutAlignment
Name Description BOTTOM LEFT NONE RIGHT TOP
390 wx
Name wx.LayoutOrientation
Constants
Table 16.38. Constants of wx.LayoutOrientation
Name Description HORIZONTAL VERTICAL
391 wx
Name wx.ListAlign
Constants
Table 16.39. Constants of wx.ListAlign
Name Description ALIGN_LEFT ALIGN_SNAP_TO_GRID ALIGN_TOP DEFAULT
392 wx
Name wx.Listbook — Listbook is a class similar to wx.Notebook but which uses a wx.ListCtrl to show the labels instead of the tabs.
Prototype: wx.BookCtrlBase Constants
Table 16.40. Constants of wx.Listbook
Name Description ALIGN_MASK BOTTOM DEFAULT LEFT RIGHT TOP
Constructor
Listbook();
Listbook(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Constructs a new Listbook. Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Creates a Listbook. Events onPageChanged
393 wx onPageChanging
394 wx
Name wx.ListbookEvent — This object is passed to a function that is set to a wx.Listbook event property.
Prototype: wx.BookCtrlBaseEvent
395 wx
Name wx.ListBox — A listbox is used to select one or more of a list of strings.
Prototype: wx.ControlWithItems
The strings are displayed in a scrolling box, with the selected string(s) marked in reverse video. A listbox can be single selection (if an item is selected, the previous selection is removed) or multiple selection (clicking an item toggles the item on or off independently of other selections). Constants
Table 16.41. Constants of wx.ListBox Name Description ALWAYS_SB EXTENDED HSCROLL MULTIPLE NEEDED_SB SINGLE SORT Constructor
ListBox();
ListBox(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Array Items= null, Integer Style= 0, wx.Validator Validator= null);
Creates a new ListBox object Properties selections
Array selections ;
An array with all the indexes of the selected items Methods create
396 wx
Boolean create(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Array Items= null, Integer Style= 0, wx.Validator Validator= null);
Creates a wxListBox setFirstItem
setFirstItem(Integer Idx);
setFirstItem(String Str);
Set the specified item to be the first visible item. Windows only. insertItems
insertItems(Array Items, Integer Index);
Inserts all the items Events onListBox Called when an item is selected. The type of the argument that your handler receives is wx.CommandEvent. onDoubleClicked Called when the listbox is double clicked. The type of the argument that your handler receives is wx.CommandEvent.
397 wx
Name wx.ListColumnFormat
Constants
Table 16.42. Constants of wx.ListColumnFormat
Name Description CENTER CENTRE LEFT RIGHT
398 wx
Name wx.ListCtrl — A list control presents lists in a number of formats: list view, report view,icon view and small icon view. In any case, elements are numbered from zero. For all these modes, the items are stored in the control and must be added to it using insertItem method.
Prototype: wx.Control
A special case of report view quite different from the other modes of the list control is a virtual control in which the items data (including text, images and attributes) is managed by the main program and is requested by the control itself only when needed which allows to have controls with millions of items without consuming much memory. To use virtual list control you must set itemCount first and set at least onGetItemText (and optionally onGetItemImage and onGetItemAttr) to return the information about the items when the control requests it. Virtual list control can be used as a normal one except that no operations which can take time proportional to the number of items in the control happen -- this is required to allow having a practically infinite number of items. For example, in a multiple selection virtual list control, the selections won't be sent when many items are selected at once because this could mean iterating over all the items.
How to sort items? This example shows a dialog containing a ListCtrl and two buttons. The list control contains 4 elements 'A', 'B', 'C' and 'D'. Clicking on one of the buttons, will sort the elements in descending or ascending order. First the dialog box is created. A wx.BoxSizer is used to layout the dialog. The list control will be shown above the buttons and centered horizontally. Above and below the listcontrol a space of 10 is placed.
var wx = require("wx"); dlg = new wx.Dialog(null, -1, "ListCtrl sort example", wx.DefaultPosition, new wx.Size(200, 200)); // The main sizer dlg.sizer = new wx.BoxSizer(wx.Orientation.VERTICAL);
// Create the listcontrol and add it to the sizer. list = new wx.ListCtrl(dlg, -1, wx.DefaultPosition, new wx.Size(100, 100)); dlg.sizer.add(list, 0, wx.Alignment.CENTER | wx.Direction.BOTTOM | wx.Direction.TOP, 10);
// Create buttons and add them to a boxsizer. var btn1 = new wx.Button(dlg, -1, "Sort Descending"); btn1.onClicked = function() { list.sortItems(sort, 1); };
var btn2 = new wx.Button(dlg, -2, "Sort Ascending"); btn2.onClicked = function() { list.sortItems(sort, 0); };
boxsizer = new wx.BoxSizer(wx.Orientation.HORIZONTAL); boxsizer.add(btn1, 0, wx.Direction.RIGHT, 10); boxsizer.add(btn2);
399 wx
dlg.sizer.add(boxsizer, 0, wx.Alignment.CENTER);
An array which hold the characters 'A', 'B', 'C' and 'D' is created. Each element is inserted. The itemdata is set to the letter. This is necessary because the sort function uses the itemdata.
var letter = new Array(); letter[0] = "A"; letter[1] = "B"; letter[2] = "C"; letter[3] = "D"; for(e in letter) { var idx = list.insertItem(e, letter[e]); list.setItemData(idx, letter[e]); }
Show the dialog.
dlg.layout(); dlg.showModal();
The function gets 3 arguments. The first two are the itemdata (which is the index of the corresponding array element) of the first item and the second item. Data is the data passed to sortItems in the onClicked event of wx.Button. This way the sort function knows how to sort the items.
function sort(item1, item2, data) { if ( data == 1 ) { if ( item1 > item2 ) return -1; else if ( item1 < item2 ) return 1; else return 0; } else { if ( item1 > item2 ) return 1; else if ( item1 < item2 ) return -1; else return 0; } }
How to use virtual list controls ? This example shows how a virtual list control is built. First an array is create which will contain objects of type Car.
400 wx
var cars = new Array();
function Car(brand, type, colour) { this.brand = brand; this.type = type; this.colour = colour; }
cars[0] = new Car("Opel", "Astra", "Red"); cars[1] = new Car("Ford", "Focus", "Black"); cars[2] = new Car("Skoda", "Octavia", "Green"); cars[3] = new Car("Peugeot", "305", "White"); cars[4] = new Car("Citroen", "Picasso", "Green");
The init function will create a frame and a list control. The list control is the child of the frame and its style is REPORT and VIRTUAL. For each property of Car, a column is created. Because the list control is virtual, onGetItemText and itemCount must be set.
function init() { var frame = new wx.Frame(null, -1, "ListCtrl example");
var listCtrl = new wx.ListCtrl(frame, -1, wx.DefaultPosition, wx.DefaultSize, wx.ListCtrl.REPORT | wx.ListCtrl.VIRTUAL); listCtrl.insertColumn(0, "Brand"); listCtrl.insertColumn(1, "Type"); listCtrl.insertColumn(2, "Colour"); listCtrl.onGetItemText = getItemText; listCtrl.itemCount = cars.length;
frame.visible = true; topWindow = frame;
return true; }
The function getItemText will be called by wxWidgets whenever it needs to know the text of an item. This function gets two arguments: the item and the column index. The text that must be shown is returned.
function getItemText(item, col) { var car = cars[item];
switch(col) { case 0: return car.brand; case 1: return car.type; case 2: return car.colour; } }
401 wx
wx.TheApp.onInit = init;
Constants
Table 16.43. Constants of wx.ListCtrl
Name Description ALIGN_LEFT Icons align to the left. ALIGN_TOP Icons align to the top. Win32 default, Win32 only. AUTOARRANGE Icons arrange themselves. Win32 only. AUTOSIZE Resize the column to the length of its longest item AUTOSIZE_USEHEADER Resize the column to the length of the header (Win32) or 80 pixels (other platforms). EDIT_LABELS Labels are editable: the application will be notified when editing starts. HRULES Draws light horizontal rules between rows in report mode. ICON Large icon view, with optional labels. LIST Multicolumn list view, with optional small icons. Columns are computed automatically, i.e. you don't set columns as in REPORT. In other words, the list wraps, unlike a wxListBox. NORMAL The normal (large icon) image list. NO_HEADER No header in report mode. Win32 only. REPORT Single or multicolumn report view, with optional header. SINGLE_SEL Single selection. SMALL The small icon image list. SMALL_ICON Small icon view, with optional labels. SORT_ASCENDING Sort in ascending order (must still supply a comparison callback in SortItems). SORT_DESCENDING Sort in descending order (must still supply a comparison callback in SortItems). STATE The user-defined state image list (unimplemented). USER_TEXT The application provides label text on demand, except for column headers. Win32 only. VIRTUAL Virtual control, may only be used with REPORT VRULES Draws light vertical rules between columns in report mode. Constructor
ListCtrl();
402 wx
ListCtrl(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.ListCtrl.ICON, wx.Validator Validator= null);
Constructs a new ListCtrl object. Properties columnCount
Integer columnCount ;
Gets the number of columns. countPerPage
Integer countPerPage ;
Gets the number of items that can fit vertically in the visible area of the list control (list or report view) or the total number of items in the list control (icon or small icon view). editControl
wx.TextCtrl editControl ;
Gets the textcontrol used for editing labels. virtual
Boolean virtual ;
Returns true when the list control is virtual. itemCount
Integer itemCount ;
Gets/Sets the number of items. Setting the number of items is only allowed with virtual list controls. onGetItemAttr
Function onGetItemAttr ;
Assign a function that returns a wx.ListItemAttr object. The function gets one argument: the index of the item. This can only be used in virtual list controls. onGetItemImage
403 wx
Function onGetItemImage ;
Assign a function that returns the index of the image. The function gets one argument: the index of the item. This can only be used in virtual list controls. onGetItemText
Function onGetItemText ;
Assign a function that returns a String. This String is used as text of the item. The function gets two arguments: the index of the item and the index of the column. You must set this property for virtual list controls. selectedItemCount
Integer selectedItemCount ;
Gets the number of selected items. textColour
wx.Colour textColour ;
Gets/Sets the text colour of the list control. topItem
Integer topItem ;
Gets the index of the topmost visible item in report view. windowStyleFlag
Integer windowStyleFlag ;
Gets/Sets the window style flag. itemSpacing
Integer itemSpacing ;
Retrieves the spacing between icons in pixels: horizontal spacing is returned as x component of the wxSize object and the vertical spacing as its y component. Methods create
404 wx
Boolean create(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.ListCtrl.ICON, wx.Validator Validator= null);
Constructs a new ListCtrl object. getColumn
wx.ListItem getColumn(Integer Col, Integer Item);
Boolean getColumn(Integer Col, wx.ListItem ListItem);
Gets the column information. The first form returns a wx.ListItem object or undefined when the column is not found. The second form returns true when the column is found and puts the column information in the second argument. setColumn
wx.ListItem setColumn(Integer Col, Integer Item);
Boolean setColumn(Integer Col, wx.ListItem ListItem);
Sets the column information. False is returned when the column doesn't exist. getColumnWidth
Integer getColumnWidth(Integer Col);
Returns the width of the column. setColumnWidth
Boolean setColumnWidth(Integer Col, Integer Width);
Sets the columnwidth. Returns true on success, false on failure. Width can be the width in pixels, AUTOSIZE or AUTOSIZE_USEHEADER. AUTOSIZE will resize the column to the length of the longest item. AUTOSIZE_USEHEADER will resize the column to the length of the header (on windows) or on 80 pixels (other platforms). getItem
wx.ListItem getItem(Integer Item);
405 wx
Boolean getItem(wx.ListItem ListItem);
Gets the item information. The first form returns a wx.ListItem object or undefined when the item is not found. The second form returns true when the item is found and puts the item information in the argument. setItem
Boolean setItem(wx.ListItem ListItem);
Integer setItem(Integer Item, Integer Col, String Label, Integer ImageId= -1);
Sets the item information. On success, true is returned. getItemState
Integer getItemState(Integer Item, Integer StateMask);
Gets the item state. See wx.ListState. setItemState
Boolean setItemState(Integer Item, Integer State, Integer StateMask);
Sets the new state of an item. See wx.ListState. setItemImage
Boolean setItemImage(Integer Item, Integer Image, Integer SelImage);
Sets the unselected and selected images associated with the item. The images are indices into the image list associated with the list control. getItemText
String getItemText(Integer Item);
Returns the text of the item. setItemText
setItemText(Integer Item,
406 wx
String Text);
Sets the text of an item. getItemData
Any getItemData(Integer Item);
Returns the associated data of the item. The type of the data can be any type: integer, long, object, ... setItemData
Boolean setItemData(Integer Item, Any Data);
Sets the associated data of an item. The type of the data can be any type: integer, long, object, ... When the listcontrol is sortable, the item data must be set. getItemRect
wx.Rect getItemRect(Integer Item, Integer Code);
Returns the item rectangle. See wx.ListRect. getItemPosition
wx.Point getItemPosition(Integer Item);
Returns the position of the item in icon or small icon view. Returns undefined on failure. setItemPosition
Boolean setItemPosition(Integer Item, wx.Point Pos);
Sets the item position in icon or small icon view. Returns true on success. setSingleStyle
setSingleStyle(Integer Style, Boolean Add= true);
Adds or removes a single window style. getNextItem
Integer getNextItem(Integer Item, Integer Geometry= wx.ListNext.ALL,
407 wx
Integer State= wx.ListState.DONTCARE);
Searches for an item with the given goemetry or state, starting from item but excluding the item itself. If item is -1, the first item that matches the specified flags will be returned.
The following example iterates all selected items:
var item = -1; do { item = listctrl.getNextItem(item, wx.ListNext.ALL, wx.ListState.SELECTED); } while(item != -1);
getImageList
wx.ImageList getImageList(Integer Which);
Returns the associated imagelist. setImageList
setImageList(wx.ImageList ImageList, Integer Which);
Sets the imagelist associated with the control. refreshItem
refreshItem(Integer Item);
Refreshes the item. Only useful for virtual list controls. refreshItems
refreshItems(Integer From, Integer To);
Refreshes a range of items. Only useful for virtual list controls. arrange
Boolean arrange(Integer Align= wx.ListAlign.DEFAULT);
Arranges the items in icon or small icon view. (Windows only) See wx.ListAlign deleteItem
408 wx
Boolean deleteItem(Integer Item);
Deletes the item. Returns true on success. deleteAllItems
Boolean deleteAllItems();
Deletes all items. Returns true on success. deleteColumn
Boolean deleteColumn(Integer Col);
Deletes the column. Returns true on success. deleteAllColumns
Boolean deleteAllColumns();
Deletes all columns. Returns true on success. clearAll
clearAll();
Deletes all items and columns. insertColumn
Integer insertColumn(Integer Col, wx.ListItem ListItem);
Integer insertColumn(Integer Col, String Heading, Integer Format= wx.ListFormat.LEFT, Integer Width= -1);
Inserts a column. On success, the index of the new column is returned. On failure, -1 is returned. insertItem
Integer insertItem(wx.ListItem ListItem);
Integer insertItem(Integer Item, String Label, Integer ImageIdx= -1);
409 wx
Integer insertItem(Integer Item, Integer ImageIdx);
Inserts an item. On success, the index of the new item is returned. On failure, -1 is returned. editLabel
wx.TextCtrl editLabel(Integer Item);
Edit the label. The text control is returned (on Windows). endEditLabel
Boolean endEditLabel(Boolean Cancel);
Ends editing the label. When Cancel is true, the label is left unchanged. Windows only ensureVisible
Boolean ensureVisible(Integer Item);
Makes sure the item is visible. Returns true on success. findItem
Integer findItem(Integer Start, String Str, Boolean Partial= false);
Integer findItem(Integer Start, Integer Data);
Integer findItem(Integer Start, wx.Point Pos, Integer Direction);
1. Find an item whose label matches the string exact or partial. 2. Find an item with the given associated data. 3. Find an item nearest the position in the specified direction. The search starts from the given item, or at the beginning when start is -1. hitTest
Array hitTest(wx.Point Pos);
Determines which item (if any) is at the specified point. This method returns multiple values. Use it as follows:
var item;
410 wx
var flags; [item, flags] = list.hitTest(new wxPoint(1, 1));
scrollList
Boolean scrollList(Integer X, Integer Y);
Scrolls the list control. If in icon, small icon or report view mode, X specifies the number of pixels to scroll. If in list view mode, X specifies the number of columns to scroll. If in icon, small icon or list view mode, Y specifies the number of pixels to scroll. If in report view mode, Y specifies the number of lines to scroll. sortItems
Boolean sortItems(Function SortFn, Integer Data= 0);
Call this method to sort the items in the list control. Sorting is done using the specified SortFn is a function that receives 3 arguments. The first argument is the associated data of the first item. The second argument is the associated data of the second item. The third arugment is the Data argument you specify with this method. The third argument may be omitted when you don't use it. The return value is an integer value. Return 0 when the items are equal, a negative value if the first item is less then the second item and a positive value when the first item is greater then the second item. Note Notice that the control may only be sorted on client data associated with the items, so you must use setItemData if you want to be able to sort the items in the control.
411 wx
Name wx.ListEvent — This object is passed to a function that is set to a wx.ListCtrl event property.
Prototype: wx.NotifyEvent Properties cacheFrom
Integer cacheFrom ;
The first item which the list control advises us to cache. cacheTo
Integer cacheTo ;
The last item which the list control advises us to cache. column
Integer column ;
The column index. For the column dragging events, it is the column to the left of the divider being dragged, for the column click events it may be -1 if the user clicked in the list control header outside any column. data
Integer data ;
The associated data of the item. image
Integer image ;
The image index of the item. index
Integer index ;
The item index. item
wx.ListItem item ;
412 wx
The item. keyCode
Integer keyCode ;
Keycode when the event is a keypress event. See wx.KeyCode label
String label ;
The label. mask
Integer mask ;
The mask. point
wx.Point point ;
The position of the mouse pointer when the event is a drag event. text
String text ;
The text.
413 wx
Name wx.ListFind
Constants
Table 16.44. Constants of wx.ListFind
Name Description DOWN LEFT RIGHT UP
414 wx
Name wx.ListItemAttr — ListItemAttr is used in virtual list controls
See onGetItemAttr property Constructor
ListItemAttr();
Creates a new ListItemAttr object. Properties textColour
wx.Colour textColour ;
The colour used for displaying text. backgroundColour
wx.Colour backgroundColour ;
The colour used as background. font
wx.Font font ;
The font used for displaying text. hasTextColour
Boolean hasTextColour ;
Indicates that this attribute defines the text colour. hasBackgroundColour
Boolean hasBackgroundColour ;
Indicates that this attribute defines the background colour. hasFont
Boolean hasFont ;
415 wx
Indicates that this attributes defines a font.
416 wx
Name wx.ListItem — This class stores information about a wx.ListCtrl item or column.
Constructor
ListItem(Integer Index);
Creates a new ListItem object. See getItem and setItem Properties align
Integer align ;
The column alignment. See wx.ListColumnFormat. backgroundColour
wx.Colour backgroundColour ;
Get/Set the background colour of the item. column
Integer column ;
Get/Set the column. data
Integer data ;
Get/Set the associated data. font
wx.Font font ;
Get/Set the font of the item. hasAttributes
Boolean hasAttributes ;
Returns true when the item has attributes.
417 wx id
Integer id ;
Get/Set index of the item. image
Integer image ;
Get/Set the index of the image in the associated imagelist of the list control. mask
Integer mask ;
Get/Set the mask. The mask indicates which fields of wxListItem are valid. See wx.ListMask state
Integer state ;
Get/Set the state. See wx.ListState stateMask
Integer stateMask ;
Get/Set the state mask. This indicates which state is valid. See wx.ListState text
String text ;
Get/Set the text of the item. textColour
wx.Colour textColour ;
Get/Set the text colour. width
Integer width ;
Get/Set the width.
418 wx
Name wx.ListMask
Constants
Table 16.45. Constants of wx.ListMask
Name Description DATA FORMAT IMAGE ITEM STATE TEXT WIDTH
419 wx
Name wx.ListNext
Constants
Table 16.46. Constants of wx.ListNext
Name Description ABOVE Searches for an item above the specified item ALL Searches for subsequent item by index BELOW Searches for an item below the specified item LEFT Searches for an item to the left of the specified item RIGHT Searches for an item to the right of the specified item
420 wx
Name wx.ListRect
Constants
Table 16.47. Constants of wx.ListRect
Name Description BOUNDS ICON LABEL
421 wx
Name wx.ListState
Constants
Table 16.48. Constants of wx.ListState
Name Description CUT (Windows only) DONTCARE DROPHILITED (Windows only) FOCUSED SELECTED
422 wx
Name wx.MaximizeEvent — An event being sent when the frame is maximized (minimized) or restored.
Prototype: wx.Event
See wx.Frame.
423 wx
Name wx.MDIChildFrame — An MDI child frame is a frame that can only exist in a wx.MDIParentFrame.
Prototype: wx.Frame Constructor
MDIChildFrame();
MDIChildFrame(wx.MDIParentFrame Parent, Integer Id, String Title, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Frame.DEFAULT_FRAME_STYLE);
Creates a new MDI child frame. Methods create
Boolean create(wx.MDIParentFrame Parent, Integer Id, String Title, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Frame.DEFAULT_FRAME_STYLE | wx.Window.VSCROLL | wx.Window.HSCROLL);
Creates a MDIChildFrame. activate
activate();
Activates this MDI child frame maximize
maximize(Boolean Maximize);
Maximizes this MDI child frame restore
restore();
424 wx
Restores this MDI child frame
425 wx
Name wx.MDIParentFrame — An MDI (Multiple Document Interface) parent frame is a window which can contain MDI child frames in its own 'desktop'.
Prototype: wx.Frame
It is a convenient way to avoid window clutter, and is used in many popular Windows applications, such as Microsoft Word(TM). Constructor
MDIParentFrame();
MDIParentFrame(wx.Window Parent, Integer Id, String Title, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Frame.DEFAULT_FRAME_STYLE | wx.Window.VSCROLL | wx.Window.HSCROLL);
Creates a new MDI parent frame. Properties activeChild
wx.MDIChildFrame activeChild ;
The active MDI child, if there is one. Methods create
Boolean create(wx.Window Parent, Integer Id, String Title, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Frame.DEFAULT_FRAME_STYLE | wx.Window.VSCROLL | wx.Window.HSCROLL);
Creates a MDIParentFrame activeNext
activeNext();
Activates the MDI child following the currently active one.
426 wx activePrevious
activePrevious();
Activates the MDI child preceding the currently active one. arrangeIcons
arrangeIcons();
Arranges any iconized (minimized) MDI child windows. cascade
cascade();
Arranges the MDI child windows in a cascade. tile
tile(wx.Orientation Orientation= wx.Orientation.HORIZONTAL);
Tiles the MDI child windows either horizontally or vertically. Currently only implemented for MSW, does nothing under the other platforms.
427 wx
Name wx.MenuBar — A menu bar is a series of menus accessible from the top of a frame.
See menuBar property, wx.Menu and wx.MenuItem. Constants
Table 16.49. Constants of wx.MenuBar
Name Description DOCKABLE (wxGTK only)
Constructor
MenuBar(Integer Style= 0);
Constructs a new MenuBar object. Properties menuCount
Integer menuCount ;
The number of menus menus
Array menus ;
Returns all the menus belonging to the menubar. Methods append
Boolean append(wx.Menu Menu, String Name);
Adds the menu to the menubar check
check(Integer Id, Boolean Switch);
428 wx
Checks/Unchecks the menu with the given id. Only use this when the menu bar has been associated with a wx.Frame; otherwise, use the wx.Menu equivalent call. enable
enable(Integer Id, Boolean Switch);
Enables/Disables the menu with the given id. Only use this when the menu bar has been associated with a wx.Frame; otherwise, use the wx.Menu equivalent call. enableTop
enableTop(Integer Pos, Boolean Switch);
Enables or disables a whole menu. Only use this when the menu bar has been associated with a wx.Frame. findMenu
Integer findMenu(String Name);
Returns the index of the menu with the given name. -1 is returned when the menu is not found. findMenuItem
Integer findMenuItem(String MenuName, String ItemName);
Finds the menu item id for a menu name/menu item string pair. -1 is returned when nothing is found. getHelpString
String getHelpString(Integer Id);
Returns the helpstring associated with the menu item or an empty String when the menu item is not found. See help property and getHelpString method. getLabel
String getLabel(Integer Id);
Returns the label associated with the menu item or an empty String when the menu item is not found. Use only after the menubar has been associated with a wx.Frame. getMenuLabel
String getMenuLabel(Integer Index);
429 wx
Returns the menu label, or the empty string if the menu was not found. Use only after the menubar has been associated with a wx.Frame. See also title and setMenuLabel getMenu
wx.Menu getMenu(Integer Index);
Returns the wx.Menu at the given index (zero-indexed). insert
Boolean insert(Integer Pos, wx.Menu Menu, String Title);
Inserts the menu at the given position into the menu bar. Inserting menu at position 0 will insert it in the very beginning of it, inserting at position menuCount is the same as calling append. isChecked
Boolean isChecked(Integer Id);
Returns true when the menu item is checked. See check method, isChecked and check property. isEnabled
Boolean isEnabled(Integer Id);
Returns true when the menu item is enabled. enable method, enable property and enable refresh
refresh();
Redraw the menu bar. remove
Boolean remove(Integer Index);
Removes the menu from the menu bar and returns the wx.Menu object. This function may be used together with insert to change the menubar dynamically. replace
wx.Menu replace(Integer Index, wx.Menu Menu, String Title);
Replaces the menu at the given position with the new one.
430 wx setHelpString
setHelpString(Integer Id, String Help);
Sets the help associated with a menu item. See help property and setHelpString method setLabel
setLabel(Integer Id, String Label);
Sets the label of a menu item. Only use this when the menubar is associated with a wx.Frame label property and setLabel method setMenuLabel
setMenuLabel(Integer Index, String Label);
Sets the label of a menu. Only use this when the menubar is associated with a wx.Frame See title property
431 wx
Name wx.Menu — A menu is a popup (or pull down) list of items, one of which may be selected before the menu goes away (clicking elsewhere dismisses the menu).
Menus may be used to construct either menu bars or popup menus. See wx.MenuBar and menuBar property. Constants
Table 16.50. Constants of wx.Menu
Name Description TEAROFF (wxGTK only) Constructor
Menu(String Title= "", Integer Style= 0);
Menu(Integer Style= 0);
Creates a new Menu object Properties actions
Array actions ;
An array containing the function callbacks. A function will be called when a menu item is selected. Use id id as index of the array. It is possible to change the function after the menu item is appended to the menu. menuItemCount
Integer menuItemCount ;
Returns the number of menu items. menuItems
Array menuItems ;
Returns all the menu items. title
String title ;
432 wx
Get/Set the title of the menu Methods append
wx.MenuItem append(wx.MenuItem Item);
wx.MenuItem append(Integer Id);
wx.MenuItem append(Integer Id, String Name, String HelpString= "", Integer Kind= wx.ItemKind.NORMAL);
wx.MenuItem append(Integer Id, wx.Menu SubMenu, String HelpString= "");
Appends a new menu item to the menu. appendCheckItem
wx.MenuItem appendCheckItem(Integer Id, String Item, String Help= "");
Adds a checkable item to the end of the menu. appendRadioItem
wx.MenuItem appendRadioItem(Integer Id, String Item, String Help= "");
Adds a radio item to the end of the menu. appendSeparator
wx.MenuItem appendSeparator();
Adds a separator appendSubMenu
wx.MenuItem appendSubMenu(wx.Menu Menu, String Item, String Help= "");
433 wx
Adds a submenu to the end of the menu. check
check(Integer Id, Boolean Check);
Checks or unchecks the menu item. enable
enable(Integer Id, Boolean Enable);
Enables or disables the menu item. deleteItem
deleteItem(Integer Id);
deleteItem(wx.MenuItem MenuItem);
Deletes the menu item from the menu. If the item is a submenu, it will not be deleted. Use destroy if you want to delete a submenu. newColumn
newColumn();
Adds a new column getHelpString
String getHelpString(Integer Id);
Returns the helpstring of the menu item with the given id. See setHelpString and help property getLabel
String getLabel(Integer Id);
Returns the label of the menu item with the given id. See setLabel and label property. findItem
wx.MenuItem findItem(Integer Id);
Integer findItem(String Name);
434 wx
Returns the wx.MenuItem object of the menu item with the given id. Or returns the id of the item with the given name or wx.NOT_FOUND. destroy
destroy(Integer Id);
destroy(wx.MenuItem MenuItem);
Deletes the menu item from the menu. If the item is a submenu, it will be deleted. Use remove if you want to keep the submenu (for example, to reuse it later). insert
wx.MenuItem insert(Integer Pos, wx.MenuItem MenuItem);
wx.MenuItem insert(Integer Pos, Integer Id, String Item= "", String Help= "", Integer Kind= wx.ItemKind.NORMAL);
Inserts the given item before the position pos. Inserting the item at the position menuItemCount is the same as appending it. insertCheckItem
wx.MenuItem insertCheckItem(Integer Pos, Integer Id, String Item, String Help= ""); insertSeparator
wx.MenuItem insertSeparator(Integer Pos); insertRadioItem
wx.MenuItem insertRadioItem(Integer Pos, Integer Id, String Item, String Help= ""); isChecked
435 wx
Boolean isChecked(Integer Id);
Returns true when the menu item is checked. isEnabled
Boolean isEnabled(Integer Id);
Returns true when the menu item is enabled. remove
wx.MenuItem remove(Integer Id);
wx.MenuItem remove(wx.MenuItem MenuItem);
Removes the menu item from the menu but doesn't delete the object. This allows to reuse the same item later by adding it back to the menu (especially useful with submenus). setHelpString
setHelpString(Integer Id, String Help);
Sets the help associated with a menu item. See help property and setHelpString method. setLabel
setLabel(Integer Id, String Label);
Sets the label of a menu item. See label property and setLabel method prepend
wx.MenuItem prepend(wx.MenuItem Item);
wx.MenuItem prepend(Integer Id, String Name, String HelpString= "", Integer Kind= wx.ItemKind.NORMAL);
Inserts the given item at position 0, i.e. before all the other existing items. prependCheckItem
wx.MenuItem prependCheckItem(Integer Id, String Item,
436 wx
String Help= "");
Inserts a checkable item at position 0. prependRadioItem
wx.MenuItem prependRadioItem(Integer Id, String Item, String Help= "");
Adds a radio item to the end of the menu. prependSeparator
wx.MenuItem prependSeparator();
Adds a separator
437 wx
Name wx.MenuItem — A menu item represents an item in a popup menu.
Note that the majority of this class is only implemented under Windows so far, but everything except fonts, colours and bitmaps can be achieved via wx.Menu on all platforms. Constructor
MenuItem(wx.Menu Menu, Integer Id= 0, String Text= "", String Help= "", Integer Kind= wx.ItemKind.NORMAL, wx.Menu SubMenu= null);
Constructs a new MenuItem object Properties accel
wx.AcceleratorEntry accel ;
Get/Set the accelerator. backgroundColour
wx.Colour backgroundColour ;
Get/Set the background colour of the item (Windows only) bitmap
wx.Bitmap bitmap ;
Get/Set the checked bitmap. (Windows only) check
Boolean check ;
Check or uncheck the menu item. checkable
Boolean checkable ;
438 wx
Returns true if the item is checkable. enable
Boolean enable ;
Enables or disables the menu item. font
wx.Font font ;
Get/Set the font. (Windows only) help
String help ;
Get/Set the helpstring shown in the statusbar. id
Integer id ;
Get/Set the id of the menu item label
String label ;
Gets the text associated with the menu item without any accelerator characters it might contain. marginWidth
Integer marginWidth ;
Get/Set the width of the menu item checkmark bitmap (Windows only). menu
wx.Menu menu ;
Gets the menu that owns this item. separator
Boolean separator ;
Returns true if the item is a separator.
439 wx subMenu
wx.Menu subMenu ;
Gets the submenu associated with the menu item itemLabel
String itemLabel ;
Get/Set the text associated with the menu item with any accelerator characters it may contain. textColour
wx.Colour textColour ;
Get/Set the text colour. (Windows Only) Methods setBitmaps
setBitmaps(wx.Bitmap BitmapChecked, wx.Bitmap BitmapUnchecked= null);
Sets the checked/unchecked bitmaps for the menu item (Windows only). The first bitmap is also used as the single bitmap for uncheckable menu items.
440 wx
Name wx.MouseEvent — This event class contains information about mouse events.
Prototype: wx.Event
Note the difference between methods like leftDown and leftIsDown: the formet returns true when the event corresponds to the left mouse button click while the latter returns true if the left mouse button is currently being pressed. For example, when the user is dragging the mouse you can use leftIsDown to test whether the left mouse button is (still) depressed. Also, by convention, if leftDown returns true, leftIsDown will also return true in wxWindows whatever the underlying GUI behaviour is (which is platform-dependent). The same applies, of course, to other mouse buttons as well.
See onMouseEvents , onEnterWindow , onLeaveWindow , onLeftUp , onLeftDown , onLeftDClick , onMiddleUp, onMiddleDown, onMiddleDClick, onRightUp, onRightDown, onRightDClick. Properties altDown
Boolean altDown ;
Returns true when the alt key is down at the time of the key event. button
Integer button ;
Get the button which is changing state controlDown
Boolean controlDown ;
Returns true when the control key is down at the time of the event. dragging
Boolean dragging ;
Returns true when this is a dragging event. entering
Boolean entering ;
Returns true when the mouse was entering the window. See leaving leaving
441 wx
Boolean leaving ;
Returns true when the mouse was leaving the window. See entering. leftDClick
Boolean leftDClick ;
Returns true when the event is a left double click event (wxEVT_LEFT_DCLICK). leftDown
Boolean leftDown ;
Returns true when the event is a left down event (wxEVT_LEFT_DOWN). leftIsDown
Boolean leftIsDown ;
Returns true if the left mouse button is currently down, independent of the current event type. Please notice that it is not the same as leftDown which returns true if the left mouse button was just pressed. Rather, it describes the state of the mouse button before the event happened. linesPerAction
Integer linesPerAction ;
Returns the configured number of lines (or whatever) to be scrolled per wheel action. Defaults to 1. metaDown
Boolean metaDown ;
Returns true when the meta key was down at the time of the event. middleDClick
Boolean middleDClick ;
Returns true when the event is a middle double click event (wxEVT_MIDDLE_DCLICK). middleDown
Boolean middleDown ;
Returns true when the event is a middle down event (wxEVT_MIDDLE_DOWN). middleIsDown
442 wx
Boolean middleIsDown ;
Returns true if the middle mouse button is currently down, independent of the current event type. moving
Boolean moving ;
Returns true when this was a moving event (wxEVT_MOTION) position
wx.Point position ;
Returns the physical mouse position in pixels. rightDClick
Boolean rightDClick ;
Returns true when the event is a right double click event (wxEVT_RIGHT_DCLICK). rightDown
Boolean rightDown ;
Returns true when the event is a right down event (wxEVT_RIGHT_DOWN). rightIsDown
Boolean rightIsDown ;
Returns true if the right mouse button is currently down, independent of the current event type. shiftDown
Boolean shiftDown ;
Returns true when the shift key was down at the time of the event. wheelDelta
Integer wheelDelta ;
Get wheel delta, normally 120. This is the threshold for action to be taken, and one such action (for example, scrolling one increment) should occur for each delta. wheelRotation
Integer wheelRotation ;
443 wx
Get wheel rotation, positive or negative indicates direction of rotation. Current devices all send an event when rotation is equal to +/-WheelDelta, but this allows for finer resolution devices to be created in the future. Because of this you shouldn't assume that one event is equal to 1 line or whatever, but you should be able to either do partial line scrolling or wait until +/-WheelDelta rotation values have been accumulated before scrolling. x
Integer x ;
Returns the x-coordinate of the physical mouse position. See position and y y
Integer y ;
Returns the y-coordinate of the physical mouse position. See position and x Methods button
Boolean button(Integer Number);
Returns true if the identified mouse button is changing state. Valid values of Number are 1, 2 or 3 for left, middle and right buttons respectively. buttonDClick
Boolean buttonDClick(Integer Number);
If the argument is omitted, this returns true if the event was a mouse double click event. Otherwise the argument specifies which double click event was generated (1, 2 or 3 for left, middle and right buttons respectively). buttonDown
Boolean buttonDown(Integer Number);
If the argument is omitted, this returns true if the event was a mouse button down event. Otherwise the argument specifies which button-down event was generated (1, 2 or 3 for left, middle and right buttons respectively). buttonUp
Boolean buttonUp(Integer Number);
If the argument is omitted, this returns true if the event was a mouse button up event. Otherwise the argument specifies which button-up event was generated (1, 2 or 3 for left, middle and right buttons respectively).
444 wx
Name wx.MoveEvent — A move event holds information about move change events.
Prototype: wx.Event
Handle this event by setting a function to the onMove property on a wx.Window object. Properties position
wx.Point position ;
Returns the position of the window generating this event.
445 wx
Name global
These are some global constants Constants
Table 16.51. Constants of global
Name Description CANCEL ICON_ERROR ICON_EXCLAMATION ICON_HAND ICON_INFORMATION ICON_QUESTION InvalidOffset NO NOT_FOUND OK YES YES_NO
446 wx
Name wx.Notebook — This class represents a notebook control, which manages multiple windows with associated tabs.
Prototype: wx.BookCtrlBase Constants
Table 16.52. Constants of wx.Notebook
Name Description ALIGN_MASK BOTTOM DEFAULT FIXEDWIDTH FLAT LEFT MULTILINE NOPAGETHEME RIGHT TOP
Constructor
Notebook();
Notebook(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Constructs a new Notebook. Properties rowCount
Integer rowCount ;
Get the number of rows for a control with wx.Notebook.MULTILINE style (not all versions support it - they will always return 1 then). themeBackgroundColour
447 wx
wx.Colour themeBackgroundColour ;
On platforms that support it, get the theme page background colour, else null Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Creates a notebook. setPadding
setPadding(wx.Size size);
Sets the amount of space around each page's icon and label, in pixels. setTabSize
setTabSize(wx.Size size);
Set the size of the tabs for wx.Notebook.FIXEDWIDTH controls. Events onPageChanged onPageChanging
448 wx
Name wx.NotebookEvent — This object is passed to a function that is set to a wx.Notebook event property.
Prototype: wx.NotifyEvent
449 wx
Name wx.NotebookHittest
Constants
Table 16.53. Constants of wx.NotebookHittest
Name Description NOWHERE There was no tab under this point. ONICON The point was over an icon (currently wxMSW only). ONITEM The point was over an item, but not on the label or icon. ONLABEL The point was over a label (currently wxMSW only). ONPAGE The point was over a currently selected page, not over any tab. Note that this flag is present only if -1 is returned.
450 wx
Name wx.NotifyEvent — This class is a prototype for several events.
Prototype: wx.Event Properties allowed
Boolean allowed ;
Allow/Disallow the change. Setting allowed to false, is the same as setting veto to true. veto
Boolean veto ;
When set to true, prevents the change announced by this event from happening. Setting veto to false, is the same as setting allow to true.
451 wx
Name wx.Orientation
Constants
Table 16.54. Constants of wx.Orientation
Name Description BOTH HORIZONTAL VERTICAL
452 wx
Name wx.Panel — A panel is a window on which controls are placed.
Prototype: wx.Window
It is usually placed within a frame. Its main purpose is to be similar in appearance and functionality to a dialog, but with the flexibility of having any window as a parent. See wx.Dialog and wx.Frame Constructor
Panel();
Panel(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Constructs a new Panel object. Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Constructs a new Panel object. initDialog
initDialog();
Sends a wx.InitDialogEvent, which in turn transfers data to the dialog via validators. setFocusIgnoringChildren
setFocusIgnoringChildren();
In contrast to setFocus this will set the focus to the panel even of there are child windows in the panel. This is only rarely needed. Events onSysColourChanged To process a system colour changed event, use this property to set an event handler function. The function takes a wx.SysColourChangedEvent argument.
453 wx
Name wx.PasswordEntryDialog — This class represents a dialog that requests a password from the user.
Prototype: wx.TextEntryDialog Constructor
PasswordEntryDialog();
PasswordEntryDialog(wx.Window Parent, String Message, String Title, String DefaultValue, wx.Point Position= wx.DefaultPosition, Integer Style= wx.Id.OK + wx.Id.CANCEL);
Constructs a new PasswordEntryDialog object.
454 wx
Name wx.PCXHandler — Image handler for bitmaps.
Prototype: wx.ImageHandler
455 wx
Name wx.PickerBase — Prototype for all pickers which support an auxiliary text control.
This class handles all positioning and sizing of the text control like a an horizontal wx.BoxSizer would do, with the text control on the left of the picker button. The proportion (see wx.Sizer documentation for more info about proportion values) of the picker control defaults to 1 when there isn't a text control associated (see wx.PickerBase.USE_TEXTCTRL style) and to 0 otherwise. Constants
Table 16.55. Constants of wx.PickerBase
Name Description USE_TEXTCTRL
Properties colour
wx.Colour colour ;
456 wx
Name wx.PNGHandler — Image handler for bitmaps.
Prototype: wx.ImageHandler
457 wx
Name wx.PNMHandler — Image handler for bitmaps.
Prototype: wx.ImageHandler
458 wx
Name wx.Point — A Point is a useful data structure for graphics operations.
It simply contains integer x and y members. Constructor
Point(Integer X= wx.DefaultPosition.x, Integer Y= 0);
Point(Object Object);
Creates a new Point. When no arguments are given then wxPoint gets the same value as wx.DefaultPosition. The second form can be used to create a Point from a JSON Class. Properties x
Integer x ;
The x-coordinate. y
Integer y ;
The y-coordinate.
459 wx
Name wx.QueryLayoutInfoEvent — This event is sent when wx.LayoutAlgorithm wishes to get the size, orientation and alignment of a window. More precisely, the event is sent by the onCalculateLayout handler which is itself invoked by wx.LayoutAlgorithm.
Prototype: wx.Event Properties flags
Integer flags ;
Get/Set the flags associated with this event. Not currently used. alignment
Integer alignment ;
Get/Set the alignment of the window (which side of the remaining parent client area the window sticks to). One of wx.LayoutAlignment.TOP, wx.LayoutAlignment.LEFT, wx.LayoutAlignment.RIGHT, wx.LayoutAlignment.BOTTOM. orientation
Integer orientation ;
Get/Set the orientation that the event handler specified to the event object. May be one of wx.LayoutOrientation.HORIZONTAL, wx.LayoutOrientation.VERTICAL. requestedLength
Integer requestedLength ;
Get/Set the requested length of the window in the direction of the window orientation. This information is not yet used. size
wx.Size size ;
Returns the size that the event handler specified to the event object as being the requested size of the window. Call this to let the calling code know what the size of the window is.
460 wx
Name wx.RadioBox — A radio box item is used to select one of number of mutually exclusive choices. It is displayed as a vertical column or horizontal row of labelled buttons.
Prototype: wx.Control Constants
Table 16.56. Constants of wx.RadioBox
Name Description SPECIFY_COLS The major dimension parameter refers to the maximum number of columns. SPECIFY_ROWS The major dimension parameter refers to the maximum number of rows. Constructor
RadioBox();
RadioBox(wx.Window Parent, Integer Id, String Title, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Array Items= null, Integer MaximumDimension= 0, Integer Style= wx.RadioBox.SPECIFY_COLS, wx.Validator Validator= null);
Constructs a new RadioBox object. Properties count
Integer count ;
Get the number of items item
Array item ;
Get an array of with wx.RadioBoxItem items. selection
461 wx
Integer selection ;
Get/Set the selected button. (zero-indexed) stringSelection
String stringSelection ;
Get/Set the selected string. Methods create
Boolean create(wx.Window Parent, Integer Id, String Title, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Array Items= null, Integer MaximumDimension= 0, Integer Style= wx.RadioBox.SPECIFY_COLS, wx.Validator Validator= null);
Creates a new RadioBox object. setString
setString(Integer Index, String Label); findString
Integer findString(String Str);
Finds a button matching the given string, returning the position if found, or -1 if not found. enable
enable(Boolean Switch);
enable(Integer Index, Boolean Switch);
Enables/Disables the button at the given index. See wx.RadioBoxItem enable. show
462 wx
show(Boolean Switch);
show(Integer Index, Boolean Switch);
Shows/Hides the button at the given index. See wx.RadioBoxItem show. Events onRadioBox Called when a radio button is clicked. The type of the argument that your handler receives is wx.CommandEvent.
463 wx
Name wx.RadioBoxItem — RadioBoxItem is a helper class for working with items of wx.RadioBox
There's no corresponding class in wxWidgets. See wx.RadioBox.class item property. Properties enable
Boolean enable ;
Enables/Disables the button. selected
Boolean selected ;
Returns true when the item is selected or sets the selection show
Boolean show ;
Hides or shows the item. string
String string ;
Get/Set the label of the button.
464 wx
Name wx.RadioButton — A radio button item is a button which usually denotes one of several mutually exclusive options. It has a text label next to a (usually) round button.
Prototype: wx.Control
You can create a group of mutually-exclusive radio buttons by specifying wx.RadioButton.GROUP for the first in the group. The group ends when another radio button group is created, or there are no more radio buttons. See also wx.RadioBox. Constants
Table 16.57. Constants of wx.RadioButton
Name Description GROUP Marks the beginning of a new group of radio buttons.
Constructor
Boolean RadioButton();
RadioButton(wx.Window Parent, Integer Id, String Label, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0, wx.Validator Validator= null);
Constructs a new RadioButton object. Properties value
Boolean value ;
Select/Deselect the button Events onRadioButton Called when a radio button is clicked. The type of the argument that your handler receives is wx.CommandEvent.
465 wx
Name wx.Rect — A class for manipulating rectangles
Constructor
Rect(Integer X, Integer Y, Integer Width, Integer Height);
Rect(wx.Point TopLeft, wx.Point BottomRight);
Rect(wx.Point Position, wx.Size Size);
Constructs a new Rect Class. Properties width
Integer width ;
The width of the rectangle height
Integer height ;
The height of the rectangle bottom
Integer bottom ;
The bottom left
Integer left ; position
wx.Point position ;
466 wx right
Integer right ; size
wx.Size size ; top
Integer top ; x
Integer x ; y
Integer y ; empty
Boolean empty ;
Returns true if this rectangle has a width or height less than or equal to 0 and false otherwise. Methods inflate
inflate(Integer X, Integer Y);
inflate(Integer Diff);
inflate(wx.Size Size);
Increases the rectangle size by X in x direction and by Y in y direction. deflate
deflate(Integer X, Integer Y);
deflate(Integer Diff);
467 wx
deflate(wx.Size Size);
Decreases the rectangle size by X in x direction and by Y in y direction. When Y is not specified then the value of X is used. You can use negative values to decrease the size. offset
offset(Integer X, Integer Y);
offset(wx.Point Pt);
Moves the rectangle. intersect
wx.Rect intersect(wx.Rect Rect); intersects
Boolean intersects(wx.Rect Rect);
Returns true when the rectangles have a non empty intersection
468 wx
Name wx.SashDragStatus
Constants
Table 16.58. Constants of wx.SashDragStatus
Name Description OK OUT_OF_RANGE
469 wx
Name wx.SashEdgePosition
Constants
Table 16.59. Constants of wx.SashEdgePosition
Name Description BOTTOM LEFT NONE RIGHT TOP
470 wx
Name wx.SashEvent — A sash event is sent when the sash of a wx.SashWindow has been dragged by the user.
Prototype: wx.CommandEvent Properties edge
Integer edge ;
Returns the dragged edge. See wx.SashEdgePosition. dragRect
wx.Rect dragRect ;
Returns the rectangle representing the new size the window would be if the resize was applied. It is up to the application to set the window size if required dragStatus
Integer dragStatus ;
Returns the status of the sash: one of wx.SashStatus.OK, wx.SashStatus.OUT_OF_RANGE. If the drag caused the notional bounding box of the window to flip over, for example, the drag will be out of range. See wx.SashDragStatus.
471 wx
Name wx.SashLayoutWindow — SashLayoutWindow responds to onCalculateLayout events generated by wx.LayoutAlgorithm
Prototype: wx.SashWindow
It allows the application to use simple accessors to specify how the window should be laid out, rather than having to respond to events. The fact that the class derives from wx.SashWindow allows sashes to be used if required, to allow the windows to be user-resizable. Constructor
SashLayoutWindow();
SashLayoutWindow(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Window.CLIP_CHILDREN | wx.SashWindow.SW_3D);
Constructs a new SashLayoutWindow object. Properties alignment
Integer alignment ;
Get/Set the alignment of the window: one of wx.LayoutAlignment.TOP, wx.LayoutAlignment.LEFT, wx.LayoutAlignment.RIGHT, wx.LayoutAlignment.BOTTOM. orientation
Integer orientation ;
Get/Set the orientation of the window: one of wx.LayoutOrientation.HORIZONTAL, wx.LayoutOrientation.VERTICAL. Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Window.CLIP_CHILDREN | wx.SashWindow.SW_3D);
472 wx
Creates a sash layout window. setDefaultSize
setDefaultSize(wx.Size Size);
Sets the default dimensions of the window. The dimension other than the orientation will be fixed to this value, and the orientation dimension will be ignored and the window stretched to fit the available space.
473 wx
Name wx.SashWindow — SashWindow allows any of its edges to have a sash which can be dragged to resize the window.
Prototype: wx.Window
The actual content window will be created by the application as a child of SashWindow. The window (or an ancestor) will be notified of a drag via a wx.SashEvent notification. Constants
Table 16.60. Constants of wx.SashWindow
Name Description SW_3D SW_3DBORDER SW_3DSASH SW_BORDER SW_NOBORDER
Constructor
SashWindow();
SashWindow(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Window.CLIP_CHILDREN | wx.SashWindow.SW_3D);
Constructs a new SashWindow object. Properties maximumSizeX
Integer maximumSizeX ;
Gets/Sets the maximum window size in the x direction maximumSizeY
Integer maximumSizeY ;
Gets/Sets the maximum window size in the y direction
474 wx minimumSizeX
Integer minimumSizeX ;
Gets/Sets the minimum window size in the x direction minimumSizeY
Integer minimumSizeY ;
Gets/Sets the minimum window size in the y direction Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Window.CLIP_CHILDREN | wx.SashWindow.SW_3D);
Creates a sash. getSashVisible
Boolean getSashVisible(Integer Edge);
Returns true if a sash is visible on the given edge, false otherwise. setSashVisible
setSashVisible(Integer Edge, Boolean Visible);
Call this function to make a sash visible or invisible on a particular edge. Events onSashDragged
475 wx
Name wx.ScrolledWindow — ScrolledWindow class manages scrolling for its client area, transforming the coordinates according to the scrollbar positions, and setting the scroll positions, thumb sizes and ranges according to the area in view.
Prototype: wx.Panel Constructor
ScrolledWindow();
ScrolledWindow(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Window.HSCROLL + wx.Window.VSCROLL);
Constructs a new ScrolledWindow object. Properties retained
Boolean retained ;
Motif only: true if the window has a backing bitmap scrollPixelsPerUnit
Array scrollPixelsPerUnit ;
Get the number of pixels per scroll unit (line), in each direction, as set by setScrollbars. A value of zero indicates no scrolling in that direction. viewStart
Array viewStart ;
Get the position at which the visible portion of the window starts. virtualSize
Array virtualSize ;
Gets the size in device units of the scrollable window area (as opposed to the client size, which is the area of the window currently visible)
476 wx
Methods create
create(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.Window.HSCROLL + wx.Window.VSCROLL);
Creates a new ScrolledWindow object. calcScrolledPosition
Array calcScrolledPosition(Integer x, Integer y);
Translates the logical coordinates to the device ones. calcUnscrolledPosition
Array calcUnscrolledPosition(Integer x, Integer y);
Translates the device coordinates to the logical ones. enableScrolling
enableScrolling(Boolean xScrolling, Boolean yScrolling);
Enable or disable physical scrolling in the given direction. Physical scrolling is the physical transfer of bits up or down the screen when a scroll event occurs. If the application scrolls by a variable amount (e.g. if there are different font sizes) then physical scrolling will not work, and you should switch it off. Note that you will have to reposition child windows yourself, if physical scrolling is disabled. Note Physical scrolling may not be available on all platforms. Where it is available, it is enabled by default. getView
Array getView();
Get the number of pixels per scroll unit (line), in each direction, as set by setScrollbars. A value of zero indicates no scrolling in that direction. scroll
477 wx
scroll(Integer x, Integer y);
Scrolls a window so the view start is at the given point. Note The positions are in scroll units, not pixels, so to convert to pixels you will have to multiply by the number of pixels per scroll increment. If either parameter is -1, that position will be ignored (no change in that direction). setScrollbars
setScrollbars(Integer pixelsPerUnitX, Integer pixelsPerUnitY, Integer noUnitsX, Integer noUnitsY, Integer xPos= 0, Integer yPos= 0, Integer noRefresh= false);
Sets up vertical and/or horizontal scrollbars. Note The first pair of parameters give the number of pixels per 'scroll step', i.e. amount moved when the up or down scroll arrows are pressed. The second pair gives the length of scrollbar in scroll steps, which sets the size of the virtual window. xPos and yPos optionally specify a position to scroll to immediately. For example, the following gives a window horizontal and vertical scrollbars with 20 pixels per scroll step, and a size of 50 steps (1000 pixels) in each direction.
window.setScrollbars(20, 20, 50, 50);
ScrolledWindow manages the page size itself, using the current client window size as the page size. setScrollRate
setScrollRate(Integer xStep, Integer yStep);
Set the horizontal and vertical scrolling increment only. See the pixelsPerUnit parameter in setScrollbars. setTargetWindow
setTargetWindow(wx.Window Window);
Call this function to tell ScrolledWindow to perform the actual scrolling on a different window (and not on itself).
478 wx
Name wx.ScrollEvent — A scroll event holds information about events sent from stand-alone scrollbars, spin- buttons and sliders. Note that scrolled windows send the wx.ScrollWinEvent don't confuse these two kinds of events, and use this event only for the scrollbar-like controls.
Prototype: wx.CommandEvent Properties orientation
Integer orientation ;
Returns wx.Direction.HORIZONTAL or wx.Direction.VERTICAL position
Integer position ;
Returns the position of the scrollbar
479 wx
Name wx.ScrollWinEvent — A scroll event holds information about events sent from scrolling windows.
Prototype: wx.Event Properties orientation
Integer orientation ;
Returns wx.Direction.HORIZONTAL or wx.Direction.VERTICAL position
Integer position ;
Returns the position of the ScrollWinbar
480 wx
Name wx.Size — A Size is a useful data structure for graphics operations.
It simply contains integer width and height members. Constructor
Size(Integer Width= -1, Integer Height= -1);
Size(Object Object);
Creates a new Size. When no arguments are given then Size gets the same value as wx.DefaultSize. The second form can be used to create a Size Object from a JSON Class. Properties height
Integer height ;
The height property. width
Integer width ;
The width property. fullySpecified
Boolean fullySpecified ;
Returns true if neither of the size Object components is equal to -1, which is used as default for the size values in wxWidgets. Methods decBy
decBy(wx.Size Size);
decBy(Integer X, Integer Y);
decBy(Integer D);
481 wx
Decreases the size in x- and y- directions decTo
decTo(wx.Size Size);
Decrements this Object so that both of its dimensions are not greater than the corresponding dimensions of the size incBy
incBy(wx.Size Size);
incBy(Integer X, Integer Y);
incBy(Integer D);
Decreases the size in x- and y- directions incTo
incTo(wx.Size Size);
Decrements this Object so that both of its dimensions are not greater than the corresponding dimensions of the size set
set(Integer X, Integer Y);
Sets the width and height members scale
wx.Size scale(Double xScale, Double yScale);
Scales the dimensions of this Object by the given factors. Returns this Object so that you can concatenate other operations in the same line. setDefaults
setDefaults(wx.Size DefaultSize);
Combine this size Object with another one replacing the default (i.e. equal to -1) components of this Object with those of the other. It is typically used like this:
482 wx if ( !size.fullySpecified ) { size.setDefaults(GetDefaultSize()); }
483 wx
Name wx.SizeEvent — A size event holds information about size change events.
Prototype: wx.Event
Handle this event by setting a function to the onSize property on a wx.Window object.
The size retrieved with size property is the size of the whole window. Use clientSize for the area which may be used by the application. Properties size
wx.Size size ;
Returns the size of the window generating this event.
484 wx
Name wx.Sizer — Sizer is the prototype for all sizer Classs
See wx.BoxSizer, wx.FlexGridSizer, wx.GridSizer and wx.StaticBoxSizer. See also following Window properties: sizer, and autoLayout. The example will show a dialog box that asks the user to enter a name and a password. The labels, text controls and buttons are placed dynamically on the dialog using sizers.
// The Sizer example var wx = require("wx"); wx.TheApp.onInit = init;
function init() { //Create a dialog box
var dlg = new wx.Dialog(null, -1, "Sizer Example", wx.DefaultPosition, new wx.Size(200, 150)); // Create a BoxSizer for the dialog. // The main direction of this sizer is vertical. // This means that when an item is added to this sizer, it will be // added below the previous item.
dlg.sizer = new wx.BoxSizer(wx.Orientation.VERTICAL);
// Use a wx.FlexGridSizer to layout the labels with their corresponding // text controls. // The sizer is created with 2 rows and 2 columns. The first column is // used for the label, // while the second column is used for the text controls. The space // between the rows and columns is set to 10.
var sizer1 = new wx.FlexGridSizer(2, 2, 10, 10);
// Add the labels and text controls to sizer1. A label is centered vertically. // A grid sizer is filled from left to right, top to bottom.
sizer1.add(new wx.StaticText(dlg, -1, "Username"), 0, wx.Alignment.CENTER_VERTICAL); sizer1.add(new wx.TextCtrl(dlg, -1, "
// Add this sizer to the sizer of the dialog. The flag argument is 0 // which means that this item is not allowed to grow in the main // direction (which is vertically). The item is centered. Above // (wx.Direction.TOP) and below (wx.Direction.BOTTOM) the item, // a border is created with a size of 10.
dlg.sizer.add(sizer1, 0, wx.Alignment.CENTER | wx.Direction.TOP | wx.Direction.BOTTOM, 10);
// Create a new wxBoxSizer and assign it to sizer1. The main direction // of this sizer is horizontally. This means that when an item is added
485 wx
// it will be shown on the same row.
sizer1 = new wx.BoxSizer(wx.Orientation.HORIZONTAL);
// Add the Ok button to the sizer and make sure that it has a right // border of size 10. // This way there's a space between the ok button and the cancel button.
sizer1.add(new wx.Button(dlg, wx.Id.OK, "Ok"), 0, wx.Direction.RIGHT, 10);
// Add the Cancel button to the sizer.
sizer1.add(new wx.Button(dlg, wx.Id.CANCEL, "Cancel"));
// Add the sizer to the sizer of the dialog. The item is centered.
dlg.sizer.add(sizer1, 0, wx.Alignment.CENTER);
// Before showing the dialog, set the autoLayout property to true and // call layout to layout the controls. When the dialog is resized, the // controls will be automatically resized.
dlg.autoLayout = true; dlg.layout(); dlg.showModal(); return false; }
Properties minSize
wx.Size minSize ;
Get/Set the minimal size of the sizer. position
wx.Point position ;
Gets the position of the sizer. size
wx.Size size ;
Gets the current size of the sizer. children
486 wx
Array children ;
Returns the list of the items in this sizer. See wx.SizerItem. containingWindow
wx.Window containingWindow ;
Returns the window this sizer is used in or null if none Methods add
wx.SizerItem add(wx.Window Window, wx.SizerFlags Flags);
wx.SizerItem add(wx.Window Window, Integer Option= 0, Integer Flag= 0, Integer Border= 0);
add(wx.Sizer Sizer, Integer Option= 0, Integer Flag= 0, Integer Border= 0);
add(Integer Width, Integer Height, Integer Option= 0, Integer Flag= 0, Integer Border= 0);
Adds a window, another sizer or a spacer to the sizer. addSpacer
wx.SizerItem addSpacer(Integer Size);
Adds non-stretchable space to the sizer. addStretchSpacer
wx.SizerItem addStretchSpacer(Integer Prop= 1);
Adds stretchable space to the sizer. calcMin
487 wx
wx.Size calcMin(); clear
clear(Boolean Delete= Boolean);
Detaches all children from the sizer. If Delete is true then child windows will also be deleted. detach
Boolean detach(wx.Window Window);
Boolean detach(wx.Sizer Sizer);
Boolean detach(int Window);
Detach a child from the sizer without destroying it. window is the window to be detached, sizer is the equivalent sizer and index is the position of the child in the sizer, typically 0 for the first item. This method does not cause any layout or resizing to take place, call layout to update the layout 'on screen' after detaching a child from the sizer. Returns true if the child item was found and detached, false otherwise. fit
wx.Size fit(wx.Window Window);
Tell the sizer to resize the window to match the sizer's minimal size. fitInside
fitInside(wx.Window Window);
Tell the sizer to resize the virtual size of the window to match the sizer's minimal size. This will not alter the on screen size of the window, but may cause the addition/removal/alteration of scrollbars required to view the virtual area in windows which manage it. hide
Boolean hide(wx.Window Window, Boolean Recursive= false);
Boolean hide(wx.Sizer Sizer, Boolean Recursive= false);
Boolean hide(int Window);
Hides the window, sizer, or item at index. To make a sizer item disappear, use hide followed by layout. Use parameter recursive to hide elements found in subsizers.
488 wx insert
wx.SizerItem insert(Integer Index, wx.Window Window, wx.SizerFlags Flags);
wx.SizerItem insert(Integer Index, wx.Window Window, Integer Option= 0, Integer Flag= 0, Integer Border= 0);
insert(Integer Index, wx.Sizer Sizer, Integer Option= 0, Integer Flag= 0, Integer Border= 0);
insert(Integer Index, Integer Width, Integer Height, Integer Option= 0, Integer Flag= 0, Integer Border= 0);
Insert a child into the sizer before any existing item at index. insertSpacer
wx.SizerItem insertSpacer(Integer Index, Integer Size);
Inserts non-stretchable space to the sizer. insertStretchSpacer
wx.SizerItem insertStretchSpacer(Integer Index, Integer Size);
Inserts stretchable space to the sizer. isShown
Boolean isShown(wx.Window Window);
Boolean isShown(wx.Sizer Sizer);
Boolean isShown(int Window);
489 wx
Returns true if the window, sizer, or item at index is shown. getItem
wx.SizerItem getItem(wx.Window Window, Boolean Recursive= false);
wx.SizerItem getItem(wx.Sizer Sizer, Boolean Recursive= false);
wx.SizerItem getItem(int Window);
Finds item of the sizer which holds given window, sizer or is located in sizer at position index. Use parameter recursive to search in subsizers too. layout
layout();
Call this to force layout of the children. prepend
prepend(wx.Window Window, wx.SizerFlags Flags);
prepend(wx.Window Window, Integer Option= 0, Integer Flag= 0, Integer Border= 0);
prepend(wx.Sizer Sizer, wx.SizerFlags Flags);
prepend(wx.Sizer Sizer, Integer Option= 0, Integer Flag= 0, Integer Border= 0);
prepend(Integer Width, Integer Height, Integer Option= 0, Integer Flag= 0, Integer Border= 0);
Prepends a window, another sizer or a spacer to the beginning of the list of items owned by this sizer. See add.
490 wx prependSpacer
wx.SizerItem prependSpacer(Integer Size);
Prepends non-stretchable space to the sizer. prependStretchSpacer
wx.SizerItem prependStretchSpacer(Integer Prop= 1);
Prepends stretchable space to the sizer. remove
Boolean remove(Integer Index);
remove(wx.Sizer Sizer);
Removes the item from the sizer. Call layout to update the screen. replace
Boolean replace(Integer OldIndex, wx.SizerItem Item);
Boolean replace(wx.Sizer OldSizer, wx.Sizer NewSizer, Boolean Recursive= false);
Boolean replace(wx.Window OldWindow, wx.Window NewWindow, Boolean Recursive= false);
Removes the item from the sizer. Call layout to update the screen. setDimension
setDimension(Integer x, Integer y, Integer width, Integer height);
Call this to force the sizer to take the given dimension and thus force the items owned by the sizer to resize themselves according to the rules defined by the parameters in the add and prepend methods. setMinSize
setMinSize(Integer Width,
491 wx
Integer Height);
Sets the minimal size of the sizer. See minSize. setItemMinSize
setItemMinSize(wx.Window Window, Integer Width, Integer Height);
setItemMinSize(wxSizer Sizer, Integer Width, Integer Height);
setItemMinSize(Integer Item, Integer Width, Integer Height);
Sets an item minimal size. setSizeHints
setSizeHints(wx.Window Window);
This method first calls fit and then setSizeHints on the window passed to it. This only makes sense when window is actually a wx.TopLevelWindow such as a wx.Frame or a wx.Dialog, since setSizeHints only has any effect in these classes. It does nothing in normal windows or controls. setVirtualSizeHints
setVirtualSizeHints(wx.Window Window);
Tell the sizer to set the minimal size of the window virtual area to match the sizer's minimal size. For windows with managed scrollbars this will set them appropriately. show
show(Boolean Show);
Boolean show(wx.Window Window, Boolean Show= true, Boolean Recursive= false);
Boolean show(wx.Sizer Window, Boolean Show= true, Boolean Recursive= false);
Boolean show(int Window,
492 wx
Boolean Show= true);
Hides the window, sizer, or item at index. To make a sizer item disappear, use hide followed by layout. Use parameter recursive to hide elements found in subsizers.
493 wx
Name wx.SizerFlags
Normally, when you add an item to a sizer via add, you have to specify a lot of flags and parameters which can be unwieldy. This is where SizerFlags comes in: it allows you to specify all parameters using the named methods instead. For example, instead of
sizer.add(ctrl, 0, wx.Stretch.EXPAND, 10);
you can now write
sizer.add(ctrl, wx.SizerFlags().expand().border(10));
This is more readable and also allows you to create wxSizerFlags objects which can be reused for several sizer items.
wx.SizerFlags flagsExpand = new wx.SizerFlags(1); flagsExpand.Expand().Border(10);
sizer.add(ctrl1, flagsExpand); sizer.add(ctrl2, flagsExpand);
Note that by specification, all methods of SizerFlags return the SizerFlags object itself to allowing chaining multiple methods calls like in the examples above. Constructor
SizerFlags(Integer Proportion= 0);
Creates the SizerFlags with the proportion. The constructor can also be called without the 'new' keyword. Methods align
wx.SizerFlags align(Integer Align= 0);
Sets the alignment of this wxSizerFlags. See wx.Alignment border
wx.SizerFlags border(Integer Direction= wx.Direction.ALL);
wx.SizerFlags border(Integer Direction,
494 wx
Integer BorderInPixels);
Sets the SizerFlags to have a border of a number of pixels specified by BorderInPixels with the directions specified by Direction. See wx.Direction center
wx.SizerFlags center();
Sets the object of the wxSizerFlags to center itself in the area it is given. doubleBorder
wx.SizerFlags doubleBorder(Integer Direction= wxDirection.ALL);
Sets the border in the given direction having twice the default border size. See wx.Direction doubleHorzBorder
wx.SizerFlags doubleHorzBorder();
Sets the border in left and right directions having twice the default border size. expand
wx.SizerFlags expand();
Sets the object of the wxSizerFlags to expand to fill as much area as it can. left
wx.SizerFlags left();
Aligns the object to the left, shortcut for 'align(wx.Alignment.LEFT)' fixedMinSize
wx.SizerFlags fixedMinSize();
Set the wx.Stretch.FIXED_MINSIZE flag which indicates that the initial size of the window should be also set as its minimal size. proportion
wx.SizerFlags proportion(Integer Proportion= 0);
Sets the proportion of this wxSizerFlags. right
495 wx
wx.SizerFlags right();
Aligns the object to the right, shortcut for 'align(wx.Alignment.RIGHT)' shaped
wx.SizerFlags shaped();
Set the wx.Stretch.SHAPED which indicates that the elements should always keep the fixed width to height ratio equal to its original value. tripleBorder
wx.SizerFlags tripleBorder(Integer Direction= wx.Direction.ALL);
Sets the border in the given direction having thrice the default border size.
496 wx
Name wx.SizerItem — The SizerItem class is used to track the position, size and other attributes of each item managed by a wx.Sizer.
It is not usually necessary to use this class because the sizer elements can also be identified by their positions or window or sizer pointers but sometimes it may be more convenient to use it directly. Properties border
Integer border ; flag
Integer flag ; minSize
wx.Size minSize ; position
wx.Point position ; proportion
Integer proportion ; ratio
Integer ratio ; rect
wx.Rect rect ; size
wx.Size size ; sizer
wx.Sizer sizer ;
497 wx spacer
wx.Size spacer ; window
wx.Window window ; Methods calcMin
calcMin();
Calculates the minimum desired size for the item, including any space needed by borders. show
show(Boolean Show);
Set the show item attribute, which sizers use to determine if the item is to be made part of the layout or not. If the item is tracking a window then it is shown or hidden as needed.
498 wx
Name wx.Slider — A slider is a control with a handle which can be pulled back and forth to change the value.
Prototype: wx.Control
In Windows versions below Windows 95, a scrollbar is used to simulate the slider. In Windows 95, the track bar control is used. See also wx.ScrollEvent. Constants
Table 16.61. Constants of wx.Slider
Name Description AUTOTICKS Displays tick marks. HORIZONTAL Displays the slider horizontally. LABELS Displays minimum, maximum and value labels. (NB: only displays the current value label under wxGTK) LEFT Displays ticks on the left, if a vertical slider. RIGHT Displays ticks on the right, if a vertical slider. SELRANGE Allows the user to select a range on the slider. Windows 95 only. TOP Displays ticks on the top, if a horizontal slider. VERTICAL Displays the slider vertically. Constructor
Slider();
Slider(wx.Window Parent, Integer Id, Integer Value, Integer Min, Integer Max, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wxS.lider.HORIZONTAL, wx.Validator Validator= null);
Constructs a new Slider object. Properties lineSize
Integer lineSize ;
499 wx
Get/Set the line size max
Integer max ;
Get/Set the maximum value min
Integer min ;
Get/Set the minimum value pageSize
Integer pageSize ;
Get/Set the pagesize selEnd
Integer selEnd ;
Get the end selection point selStart
Integer selStart ;
Get the start selection point value
Integer value ;
Get/Set the current value Methods create
create(wx.Window Parent, Integer Id, Integer Value, Integer Min, Integer Max, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize,
500 wx
Integer Style= wxSlider.HORIZONTAL, wx.Validator Validator= null);
Constructs a new Slider object. clearSel
clearSel();
Clears the selection, for a slider with the SELRANGE style. clearTicks
clearTicks();
Clears the ticks. setRange
setRange(Integer Min, Integer Max);
Sets the minimum and maximum slider values. setSelection
setSelection(Integer Start, Integer End);
Sets the selection setTickFreq
setTickFreq(Integer Freq, Integer Pos);
Sets the tick mark frequency and position. Events onScrollChanged Event is triggered when scrolling/ moving has finished independently of the way it had started. The argument of the function is a wx.ScrollEvent. onScrollTop Catch a command to put the scroll thumb at the maximum position. The argument of the function is a wx.ScrollEvent. onScrollBottom Catch a command to put the scroll thumb at the maximum position. The argument of the function is a wx.ScrollEvent.
501 wx onScrollLineUp Catch a line up command. The argument of the function is a wx.ScrollEvent. onScrollLineDown Catch a line down command. The argument of the function is a wx.ScrollEvent. onScrollPageUp Catch a page up command. The argument of the function is a wx.ScrollEvent. onScrollPageDown Catch a page down command. The argument of the function is a wx.ScrollEvent. onScrollThumbTrack Catch a thumbtrack command (continuous movement of the scroll thumb). The argument of the function is a wx.ScrollEvent. onScrollThumbRelease Catch a thumbtrack release command. The argument of the function is a wx.ScrollEvent.
502 wx
Name wx.SpinButton — A SpinButton has two small up and down (or left and right) arrow buttons.
Prototype: wx.Control
It is often used next to a text control for increment and decrementing a value. Portable programs should try to use wx.SpinCtrl instead as SpinButton is not implemented for all platforms but wx.SpinCtrl is as it degenerates to a simple wx.TextCtrl on such platforms. Constants
Table 16.62. Constants of wx.SpinButton
Name Description ARROW_KEYS HORIZONTAL VERTICAL WRAP Constructor
SpinButton();
SpinButton(wx.Window parent, Integer id, wx.Point pos= wx.DefaultPosition, wx.Size size= wx.DefaultSize, Integer style= wx.SpinButton.ARROW_KEYS);
Create a SpinButton Properties value
String value ;
The value of the spin control. min
Integer min ;
Gets minimal allowable value. max
503 wx
Integer max ;
Gets maximal allowable value. Methods create
Boolean create(wx.Window parent, Integer id, wx.Point pos= wx.DefaultPosition, wx.Size size= wx.DefaultSize, Integer style= wx.SpinButton.HORIZONTAL);
Create a SpinButton setRange
setRange(Integer Min, Integer Max);
Sets range of allowable values. Events onSpin Generated whenever an arrow is pressed. A wx.SpinEvent is passed as argument. onSpinUp Generated when left/up arrow is pressed. A wx.SpinEvent is passed as argument. onSpinDown Generated when right/down arrow is pressed. A wx.SpinEvent is passed as argument.
504 wx
Name wx.SpinCtrl — SpinCtrl combines wx.TextCtrl and wx.SpinButton in one control.
Prototype: wx.Control Constants
Table 16.63. Constants of wx.SpinCtrl
Name Description ARROW_KEYS WRAP
Constructor
SpinCtrl();
SpinCtrl(wx.Window parent, Integer id= -1, String value= "", wx.Point pos= wx.DefaultPosition, wx.Size size= wx.DefaultSize, Integer style= wx.SpinCtrl.ARROW_KEYS, Integer min= 0, Integer max= 100, Integer initial= 0);
Create a SpinCtrl Properties value
String value ;
The value of the spin control. min
Integer min ;
Gets minimal allowable value. max
Integer max ;
505 wx
Gets maximal allowable value. Methods create
Boolean create(wx.Window parent, Integer id= -1, String value= "", wx.Point pos= wx.DefaultPosition, wx.Size size= wx.DefaultSize, Integer style= wx.SpinCtrl.ARROW_KEYS, Integer min= 0, Integer max= 100, Integer initial= 0);
Creates a SpinCtrl setSelection
setSelection(Integer From, Integer To);
Select the text in the text part of the control between positions from (inclusive) and to (exclusive). This is similar to setSelection. setRange
setRange(Integer Min, Integer Max);
Sets range of allowable values. Events onText See onText onSpinCtrl Called whenever the numeric value of the spinctrl is updated. The method takes a wx.SpinEvent. onSpin Generated whenever an arrow is pressed. A wx.SpinEvent is passed as argument. onSpinUp Generated when left/up arrow is pressed. A wx.SpinEvent is passed as argument. onSpinDown Generated when right/down arrow is pressed. A wx.SpinEvent is passed as argument.
506 wx
Name wx.SpinEvent — This event class is used for the events generated by wx.SpinButton and wx.SpinCtrl.
Prototype: wx.NotifyEvent Properties position
Integer position ;
Get/Set the current spin button or control value.
507 wx
Name wx.SplitMode
Constants
Table 16.64. Constants of wx.SplitMode
Name Description HORIZONTAL VERTICAL
508 wx
Name wx.SplitterEvent — This class represents the events generated by a wx.SplitterWindow.
Prototype: wx.NotifyEvent Properties sashPosition
Integer sashPosition ;
Returns the new sash position. x
Integer x ;
Returns the x coordinate of the double-click point. y
Integer y ;
Returns the y coordinate of the double-click point. windowBeingRemoved
??? windowBeingRemoved ;
Returns the window being removed when a splitter window is unsplit.
509 wx
Name wx.SplitterWindow — This class manages up to two subwindows. The current view can be split into two programmatically, and unsplit either programmatically or via the wxSplitterWindow user interface.
Prototype: wx.Window
The following example shows a frame that contains a wx.TreeCtrl and a wx.ListCtrl. The frame is splitted horizontally.
var wx = require("wx"); wx.TheApp.onInit = function() { var frame = new wx.Frame(null, -1, "SplitterWindow Example"); var split = new wx.SplitterWindow(frame, -1); var tree = new wx.TreeCtrl(split, -1); var list = new wx.ListCtrl(split, -1);
split.splitHorizontally(tree, list);
topWindow = frame; frame.show();
return true; };
Constants
Table 16.65. Constants of wx.SplitterWindow
Name Description BORDER Draws a thin black border around the window. FULLSASH Draws the ends of the sash (so the window can be used without a border). LIVE_UPDATE Don't draw XOR line but resize the child windows immediately. NOBORDER No border, and a black sash. PERMIT_UNSPLIT Always allow to unsplit, even with the minimum pane size other than zero. THREED Draws a 3D effect border and sash. THREED_BORDER Draws a 3D effect border. THREED_SASH Draws a 3D effect sash.
Constructor
SplitterWindow();
510 wx
SplitterWindow(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.SplitterWindow.3D);
Constructs a new SplitterWindow object. Properties minimumPaneSize
Integer minimumPaneSize ;
Get/Set the minimum pane size. sashPosition
Integer sashPosition ;
Get/Set the sash position in pixels. When set the panes, sash and border are redrawn. See setSashPosition. splitMode
Integer splitMode ;
Get/Set the split mode. window1
wx.Window window1 ;
Returns the left/top or only pane. window2
wx.Window window2 ;
Returns the right/bottom or only pane. isSplit
Boolean isSplit ;
Returns true when the window is split. Methods create
511 wx
Boolean create(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.SplitterWindow.3D);
Creates a new SplitterWindow object. setSashPosition
setSashPosition(Integer Pos, Boolean Redraw= true);
Sets the sash position. initialize
initialize(wx.Window Window);
Initializes the splitter window to have one pane. This should be called if you wish to initially view only a single pane in the splitter window. replaceWindow
Boolean replaceWindow(wx.Window OldWindow, wx.Window NewWindow);
This function replaces one of the windows managed by the SplitterWindow with another one. It is in general better to use it instead of calling unsplit and then resplitting the window back because it will provoke much less flicker (if any). It is valid to call this function whether the splitter has two windows or only one.
OldWindow must specify one of the windows managed by the splitter. If the parameters are incorrect or the window couldn't be replaced, false is returned. Otherwise the function will return true, but please notice that it will not destroy the replaced window and you may wish to do it yourself. splitHorizontally
splitHorizontally(wx.Window TopWin, wx.Window BottomWin, Integer SashPos= 0);
Initializes the top and bottom panes of the splitter window. This should be called if you wish to initially view two panes. It can also be called at any subsequent time, but the application should check that the window is not currently split using isSplit. splitVertically
splitVertically(wx.Window LeftWin, wx.Window RightWin, Integer SashPos= 0);
512 wx
Initializes the left and right panes of the splitter window. This should be called if you wish to initially view two panes. It can also be called at any subsequent time, but the application should check that the window is not currently split using isSplit. unsplit
unsplit( Window= null);
Unsplits the window. Events onSashPosChanging onSashPosChanged onUnsplit onDClick
513 wx
Name wx.StaticBox — A static box is a rectangle drawn around other panel items to denote a logical grouping of items.
Prototype: wx.Control Constructor
StaticBox();
StaticBox(wx.Window Parent, Integer Id, String Text, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Constructs a new StaticBox object Methods
Boolean (wx.Window Parent, Integer Id, String Text, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Creates a new StaticBox object
514 wx
Name wx.StaticBoxSizer — StaticBoxSizer is a sizer derived from wx.BoxSizer but adds a static box around the sizer.
Prototype: wx.BoxSizer Constructor
StaticBoxSizer(wx.StaticBox StaticBox, Integer Orientation);
Constructs a new StaticBoxSizer object. Properties staticBox
wx.StaticBox staticBox ;
The associated static box.
515 wx
Name wx.StaticText — A static text control displays one or more lines of read-only text.
Prototype: wx.Control Constants
Table 16.66. Constants of wx.StaticText
Name Description ALIGN_CENTER ALIGN_LEFT ALIGN_RIGHT NO_AUTORESIZE
Constructor
StaticText();
StaticText(wx.Window Parent, Integer Id, String Text, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Constructs a new StaticText object Properties label
String label ;
Get/Sets the text. Methods create
Boolean create(wx.Window Parent, Integer Id, String Text, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
516 wx
Creates a new StaticText object wrap
wrap(Integer Width);
This functions wraps the controls label so that each of its lines becomes at most width pixels wide if possible (the lines are broken at words boundaries so it might not be the case if words are too long). If width is negative, no wrapping is done.
517 wx
Name wx.StatusBar — A status bar is a narrow window that can be placed along the bottom of a frame to give small amounts of status information. It can contain one or more fields, one or more of which can be variable length according to the size of the window
The example shows a frame with a statusbar that contains a wx.BitmapButton.class. When you click the button the bitmap is changed.
var wx = require("wx"); wx.TheApp.onInit = init;
function init() { wx.Image.addHandler(new wx.GIFHandler());
var frame = new wx.Frame(null, -1, "A Statusbar Example");
var statusbar = frame.createStatusBar(2); statusbar.bitmapOn = new wx.Bitmap("green.gif", wx.BitmapType.GIF); statusbar.bitmapOff = new wx.Bitmap("red.gif", wx.BitmapType.GIF); statusbar.sw = true;
statusbar.button = new wx.BitmapButton(statusbar, 1, statusbar.bitmapOn); statusbar.button.onClicked = switched;
frame.visible = true; topWindow = frame;
return true; }
function switched() { sw = ! sw; if ( sw ) bitmapLabel = bitmapOn; else bitmapLabel = bitmapOff;
refresh(); }
Constants
Table 16.67. Constants of wx.StatusBar
Name Description SIZEGRIP
518 wx
Constructor
StatusBar();
StatusBar(wx.Window Parent, Integer Id, Integer Style= wx.StatusBar.SIZEGRIP);
Constructs a new StatusBar object. Properties fieldsCount
Integer fieldsCount ;
Get/Set the number of fields in the statusbar. See also setFieldsCount statusWidths
Array statusWidths ;
Get/Set the width for each field. At least one element must be -1 (meaning variable width). See also setStatusWidths Methods create
Boolean create(wx.Window Parent, Integer Id, Integer Style= wx.StatusBar.SIZEGRIP);
Constructs a new StatusBar object. getFieldRect
wx.Rect getFieldRect(Integer Field);
Returns the size and position of a field's internal bounding rectangle getStatusText
String getStatusText(Integer Field= 0);
Gets the status text of the given field setFieldsCount
519 wx
setFieldsCount(Integer Count, Array Widths= null);
Sets the number of fields, and optionally the field widths. setStatusText
setStatusText(String Text, Integer Field= 0);
Sets the text of the field.
520 wx
Name wx.Stretch
Constants
Table 16.68. Constants of wx.Stretch
Name Description EXPAND FIXED_MINSIZE GROW NOT SHAPED SHRINK TILE
521 wx
Name wx.SysColourChangedEvent — An event being sent when a system colour is changed.
Prototype: wx.Event
See wx.Panel.
522 wx
Name wx.SystemSettings — SystemSettings allows the application to ask for details about the system.
This can include settings such as standard colours, fonts, and user interface element sizes. Constants
Table 16.69. Constants of wx.SystemSettings
Name Description ANSI_FIXED_FONT Windows fixed-pitch font. ANSI_VAR_FONT Windows variable-pitch (proportional) font. BORDER_X Width of single border. BORDER_Y Height of single border. CAPTION_Y Height of normal caption area. COLOUR_3DDKSHADOW Dark shadow for three-dimensional display elements. COLOUR_3DFACE Same as COLOUR_BTNFACE. COLOUR_3DHIGHLIGHT Same as COLOUR_BTNHIGHLIGHT. COLOUR_3DHILIGHT Same as COLOUR_BTNHIGHLIGHT. COLOUR_3DLIGHT Light colour for three-dimensional display elements. COLOUR_3DSHADOW Same as COLOUR_BTNSHADOW. COLOUR_ACTIVEBORDER Active window border. COLOUR_ACTIVECAPTION Active window caption. COLOUR_APPWORKSPACE Background colour MDI applications. COLOUR_BACKGROUND The desktop colour. COLOUR_BTNFACE Face shading on push buttons. COLOUR_BTNHIGHLIGHT Highlight colour for buttons (same as constant name="COLOUR_3DHILIGHT). COLOUR_BTNHILIGHT Same as COLOUR_BTNHIGHLIGHT. COLOUR_BTNSHADOW Edge shading on push buttons. COLOUR_BTNTEXT Text on push buttons. COLOUR_CAPTIONTEXT Text in caption, size box and scrollbar arrow box. COLOUR_DESKTOP Same as COLOUR_BACKGROUND. COLOUR_GRAYTEXT Greyed (disabled) text. COLOUR_HIGHLIGHT Item(s) selected in a control. COLOUR_HIGHLIGHTTEXT Text of item(s) selected in a control. COLOUR_INACTIVEBORDER Inactive window border. COLOUR_INACTIVECAPTION Inactive window caption. COLOUR_INACTIVECAPTIONTEXT Colour of text in active captions.
523 wx
Name Description COLOUR_INFOBK Background colour for tooltip controls. COLOUR_INFOTEXT Text colour for tooltip controls. COLOUR_MENU Menu background. COLOUR_MENUTEXT Menu text. COLOUR_SCROLLBAR The scrollbar grey area. COLOUR_WINDOW Window background. COLOUR_WINDOWFRAME Window frame. COLOUR_WINDOWTEXT Text in windows. CURSOR_X Width of cursor. CURSOR_Y Height of cursor. DCLICK_X Width in pixels of rectangle within which two successive mouse clicks must fall to generate a double-click. DCLICK_Y Height in pixels of rectangle within which two successive mouse clicks must fall to generate a double-click. DEFAULT_GUI_FONT Default font for user interface objects such as menus and dialog boxes. Note that with modern GUIs nothing guarantees that the same font is used for all GUI elements, so some controls might use a different font by default. DEVICE_DEFAULT_FONT Device-dependent font (Windows NT only). DRAG_X Width in pixels of a rectangle centered on a drag point to allow for limited movement of the mouse pointer before a drag operation begins. DRAG_Y Height in pixels of a rectangle centered on a drag point to allow for limited movement of the mouse pointer before a drag operation begins. EDGE_X Width of a 3D border, in pixels. EDGE_Y Height of a 3D border, in pixels. FRAMESIZE_X Width of the window frame for a wxTHICK_FRAME window. FRAMESIZE_Y Height of the window frame for a wxTHICK_FRAME window. HSCROLL_ARROW_X Width of arrow bitmap on horizontal scrollbar. HSCROLL_ARROW_Y Height of arrow bitmap on horizontal scrollbar. HSCROLL_Y Height of horizontal scrollbar in pixels. HTHUMB_X Width of horizontal scrollbar thumb. ICONSPACING_X Width of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of this size when arranged.
524 wx
Name Description ICONSPACING_Y Height of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of this size when arranged. ICON_X The default width of an icon. ICON_Y The default height of an icon. MENU_Y Height of single-line menu bar. MOUSE_BUTTONS Number of buttons on mouse, or zero if no mouse was installed. NETWORK_PRESENT 1 if there is a network present, 0 otherwise. OEM_FIXED_FONT Original equipment manufacturer dependent fixed- pitch font. PENWINDOWS_PRESENT 1 if PenWindows is installed, 0 otherwise. SCREEN_X Width of the screen in pixels. SCREEN_Y Height of the screen in pixels. SHOW_SOUNDS Non-zero if the user requires an application to present information visually in situations where it would otherwise present the information only in audible form; zero otherwise. SMALLICON_X Recommended width of a small icon (in window captions, and small icon view). SMALLICON_Y Recommended height of a small icon (in window captions, and small icon view). SWAP_BUTTONS Non-zero if the meanings of the left and right mouse buttons are swapped; zero otherwise. SYSTEM_FONT System font. VSCROLL_ARROW_X Width of arrow bitmap on a vertical scrollbar. VSCROLL_ARROW_Y Height of arrow bitmap on a vertical scrollbar. VSCROLL_X Width of vertical scrollbar in pixels. VTHUMB_Y Height of vertical scrollbar thumb. WINDOWMIN_X Minimum width of a window. WINDOWMIN_Y Minimum height of a window. Class Properties screenType
Integer screenType ; Class Methods getColour
wx.Colour getColour(Integer Index);
525 wx
Returns a system colour. getFont
wx.Font getFont(Integer Index);
Returns a system font. getMetric
Integer getMetric(Integer Index, wx.Window Win= null);
Returns the value of a system metric, or -1 if the metric is not supported on the current system. Specifying the win parameter is encouraged, because some metrics on some ports are not supported without one, or they might be capable of reporting better values if given one. If a window does not make sense for a metric, one should still be given, as for example it might determine which displays cursor width is requested with SystemSettings.CURSOR_X
526 wx
Name wx.TextCtrl — A text control allows text to be displayed and edited. It may be single line or multi-line.
Prototype: wx.Control Constants
Table 16.70. Constants of wx.TextCtrl
Name Description MULTILINE PASSWORD PROCESS_ENTER PROCESS_TAB READONLY RICH Constructor
TextCtrl();
TextCtrl(wx.Window Parent, Integer Id, String Text, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, wx.Validator Validator= null);
Constructs a new TextCtrl object Properties canCopy
Boolean canCopy ;
Returns true if the selection can be copied to the clipboard. canCut
Boolean canCut ;
Returns true when the selection can be cut to the clipboard. canPaste
527 wx
Boolean canPaste ;
Returns true when the contents of clipboard can be pasted into the text control. canRedo
Boolean canRedo ;
Returns true if there is a redo facility available and the last operation can be redone. canUndo
Boolean canUndo ;
Returns true if there is an undo facility available and the last operation can be undone. insertionPoint
Integer insertionPoint ;
Get/Sets the insertion point numberOfLines
Integer numberOfLines ;
Get the number of lines value
String value ;
Get/Set the text modified
Boolean modified ;
Returns true when the text is changed lastPosition
Integer lastPosition ;
Get the position of the last character in the text control editable
Boolean editable ;
528 wx
Enables/Disables the text control multiLine
Boolean multiLine ;
Returns true if this is a multi line edit control and false otherwise. singleLine
Boolean singleLine ;
Returns true if this is a single line edit control and false otherwise. empty
Boolean empty ;
Returns true if the control is currently empty. Methods appendText
appendText(String Text);
Appends the text to the text of the control. clear
clear();
Removes the text. cut
cut();
Removes the selected text and copies it to the clipboard. discardEdits
discardEdits();
Resets the modified flag getLineLength
529 wx
Integer getLineLength(Integer Line);
Returns the length of the given line getLineText
String getLineText(Integer Line);
Returns the text of the given line setSelection
setSelection(Integer From= 0, Integer To);
Selects the text between From and To. loadFile
loadFile(String File);
Loads a file into the text control paste
paste();
Pastes the content of the clipboard in the selection of the text control. redo
redo();
Tries to redo the last operation replace
replace(Integer From, Integer To, String Text);
Replaces the text between From and To with the new text remove
remove(Integer From, Integer To);
Removes the text between From and To.
530 wx saveFile
Boolean saveFile(String File);
Saves the content of the text control to the given file setMaxLength
setMaxLength(Integer Max);
This function sets the maximum number of characters the user can enter into the control. If len is 0, the previously set max length limit, if any, is discarded and the user may enter as much text as the underlying native text control widget supports (typically at least 32Kb). Events onText Triggered when the text is changed. The argument of the function is wx.CommandEvent onTextEnter Triggered when the enter key is pressed in a single-line text control. The argument of the function is wx.CommandEvent onTextURL A mouse event occurred over an URL in the text control (wxMSW and wxGTK2 only) onTextMaxLen User tried to enter more text into the control than the limit set by setMaxLength
531 wx
Name wx.TextEntryDialog
Prototype: wx.Dialog Constructor
TextEntryDialog(wx.Window Parent, String Message, String Title, String DefaultValue, wx.Point Position= wx.DefaultPosition, Integer Style= wx.Id.OK + wx.Id.CANCEL);
Constructs a new TextEntryDialog object. Properties value
String value ;
The value entered in the dialog
532 wx
Name wx.TextValidator — TextValidator validates text controls, providing a variety of filtering behaviours.
Prototype: wx.Validator
The following example shows a dialog with a textfield. It's only allowed to enter numeric characters. The textfield is initialised using the validator.
var wx = require("wx"); function init() { var dlg = new wx.Dialog(null, -1); var txtField = new wx.TextCtrl(dlg, -1);
txtField.validator = new wx.TextValidator(wx.Filter.NUMERIC, "10");
dlg.fit(); dlg.showModal();
wx.MessageBox("You have entered: " + txtField.value);
return false; }
wx.TheApp.onInit = init;
Constructor
TextValidator(Integer Style= wx.Filter.NONE, String Value= "");
Constructs a new TextValidator object. Properties excludes
Array excludes ;
Get/Set an array of invalid values. includes
Array includes ;
Get/Set an array of valid values.
533 wx style
Integer style ;
Get/Set the filter style. See wx.Filter value
String value ;
Get the value entered in the textfield.
534 wx
Name wx.TIFFHandler — Image handler for bitmaps.
Prototype: wx.ImageHandler
535 wx
Name wx.ToolBar — A toolbar.
Prototype: wx.Control
Event handling is done as follows: When the tool has a function set as onTool, then that function will be executed. When a menu exists with the same id of the selected tool, the menu action is executed. When there is no menu, the action associated with the toolbar is executed. See actions and actions. See also createToolBar Constants
Table 16.71. Constants of wx.ToolBar
Name Description 3DBUTTONS Gives wxToolBarSimple a mild 3D look to its buttons. DOCKABLE Makes the toolbar floatable and dockable. GTK only. FLAT Gives the toolbar a flat look ('coolbar' or 'flatbar' style). Windows 95 and GTK 1.2 only. HORIZONTAL Specifies horizontal layout. NOALIGN Specifies no alignment with the parent window. Windows only. NODIVIDER Specifies no divider above the toolbar; by default it is shown. Windows only. NOICONS Specifies no icons in the toolbar buttons; by default they are shown. TEXT Show the text in the toolbar buttons; by default only icons are shown. VERTICAL Specifies vertical layout (not available for the GTK and Windows 95 toolbar).
Constructor
ToolBar();
ToolBar(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size, Integer Style= wx.ToolBar.HORIZONTAL | wx.ToolBar.NO_BORDER);
Constructs a new ToolBar object.
536 wx
Properties actions
Array actions ;
An array containing the function callbacks. A function will be called when a tool is selected. Use the id as index of the array. margins
wx.Size margins ;
Gets/Sets the left/right and top/bottom margins, which are also used for inter-toolspacing. toolBitmapSize
wx.Size toolBitmapSize ;
Gets/Sets the size of bitmap that the toolbar expects to have. The default bitmap size is 16 by 15 pixels. toolPacking
Integer toolPacking ;
Gets/Sets the value used for spacing tools. The default value is 1. The packing is used for spacing in the vertical direction if the toolbar is horizontal, and for spacing in the horizontal direction if the toolbar is vertical. toolSeparation
Integer toolSeparation ;
Gets/Sets the separator size. The default value is 5. toolSize
wx.Size toolSize ;
Gets the size of a whole button, which is usually larger than a tool bitmap because of added 3D effects. Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition,
537 wx
wx.Size Size, Integer Style= wx.ToolBar.HORIZONTAL | wx.ToolBar.NO_BORDER);
Creates a ToolBar object. addControl
addControl(wx.Control Control);
Adds a control to the toolbar. addSeparator
addSeparator();
Adds a separator for spacing groups of tools. addTool
wx.ToolBarTool addTool(Integer Id, String Label, wx.Bitmap Bitmap1, String ShortHelp= "", Integer Kind= wx.ItemKind.NORMAL);
addTool(Integer Id, String Label, wx.Bitmap Bitmap1, wx.Bitmap.class Bitmap2, Integer Kind= wx.ItemKind.NORMAL, String ShortHelp= "", String LongHelp= "");
Adds a tool to the toolbar. Kind may be wx.ItemKind.NORMAL for a normal button (default), wx.ItemKind.CHECK for a checkable tool (such tool stays pressed after it had been toggled) or wx.ItemKind.RADIO for a checkable tool which makes part of a radio group of tools each of which is automatically unchecked whenever another button in the group is checked. addCheckTool
wx.ToolBarTool addCheckTool(Integer Id, String Label, wx.Bitmap Bitmap1, wx.Bitmap Bitmap2, String ShortHelp= "", String LongHelp= "");
Adds a new check (or toggle) tool to the toolbar. addRadioTool
538 wx
addRadioTool(Integer Id, String Label, wx.Bitmap Bitmap1, wx.Bitmap Bitmap2, String ShortHelp= "", String LongHelp= "");
Adds a new radio tool to the toolbar. Consecutive radio tools form a radio group such that exactly one button in the group is pressed at any moment, in other words whenever a button in the group is pressed the previously pressed button is automatically released. You should avoid having the radio groups of only one element as it would be impossible for the user to use such button. By default, the first button in the radio group is initially pressed, the others are not. deleteTool
Boolean deleteTool(Integer Id);
Deletes the tool with the given id. deleteToolByPos
Boolean deleteToolByPos(Integer Pos);
Deletes the tool on the given position. enableTool
Boolean enableTool(Integer Id, Boolean Enable);
Enables/disables the tool with the given id. findControl
wx.Control findControl(Integer Id);
Returns the control identified by Id or null when not found. getToolEnabled
Boolean getToolEnabled(Integer Id);
Returns true when the tool with the given id is enabled. See enableTool getToolLongHelp
String getToolLongHelp(Integer Id);
Returns the long help from the tool with the given id.
539 wx getToolShortHelp
String getToolShortHelp(Integer Id);
Returns the short help from the tool with the given id. getToolState
getToolState(Integer Id);
Returns true when the tool with the given id is toggled on. insertControl
insertControl(Integer Pos, wx.Control Control);
Inserts the control into the toolbar at the given position. You must call realize for the change to take place. insertSeparator
insertSeparator(Integer Pos);
Inserts a separator into the toolbar at the given position. You must call realize for the change to take place. insertTool
wx.ToolBarTool insertTool(Integer Pos, Integer Id, String Label, wx.Bitmap Bitmap1, wx.Bitmap Bitmap2, Boolean Toogle= false, String ShortHelp= "", String LongHelp= "");
Inserts the tool to the toolbar at the given position. realize
Boolean realize();
Call this method after you have added tools. setToolLongHelp
setToolLongHelp(Integer Id, String Help);
540 wx
Sets the long help from the tool with the given id. setToolShortHelp
setToolShortHelp(Integer Id, String Help);
Sets the short help for the tool with the given id. The short help will be used to show a tooltip. toggleTool
toggleTool(Integer Id, Boolean Toggle);
Toggles a tool on or off. See getToolState.
541 wx
Name wx.ToolBarTool — A tool on a toolbar.
See wx.ToolBar. Properties onTool
Function onTool ;
The function to execute when the tool is clicked Methods enable
Boolean enable(Boolean Switch);
Enable/disable the tool toggle
Boolean toggle(Boolean Switch);
Toggle the tool
542 wx
Name wx.Toolbook — Toolbook is a class similar to wx.Notebook but which uses a wx.ToolBar to show the labels instead of the tabs.
Prototype: wx.BookCtrlBase Constructor
Toolbook();
Toolbook(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Constructs a new Toolbook. Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Creates a Toolbook. realize
realize();
Realize the toolbar and select the initial page. Events onPageChanged onPageChanging
543 wx
Name wx.ToolbookEvent — This object is passed to a function that is set to a wx.Toolbook event property.
Prototype: wx.BookCtrlBaseEvent
544 wx
Name wx.TopLevelWindow — TopLevelWindow is the prototype class for wx.Dialog and wx.Frame.
Prototype: wx.Window Properties fullScreen
Boolean fullScreen ;
Get/Set fullscreen mode icon
wx.Icon icon ;
Get/Set icon active
Boolean active ;
Is the window active? defaultItem
wx.Window defaultItem ; iconized
Boolean iconized ;
Get/Set iconized mode maximized
Boolean maximized ;
Get/Set maximized mode title
String title ;
Get/Set the title
545 wx
Methods showFullScreen
Boolean showFullScreen(Boolean Show, Integer Style== wx.FullScreen.ALL);
Shows the frame in full screen or restores the frame. See wx.FullScreen. setSizeHints
setSizeHints(Integer MinWidth= -1, Integer MinHeight= -1, Integer MaxWidth= -1, Integer MaxHeight= -1, Integer IncWidth= -1, Integer IncHeight= -1);
setSizeHints(wx.Size MinSize, wx.Size MaxSize, wx.Size IncSize);
Allows specification of minimum and maximum window sizes, and window size increments. If a pair of values is not set (or set to -1), the default values will be used. If this function is called, the user will not be able to size the window outside the given bounds.
The resizing increments are only significant under Motif or Xt.
546 wx
Name wx.Treebook — This class is an extension of the wx.Notebook class that allows a tree structured set of pages to be shown in a control.
Prototype: wx.BookCtrlBase
A classic example is a netscape preferences dialog that shows a tree of preference sections on the left and select section page on the right. Constructor
Treebook();
Treebook(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Constructs a new Treebook. Methods create
Boolean create(wx.Window Parent, Integer Id, wx.Point Pos= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= 0);
Creates a Treebook. addSubPage
Boolean addSubPage(wx.Window Win, String Caption, Boolean Select= false, Integer ImageId= -1);
Adds a new child-page to the last top-level page inserted. Useful when constructing 1 level tree structure. collapseNode
Boolean collapseNode(Integer Node);
Shortcut for expandNode(node, false)
547 wx expandNode
Boolean expandNode(Integer Node, Boolean Expand= true);
Expands or collapses the page node. Returns the previous state. May generate page changing events (if selected page is under the collapsed branch, then parent is autoselected). getPageParent
Integer getPageParent(Integer Node);
Get the parent page or -1 if this is a top level page. insertSubPage
Boolean insertSubPage(Integer Index, wx.Window Win, String Caption, Boolean Select= false, Integer Image= -1); isNodeExpanded
Boolean isNodeExpanded(Integer Node);
Gets the page node state -- node is expanded or collapsed. Events onPageChanged onPageChanging onPageCollapsed onNodeExpanded
548 wx
Name wx.TreebookEvent — This object is passed to a function that is set to a wx.Treebook event property.
Prototype: wx.BookCtrlBaseEvent
549 wx
Name wx.TreeCtrl — A tree control presents information as a hierarchy, with items that may be expanded to show further items. Items in a tree control are referenced by wx.TreeItemId handles
Prototype: wx.Control Constants
Table 16.72. Constants of wx.TreeCtrl Name Description AQUA_BUTTONS DEFAULT_STYLE EDIT_LABELS EXTENDED FULL_ROW_HIGHLIGHT HAS_BUTTONS HAS_VARIABLE_ROW_HEIGHT HIDE_ROOT LINES_AT_ROOT MAC_BUTTONS MULTIPLE NO_BUTTONS NO_LINES ROW_LINES SINGLE TWIST_BUTTONS Constructor
TreeCtrl();
TreeCtrl(wx.Window Parent, Integer Id, wx.Point Position= wx.DefaultPosition, wx.Size Size= wx.DefaultSize, Integer Style= wx.TreeCtrl.ICON, wx.Validator Validator);
Constructs a new TreeCtrl object. Properties count
550 wx
Integer count ;
Get the total number of items in the control. firstVisibleItem
wx.TreeItemId firstVisibleItem ;
Gets the first visible item. imageList
wx.ImageList imageList ;
Get/Set the normal image list. indent
Integer indent ;
Get/Set the indent. Indent is the number of pixels the children are indented relative to the parents position. Setting indent also redraws the control immediately. onCompareItems
Function onCompareItems ;
Set this to a function when you want to change the sort order of the items in the tree control. The function should return a negative, zero or positive value if the first item is less than, equal to or greater than the second one. The function gets two wx.TreeItemId objects as arguments. When not set, the items are sorted alphabetically. rootItem
wx.TreeItemId rootItem ;
Gets the root item. selection
wx.TreeItemId selection ;
Gets the selection. Use selections when the tree can have more then one selected item (MULTIPLE style). selections
Array selections ;
Gets all selected items (An array with wx.TreeItemId objects).
551 wx stateImageList
wx.ImageList stateImageList ;
Get/Set the state image list. Methods getItem
wx.TreeItem getItem(wx.TreeItemId Id);
Creates a wx.TreeItem from the given wx.TreeItemId. wx.TreeItem can be used to alter the item without always passing the id to the tree control. null is returned when the id is not valid. getItemText
String getItemText(wx.TreeItemId Id);
Gets the text of the given item. See also wx.TreeItem text property setItemText
setItemText(wx.TreeItemId Id, String Text);
Sets the text of the given item. The example changes the text of the root.
tree.setItemText(tree.rootItem, "root");
See wx.TreeItem text property getItemImage
Integer getItemImage(wx.TreeItemId Id, Integer Which);
Gets the specified item image. See wx.TreeItem getImage method setItemImage
setItemImage(wx.TreeItemId Id, Integer Image, Integer Which);
Sets the image for the given item. See wx.TreeItem setImage method getItemData
552 wx
Any getItemData(wx.TreeItemId Id);
Gets the associated object or value of the item. The item data can be any possible JavaScript type. See wx.TreeItem data property, setItemData setItemData
setItemData(wx.TreeItemId Id, Any Data);
Sets the associated data for the given item. You can use any type: Integer, Object, Boolean, ... The following example shows that you can use an object as item data.
var wx = require("wx"); dlg = new wx.Dialog(null, -1, "Tree example"); dlg.tree = new wx.TreeCtrl(dlg, 1);
var root = dlg.tree.addRoot("Root"); var id = dlg.tree.appendItem(root, "Child 1");
dlg.tree.setItemData(id, new Date()); id = dlg.tree.appendItem(root, "Child 2"); dlg.tree.setItemData(id, new Date()); id = dlg.tree.appendItem(root, "Child 3"); dlg.tree.setItemData(id, new Date());
See wx.TreeItem data property, getItemData getItemTextColour
wx.Colour getItemTextColour(wx.TreeItemId Id);
Gets the text colour of the item. See wx.TreeItem textColour property setItemTextColour
setItemTextColour(wx.TreeItemId Id, wx.Colour Colour);
Sets a new text colour for this item. The example sets red as the text colour of the root item.
tree.setItemTextColour(tree.rootItem, wxRED);
See wx.TreeItem textColour property getItemBackgroundColour
wx.Colour getItemBackgroundColour(wx.TreeItemId Id);
553 wx
Gets the background colour of the item. See wx.TreeItem backgroundColour property setItemBackgroundColour
setItemBackgroundColour(wx.TreeItemId Id, wx.Colour Colour);
Sets a new background colour for this item. The example sets the backgroundcolour of the root item to red.
tree.setItemBackgroundColour(tree.rootItem, wx.RED);
See wx.TreeItem backgroundColour property getItemFont
wx.Font getItemFont(wx.TreeItemId Id);
Gets the font of the item. See wx.TreeItem font property setItemFont
setItemFont(wx.TreeItemId Id, wx.Font Font);
Sets a new font for this item. See wx.TreeItem font property. setItemHasChildren
setItemHasChildren(wx.TreeItemId Id, Boolean Children= true);
Force appearance of the button next to the item. This is useful to allow the user to expand the items which don't have any children now, but instead adding them only when needed, thus minimizing memory usage and loading time. See wx.TreeItem hasChildren property isBold
Boolean isBold(wx.TreeItemId Id);
Returns true when the item text is in bold. See wx.TreeItem bold property setItemBold
setItemBold(wx.TreeItemId Id, Boolean Bold= true);
Makes item appear in bold font if bold parameter is true or resets it to the normal state. See wx.TreeItem bold property
554 wx setItemDropHighlight
setItemDropHighlight(wx.TreeItemId Id, Boolean Highlight= true);
The item will be shown with a drop highlight or not. isVisible
isVisible(wx.TreeItemId Id);
Returns true when the item is visible. See wx.TreeItem visible property isExpanded
Boolean isExpanded(wx.TreeItemId Id);
Returns true when the item is expanded. See wx.TreeItem expanded property isSelected
Boolean isSelected(wx.TreeItemId Id);
Returns true when the item is selected. See wx.TreeItem selected property getChildrenCount
Integer getChildrenCount(wx.TreeItemId Id, Boolean Recurse= true);
Returns the number of childrens of the item. If Recurse is true (the default), returns the total number of descendants, otherwise only one level of children is counted getItemParent
wx.TreeItemId getItemParent(wx.TreeItemId Id);
Returns the parent of the item. See wx.TreeItem parent property getFirstChild
wx.TreeItemId getFirstChild(wx.TreeItemId Id, Integer Cookie);
Returns the first child item. An invalid item is returned when there is no child item. For this enumeration function you must pass in a 'cookie' parameter which is opaque for the application but is necessary for the library to make these functions reentrant (i.e. allow more than one enumeration on one and the same object simultaneously). The cookie passed to getFirstChild and getNextChild should be the same variable. See wx.TreeItem getFirstChild method
555 wx getNextChild
wx.TreeItemId getNextChild(wx.TreeItemId Id, Integer Cookie);
Returns the next child item. An invalid item is returned when there is no child item. See wx.TreeItem getNextChild method getPrevSibling
wx.TreeItemId getPrevSibling(wx.TreeItemId Id);
Returns the previous sibling item. An invalid item is returned when there is no child item. See wx.TreeItem prevSibling property getNextSibling
wx.TreeItemId getNextSibling(wx.TreeItemId Id);
Returns the next sibling item. An invalid item is returned when there is no child item. See wx.TreeItem nextSibling property getPrevVisible
wx.TreeItemId getPrevVisible(wx.TreeItemId Id);
Returns the previous visible item. getNextVisible
wx.TreeItemId getNextVisible(wx.TreeItemId Id);
Returns the next visible item. The item itself must also be visible. See wx.TreeItem nextSibling property addRoot
wx.TreeItemId addRoot(String Text, Integer Image= -1, Integer SelectedImage= -1, Any Data= null);
Adds the root node to the tree, returning the id of the new item. The Image and SelectedImage parameters are an index within the normal image list specifying the image to use for unselected and selected items, respectively. If Image > -1 and SelectedImage is -1, the same image is used for both selected and unselected items. The following example adds a root item and 3 childs to the root.
var wx = require("wx"); var dlg = new wx.Dialog(null, -1, "Tree example"); dlg.tree = new wx.TreeCtrl(dlg, 1);
556 wx
var root = dlg.tree.addRoot("Root"); dlg.tree.appendItem(root, "Child 1"); dlg.tree.appendItem(root, "Child 2"); dlg.tree.appendItem(root, "Child 3");
appendItem
wx.TreeItemId appendItem(wx.TreeItemId Parent, String Text, Integer Image= -1, Integer SelectedImage= -1, Any Data= null);
Appends an item to the end of the branch identified by parent, return a new item id. The Image and SelectedImage parameters are an index within the normal image list specifying the image to use for unselected and selected items, respectively. If Image > -1 and SelectedImage is -1, the same image is used for both selected and unselected items. prependItem
wx.TreeItemId prependItem(wx.TreeItemId Parent, String Text, Integer Image= -1, Integer SelectedImage= -1, Any Data= null);
Inserts a new item as the first child of the parent item, returns a new item id. The Image and SelectedImage parameters are an index within the normal image list specifying the image to use for unselected and selected items, respectively. If Image > -1 and SelectedImage is -1, the same image is used for both selected and unselected items. insertItem
wx.TreeItemId insertItem(wx.TreeItemId Parent, wx.TreeItemId Prev, String Text, Integer Image= -1, Integer SelectedImage= -1);
wx.TreeItemId insertItem(wx.TreeItemId Parent, Integer Pos, String Text, Integer Image= -1, Integer SelectedImage= -1);
Inserts an item after a given one (Prev) or before one identified by its position (Pos). The Image and SelectedImage parameters are an index within the normal image list specifying the image to use for unselected and selected items, respectively. If Image > -1 and SelectedImage is -1, the same image is used for both selected and unselected items.
557 wx deleteItem
deleteItem(wx.TreeItemId Id);
Deletes the item. You receive an event as onDeleteItem. deleteChildren
deleteChildren(wx.TreeItemId Id);
Deletes all the children of the item. You don't get an event as onDeleteItem event for the deleted items. deleteAllItems
deleteAllItems();
Deletes all items. You don't get an onDeleteItem event for the deleted items. expand
expand(wx.TreeItemId Id);
Expands the item. See wx.TreeItem expanded property collapse
collapse(wx.TreeItemId Id);
Collapses the item. See wx.TreeItem expanded property collapseAndReset
collapseAndReset(wx.TreeItemId Id);
Collapses the item and removes the children. toggle
toggle(wx.TreeItemId Id);
Toggles the given item between collapsed and expanded states. See wx.TreeItem expanded property unselect
unselect();
Unselects the selected item. See wx.TreeItem selected property unselectAll
558 wx
unselectAll();
Unselects all selected items. selectItem
selectItem(wx.TreeItemId Id);
Selects the given item. See wx.TreeItem selected property ensureVisible
ensureVisible(wx.TreeItemId Id);
Make sure the item is visible (expanding the parent item and/or scrolling to this item if necessary) See wx.TreeItem visible property scrollTo
scrollTo(wx.TreeItemId Id);
Scroll to the item (but don't expand its parent) editLabel
editLabel(wx.TreeItemId Id);
Start editing the label of the item. The item will be selected when it hadn't been before. endEditLabel
endEditLabel(wx.TreeItemId Id, Boolean Discard= false);
Ends editing the label of the item. Only on Windows sortChildren
sortChildren(wx.TreeItemId Id);
Sorts the children of the given item using the function of onCompareItems. When no function is set, the items are sorted alphabetically. hitTest
Array hitTest(wx.Point Pos);
Determines which item (if any) is at the specified point. Returns an array with the TreeItemId and flags (or you can use a multi assign).
559 wx
Events onBeginDrag This event is triggered when the user starts dragging with the left mouse button. The event can be vetoed using veto or allowed. The function receives a wx.TreeEvent as argument. onBeginRDrag This event is triggered when the user starts dragging with the right mouse button. The event can be vetoed using veto or allowed. The function receives a wx.TreeEvent as argument. onBeginLabelEdit This event is triggered when the user starts editing an item. The event can be vetoed using veto or allowed. The function receives a wx.TreeEvent as argument. onEndLabelEdit This event is triggered when the user ends editing the label. The function receives a wx.TreeEvent as argument. The event can be vetoed using veto or allowed. onDeleteItem This event is triggered when an item is deleted. See deleteItem. The function receives a wx.TreeEvent as argument. onGetInfo This event is triggered when the application needs information. The function receives a wx.TreeEvent as argument. onSetInfo This event is triggered when information is supplied. The function receives a wx.TreeEvent as argument. onItemExpanded This event is triggered when an item is expanded. The function receives a wx.TreeEvent as argument. onItemExpanding This event is triggered when an item is about to expanded. The event can be vetoed using veto or allowed. The function receives a wx.TreeEvent as argument. onItemCollapsed This event is triggered when an item is collapsed. The function receives a wx.TreeEvent as argument. onItemCollapsing This event is triggered when an item is about to collapse. The event can be vetoed using veto or allowed. The function receives a wx.TreeEvent as argument. onSelChanged This event is triggered when the selection is changed. The function receives a wx.TreeEvent as argument. onSelChanging This event is triggered when the selection is about to change. The function receives a wx.TreeEvent as argument. onKeyDown This event is triggered when a key is pressed. The function receives a wx.TreeEvent as argument.
560 wx onItemActivated This event is triggered when an item is activated. The function receives a wx.TreeEvent as argument. onItemRightClick This event is triggered when an item is clicked with the right mousebutton. The function receives a wx.TreeEvent as argument. onItemMiddleClick This event is triggered when an item is clicked with the middle mousebutton. The function receives a wx.TreeEvent as argument. onEndDrag This event is triggered when the user releases the mouse button. The function receives a wx.TreeEvent as argument.
561 wx
Name wx.TreeEvent — This object is passed to a function that is set to a wx.TreeCtrl event property.
Prototype: wx.NotifyEvent Properties isEditCancelled
Boolean isEditCancelled ;
Returns true when the edit is cancelled. item
wx.TreeItemId item ;
The item. keyCode
Integer keyCode ;
Keycode when the event is a keypress event. See wx.KeyCode. keyEvent
wx.KeyEvent keyEvent ;
A key event. label
String label ;
The label. oldItem
wx.TreeItemId oldItem ;
Get the previously selected item. point
wx.Point point ;
562 wx
The position of the mouse pointer when the event is a drag event.
563 wx
Name wx.TreeItem
TreeItem is not available in wxWidgets. It's main purpose is to concentrate item specific properties and methods in this class which will make it easier to work with tree items. See wx.TreeCtrl, wx.TreeItemId and getItem Properties allChildrenCount
Integer allChildrenCount ;
Gets the number of child items. It returns the total number of descendants. backgroundColour
wx.Colour backgroundColour ;
Get/Set the background colour of the item. bold
Boolean bold ;
Get/Set the item text in bold. childrenCount
Integer childrenCount ;
Gets the number of child items. Only the children of one level is returned. data
Any data ;
Get/Set the associated data of the item. expanded
Boolean expanded ;
Returns true when the item is expanded. When set to true the items is expanded, collapsed when set to false. font
564 wx
wx.Font font ;
Get/Set the font of the item. hasChildren
Boolean hasChildren ;
Returns true when the item has children. When set to true you can force the appearance of the button next to the item. This is useful to allow the user to expand the items which don't have any children now, but instead adding them only when needed, thus minimizing memory usage and loading time. lastChild
wx.TreeItem lastChild ;
Get the last child item. Returns null when the item has no childs. nextSibling
wx.TreeItem nextSibling ;
Get the next sibling item. Returns null when there are no items left. parent
wx.TreeItem parent ;
Get the parent item. Returns null when this item is the root item. prevSibling
wx.TreeItem prevSibling ;
Get the previous sibling item. Returns null when there are no items left. selected
Boolean selected ;
Returns true when the item is selected. When set to true the items is selected, unselected when set to false. text
String text ;
Get/Set the item text. textColour
565 wx
wx.Colour textColour ;
Get/Set the colour of the text. visible
Boolean visible ;
Get/Set the visibility of the item. Setting visible to false doesn't do anything. Methods getImage
Integer getImage(Integer Which);
Gets the specified item image. See A wx.TreeItemIcon constant. See wx.TreeCtrl getItemImage method setImage
setImage(Integer Image, Integer Which);
Sets the specified item image. See wx.TreeCtrl setItemImage method getFirstChild
wx.TreeItem getFirstChild(Integer Cookie);
For this enumeration function you must pass in a 'cookie' parameter which is opaque for the application but is necessary for the library to make these functions reentrant (i.e. allow more than one enumeration on one and the same object simultaneously). The cookie passed to getFirstChild and getNextChild should be the same variable. Returns the first child item. An invalid item is returned when there is no child item. See wx.TreeCtrl getFirstChild method getNextChild
wx.TreeItem getNextChild(Integer Cookie);
For this enumeration function you must pass in a 'cookie' parameter which is opaque for the application but is necessary for the library to make these functions reentrant (i.e. allow more than one enumeration on one and the same object simultaneously). The cookie passed to wx.TreeItem getFirstChild and getNextChild should be the same variable. Returns the next child item. An invalid item is returned when there is no child item. See wx.TreeCtrl getNextChild method
566 wx
Name wx.TreeItemIcon
TreeItemIcon is used to associated different kind of images to a treectrl item. Constants
Table 16.73. Constants of wx.TreeItemIcon
Name Description Expanded Not selected, Expanded Normal Not selected, Not expanded Selected Selected, Not expanded SelectedExpanded Selected, Expanded
567 wx
Name wx.TreeItemId
TreeItemId identifies an element of the tree. See wx.TreeCtrl and wx.TreeEvent Properties ok
Boolean ok ;
Returns true when the item is valid.
568 wx
Name wx.Validator — Use Validator to create your own validators.
Properties bellOnError
Boolean bellOnError ; transferFromWindow
Function transferFromWindow ;
Assign a function to this property that transfers the content of the window to a variable. You must return true on success, false on failure. transferToWindow
Function transferToWindow ;
Assign a function to this property that transfers the variable to the window. You must return true on success, false on failure. validate
Function validate ;
Assign a function to this property that checks the content of the associated window. The function can have one argument: the parent of the associated window. This function should return false when the content is invalid, true when it is valid. window
wx.Window window ;
The window associated with this validator.
569 wx
Name wx.Window — Window is the prototype of all Classs based on Window.
Constants
Table 16.74. Constants of wx.Window
Name Description BORDER CLIP_CHILDREN DOUBLE_BORDER HSCROLL NO_3D NO_BORDER NO_FULL_REPAINT_ON_RESIZE RAISED_BORDER SIMPLE_BORDER SIZE_ALLOW_MINUS_ONE Allow -1 as a valid position SIZE_AUTO Use internally-calculated width and height if each is -1 SIZE_AUTO_HEIGHT Use internally-calculated height if -1 SIZE_AUTO_WIDTH Use internally-calculated width if -1 SIZE_NO_ADJUSTMENTS Don't do parent client adjustments (for implementation only) SIZE_USE_EXISTING Ignore missing (-1) dimensions (use existing). STATIC_BORDER SUNKEN_BORDER TAB_TRAVERSAL VSCROLL WANTS_CHARS WS_EX_BLOCK_EVENTS Normally, the command events are propagared upwards to the window parent recursively until a handler for them is found. Using this style allows to prevent them from being propagated beyond this window. Notice that wxDialog has this style on by default for the reasons explained in the event processing overview. WS_EX_TRANSIENT This can be used to prevent a window from being used as an implicit parent for the dialogs which were created without a parent. It is useful for the windows which can disappear at any moment as creating childs of such windows results in fatal problems.
570 wx
Name Description WS_EX_VALIDATE_RECURSIVELY TransferDataTo/FromWindow() and Validate() methods will recursively descend into all children of the window if it has this style flag set.
Class Properties capture
wx.Window capture ; Class Methods findFocus
wx.Window findFocus();
Finds the window or control which currently has the keyboard focus findWindowById
wx.Window findWindowById(Integer Id);
Find a window by identifier findWindowByLabel
wx.Window findWindowByLabel(String Label);
Find a window by label Properties acceleratorTable
wx.AcceleratorTable acceleratorTable ; acceptsFocus
Boolean acceptsFocus ;
Can this window have focus? acceptsFocusFromKeyboard
Boolean acceptsFocusFromKeyboard ;
571 wx
can this window be given focus by keyboard navigation? if not, the only way to give it focus (provided it accepts it at all) is to click it autoLayout
Boolean autoLayout ;
Indicates whether the layout method must be called automatically or not when a window is resized. See wx.Sizer backgroundColour
wx.Colour backgroundColour ;
Get/Set the background colour of the window bestSize
wx.Size bestSize ;
Gets the size best suited for the window caret
wx.Caret caret ;
Get/Set the caret. children
Array children ;
Gets a list of children clientAreaOrigin
wx.Point clientAreaOrigin ;
Get the origin of the client area of the window relative to the window top left corner (the client area may be shifted because of the borders, scrollbars, other decorations...) clientRect
wx.Rect clientRect ;
Gets the rectangle of the client area clientSize
572 wx
wx.Size clientSize ;
Get/Set the clientsize of the window. You can also use wx.Rect (only when setting) enable
Boolean enable ;
Enables/Disables the window extraStyle
Integer extraStyle ;
Get/Set the extra window styles. font
wx.Font font ;
Get/Set the font. foregroundColour
wx.Colour foregroundColour ;
Get/Set the foreground colour of the window hasCapture
Boolean hasCapture ;
Returns true when this window has the capture. id
Integer id ;
Gets the unique id of the window, or -1 when it is not set. parent
wx.Window parent ;
Get/Set the parent position
wx.Point position ;
573 wx
Get/Set the position. rect
wx.Rect rect ;
Gets the window rectangle shown
Boolean shown ;
Returns true when the window is visible See visible property, show method size
wx.Size size ;
Get/Set the size of the window. You can also use wx.Rect (only when setting) sizer
wx.Sizer sizer ;
Get/Set the sizer of the window. Set autoLayout to true when you want that the sizer is automatically used when the size of the window is changed. topLevel
Boolean topLevel ;
Returns true when the window is a top level window. Currently all frames and dialogs are considered to be top-level windows (even if they have a parent window). validator
wx.Validator validator ;
Get/Set the validator of the window visible
Boolean visible ;
Show/Hide the window. windowStyle
Integer windowStyle ;
574 wx
Get/Set the window flag styles. Please note that some styles cannot be changed after the window creation and that refresh might be called after changing the others for the change to take place immediately. Methods captureMouse
captureMouse();
Directs all mouse input to this window. Call releaseMouse to release the capture. See hasCapture centre
centre(Integer Direction= wx.Orientation.BOTH); clearBackground
clearBackground();
Clears the window by filling it with the current background color. clientToScreen
wx.Point clientToScreen(wx.Point Point);
Returns the screen coordinates from coordinates relative to this window. close
close(Boolean Force= false);
Closes the window. This applies only for wx.Frame and wx.Dialog Classs. When Force is true the application can't veto the close. convertDialogToPixels
wx.Point convertDialogToPixels(wx.Point Point);
wx.Size convertDialogToPixels(wx.Size Size);
Converts a point or a size to from dialog units to pixels. convertPixelsToDialog
wx.Point convertPixelsToDialog(wxPoint Point);
convertPixelsToDialog(wx.Size Size);
575 wx
Converts a point or a size from pixels to dialog units. destroy
Boolean destroy();
Destroys the window. Returns true when the window is destroyed. destroyChildren
destroyChildren();
Destroys all children of the window. releaseMouse
releaseMouse();
Releases mouse input captured by captureMouse. See also hasCapture warpPointer
warpPointer(Integer X, Integer Y);
warpPointer(wx.Point Point);
Moves the mouse to the given position layout
layout();
Layout the window using the sizer. move
move(Integer X, Integer Y);
move(wx.Point Point);
Moves the window. setSize
setSize(Integer X,
576 wx
Integer Y, Integer Width, Integer Height, Integer Flag);
setSize(Integer Width, Integer Height);
Sets a new window size. Use -1 for an argument to keep the original value. See size property raise
raise();
Raises the window to the top of the window hierarchy if it is a managed window (dialog or frame). lower
lower();
Lowers the window to the bottom of the window hierarchy if it is a managed window (dialog or frame). centerOnParent
centerOnParent(Integer Direction= wx.Orientation.BOTH);
Centres the window based on the parent. centreOnParent is an alias for this method. fit
fit();
Set window size to wrap around its children show
show(Boolean Visible= true);
Shows (true) or hides (false) the window. See visible property, shown property refresh
refresh(Boolean EraseBackGround= true, wx.Rect Rect= null);
Generates an event for repainting the window setFocus
577 wx
setFocus();
This sets the window to receive keyboard input. findWindow
wx.Window findWindow(Integer Id);
wx.Window findWindow(String Name);
Find a child of this window, by identifier or by name initDialog
initDialog();
Sends an onInitDialog event, which in turn transfers data to the dialog via validators transferDataToWindow
Boolean transferDataToWindow();
Transfers values to child controls from data areas specified by their validators Returns FALSE if a transfer failed. transferDataFromWindow
Boolean transferDataFromWindow();
Transfers values from child controls to data areas specified by their validators. Returns false if a transfer failed. validate
Boolean validate();
Validates the current values of the child controls using their validators. makeModal
makeModal(Boolean Flag= true);
Make modal or not. When flag is true, all other windows are disabled. update
update();
Repaint all invalid areas of the window immediately
578 wx freeze
freeze();
Freeze the window: don't redraw it until it is thawed See thaw thaw
thaw();
Thaw the window: redraw it after it had been frozen. See freeze setClientSize
setClientSize(Integer Width, Integer Height);
setClientSize(wx.Size Size);
This sets the size of the window client area in pixels. Events onActivate Called when the window is activated/disactivated. The function gets a wx.ActivateEvent as argument. onCalculateLayout onChar Called when the user enters a character. The function gets a wx.KeyEvent Object as argument. onCharHook This event is triggered to allow the window to intercept keyboard events before they are processed by child windows. The function gets a wx.KeyEvent as argument. onKeyDown Called when the user has pressed a key, before it is translated into an ASCII value using other modifier keys that might be pressed at the same time. The function gets a wx.KeyEvent Object as argument. onKeyUp Called when the user has released the key. The function gets a wx.KeyEvent Object as argument. onSetFocus Called when the window gets the focus. The function gets a wx.FocusEvent Object as argument. onKillFocus Called when the window looses the focus. The function gets a wx.FocusEvent Object as argument. onMouseEvents Used for handling all the mouse events. The function gets a wx.MouseEvent as argument.
579 wx onEnterWindow Event triggered when the mouse enters the window. The function gets a wx.MouseEvent as argument. Under Windows mouse enter and leave events are not natively supported by the system but are generated by wxWindows itself. This has several drawbacks: the onLeaveWindow event might be received some time after the mouse left the window and the state variables for it may have changed during this time. See onLeaveWindow onLeaveWindow Event triggered when the mouse leaves the window. The function gets a wx.MouseEvent as argument. Under Windows mouse enter and leave events are not natively supported by the system but are generated by wxWindows itself. This has several drawbacks: the onLeaveWindow event might be received some time after the mouse left the window and the state variables for it may have changed during this time. See onEnterWindow onLeftDown Event triggered when the left button is pressed. The function gets a wx.MouseEvent as argument. onLeftUp Event triggered when the left button is released. The function gets a wx.MouseEvent as argument. onLeftDClick Event triggered when the left button is double clicked. The function gets a wx.MouseEvent as argument. onMiddleDown Event triggered when the middle button is pressed. The function gets a wx.MouseEvent as argument. onMiddleUp Event triggered when the middle button is released. The function gets a wx.MouseEvent as argument. onMiddleDClick Event triggered when the middle button is double clicked. The function gets a wx.MouseEvent as argument. onRightDown Event triggered when the right button is pressed. The function gets a wx.MouseEvent as argument. onRightUp Event triggered when the right button is released. The function gets a wx.MouseEvent as argument. onRightDClick Event triggered when the right button is double clicked. The function gets a wx.MouseEvent as argument. onMotion Event triggered when the mouse is moved. The function gets a wx.MouseEvent as argument. onMouseWheel Event triggered when the mousewheel is used. The function gets a wx.MouseEvent as argument. onMove Called when the window is moved. The function gets a wx.MoveEvent as argument. onSize Called when the window is resized. The function gets a wx.SizeEvent as argument.
580 wx onScroll Catch all scroll commands. The argument of the function is a wx.ScrollWinEvent. onScrollTop Catch a command to put the scroll thumb at the maximum position. The argument of the function is a wx.ScrollWinEvent. onScrollBottom Catch a command to put the scroll thumb at the maximum position. The argument of the function is a wx.ScrollWinEvent. onScrollLineUp Catch a line up command. The argument of the function is a wx.ScrollWinEvent. onScrollLineDown Catch a line down command. The argument of the function is a wx.ScrollWinEvent. onScrollPageUp Catch a page up command. The argument of the function is a wx.ScrollWinEvent. onScrollPageDown Catch a page down command. The argument of the function is a wx.ScrollWinEvent. onScrollThumbTrack Catch a thumbtrack command (continuous movement of the scroll thumb). The argument of the function is a wx.ScrollWinEvent. onScrollThumbRelease Catch a thumbtrack release command. The argument of the function is a wx.ScrollWinEvent. onHelp Triggered when the user pressed F1 (on Windows) or when the user requested context-sensitive help. The argument of the function is a wx.HelpEvent. See wx.ContextHelp, wx.HelpEvent and wx.ContextHelpButton
581 wx
Name wx.XPMHandler — Image handler for bitmaps.
Prototype: wx.ImageHandler
582 ftpFileMethod, 19 Index ftpPort, 19 ftpResponseTimeout, 19 ftpSkipPasvIp, 19 C ftpSSLAuth, 20 core.Binary, 9 ftpSSLCCC, 20 byteAt, 9 ftpUseEPRT, 20 concat, 9 ftpUseEPSV, 20 decodeToString, 9 getinfo, 34 get, 9 header, 20 length, 9 http200Aliases, 20 core.BinaryString, 10 httpAuth, 20 Constructor, 10 HttpContentDecoding, 21 core.Encoding, 11 httpGet, 21 core.Version, 12 httpHeader, 21 description, 12 httpPost, 21 major, 12 httpProxyTunnel, 21 minor, 12 httpTransferDecoding, 22 release, 12 httpVersion, 21 Curl, 45 ignoreContentLength, 22 curl.Auth, 15 inFileSize, 22 curl.Easy, 16 interface, 22 append, 16 ipResolve, 29 autoReferer, 16 keyPasswd, 30 bufferSize, 28 krbLevel, 32 cainfo, 31 localPort, 22 capath, 31 localPortRange, 22 cleanup, 33 lowSpeedLimit, 28 connectOnly, 30 lowSpeedTime, 28 connectTimeout, 29 maxConnects, 29 connectTimeoutMS, 29 maxFileSize, 23 Constructor, 16 maxRecvSpeed, 29 cookie, 16 maxRedirs, 23 cookieFile, 17 maxSendSpeed, 28 cookieJar, 17 netrc, 23 cookieList, 17 netrcFile, 23 cookieSession, 17 newDirectory, 33 crlf, 17 newFilePerms, 33 customRequest, 17 noBody, 23 dirListOnly, 18 noProgress, 23 dnsCacheTimeout, 18 onProgress, 35 duphandle, 34 onRead, 35 effectiveUrl, 18 onWrite, 35 egdSocket, 31 password, 27 encoding, 18 perform, 35 error, 18 port, 23 escape, 33 post, 24 filetime, 18 postFields, 24 followLocation, 18 postQuote, 24 forbidReuse, 29 preQuote, 24 freshConnect, 29 protocols, 24 ftpAccount, 19 proxy, 24 ftpAlternativeToUser, 19 proxyAuth, 24 ftpCreateMissingDirs, 19 proxyPassword, 27
583 Index
proxyPort, 25 curl.Multi, 44 proxyType, 33 addHandle, 44 proxyUsername, 27 Constructor, 44 proxyUserPwd, 25 perform, 44 quote, 25 removeHandle, 44 randomFile, 31 strerror, 44 range, 25 curl.Netrc, 46 redirProtocols, 25 curl.Option, 47 referer, 25 curl.Protocol, 51 reset, 34 curl.ProxyType, 52 resumeFrom, 25 curl.SSHAuth, 53 setopt, 34 curl.SSLVersion, 54 sshAuthTypes, 32 curl.UseSSL, 55 sshHostPublicKeyMD5, 32 sshPrivateKeyFile, 32 D sshPublicKeyFile, 32 data.RecordSet, 60 sslCert, 30 columnCount, 60 sslCertType, 30 columnLength, 60 sslCipherList, 32 columnName, 60 sslEngine, 30 columnPrecision, 61 sslEngineDefault, 31 columnType, 61 sslKey, 30 Constructor, 60 sslKeyType, 30 moveFirst, 61 sslSessionIdCache, 32 moveLast, 61 sslVerifyHost, 31 moveNext, 61 sslVerifyPeer, 31 movePrevious, 61 sslVersion, 31 rowCount, 60 strerror, 16 value, 61 tcpNoDelay, 26 data.Session, 57 telnetOptions, 33 begin, 57 timeCondition, 26 close, 57 timeout, 26 commit, 57 timeoutMs, 26 connected, 57 timeValue, 26 Constructor, 57 transferText, 26 execute, 57 unescape, 33 getFeature, 58 unrestrictedAuth, 26 getProperty, 58 upload, 27 prepare, 58 url, 27 rollback, 58 useragent, 27 setFeature, 58 username, 27 setProperty, 58 userPwd, 28 transaction, 57 useSSL, 28 data.Statement, 59 verbose, 28 bind, 59 curl.Form, 36 done, 59 addFile, 36 execute, 59 addName, 36 toString, 59 Constructor, 36 curl.FTPAuth, 37 curl.FTPMethod, 38 E curl.FTPSSL, 39 expat.Parser, 63 curl.Http, 40 characters, 63 curl.Info, 41 Constructor, 63 curl.IPResolve, 43 onCharacter, 63
584 Index
onComment, 63 colorResolveAlpha, 82 onDefault, 63 colorsTotal, 77 onDefaultExpand, 64 Constructor, 77 onEndCData, 64 copy, 91 onEndElement, 64 copyMerge, 93 onEndNamespaceDecl, 64 copyMergeGray, 94 onExternalEntityRef, 64 copyResampled, 92 onProcessing, 64 copyResized, 91 onSkippedEntity, 64 copyRotated, 92 onStartCData, 65 fill, 86 onStartElement, 65 filledArc, 85 parse, 65 filledEllipse, 85 reset, 65 filledPolygon, 84 filledRectangle, 84 F fillToBorder, 86 getPixel, 88 FCGI, 68 green, 82 flush, 68 height, 78 getParam, 68 interlace, 77 read, 68 line, 83 write, 68 openPolygon, 84 writeError, 68 paletteCopy, 94 polygon, 83 G rectangle, 84 gd, 98 red, 82 antiAliased, 98 saveAlpha, 95 brushed, 99 setAntiAliased, 86 maxColors, 99 setAntiAliasedDontBlend, 87 styled, 99 setBrush, 87 styledBrushed, 99 setPixel, 83 tiled, 99 setStyle, 87 transparent, 99 setThickness, 88 trueColor, 98 setTile, 87 trueColorAlpha, 98 sharpen, 94 useFontConfig, 98 size, 78 gd.Font, 75 squareToCircle, 94 h, 75 string, 88 size, 75 stringFT, 89 w, 75 stringFTCircle, 90 gd.Image, 77 stringUp, 88 alphaBlending, 94 tile, 77 arc, 84 transparent, 78 blue, 83 trueColour, 78 boundsSafe, 88 width, 78 clip, 78 gd.ImageGIF, 76 colorAllocate, 79 Constructor, 76 colorAllocateAlpha, 79 write, 76 colorClosest, 80 writeToBuffer, 76 colorClosestAlpha, 80 gd.ImageJPEG, 96 colorClosestHWB, 81 Constructor, 96 colorDeallocate, 79 write, 96 colorExact, 81 writeToBuffer, 96 colorExactAlpha, 81 gd.ImagePNG, 97 colorResolve, 82 Constructor, 97
585 Index
write, 97 sqlState, 110 writeToBuffer, 97 sslSet, 113 global, 446 stat, 110 Global Functions, 192 warningCount, 110 glob, 192 mysql.Field, 114 autoIncrement, 114 M binary, 114 catalog, 114 memcache.Client, 102 db, 114 add, 102 def, 114 addServer, 102 length, 114 append, 103 maxLength, 114 clearServers, 103 multipleKey, 115 Constructor, 102 name, 115 decrement, 104 notNull, 115 get, 104 orgName, 115 increment, 104 orgTable, 115 prepend, 103 primaryKey, 115 removeServer, 104 table, 115 replace, 104 uniqueKey, 115 set, 103 unsigned, 116 MySQL, 117 zeroFill, 116 mysql.Database, 106 mysql.Result, 118 affectedRows, 108 dataSeek, 118 autocommit, 110 fetchField, 118 changeUser, 110 fetchFieldDirect, 118 characterSet, 108 fetchFields, 119 clientInfo, 108 fetchLengths, 119 clientVersion, 108 fetchObject, 119 commit, 111 fetchRow, 119 connect, 111 fieldTell, 118 Constructor, 108 next, 119 errno, 108 numFields, 118 error, 108 numRows, 118 fieldCount, 109 mysql.Statement, 120 hostInfo, 109 affectedRows, 120 info, 109 bind, 120 insertId, 109 errno, 120 listDbs, 111 error, 120 listFields, 111 execute, 121 listProcesses, 111 fetchArray, 121 listTables, 112 fetchObject, 121 moreResults, 109 insertId, 120 options, 112 paramCount, 120 ping, 112 sqlState, 120 prepare, 112 protoInfo, 109 query, 112 N refresh, 113 Net, 159 rollback, 113 net.Cookie, 133 selectDb, 113 comment, 134 serverInfo, 109 Constructor, 134 serverVersion, 110 domain, 134 setServerOption, 113 escape, 133
586 Index
httpOnly, 134 net.HTTPRequestHandlerFactory, 140 maxAge, 134 Constructor, 140 name, 134 net.HTTPResponse, 141 path, 134 addCookie, 143 secure, 135 Constructor, 142 toString, 135 cookies, 142 unescape, 133 date, 142 value, 135 reason, 143 version, 135 status, 143 net.DatagramSocket, 125 net.HTTPServer, 144 bind, 125 Constructor, 144 broadcast, 125 net.HTTPServerParams, 145 connect, 125 Constructor, 145 Constructor, 125 keepAlive, 145 receiveBytes, 125 keepAliveTimeout, 145 receiveFrom, 126 maxKeepAliveRequests, 145 sendBytes, 126 serverName, 145 sendTo, 126 softwareVersion, 145 net.DialogSocket, 127 timeout, 145 Constructor, 127 net.HTTPServerRequest, 147 get, 127 clientAddress, 147 peek, 127 expectContinue, 147 receiveMessage, 127 serverAddress, 147 receiveStatusMessage, 127 net.HTTPServerResponse, 148 sendByte, 128 print, 148 sendMessage, 128 redirect, 148 sendString, 128 requireAuthentication, 148 sendTelnetCommand, 128 sendBuffer, 148 synch, 128 sendFile, 148 net.Family, 129 sent, 148 net.FilePartSource, 130 net.IPAddress, 149 Constructor, 130 broadcast, 149 net.HTMLForm, 131 Constructor, 149 boundary, 131 family, 149 Constructor, 131 globalMC, 149 encoding, 131 ipv4Compatible, 149 prepareSubmit, 131 ipv4Mapped, 150 net.HTTPMessage, 136 linkLocal, 150 chunckedTransferEncoding, 136 linkLocalMC, 150 contentLength, 136 loopback, 150 contentType, 136 multicast, 150 KeepAlive, 136 nodeLocalMC, 150 version, 136 orgLocalMC, 150 net.HTTPRequest, 137 siteLocal, 150 Constructor, 137 siteLocalMC, 151 cookies, 137 unicast, 151 credentials, 137 wellKnownMC, 151 host, 137 wildcard, 151 method, 138 net.MailMessage, 152 path, 138 addAttachment, 153 query, 138 addContent, 153 uri, 138 addRecipient, 153 net.HTTPRequestHandler, 139 Constructor, 152 Constructor, 139 content, 152
587 Index
contentType, 152 bind, 166 date, 152 Constructor, 166 recipients, 152 listen, 166 sender, 152 net.SMTPClientSession, 167 subject, 152 close, 168 net.MailRecipient, 154 Constructor, 167 address, 154 login, 168 Constructor, 154 open, 168 realName, 154 sendCommand, 168 type, 154 sendMessage, 168 net.MessageHeader, 155 timeout, 167 Constructor, 155 net.Socket, 171 splitElements, 155 address, 171 splitParameters, 155 available, 171 write, 156 blocking, 171 net.MulticastSocket, 157 close, 173 Constructor, 157 keepAlive, 171 interface, 157 linger, 171 joinGroup, 157 noDelay, 172 leaveGroup, 158 OOBInline, 172 loopback, 157 peerAddress, 173 timeToLive, 157 poll, 173 net.NameValueCollection, 160 receiveBufferSize, 172 add, 160 receiveTimeout, 172 clear, 160 reuseAddress, 172 empty, 160 reusePort, 172 erase, 160 sendBufferSize, 172 get, 160 sendTimeout, 172 getArray, 161 supportsIPV4, 171 getObject, 161 supportsIPV6, 171 has, 161 net.SocketAddress, 169 set, 161 Constructor, 169 size, 160 family, 169 net.NetworkInterface, 162 host, 169 address, 162 port, 169 broadcastAddress, 163 toString, 170 Constructor, 162 net.StreamSocket, 174 displayName, 163 connect, 174 forAddress, 162 connectNB, 174 forIndex, 162 Constructor, 174 forName, 162 receiveBytes, 174 index, 163 sendBytes, 174 list, 162 sendUrgent, 175 Name, 163 shutdown, 175 subnetMask, 163 shutdownReceive, 175 supportsIPv4, 163 shutdownSend, 175 supportsIPv6, 163 net.StringPartSource, 176 net.PartHandler, 165 Constructor, 176 Constructor, 165 net.TCPServer, 177 net.PartSource, 164 Constructor, 177 filename, 164 currentConnections, 177 mediatype, 164 currentThreads, 177 net.ServerSocket, 166 maxConcurrentConnections, 177 acceptConnection, 166 port, 177
588 Index
queuedConnections, 177 createDirectory, 195 refusedConnections, 177 createFile, 195 start, 178 directory, 193 stop, 178 exists, 194 net.TCPServerConnection, 179 file, 194 Constructor, 179 hidden, 194 socket, 179 lastModified, 194 net.TCPServerConnectionFactory, 180 link, 194 Constructor, 180 list, 195 net.TCPServerParams, 181 moveTo, 195 Constructor, 181 path, 194 maxQueued, 181 remove, 195 maxThreads, 181 renameTo, 195 threadIdleTime, 181 size, 194 threadPriority, 181 system.FileInputStream, 196 close, 196 S Constructor, 196 system.FileOutputStream, 197 SQLite, 187 close, 197 sqlite.Database, 183 Constructor, 197 autocommit, 184 system.InputStream, 198 changes, 184 count, 198 complete, 184 eof, 198 Constructor, 184 ignore, 198 errMsg, 185 peek, 198 errNo, 185 pos, 198 exec, 186 read, 199 lastInsertRowID, 184 seek, 199 onCommit, 185 unget, 199 onRollback, 185 system.OutputStream, 200 onTrace, 185 flush, 200 onUpdate, 185 pos, 200 opened, 185 seek, 200 prepare, 186 write, 200 totalChanges, 186 system.Path, 202 sqlite.Statement, 188 absolute, 205 bind, 188 append, 206 columnCount, 188 assign, 206 columnDeclType, 188 basename, 204 columnName, 189 clear, 206 columnOriginalName, 189 Constructor, 203 columnTableName, 189 current, 202 fetchArray, 189 depth, 204 fetchObject, 189 device, 204 reset, 190 directory, 206 step, 190 directoryName, 204 system.File, 193 expand, 203 canExecute, 193 extension, 204 canRead, 193 filename, 204 canWrite, 193 find, 203 Constructor, 193 forDirectory, 203 copyTo, 194 home, 202 created, 193 isAbsolute, 205 createDirectories, 195 isDirectory, 205
589 Index
isFile, 205 addDocWriter, 225 isRelative, 205 addTranslator, 225 makeAbsolute, 206 artists, 224 makeDirectory, 207 Constructor, 223 makeFile, 207 copyright, 223 makeParent, 207 description, 223 node, 205 developers, 224 null, 202 docWriters, 224 parent, 205 icon, 224 parseDirectory, 207 license, 223 pathSeparator, 202 name, 223 popDirectory, 207 translators, 224 pushDirectory, 207 version, 223 resolve, 207 website, 224 roots, 202 websiteDescription, 224 separator, 202 wx.AcceleratorEntry, 226 temp, 203 command, 226 toString, 207 Constructor, 226 system.Pipe, 209 flags, 226 Constructor, 209 keyCode, 226 system.PipeInputStream, 210 set, 226 Constructor, 210 wx.AcceleratorTable, 228 system.PipeOutputStream, 211 Constructor, 228 Constructor, 211 ok, 229 system.Process, 212 wx.ActivateEvent, 230 Constructor, 212 active, 230 pid, 212 wx.Alignment, 231 wait, 212 wx.Animation, 232 system.TemporaryFile, 213 Constructor, 232 Constructor, 213 frameCount, 232 keep, 213 getDelay, 232 keepUntilExit, 213 getFrame, 233 tempName, 213 loadFile, 233 system.TextInputStream, 214 ok, 232 close, 214 size, 232 Constructor, 214 wx.AnimationCtrl, 234 readAll, 214 animation, 234 readLine, 214 Constructor, 234 system.TextOutputStream, 216 create, 235 close, 216 inactiveBitmap, 234 Constructor, 216 loadFile, 235 writeLine, 216 play, 235 playing, 235 T stop, 235 wx.App, 236 tpl.Engine, 219 appName, 236 Constructor, 219 argv, 236 load, 220 className, 236 parse, 220 topWindow, 236 vendorName, 236 W wx.AuiManager, 237 wx.AboutDialogInfo, 223 addPane, 237 addArtist, 224 allPanes, 237 addDeveloper, 225 Constructor, 237
590 Index
detachPane, 238 defaultPane, 253 dockSizeConstraint, 237 destroyOnClose, 249 flags, 237 direction, 250 getPane, 238 dock, 253 hideHint, 238 dockable, 250 insertPane, 238 docked, 251 loadPaneInfo, 239 dockFixed, 250 loadPerspective, 239 fixed, 250 managedWindow, 237 float, 253 savePaneInfo, 239 floatable, 250 savePerspective, 239 floating, 251 showHint, 239 floatingPosition, 250 unInit, 239 floatingSize, 250 update, 239 gripper, 251 wx.AuiManagerDock, 241 gripperTop, 251 wx.AuiManagerOption, 242 hide, 253 wx.AuiNotebook, 243 layer, 253 addPage, 244 left, 254 advanceSelection, 244 maximizeButton, 251 Constructor, 243 minimizeButton, 251 create, 244 moveable, 252 deletePage, 244 name, 252 getHeightForPageHeight, 245 ok, 252 getPage, 245 paneBorder, 251 getPageBitmap, 245 pinButton, 251 getPageIndex, 245 position, 252 getPageText, 245 resizeable, 252 insertPage, 245 right, 254 pageCount, 244 row, 252 removePage, 245 show, 253 selection, 244 toolbar, 252 setFont, 246 top, 254 setMeasuringFont, 246 wx.AuiPaneInsertLevel, 255 setNormalFont, 246 wx.AutomationObject, 256 setPageBitmap, 246 callMethod, 256 setPageText, 246 Constructor, 256 setSelectedFont, 246 createInstance, 256 setUniformBitmapSize, 246 getInstance, 257 showWindowMenu, 247 getObject, 257 split, 247 getProperty, 257 tabCtrlHeight, 244 putProperty, 257 wx.AuiNotebookEvent, 248 wx.Bitmap, 261 oldSelection, 248 Constructor, 261 selection, 248 create, 261 wx.AuiPaneInfo, 249 depth, 261 bestSize, 249 height, 261 bottom, 252 loadFile, 262 bottomDockable, 249 ok, 261 caption, 249 width, 261 captionVisible, 249 wx.BitmapButton, 259 center, 253 bitmapDisabled, 259 centerPane, 253 bitmapFocus, 259 closeButton, 249 bitmapLabel, 259 Constructor, 249 bitmapSelected, 259
591 Index
Constructor, 259 enableYearChange, 278 create, 259 headerColourBg, 278 wx.BitmapType, 263 headerColourFg, 278 wx.BMPHandler, 264 highlightColourBg, 278 wx.BookCtrlBase, 265 highlightColourFg, 278 addPage, 267 holidayColourBg, 279 advanceSelection, 268 holidayColourFg, 279 changeSelection, 268 lowerDateLimit, 279 controlMargin, 266 onCalendar, 280 controlSizer, 266 onCalendarDay, 280 currentPage, 265 onCalendarMonth, 280 deleteAllPages, 267 onCalendarSelChanged, 280 deletePage, 267 onCalendarWeekDayClicked, 280 fitToCurrentPage, 266 onCalendarYear, 280 getPage, 266 setDateRange, 279 getPageImage, 267 setHeaderColours, 279 getPageText, 266 setHighlightColours, 280 hitTest, 268 setHolidayColours, 280 imagelist, 265 upperDateLimit, 279 insertPage, 267 wx.CalendarDateAttr, 281 internalBorder, 265 backgroundColour, 281 pageCount, 265 border, 281 removePage, 268 borderColour, 281 selection, 265 Constructor, 281 setPageImage, 267 font, 281 setPageSize, 267 holiday, 281 setPageText, 266 textColour, 282 vertical, 266 wx.CalendarDateBorder, 283 wx.BookCtrlBaseEvent, 269 wx.CalendarEvent, 284 oldSelection, 269 date, 284 selection, 269 weekDay, 284 wx.BookCtrlEvent, 270 wx.Caret, 285 wx.BookHittest, 271 blinkTime, 285 wx.Border, 272 Constructor, 285 wx.BoxSizer, 273 create, 286 Constructor, 273 hide, 286 orientation, 273 move, 286 wx.Button, 274 ok, 285 Constructor, 274 position, 285 create, 275 show, 286 defaultSize, 274 size, 285 label, 275 visible, 286 onClicked, 275 window, 285 setDefault, 275 wx.CheckBox, 287 wx.CalculateLayoutEvent, 276 checked, 288 flags, 276 Constructor, 287 rect, 276 create, 288 wx.CalendarCtrl, 277 onCheckBox, 289 attr, 277 thirdStateAllowedForUser, 288 Constructor, 277 threeState, 288 create, 279 threeStateValue, 288 date, 278 value, 288 enableHolidayDisplay, 278 wx.CheckBoxState, 290 enableMonthChange, 278 wx.CheckListBox, 291
592 Index
check, 291 Constructor, 307 checked, 291 create, 307 Constructor, 291 wx.ColourPickerEvent, 309 create, 291 colour, 309 isChecked, 292 wx.ComboBox, 310 onCheckListBox, 292 canCopy, 310 wx.CheckListBoxItem, 293 canCut, 310 wx.Choice, 296 canPaste, 311 columns, 296 canRedo, 311 Constructor, 296 canUndo, 311 create, 296 Constructor, 310 currentSelection, 296 copy, 312 onChoice, 297 create, 311 wx.Choicebook, 294 cut, 312 Constructor, 294 insertionPoint, 311 create, 294 lastPosition, 311 onPageChanged, 294 onComboBox, 313 onPageChanging, 294 onText, 313 wx.ChoicebookEvent, 295 paste, 312 wx.CloseEvent, 298 redo, 312 canVeto, 298 remove, 312 loggingOff, 298 replace, 312 veto, 298 undo, 312 wx.CollapsiblePane, 299 value, 311 collapsed, 300 wx.CommandEvent, 314 Constructor, 299 checked, 314 create, 300 integer, 314 expanded, 300 selection, 314 onChanged, 300 string, 314 pane, 300 wx.ContextHelp, 316 wx.CollapsiblePaneEvent, 301 beginContextHelp, 316 collapsed, 301 Constructor, 316 wx.Colour, 302 endContextHelp, 316 alpha, 302 wx.ContextHelpButton, 315 blue, 302 Constructor, 315 Constructor, 302 wx.Control, 317 green, 302 label, 317 ok, 302 wx.ControlItem, 318 red, 303 remove, 318 set, 303 select, 318 wx.ColourData, 305 value, 318 chooseFull, 305 wx.ControlWithItems, 319 colour, 305 append, 319 Constructor, 305 clear, 320 customColour, 305 count, 319 wx.ColourDatabase, 304 deleteItem, 320 addColour, 304 empty, 319 find, 304 findString, 320 findName, 304 insert, 320 wx.ColourDialog, 306 item, 319 colourData, 306 selection, 319 Constructor, 306 stringSelection, 319 wx.ColourPickerCtrl, 307 wx.Cursor, 321 colour, 307 Constructor, 321
593 Index wx.Dialog, 322 family, 338 Constructor, 322 ok, 338 create, 323 pointSize, 338 endModal, 323 style, 338 modal, 323 underlined, 338 onClose, 323 weight, 338 onInitDialog, 324 wx.FontData, 339 returnCode, 323 allowSymbols, 339 showModal, 323 chosenFont, 339 wx.DirDialog, 325 colour, 339 Constructor, 325 Constructor, 339 message, 325 enableEffects, 339 path, 325 initialFont, 339 wx.Direction, 326 showHelp, 339 wx.Event, 327 wx.FontDialog, 341 id, 327 Constructor, 341 skip, 327 FontData, 341 wx.FileDialog, 328 wx.FontEncoding, 342 Constructor, 328 wx.FontEnumerator, 344 directory, 328 Constructor, 344 filename, 329 encodings, 344 filenames, 329 enumerateEncodings, 345 filterIndex, 329 enumerateFaceNames, 345 message, 329 facenames, 344 path, 329 onFacename, 344 paths, 329 onFontEncoding, 344 wildcard, 329 wx.FontList, 346 wx.Filter, 330 findOrCreateFont, 346 wx.FindDialogEvent, 331 wx.Frame, 347 findString, 331 Constructor, 347 flags, 331 create, 348 replaceString, 331 createStatusBar, 349 wx.FindReplaceData, 332 createToolBar, 349 Constructor, 332 menuBar, 348 findString, 332 onClose, 349 flags, 332 onIconize, 349 replaceString, 332 onMaximize, 349 wx.FindReplaceDialog, 333 processCommand, 348 Constructor, 333 setStatusText, 349 create, 333 setStatusWidths, 349 data, 333 statusBar, 348 onFind, 334 statusBarFields, 348 onFindClose, 334 statusBarPane, 348 onFindNext, 334 toolBar, 348 onFindReplace, 334 wx.FullScreen, 350 onFindReplaceAll, 334 wx.Gauge, 351 wx.FlexGridSizer, 335 bezelFace, 351 Constructor, 335 Constructor, 351 wx.FocusEvent, 336 create, 352 wx.Font, 337 pulse, 352 Constructor, 337 range, 351 defaultEncoding, 337 shadowWidth, 351 encoding, 337 value, 352 faceName, 338 vertical, 352
594 Index wx.GenericValidator, 353 findHandler, 368 Constructor, 354 findHandlerMime, 368 validate, 354 getBlue, 373 value, 354 getColour, 373 wx.GIFHandler, 355 getGreen, 373 wx.GridSizer, 356 getOption, 375 Constructor, 356 getOptionInt, 375 wx.HelpEvent, 357 getRed, 373 position, 357 getSubImage, 371 wx.HtmlLinkEvent, 358 handlers, 368 href, 358 hasOption, 375 target, 358 height, 369 wx.HtmlWindow, 359 insertHandler, 369 appendToPage, 360 loadFile, 374 Constructor, 359 mask, 369 create, 360 maskBlue, 370 historyBack, 360 maskGreen, 370 historyCanBack, 359 maskRed, 370 historyCanForward, 359 mirror, 372 historyClear, 361 ok, 370 historyForward, 361 paste, 371 loadFile, 361 removeHandler, 369 loadPage, 361 replace, 372 onLinkClicked, 362 rescale, 371 openedAnchor, 359 rotate, 371 openedPage, 360 rotate90, 372 openedPageTitle, 360 saveFile, 374 relatedFrame, 360 scale, 371 selectAll, 361 setMaskColour, 374 selectLine, 361 setMaskFromImage, 374 selectWord, 361 setOption, 375 setBorders, 361 setRGB, 372 setFonts, 362 width, 370 setPage, 362 wx.ImageHandler, 376 setRelatedFrame, 362 extension, 376 setRelatedStatusBar, 362 getImageCount, 376 text, 360 loadFile, 376 wx.ICOHandler, 363 mimeType, 376 wx.Icon, 364 name, 376 Constructor, 364 saveFile, 377 loadFile, 364 type, 376 wx.IconizeEvent, 365 wx.ImageList, 378 iconized, 365 add, 378 wx.Id, 366 Constructor, 378 wx.Image, 368 create, 378 addHandler, 368 getSize, 379 canRead, 368 imageCount, 378 cleanUpHandlers, 368 remove, 379 Constructor, 369 removeAll, 379 convertToMono, 372 replace, 379 copy, 371 wx.InitDialogEvent, 381 create, 370 wx.ItemKind, 380 destroy, 370 wx.JPEGHandler, 382 findFirstUnusedColour, 373 wx.KeyCode, 383
595 Index wx.KeyEvent, 386 getItemRect, 407 altDown, 386 getItemState, 406 controlDown, 386 getItemText, 406 hasModifiers, 386 getNextItem, 407 keyCode, 386 hitTest, 410 metaDown, 386 insertColumn, 409 shiftDown, 386 insertItem, 409 x, 386 itemCount, 403 y, 387 itemSpacing, 404 wx.LayoutAlgorithm, 388 onGetItemAttr, 403 Constructor, 388 onGetItemImage, 403 layoutFrame, 389 onGetItemText, 404 layoutMDIFrame, 389 refreshItem, 408 layoutWindow, 389 refreshItems, 408 wx.LayoutAlignment, 390 scrollList, 411 wx.LayoutOrientation, 391 selectedItemCount, 404 wx.ListAlign, 392 setColumn, 405 wx.Listbook, 393 setColumnWidth, 405 Constructor, 393 setImageList, 408 create, 393 setItem, 406 onPageChanged, 393 setItemData, 407 onPageChanging, 394 setItemImage, 406 wx.ListbookEvent, 395 setItemPosition, 407 wx.ListBox, 396 setItemState, 406 Constructor, 396 setItemText, 406 create, 396 setSingleStyle, 407 insertItems, 397 sortItems, 411 onDoubleClicked, 397 textColour, 404 onListBox, 397 topItem, 404 selections, 396 virtual, 403 setFirstItem, 397 windowStyleFlag, 404 wx.ListColumnFormat, 398 wx.ListEvent, 412 wx.ListCtrl, 399 cacheFrom, 412 arrange, 408 cacheTo, 412 clearAll, 409 column, 412 columnCount, 403 data, 412 Constructor, 402 image, 412 countPerPage, 403 index, 412 create, 404 item, 412 deleteAllColumns, 409 keyCode, 413 deleteAllItems, 409 label, 413 deleteColumn, 409 mask, 413 deleteItem, 408 point, 413 editControl, 403 text, 413 editLabel, 410 wx.ListFind, 414 endEditLabel, 410 wx.ListItem, 417 ensureVisible, 410 align, 417 findItem, 410 backgroundColour, 417 getColumn, 405 column, 417 getColumnWidth, 405 Constructor, 417 getImageList, 408 data, 417 getItem, 405 font, 417 getItemData, 407 hasAttributes, 417 getItemPosition, 407 id, 418
596 Index
image, 418 isChecked, 435 mask, 418 isEnabled, 436 state, 418 menuItemCount, 432 stateMask, 418 menuItems, 432 text, 418 newColumn, 434 textColour, 418 prepend, 436 width, 418 prependCheckItem, 436 wx.ListItemAttr, 415 prependRadioItem, 437 backgroundColour, 415 prependSeparator, 437 Constructor, 415 remove, 436 font, 415 setHelpString, 436 hasBackgroundColour, 415 setLabel, 436 hasFont, 415 title, 432 hasTextColour, 415 wx.MenuBar, 428 textColour, 415 append, 428 wx.ListMask, 419 check, 428 wx.ListNext, 420 Constructor, 428 wx.ListRect, 421 enable, 429 wx.ListState, 422 enableTop, 429 wx.MaximizeEvent, 423 findMenu, 429 wx.MDIChildFrame, 424 findMenuItem, 429 activate, 424 getHelpString, 429 Constructor, 424 getLabel, 429 create, 424 getMenu, 430 maximize, 424 getMenuLabel, 429 restore, 424 insert, 430 wx.MDIParentFrame, 426 isChecked, 430 activeChild, 426 isEnabled, 430 activeNext, 426 menuCount, 428 activePrevious, 427 menus, 428 arrangeIcons, 427 refresh, 430 cascade, 427 remove, 430 Constructor, 426 replace, 430 create, 426 setHelpString, 431 tile, 427 setLabel, 431 wx.Menu, 432 setMenuLabel, 431 actions, 432 wx.MenuItem, 438 append, 433 accel, 438 appendCheckItem, 433 backgroundColour, 438 appendRadioItem, 433 bitmap, 438 appendSeparator, 433 check, 438 appendSubMenu, 433 checkable, 438 check, 434 Constructor, 438 Constructor, 432 enable, 439 deleteItem, 434 font, 439 destroy, 435 help, 439 enable, 434 id, 439 findItem, 434 itemLabel, 440 getHelpString, 434 label, 439 getLabel, 434 marginWidth, 439 insert, 435 menu, 439 insertCheckItem, 435 separator, 439 insertRadioItem, 435 setBitmaps, 440 insertSeparator, 435 subMenu, 440
597 Index
textColour, 440 wx.PCXHandler, 455 wx.MouseEvent, 441 wx.PickerBase, 456 altDown, 441 colour, 456 button, 441, 444 wx.PNGHandler, 457 buttonDClick, 444 wx.PNMHandler, 458 buttonDown, 444 wx.Point, 459 buttonUp, 444 Constructor, 459 controlDown, 441 x, 459 dragging, 441 y, 459 entering, 441 wx.QueryLayoutInfoEvent, 460 leaving, 441 alignment, 460 leftDClick, 442 flags, 460 leftDown, 442 orientation, 460 leftIsDown, 442 requestedLength, 460 linesPerAction, 442 size, 460 metaDown, 442 wx.RadioBox, 461 middleDClick, 442 Constructor, 461 middleDown, 442 count, 461 middleIsDown, 442 create, 462 moving, 443 enable, 462 position, 443 findString, 462 rightDClick, 443 item, 461 rightDown, 443 onRadioBox, 463 rightIsDown, 443 selection, 461 shiftDown, 443 setString, 462 wheelDelta, 443 show, 462 wheelRotation, 443 stringSelection, 462 x, 444 wx.RadioBoxItem, 464 y, 444 enable, 464 wx.MoveEvent, 445 selected, 464 position, 445 show, 464 wx.Notebook, 447 string, 464 Constructor, 447 wx.RadioButton, 465 create, 448 Constructor, 465 onPageChanged, 448 onRadioButton, 465 onPageChanging, 448 value, 465 rowCount, 447 wx.Rect, 466 setPadding, 448 bottom, 466 setTabSize, 448 Constructor, 466 themeBackgroundColour, 447 deflate, 467 wx.NotebookEvent, 449 empty, 467 wx.NotebookHittest, 450 height, 466 wx.NotifyEvent, 451 inflate, 467 allowed, 451 intersect, 468 veto, 451 intersects, 468 wx.Orientation, 452 left, 466 wx.Panel, 453 offset, 468 Constructor, 453 position, 466 create, 453 right, 467 initDialog, 453 size, 467 onSysColourChanged, 453 top, 467 setFocusIgnoringChildren, 453 width, 466 wx.PasswordEntryDialog, 454 x, 467 Constructor, 454 y, 467
598 Index wx.SashDragStatus, 469 width, 481 wx.SashEdgePosition, 470 wx.SizeEvent, 484 wx.SashEvent, 471 size, 484 dragRect, 471 wx.Sizer, 485 dragStatus, 471 add, 487 edge, 471 addSpacer, 487 wx.SashLayoutWindow, 472 addStretchSpacer, 487 alignment, 472 calcMin, 487 Constructor, 472 children, 486 create, 472 clear, 488 orientation, 472 containingWindow, 487 setDefaultSize, 473 detach, 488 wx.SashWindow, 474 fit, 488 Constructor, 474 fitInside, 488 create, 475 getItem, 490 getSashVisible, 475 hide, 488 maximumSizeX, 474 insert, 489 maximumSizeY, 474 insertSpacer, 489 minimumSizeX, 475 insertStretchSpacer, 489 minimumSizeY, 475 isShown, 489 onSashDragged, 475 layout, 490 setSashVisible, 475 minSize, 486 wx.ScrolledWindow, 476 position, 486 calcScrolledPosition, 477 prepend, 490 calcUnscrolledPosition, 477 prependSpacer, 491 Constructor, 476 prependStretchSpacer, 491 create, 477 remove, 491 enableScrolling, 477 replace, 491 getView, 477 setDimension, 491 retained, 476 setItemMinSize, 492 scroll, 477 setMinSize, 491 scrollPixelsPerUnit, 476 setSizeHints, 492 setScrollbars, 478 setVirtualSizeHints, 492 setScrollRate, 478 show, 492 setTargetWindow, 478 size, 486 viewStart, 476 wx.SizerFlags, 494 virtualSize, 476 align, 494 wx.ScrollEvent, 479 border, 494 orientation, 479 center, 495 position, 479 Constructor, 494 wx.ScrollWinEvent, 480 doubleBorder, 495 orientation, 480 doubleHorzBorder, 495 position, 480 expand, 495 wx.Size, 481 fixedMinSize, 495 Constructor, 481 left, 495 decBy, 481 proportion, 495 decTo, 482 right, 495 fullySpecified, 481 shaped, 496 height, 481 tripleBorder, 496 incBy, 482 wx.SizerItem, 497 incTo, 482 border, 497 scale, 482 calcMin, 498 set, 482 flag, 497 setDefaults, 482 minSize, 497
599 Index
position, 497 setSelection, 506 proportion, 497 value, 505 ratio, 497 wx.SpinEvent, 507 rect, 497 position, 507 show, 498 wx.SplitMode, 508 size, 497 wx.SplitterEvent, 509 sizer, 497 sashPosition, 509 spacer, 498 windowBeingRemoved, 509 window, 498 x, 509 wx.Slider, 499 y, 509 clearSel, 501 wx.SplitterWindow, 510 clearTicks, 501 Constructor, 510 Constructor, 499 create, 511 create, 500 initialize, 512 lineSize, 499 isSplit, 511 max, 500 minimumPaneSize, 511 min, 500 onDClick, 513 onScrollBottom, 501 onSashPosChanged, 513 onScrollChanged, 501 onSashPosChanging, 513 onScrollLineDown, 502 onUnsplit, 513 onScrollLineUp, 502 replaceWindow, 512 onScrollPageDown, 502 sashPosition, 511 onScrollPageUp, 502 setSashPosition, 512 onScrollThumbRelease, 502 splitHorizontally, 512 onScrollThumbTrack, 502 splitMode, 511 onScrollTop, 501 splitVertically, 512 pageSize, 500 unsplit, 513 selEnd, 500 window1, 511 selStart, 500 window2, 511 setRange, 501 wx.StaticBox, 514 setSelection, 501 Constructor, 514 setTickFreq, 501 wx.StaticBoxSizer, 515 value, 500 Constructor, 515 wx.SpinButton, 503 staticBox, 515 Constructor, 503 wx.StaticText, 516 create, 504 Constructor, 516 max, 503 create, 516 min, 503 label, 516 onSpin, 504 wrap, 517 onSpinDown, 504 wx.StatusBar, 518 onSpinUp, 504 Constructor, 519 setRange, 504 create, 519 value, 503 fieldsCount, 519 wx.SpinCtrl, 505 getFieldRect, 519 Constructor, 505 getStatusText, 519 create, 506 setFieldsCount, 519 max, 505 setStatusText, 520 min, 505 statusWidths, 519 onSpin, 506 wx.Stretch, 521 onSpinCtrl, 506 wx.SysColourChangedEvent, 522 onSpinDown, 506 wx.SystemSettings, 523 onSpinUp, 506 getColour, 525 onText, 506 getFont, 526 setRange, 506 getMetric, 526
600 Index
screenType, 525 deleteTool, 539 wx.TextCtrl, 527 deleteToolByPos, 539 appendText, 529 enableTool, 539 canCopy, 527 findControl, 539 canCut, 527 getToolEnabled, 539 canPaste, 527 getToolLongHelp, 539 canRedo, 528 getToolShortHelp, 540 canUndo, 528 getToolState, 540 clear, 529 insertControl, 540 Constructor, 527 insertSeparator, 540 cut, 529 insertTool, 540 discardEdits, 529 margins, 537 editable, 528 realize, 540 empty, 529 setToolLongHelp, 540 getLineLength, 529 setToolShortHelp, 541 getLineText, 530 toggleTool, 541 insertionPoint, 528 toolBitmapSize, 537 lastPosition, 528 toolPacking, 537 loadFile, 530 toolSeparation, 537 modified, 528 toolSize, 537 multiLine, 529 wx.ToolBarTool, 542 numberOfLines, 528 enable, 542 onText, 531 onTool, 542 onTextEnter, 531 toggle, 542 onTextMaxLen, 531 wx.Toolbook, 543 onTextURL, 531 Constructor, 543 paste, 530 create, 543 redo, 530 onPageChanged, 543 remove, 530 onPageChanging, 543 replace, 530 realize, 543 saveFile, 531 wx.ToolbookEvent, 544 setMaxLength, 531 wx.TopLevelWindow, 545 setSelection, 530 active, 545 singleLine, 529 defaultItem, 545 value, 528 fullScreen, 545 wx.TextEntryDialog, 532 icon, 545 Constructor, 532 iconized, 545 value, 532 maximized, 545 wx.TextValidator, 533 setSizeHints, 546 Constructor, 533 showFullScreen, 546 excludes, 533 title, 545 includes, 533 wx.Treebook, 547 style, 534 addSubPage, 547 value, 534 collapseNode, 547 wx.TIFFHandler, 535 Constructor, 547 wx.ToolBar, 536 create, 547 actions, 537 expandNode, 548 addCheckTool, 538 getPageParent, 548 addControl, 538 insertSubPage, 548 addRadioTool, 538 isNodeExpanded, 548 addSeparator, 538 onNodeExpanded, 548 addTool, 538 onPageChanged, 548 Constructor, 536 onPageChanging, 548 create, 537 onPageCollapsed, 548
601 Index wx.TreebookEvent, 549 onKeyDown, 560 wx.TreeCtrl, 550 onSelChanged, 560 addRoot, 556 onSelChanging, 560 appendItem, 557 onSetInfo, 560 collapse, 558 prependItem, 557 collapseAndReset, 558 rootItem, 551 Constructor, 550 scrollTo, 559 count, 550 selection, 551 deleteAllItems, 558 selections, 551 deleteChildren, 558 selectItem, 559 deleteItem, 558 setItemBackgroundColour, 554 editLabel, 559 setItemBold, 554 endEditLabel, 559 setItemData, 553 ensureVisible, 559 setItemDropHighlight, 555 expand, 558 setItemFont, 554 firstVisibleItem, 551 setItemHasChildren, 554 getChildrenCount, 555 setItemImage, 552 getFirstChild, 555 setItemText, 552 getItem, 552 setItemTextColour, 553 getItemBackgroundColour, 553 sortChildren, 559 getItemData, 552 stateImageList, 552 getItemFont, 554 toggle, 558 getItemImage, 552 unselect, 558 getItemParent, 555 unselectAll, 558 getItemText, 552 wx.TreeEvent, 562 getItemTextColour, 553 isEditCancelled, 562 getNextChild, 556 item, 562 getNextSibling, 556 keyCode, 562 getNextVisible, 556 keyEvent, 562 getPrevSibling, 556 label, 562 getPrevVisible, 556 oldItem, 562 hitTest, 559 point, 562 imageList, 551 wx.TreeItem, 564 indent, 551 allChildrenCount, 564 insertItem, 557 backgroundColour, 564 isBold, 554 bold, 564 isExpanded, 555 childrenCount, 564 isSelected, 555 data, 564 isVisible, 555 expanded, 564 onBeginDrag, 560 font, 564 onBeginLabelEdit, 560 getFirstChild, 566 onBeginRDrag, 560 getImage, 566 onCompareItems, 551 getNextChild, 566 onDeleteItem, 560 hasChildren, 565 onEndDrag, 561 lastChild, 565 onEndLabelEdit, 560 nextSibling, 565 onGetInfo, 560 parent, 565 onItemActivated, 561 prevSibling, 565 onItemCollapsed, 560 selected, 565 onItemCollapsing, 560 setImage, 566 onItemExpanded, 560 text, 565 onItemExpanding, 560 textColour, 565 onItemMiddleClick, 561 visible, 566 onItemRightClick, 561 wx.TreeItemIcon, 567
602 Index wx.TreeItemId, 568 onKeyDown, 579 ok, 568 onKeyUp, 579 wx.Validator, 569 onKillFocus, 579 bellOnError, 569 onLeaveWindow, 580 transferFromWindow, 569 onLeftDClick, 580 transferToWindow, 569 onLeftDown, 580 validate, 569 onLeftUp, 580 window, 569 onMiddleDClick, 580 wx.Window, 570 onMiddleDown, 580 acceleratorTable, 571 onMiddleUp, 580 acceptsFocus, 571 onMotion, 580 acceptsFocusFromKeyboard, 571 onMouseEvents, 579 autoLayout, 572 onMouseWheel, 580 backgroundColour, 572 onMove, 580 bestSize, 572 onRightDClick, 580 capture, 571 onRightDown, 580 captureMouse, 575 onRightUp, 580 caret, 572 onScroll, 581 centerOnParent, 577 onScrollBottom, 581 centre, 575 onScrollLineDown, 581 children, 572 onScrollLineUp, 581 clearBackground, 575 onScrollPageDown, 581 clientAreaOrigin, 572 onScrollPageUp, 581 clientRect, 572 onScrollThumbRelease, 581 clientSize, 572 onScrollThumbTrack, 581 clientToScreen, 575 onScrollTop, 581 close, 575 onSetFocus, 579 convertDialogToPixels, 575 onSize, 580 convertPixelsToDialog, 575 parent, 573 destroy, 576 position, 573 destroyChildren, 576 raise, 577 enable, 573 rect, 574 extraStyle, 573 refresh, 577 findFocus, 571 releaseMouse, 576 findWindow, 578 setClientSize, 579 findWindowById, 571 setFocus, 577 findWindowByLabel, 571 setSize, 576 fit, 577 show, 577 font, 573 shown, 574 foregroundColour, 573 size, 574 freeze, 579 sizer, 574 hasCapture, 573 thaw, 579 id, 573 topLevel, 574 initDialog, 578 transferDataFromWindow, 578 layout, 576 transferDataToWindow, 578 lower, 577 update, 578 makeModal, 578 validate, 578 move, 576 validator, 574 onActivate, 579 visible, 574 onCalculateLayout, 579 warpPointer, 576 onChar, 579 windowStyle, 574 onCharHook, 579 wx.XPMHandler, 582 onEnterWindow, 580 onHelp, 581
603