nobody at rubyforge.org
2007-Jul-04 19:08 UTC
[Wxruby-development] [1104] trunk/wxruby2: Added 2.8 methods to TextCtrl & document them; tidy up header file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type"
content="text/html; charset=utf-8" /><style
type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:'':'';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family:
verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;
font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding:
6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid;
padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family:
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch
.binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[1104] trunk/wxruby2: Added 2.8 methods to TextCtrl & document
them; tidy up header file</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>1104</dd>
<dt>Author</dt> <dd>brokentoy</dd>
<dt>Date</dt> <dd>2007-07-04 15:08:07 -0400 (Wed, 04 Jul
2007)</dd>
</dl>
<h3>Log Message</h3>
<pre>Added 2.8 methods to TextCtrl & document them; tidy up header
file</pre>
<h3>Modified Paths</h3>
<ul>
<li><a
href="#trunkwxruby2doctextiletextctrltxtl">trunk/wxruby2/doc/textile/textctrl.txtl</a></li>
<li><a
href="#trunkwxruby2swigclassesincludewxTextCtrlh">trunk/wxruby2/swig/classes/include/wxTextCtrl.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwxruby2doctextiletextctrltxtl"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/doc/textile/textctrl.txtl (1103 => 1104)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/doc/textile/textctrl.txtl        2007-07-04
19:00:47 UTC (rev 1103)
+++
trunk/wxruby2/doc/textile/textctrl.txtl        2007-07-04
19:08:07 UTC (rev 1104)
</span><span class="lines">@@ -41,6 +41,14 @@
</span><span class="cx">
</span><span class="cx"> See also "window styles
overview":windowstyles.html and
"TextCtrl.new":textctrl.html#TextCtrl_new.
</span><span class="cx">
</span><ins>+Note that alignment styles (@TE_LEFT@,
+@TE_CENTRE@ and @TE_RIGHT@) can be changed
+dynamically after control creation on MSW and GTK.
+@TE_READONLY@, @TE_PASSWORD@ and wrapping styles
+can be dynamically changed under GTK but not MSW. The other styles can be
+only set during control creation.
+
+
</ins><span class="cx"> h2. TextCtrl text format
</span><span class="cx">
</span><span class="cx"> The multiline text controls
always store the text as a sequence of lines
</span><span class="lines">@@ -92,6 +100,27 @@
</span><span class="cx"> text.set_default_style(
Wx::TextAttr.new(Wx::BLUE) )
</span><span class="cx"> text.append_text("Blue
on grey text\n")
</span><span class="cx">
</span><ins>+h2. Constants
+
+The values below are the possible return codes of the
+"hit_test":#TextCtrl_hittest method:
+
+
+
+ // the point asked is ...
+ enum TextCtrlHitTestResult
+ {
+ TE_HT_UNKNOWN = -2, // this means HitTest() is simply not implemented
+ TE_HT_BEFORE, // either to the left or upper
+ TE_HT_ON_TEXT, // directly on
+ TE_HT_BELOW, // below [the last line]
+ TE_HT_BEYOND // after [the end of line]
+ };
+ // ... the character returned
+
+
+
+
</ins><span class="cx"> h2. Event handling
</span><span class="cx">
</span><span class="cx"> The following commands are
processed by default event handlers in
</span><span class="lines">@@ -104,7 +133,7 @@
</span><span class="cx"> argument.
</span><span class="cx">
</span><span class="cx">
</span><del>-|*evt_text(id) { | event | ... }*|Respond
to a EVT_COMMAND_TEXT_UPDATED event,generated when the text changes. Notice that
this event will always be sentwhen the text controls contents changes - whether
this is due to user input orcomes from the program itself (for example, if
SetValue() is called)|
</del><ins>+|*evt_text(id) { | event | ... }*|Respond
to a EVT_COMMAND_TEXT_UPDATED event,generated when the text changes. Notice that
this event will be sentwhen the text controls contents changes - whether this is
due to user input orcomes from the program itself (for example, if SetValue() is
called); see ChangeValue() fora function which does not send this event.|
</ins><span class="cx">
|*evt_text_enter(id) { | event | ... }*|Respond
to a EVT_COMMAND_TEXT_ENTER event,generated when enter is pressed in a text
control (which must haveTE_PROCESS_ENTER style for this event to be generated).|
</span><span class="cx">
|*evt_text_maxlen(id) { | event | ... }*|User
tried to enter more textinto the control than the limit set by
"set_max_length":#TextCtrl_setmaxlength.|
</span><span class="cx">
</span><span class="lines">@@ -145,6 +174,7 @@
</span><span class="cx"> *
"TextCtrl#get_value":#TextCtrl_getvalue
</span><span class="cx"> *
"TextCtrl#hit_test":#TextCtrl_hittest
</span><span class="cx"> *
"TextCtrl#is_editable":#TextCtrl_iseditable
</span><ins>+* "TextCtrl#is_empty":#TextCtrl_isempty
</ins><span class="cx"> *
"TextCtrl#is_modified":#TextCtrl_ismodified
</span><span class="cx"> *
"TextCtrl#is_multi_line":#TextCtrl_ismultiline
</span><span class="cx"> *
"TextCtrl#is_single_line":#TextCtrl_issingleline
</span><span class="lines">@@ -162,9 +192,11 @@
</span><span class="cx"> *
"TextCtrl#set_insertion_point":#TextCtrl_setinsertionpoint
</span><span class="cx"> *
"TextCtrl#set_insertion_point_end":#TextCtrl_setinsertionpointend
</span><span class="cx"> *
"TextCtrl#set_max_length":#TextCtrl_setmaxlength
</span><ins>+*
"TextCtrl#set_modified":#TextCtrl_setmodified
</ins><span class="cx"> *
"TextCtrl#set_selection":#TextCtrl_setselection
</span><span class="cx"> *
"TextCtrl#set_style":#TextCtrl_setstyle
</span><span class="cx"> *
"TextCtrl#set_value":#TextCtrl_setvalue
</span><ins>+*
"TextCtrl#change_value":#TextCtrl_changevalue
</ins><span class="cx"> *
"TextCtrl#show_position":#TextCtrl_showposition
</span><span class="cx"> *
"TextCtrl#undo":#TextCtrl_undo
</span><span class="cx"> *
"TextCtrl#write_text":#TextCtrl_writetext
</span><span class="lines">@@ -408,14 +440,19 @@
</span><span class="cx"> h4. Remarks
</span><span class="cx">
</span><span class="cx"> Note that even empty text
controls have one line (where the insertion point
</span><del>-is), so GetNumberOfLines() never returns 0.
</del><ins>+is), so GetNumberOfLines() never returns $0$.
</ins><span class="cx">
</span><del>-For gtk_text (multi-line) controls, the number of lines
is
-calculated by actually counting newline characters in the buffer. You
-may wish to avoid using functions that work with line numbers if you are
-working with controls that contain large amounts of text.
</del><ins>+For GTK using GTK+ 1.2.x and earlier, the number of
lines in a multi-line
+text control is calculated by actually counting newline characters in the
+buffer, i.e. this function returns the number of logical lines and
doesn''t
+depend on whether any of them are wrapped. For all the other platforms, the
+number of physical lines in the control is returned.
</ins><span class="cx">
</span><ins>+Also note that you may wish to avoid using functions
that work with line
+numbers if you are working with controls that contain large amounts of text as
+this function has $O(N)$ complexity for $N$ being the number of lines.
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> h3(#TextCtrl_getrange).
TextCtrl#get_range
</span><span class="cx">
</span><span class="cx"> String
*get_range*(%(arg-type)Integer% from, %(arg-type)Integer% to)
</span><span class="lines">@@ -505,6 +542,7 @@
</span><span class="cx">
</span><span class="cx">
"position_to_xy":#TextCtrl_positiontoxy,
"XYToPosition":textctrlxytoposition.html
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> h3(#TextCtrl_iseditable).
TextCtrl#is_editable
</span><span class="cx">
</span><span class="cx"> Boolean *is_editable*()
</span><span class="lines">@@ -515,6 +553,17 @@
</span><span class="cx">
"set_editable":#TextCtrl_seteditable.
</span><span class="cx">
</span><span class="cx">
</span><ins>+h3(#TextCtrl_isempty). TextCtrl#is_empty
+
+ Boolean *is_empty*()
+
+Returns if the control is currently empty. This is the same as
+@GetValue().empty()@ but can be much more efficient for the multiline
+controls containing big amounts of text.
+
+2.7.1
+
+
</ins><span class="cx"> h3(#TextCtrl_ismodified).
TextCtrl#is_modified
</span><span class="cx">
</span><span class="cx"> Boolean *is_modified*()
</span><span class="lines">@@ -553,13 +602,14 @@
</span><span class="cx">
</span><span class="cx"> h3(#TextCtrl_loadfile).
TextCtrl#load_file
</span><span class="cx">
</span><del>- Boolean *load_file*(%(arg-type)String% filename)
</del><ins>+ Boolean *load_file*(%(arg-type)String% filename,
%(arg-type)Integer% fileType = TEXT_TYPE_ANY)
</ins><span class="cx">
</span><span class="cx"> Loads and displays the named
file, if it exists.
</span><span class="cx">
</span><span class="cx"> h4. Parameters
</span><span class="cx">
</span><span class="cx"> * _filename_ The filename of the
file to load.
</span><ins>+* _fileType_ The type of file to load. This is
currently ignored in TextCtrl.
</ins><span class="cx">
</span><span class="cx"> h4. Return value
</span><span class="cx">
</span><span class="lines">@@ -668,13 +718,14 @@
</span><span class="cx">
</span><span class="cx"> h3(#TextCtrl_savefile).
TextCtrl#save_file
</span><span class="cx">
</span><del>- Boolean *save_file*(%(arg-type)String% filename)
</del><ins>+ Boolean *save_file*(%(arg-type)String% filename,
%(arg-type)Integer% fileType = TEXT_TYPE_ANY)
</ins><span class="cx">
</span><span class="cx"> Saves the contents of the control
in a text file.
</span><span class="cx">
</span><span class="cx"> h4. Parameters
</span><span class="cx">
</span><span class="cx"> * _filename_ The name of the file
in which to save the text.
</span><ins>+* _fileType_ The type of file to save. This is
currently ignored in TextCtrl.
</ins><span class="cx">
</span><span class="cx"> h4. Return value
</span><span class="cx">
</span><span class="lines">@@ -766,6 +817,17 @@
</span><span class="cx"> Only implemented in MSW/GTK
starting with Widgets 2.3.2.
</span><span class="cx">
</span><span class="cx">
</span><ins>+h3(#TextCtrl_setmodified). TextCtrl#set_modified
+
+ *set_modified*(%(arg-type)Boolean% modified)
+
+Marks the control as being modified by the user or not.
+
+h4. See also
+
+"mark_dirty":#TextCtrl_markdirty,
"discard_edits":#TextCtrl_discardedits
+
+
</ins><span class="cx"> h3(#TextCtrl_setselection).
TextCtrl#set_selection
</span><span class="cx">
</span><span class="cx">
*set_selection*(%(arg-type)Integer% from, %(arg-type)Integer% to)
</span><span class="lines">@@ -814,10 +876,33 @@
</span><span class="cx"> Note that this function will
generate a @EVT_COMMAND_TEXT_UPDATED@
</span><span class="cx"> event.
</span><span class="cx">
</span><ins>+This function is deprecated and should not be used in
new code. Please use the
+"change_value":#TextCtrl_changevalue function instead.
+
</ins><span class="cx"> h4. Parameters
</span><span class="cx">
</span><span class="cx"> * _value_ The new value to set.
It may contain newline characters if the text control is multi-line.
</span><span class="cx">
</span><ins>+
+h3(#TextCtrl_changevalue). TextCtrl#change_value
+
+ *change_value*(%(arg-type)String% value)
+
+Sets the text value and marks the control as not-modified (which means that
+"is_modified":#TextCtrl_ismodified would return @false@ immediately
+after the call to SetValue).
+
+Note that this function will not generate the @EVT_COMMAND_TEXT_UPDATED@
+event.
+This is the only difference with "set_value":#TextCtrl_setvalue.
+See "this topic":progevent.html for more information.
+
+2.7.1
+
+h4. Parameters
+
+* _value_ The new value to set. It may contain newline characters if the text
control is multi-line.
+
</ins><span class="cx"> h3(#TextCtrl_showposition).
TextCtrl#show_position
</span><span class="cx">
</span><span class="cx">
*show_position*(%(arg-type)Integer% pos)
</span></span></pre></div>
<a id="trunkwxruby2swigclassesincludewxTextCtrlh"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/swig/classes/include/wxTextCtrl.h (1103 => 1104)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/include/wxTextCtrl.h        2007-07-04
19:00:47 UTC (rev 1103)
+++
trunk/wxruby2/swig/classes/include/wxTextCtrl.h        2007-07-04
19:08:07 UTC (rev 1104)
</span><span class="lines">@@ -7,10 +7,15 @@
</span><span class="cx"> {
</span><span class="cx"> public:
</span><span class="cx"> wxTextCtrl();
</span><del>- wxTextCtrl(wxWindow *parent, wxWindowID id,
wxString const &value = wxT(""),
-                wxPoint
const &pos = wxDefaultPosition, wxSize const &size = wxDefaultSize,
-                long
style = 0, wxValidator const &validator = wxDefaultValidator,
-                wxString
const &name = wxTextCtrlNameStr);
</del><ins>+ wxTextCtrl(wxWindow *parent,
+                        
wxWindowID id,
+                        
wxString const &value = wxT(""),
+                        
wxPoint const &pos = wxDefaultPosition,
+                        
wxSize const &size = wxDefaultSize,
+                        
long style = 0,
+                        
wxValidator const &validator = wxDefaultValidator,
+                        
wxString const &name = wxTextCtrlNameStr);
+
</ins><span class="cx"> bool Create(wxWindow *parent,
</span><span class="cx"> wxWindowID id,
</span><span class="cx"> const wxString
&value = wxEmptyString,
</span><span class="lines">@@ -21,12 +26,17 @@
</span><span class="cx"> const wxString
&name = wxTextCtrlNameStr);
</span><span class="cx">
</span><span class="cx"> virtual wxString GetValue()
const;
</span><del>- virtual void SetValue(const wxString& value);
</del><ins>+ virtual void SetValue(const wxString& value); //
deprecated since 2.8
+        virtual
void ChangeValue(const wxString& value);
+
+
</ins><span class="cx"> virtual int GetLineLength(long
lineNo) const;
</span><span class="cx"> virtual wxString
GetLineText(long lineNo) const;
</span><span class="cx"> virtual int
GetNumberOfLines() const;
</span><span class="cx"> virtual bool IsModified()
const;
</span><span class="cx"> virtual bool IsEditable()
const;
</span><ins>+        bool
IsEmpty() const;
+
</ins><span class="cx"> virtual void
GetSelection(long* from, long* to) const;
</span><span class="cx"> virtual void Clear();
</span><span class="cx"> virtual void Replace(long
from, long to, const wxString& value);
</span><span class="lines">@@ -74,6 +84,9 @@
</span><span class="cx"> bool
SetForegroundColour(const wxColour& colour);
</span><span class="cx"> bool
SetBackgroundColour(const wxColour& colour);
</span><span class="cx">
</span><ins>+
+ void SetModified(bool modified);
+
</ins><span class="cx">
        //
Although the following were public in the .h file,
</span><span class="cx">
        // I
believe they are not part of the public API
</span><span class="cx">
        //GtkWidget*
GetConnectWidget();
</span><span class="lines">@@ -82,7 +95,7 @@
</span><span class="cx"> //void CalculateScrollbar();
</span><span class="cx"> //void OnInternalIdle();
</span><span class="cx"> //void SetUpdateFont(bool ) {
}
</span><del>- //void SetModified() { m_modified = true; }
</del><ins>+
</ins><span class="cx"> //virtual void Freeze();
</span><span class="cx"> //virtual void Thaw();
</span><span class="cx"> //virtual bool
ScrollLines(int lines);
</span><span class="lines">@@ -103,9 +116,6 @@
</span><span class="cx"> //virtual wxString
GetLineText(long lineNo) const = 0;
</span><span class="cx"> //virtual int
GetNumberOfLines() const = 0;
</span><span class="cx">
</span><del>- //virtual bool IsModified() const = 0;
- //virtual bool IsEditable() const = 0;
-
</del><span class="cx"> bool IsSingleLine() const;
</span><span class="cx"> bool IsMultiLine() const;
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>
Maybe Matching Threads
- [971] branches/wxruby2/wxwidgets_282/swig/classes: Added method to turn off ''Check Spelling as You Type'' on OS X 10.4.x and above.
- [1112] trunk/wxruby2/swig/classes/include/wxTextCtrl.h: Remove unsupported form of TextCtrl#hit_test that''s not documented anyway
- [916] branches/wxruby2/wxwidgets_282: More Wx::AUI classes, event hooks and sample
- Mouse motion example - help
- [ wxruby-Bugs-14374 ] TextCtrl TE_RICH and SUNKEN_BORDER (WxRuby1.9.1)
