Changes from Version 1 of documentation/PythonManual/APIReference

Show
Ignore:
Author:
lloydw (IP: 192.168.0.1)
Timestamp:
01/04/08 14:16:10 (10 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • documentation/PythonManual/APIReference

    v0 v1  
     1[[PageOutline(1-5, Contents)]] 
     2= API Reference = 
     3 
     4== Module == 
     5 
     6 '''CreateContext'''(''name'', ''dimensions''):: 
     7   Creates and returns a new context called ''name'', with initial dimensions of ''dimensions''. The dimensions are a ''Vector2i'' type. The name of the context must be unique; if it is not, None will be returned. 
     8 
     9 '''GetContext(''name''):: 
     10   Returns the context called ''name''. If no such context exists, None will be returned. 
     11 
     12 '''LoadFontFace'''(''font_path''):: 
     13   Loads the font face at ''font_path''. The function will return True if the font face was loaded, False if not. 
     14 
     15== Basic Types == 
     16 
     17 '''class''' Vector2i(''x'', ''y''):: 
     18   Constructs a two-dimensional integral vector. 
     19 
     20 '''class''' Vector2f(''x'', ''y''):: 
     21   Constructs a two-dimensional floating-point vector. 
     22 
     23 '''class''' Colourb(''red'', ''green'', ''blue'', ''alpha''):: 
     24   Constructs a colour with four channels, each from 0 to 255. 
     25 
     26== DataSource == 
     27'''class''' DataSource(''name'') 
     28 
     29Abstract DataSource Interface. 
     30 
     31 '''GetNumRows'''(''table_name''):: 
     32   Return the number of rows in the given table 
     33 
     34 '''GetRow'''(''table_name'', ''index'', ''columns''):: 
     35   Return a list of the column values in string form 
     36 
     37 '''NotifyRowAdd'''(''table_name'', ''first_row_added'', ''num_rows_added''):: 
     38   Notify listeners that rows have been added to the data source. 
     39 
     40 '''NotifyRowRemove'''(''table_name'', ''first_row_removed'', ''num_rows_removed''):: 
     41   Notify listeners that rows have been removed from the data source. 
     42 
     43 '''NotifyRowChange'''(''table_name'', ''first_row_changed'', ''num_rows_changed''):: 
     44   Notify listeners that rows have been changed on the data source. 
     45 
     46 '''NotifyRowChange'''(''table_name''):: 
     47   Notify listeners that all rows on the data source have changed. 
     48 
     49== Element == 
     50 
     51'''class''' Element 
     52 
     53The ''Element'' class has no constructor; it must be instantiated through a ''[wiki:documentation/PythonManual/APIReference#Document Document]'' object instead. It has the following methods and properties: 
     54 
     55 '''AddEventListener'''(''event'', ''listener''[, ''in_capture_phase'']):: 
     56   Attaches ''listener'' to this element, listening for occurrences of ''event'' in either the bubble or capture phase. If not specified, ''in_capture_phase'' will default to False.[[br]]''NOTE: Events added from python cannot be removed.'' 
     57 
     58 '''AppendChild'''(''element''):: 
     59   Appends ''element'' as a child to this element. 
     60 
     61 '''Blur'''():: 
     62   Removes input focus from this element. 
     63 
     64 '''Click'''():: 
     65   Fakes a click on this element. 
     66 
     67 '''DispatchEvent'''(''event'', ''parameters'', ''interruptible''):: 
     68   Dispatches an event to this element. The event is of type ''event''. Parameters to the event are given in the dictionary ''parameters''; the dictionary must only contain string keys and floating-point, integer or string values. ''interruptible'' determines if the event can be forced to stop propagation early. 
     69 
     70 '''Focus'''():: 
     71   Gives input focus to this element. 
     72 
     73 '''GetAttribute'''(''name''):: 
     74   Returns the value of the attribute named ''name''. If no such attribute exists, the empty string will be returned. 
     75 
     76 '''GetElementById'''(''id''):: 
     77   Returns the descendant element with an id of ''id''. 
     78 
     79 '''GetElementsByTagName'''(''tag_name''):: 
     80   Returns a list of all descendant elements with the tag of ''tag_name''. 
     81 
     82 '''HasAttribute'''(''name''):: 
     83   Returns True if the element has a value for the attribute named ''name'', False if not. 
     84 
     85 '''HasChildNodes'''():: 
     86   Returns True if the element has at least one child node, false if not. 
     87 
     88 '''InsertBefore'''(''element'', ''adjacent_element''):: 
     89   Inserts the element ''element'' as a child of this element, directly before ''adjacent_element'' in the list of children. 
     90 
     91 '''RemoveAttribute'''(''name''):: 
     92   Removes the attribute named ''name'' from the element. 
     93 
     94 '''RemoveChild'''(''element''):: 
     95   Removes the child element ''element'' from this element. 
     96 
     97 '''ReplaceChild'''(''inserted_element'', ''replaced_element''):: 
     98   Replaces the child element ''replaced_element'' with ''inserted_element'' in this element's list of children. If ''replaced_element'' is not a child of this element, ''inserted_element'' will be appended onto the list instead. 
     99 
     100 '''ScrollIntoView'''(''align_with_top''):: 
     101   Scrolls this element into view if its ancestors have hidden overflow. If ''align_with_top'' is True, the element's top edge will be aligned with the top (or as close as possible to the top) of its ancestors' viewing windows. If False, its bottom edge will be aligned to the bottom. 
     102 
     103 '''SetAttribute'''(''name'', ''value''):: 
     104   Sets the value of the attribute named ''name'' to ''value''. 
     105 
     106 '''attributes''':: 
     107   The array of attributes on the element. Each element has the read-only properties ''name'' and ''value''. Read-only. 
     108 
     109 '''child_nodes''':: 
     110   The array of child nodes on the element. Read-only. 
     111 
     112 '''class_name''':: 
     113   The space-separated list of classes on the element. 
     114 
     115 '''client_left''':: 
     116   The distance between the left border edge and the left client edge of the element. Read-only. 
     117 
     118 '''client_height''':: 
     119   The height of the element's client area. Read-only. 
     120 
     121 '''client_top''':: 
     122   The distance between the top border edge and the top client edge of the element. Read-only. 
     123 
     124 '''client_width''':: 
     125   The width of the element's client area. Read-only. 
     126 
     127 '''first_child''':: 
     128   The first child of the element, or None if the client has no children. Read-only. 
     129 
     130 '''id''':: 
     131   The ID of the element, or the empty string if the element has no ID. 
     132 
     133 '''inner_rml''':: 
     134   The element's RML content. 
     135 
     136 '''last_child''':: 
     137   The last child of the element, or None if the client has no children. Read-only. 
     138 
     139 '''next_sibling''':: 
     140   The element's next sibling, or None if it is the last sibling. Read-only. 
     141 
     142 '''offset_height''':: 
     143   The height of the element, excluding margins. Read-only. 
     144 
     145 '''offset_left''':: 
     146   The distance between the element's offset parent's left border edge and this element's left border edge. Read-only. 
     147 
     148 '''offset_parent''':: 
     149   The element's offset parent. Read only. 
     150 
     151 '''offset_top''':: 
     152   The distance between the element's offset parent's top border edge and this element's top border edge. Read-only. 
     153 
     154 '''offset_width''':: 
     155   The width of the element, excluding margins. Read-only. 
     156 
     157 '''owner_document''':: 
     158   The document this element is part of. Read-only. 
     159 
     160 '''parent_node''':: 
     161   The element this element is directly parented to. Read-only. 
     162 
     163 '''previous_sibling''':: 
     164   The element's previous sibling, or None if it is the first sibling. Read-only. 
     165 
     166 '''scroll_height''':: 
     167   The height of this element's content. This will be at least as high as the client height. Read-only. 
     168 
     169 '''scroll_left''':: 
     170   The offset between the left edge of this element's client area and the left edge of the content area. 
     171 
     172 '''scroll_top''':: 
     173   The offset between the top edge of this element's client area and the top edge of the content area. 
     174 
     175 '''scroll_width''':: 
     176   The width of this element's content. This will be at least as wide as the client width. Read-only. 
     177 
     178 '''style''':: 
     179   An object used to access this element's style information. Individual RCSS properties can be accessed by using the name of the property as a Python property on the object itself (ie, element.style.width = "40px"). 
     180 
     181 '''tag_name''':: 
     182   The tag name used to instance this element. Read-only. 
     183 
     184== ElementText == 
     185 
     186'''class''' IElementText 
     187 
     188''IElementText'' derives from ''Element''. ''IElementText'' is an interface, and therefore cannot be instanced directly. A concrete ''ElementText'' must be instantiated through a ''[wiki:documentation/PythonManual/APIReference#Document Document]'' object instead. It has the following property: 
     189 
     190 '''text''':: 
     191   The raw text content of the text element in UTF-8 encoding. 
     192 
     193== Document == 
     194 
     195'''class''' Document 
     196 
     197''Document'' derives from ''Element''. ''Document'' has no constructor; it must be instantiated through a ''[wiki:documentation/PythonManual/APIReference#Context Context]'' object instead, either by loading an external RML file or creating an empty document. It has the following methods and properties: 
     198 
     199 '''PullToFront'''():: 
     200   Pulls the document in front of other documents within its context with a similar z-index. 
     201 
     202 '''PushToBack'''():: 
     203   Pushes the document behind other documents within its context with a similar z-index. 
     204 
     205 '''Show'''([''flags'']):: 
     206   Shows the document. ''flags'' is either ''NONE'', ''FOCUS'' or ''MODAL''. ''flags'' defaults to ''FOCUS''. 
     207 
     208 '''Hide'''():: 
     209   Hides the document. 
     210 
     211 '''Close'''():: 
     212   Hides and closes the document, destroying its contents. 
     213 
     214 '''CreateElement'''(''tag_name''):: 
     215   Instances an element with a tag of ''tag_name''. 
     216 
     217 '''CreateTextNode'''(''text''):: 
     218   Instances a text element containing the string ''text''. 
     219 
     220 '''title''':: 
     221   The title of the document, as initially set by the <title> tag in the document's header. 
     222 
     223 '''context''':: 
     224   The context the document belongs to. Read-only. 
     225 
     226== Event == 
     227 
     228'''class''' Event 
     229 
     230The Event class has no constructor; it is generated internally. It has the following methods and properties: 
     231 
     232 '''StopPropagation'''():: 
     233   Stops the propagation of the event through the event cycle, if allowed. 
     234 
     235 '''current_element''':: 
     236   The element the event has propagated to. Read-only. 
     237 
     238 '''type''':: 
     239   The string name of the event. Read-only. 
     240 
     241 '''target_element''':: 
     242   The element the event was originally targeted at. Read-only. 
     243 
     244Parameters on the event are accessed by name as properties on the event itself. 
     245 
     246== Context == 
     247 
     248'''class''' Context 
     249 
     250The ''Context'' class has no constructor; it must be instantiated through the ''CreateContext()'' function. It has the following methods and properties: 
     251 
     252 '''AddEventListener'''(''event'', ''script'', ''element_context'', ''in_capture_phase''):: 
     253   Adds the inline Python script, ''script'', as an event listener to the context. ''element_context'' is an optional Element; if it is not None, then the script will be executed as if it was bound to that element. 
     254 
     255 '''AddMouseCursor'''(''cursor_document''):: 
     256   Adds a cursor document loaded by another context into this context. The cursor document will be returned. 
     257 
     258 '''CreateDocument'''(''tag''):: 
     259   Creates a new document with the tag name of ''tag''. 
     260 
     261 '''LoadDocument'''(''document_path''):: 
     262   Attempts to load a document from the RML file found at ''document_path''. If successful, the document will be returned with a reference count of one. 
     263 
     264 '''LoadMouseCursor'''(''cursor_document_path''):: 
     265   Attempts to load a document from the RML file found at ''cursor_document_path'' as a cursor. If successful, the cursor's document will be returned with a reference count of one. 
     266 
     267 '''Render'''():: 
     268   Renders the context. 
     269 
     270 '''ShowMouseCursor'''(''show''):: 
     271   If ''show'' is True, this shows the mouse cursor, otherwise hides it. 
     272 
     273 '''UnloadAllDocuments'''():: 
     274   Closes all documents currently loaded with the context. 
     275 
     276 '''UnloadAllMouseCursors'''():: 
     277   Unloads all cursors currently loaded with the context. 
     278 
     279 '''UnloadDocument'''(''document''):: 
     280   Unloads a specific document within the context. 
     281 
     282 '''UnloadMouseCursor'''(''cursor_name''):: 
     283   Unloads a specific cursor by name. 
     284 
     285 '''Update'''():: 
     286   Updates the context. 
     287 
     288 '''dimensions''':: 
     289   The dimensions of the context, as a ''Vector2i'' type. 
     290 
     291 '''documents''':: 
     292   Returns an array of the documents within the context. This can be looked up as an array or a dictionary. Read-only. 
     293 
     294 '''focus_element''':: 
     295   Returns the leaf of the context's focus tree. Read-only. 
     296 
     297 '''name''':: 
     298   The name of the context, specified at construction. Read-only. 
     299 
     300= Controls API Reference = 
     301 
     302== ElementForm == 
     303 
     304'''class''' ElementForm 
     305 
     306''ElementForm'' derives from ''Element''. The form element has the following method: 
     307 
     308 '''Submit'''(''submit_value''):: 
     309   Submits the form with a submit value of ''submit_value''. 
     310 
     311== ElementFormControl == 
     312 
     313'''class''' IElementFormControl 
     314 
     315''IElementFormControl'' derives from ''Element''. The form element control has the following properties: 
     316 
     317 '''disabled''':: 
     318   The disabled status of the control, either True or False. 
     319 
     320 '''name''':: 
     321   The name of the control, initial set with the "name" attribute. 
     322 
     323 '''value''':: 
     324   The current value of the control. 
     325 
     326== ElementFormControlSelect == 
     327 
     328'''class''' ElementFormControlSelect 
     329 
     330''ElementFormControlSelect'' derives from ''IElementFormControl''. The control has the following methods and properties: 
     331 
     332 '''Add'''(''rml'', ''value''[, ''before'']):: 
     333   Adds a new option to the select box. The new option has the string value of ''value'' and is represented by the elements created by the RML string ''rml''. The new option will be inserted by the index specified by ''before''; if this is out of bounds (the default), then the new option will be appended onto the list. The index of the new option will be returned. 
     334 
     335 '''Remove'''(''index''):: 
     336   Removes an existing option from the selection box. 
     337 
     338 '''options''':: 
     339   The array of options available in the select box. Each entry in the array has the property ''value'', the string value of the option, and ''element'', the root of the element hierarchy that represents the option in the list. 
     340 
     341 '''selection''':: 
     342   The index of the currently selected option. 
     343 
     344== ElementFormControlDataSelect == 
     345 
     346'''class''' ElementFormControlDataSelect 
     347 
     348''ElementFormControlDataSelect'' derives from ''ElementFormControlSelect''. It has the following additional method: 
     349 
     350 '''SetDataSource'''(''data_source_name''):: 
     351   Sets the name and table of the new data source to be used by the select box. 
     352 
     353== ElementFormControlInput == 
     354 
     355'''class''' ElementFormControlInput 
     356 
     357''ElementFormControlInput'' derives from ''IElementFormControl''. The control has the following properties, only appropriate on the relevant types: 
     358 
     359 '''checked''':: 
     360   Relevant for ''radio'' and ''checkbox'' types. The checked status of the input. 
     361 
     362 '''max_length''':: 
     363   Relevant for ''text'' types. The maximum number of characters permitted in the text field. 
     364 
     365 '''size''':: 
     366   Relevant for ''text'' types. The approximate number of characters the text field shows horizontally at once. 
     367 
     368 '''max''':: 
     369   Relevant for ''range'' types. The value of the control on the bottom / right of the slider. 
     370 
     371 '''min''':: 
     372   Relevant for ''range'' types. The value of the control on the top / left of the slider. 
     373 
     374 '''step''':: 
     375   Relevant for ''range'' types. The step the control's value changes in. 
     376 
     377== ElementFormControlTextArea == 
     378 
     379'''class''' ElementFormControlTextArea 
     380 
     381''ElementFormControlTextArea'' derives from ''IElementFormControl''. The control has the following properties: 
     382 
     383 '''cols''':: 
     384   The approximate number of characters the text area shows horizontally at once. 
     385 
     386 '''max_length''':: 
     387   The maximum number of characters permitted in the text area. 
     388 
     389 '''rows''':: 
     390   The number of lines the text area shows at once. 
     391 
     392 '''word_wrap''':: 
     393   True if lines are split to fit into the text area, False if not. 
     394 
     395== ElementTabSet == 
     396 
     397'''class''' ElementTabSet 
     398 
     399''ElementTabSet'' derives from ''Element''. The control has the following methods and properties: 
     400 
     401 '''SetPanel'''(''index'', ''rml''):: 
     402   Sets the contents of a panel to the RML content ''rml''. If ''index'' is out-of-bounds, a new panel will be added at the end. 
     403 
     404 '''SetTab'''(''index'', ''rml''):: 
     405   Sets the contents of a tab to the RML content ''rml''. If ''index'' is out-of-bounds, a new tab will be added at the end. 
     406 
     407 '''num_tabs''':: 
     408   The number of tabs in the tab set. Read-only. 
     409 
     410== ElementDataGrid == 
     411 
     412'''class'' ElementDataGrid 
     413 
     414''ElementDataGrid'' derives from ''Element''. The data grid has the following methods: 
     415 
     416 '''AddColumn'''(''fields'', ''formatter'', ''initial_width'', ''header_rml''):: 
     417   Adds a new column to the data grid. The column will read the columns ''fields'' (in CSV format) from the grid's data source, processing it through the data formatter named ''formatter''. ''header_rml'' specifies the RML content of the column's header. 
     418 
     419 '''SetDataSource'''(''data_source_name''):: 
     420   Sets the name and table of the new data source to be used by the data grid. 
     421 
     422== ElementDataGridRow == 
     423 
     424'''class''' ElementDataGridRow 
     425 
     426''ElementDataGridRow'' derives from ''Element''. The data grid row has the following property: 
     427 
     428 '''row_expanded''':: 
     429   The expanded state of the row, either True or False.