nobody at rubyforge.org
2006-Nov-15 18:41 UTC
[Wxruby-development] [740] trunk/wxruby2: API - Make ListCtrl#get_item return a ListCtrl item corresponding to a row and
<!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>[740] trunk/wxruby2: API - Make ListCtrl#get_item return a ListCtrl
item corresponding to a row and</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>740</dd>
<dt>Author</dt> <dd>brokentoy</dd>
<dt>Date</dt> <dd>2006-11-15 13:41:10 -0500 (Wed, 15 Nov
2006)</dd>
</dl>
<h3>Log Message</h3>
<pre>API - Make ListCtrl#get_item return a ListCtrl item corresponding to
a row and
optional column</pre>
<h3>Modified Paths</h3>
<ul>
<li><a
href="#trunkwxruby2doctextilelistctrltxtl">trunk/wxruby2/doc/textile/listctrl.txtl</a></li>
<li><a
href="#trunkwxruby2samplescontrolsget_item_samplerb">trunk/wxruby2/samples/controls/get_item_sample.rb</a></li>
<li><a
href="#trunkwxruby2swigclassesListCtrli">trunk/wxruby2/swig/classes/ListCtrl.i</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwxruby2doctextilelistctrltxtl"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/doc/textile/listctrl.txtl (739 => 740)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/doc/textile/listctrl.txtl        2006-11-13
22:32:58 UTC (rev 739)
+++
trunk/wxruby2/doc/textile/listctrl.txtl        2006-11-15
18:41:10 UTC (rev 740)
</span><span class="lines">@@ -168,7 +168,7 @@
</span><span class="cx">
*ListCtrl.new*(%(arg-type)Window% parent, %(arg-type)Integer% id,
</span><span class="cx"> %(arg-type)Point%
pos = DEFAULT_POSITION,
</span><span class="cx"> %(arg-type)Size%
size = DEFAULT_SIZE,
</span><del>- %(arg-type)Integer% style = LC_ICON,
</del><ins>+ %(arg-type)Integer% style = @LC_ICON@,
</ins><span class="cx">
%(arg-type)Validator% validator = DEFAULT_VALIDATOR,
</span><span class="cx"> %(arg-type)String%
name = ListCtrlNameStr)
</span><span class="cx">
</span><span class="lines">@@ -189,12 +189,6 @@
</span><span class="cx">
</span><span class="cx">
"ListCtrl#create":listctrl.html#ListCtrl_create,
"Validator":validator.html
</span><span class="cx">
</span><del>-
- *destructor*()
-
-Destructor, destroying the list control.
-
-
</del><span class="cx"> h3(#ListCtrl_arrange).
ListCtrl#arrange
</span><span class="cx">
</span><span class="cx"> Boolean
*arrange*(%(arg-type)Integer% flag = LIST_ALIGN_DEFAULT)
</span><span class="lines">@@ -311,10 +305,6 @@
</span><span class="cx"> _start_ or the beginning if
_start_ is -1.
</span><span class="cx">
</span><span class="cx">
</span><del>-
-
-
-
</del><span class="cx"> h3(#ListCtrl_getcolumn).
ListCtrl#get_column
</span><span class="cx">
</span><span class="cx"> Boolean
*get_column*(%(arg-type)Integer% col, %(arg-type)ListItem% item)
</span><span class="lines">@@ -371,23 +361,21 @@
</span><span class="cx"> |@IMAGE_LIST_SMALL@|The small
icon image list.|
</span><span class="cx"> |@IMAGE_LIST_STATE@|The
user-defined state image list (unimplemented).|
</span><span class="cx">
</span><del>-
-
</del><span class="cx"> h3(#ListCtrl_getitem).
ListCtrl#get_item
</span><span class="cx">
</span><del>- Boolean *get_item*(%(arg-type)ListItem% info)
</del><ins>+ "ListItem":listitem.html
*get_item*(%(arg-type)Integer% row,
+ %(arg-type)Integer% col = -1)
</ins><span class="cx">
</span><del>-Gets information about the item. See
"ListCtrl#set_item":listctrl.html#ListCtrl_setitem for more
-information.
</del><ins>+Gets information, such as the text label, font and
colour, about a
+ListCtrl item at zero-based row number @row@. The @col@ parameter is
+optional, and is only meaningful if the ListCtrl was created with the
+style @LC_REPORT@. In that case the ListItem will contain information
+such as the text content specific to that column in that row.
</ins><span class="cx">
</span><del>-You must call _info.SetId()_ to the ID of item
you''re interested in
-before calling this method.
</del><ins>+The information about the list entry is returned as a
+"ListItem":listitem.html - see that class and
+"ListCtrl#set_item":listctrl.html#ListCtrl_setitem for more
information.
</ins><span class="cx">
</span><del>-
-
-
-
-
</del><span class="cx">
h3(#ListCtrl_getitembackgroundcolour). ListCtrl#get_item_background_colour
</span><span class="cx">
</span><span class="cx"> "Colour":colour.html
*get_item_background_colour*(%(arg-type)Integer% item)
</span><span class="lines">@@ -793,18 +781,20 @@
</span><span class="cx">
</span><span class="cx"> h3(#ListCtrl_setitem).
ListCtrl#set_item
</span><span class="cx">
</span><del>- Boolean *set_item*(%(arg-type)ListItem% info)
-
</del><span class="cx"> Integer
*set_item*(%(arg-type)Integer% index, %(arg-type)Integer% col,
</span><del>- %(arg-type)% String& label,
- %(arg-type)Integer% imageId = -1)
</del><ins>+ %(arg-type)String% label,
+ %(arg-type)Integer% imageId = -1)
</ins><span class="cx">
</span><del>-Sets information about the item.
</del><ins>+ Boolean *set_item*(%(arg-type)ListItem% info)
</ins><span class="cx">
</span><del>-ListItem is a class with the following members:
</del><ins>+Sets information about the item. The first form of the
method sets the
+label in the specified row and column to the specified string.
</ins><span class="cx">
</span><ins>+The second form is more flexible, as it allows setting
a number of
+attributes at once. ListItem is a class with the following attributes -
+see the "ListItem":listitem.html class for how to create this class
and
+set its attributes in wxRuby.
</ins><span class="cx">
</span><del>-
</del><span class="cx"> |long m_mask|Indicates which
fields are valid. See the list of valid mask flags below.|
</span><span class="cx"> |long m_itemId|The zero-based
item position.|
</span><span class="cx"> |int m_col|Zero-based column, if
in report mode.|
</span><span class="lines">@@ -819,8 +809,6 @@
</span><span class="cx">
</span><span class="cx"> The *m_mask* member contains a
bitlist specifying which of the other fields are valid. The flags are:
</span><span class="cx">
</span><del>-
-
</del><span class="cx"> |LIST_MASK_STATE|The *m_state*
field is valid.|
</span><span class="cx"> |LIST_MASK_TEXT|The *m_text*
field is valid.|
</span><span class="cx"> |LIST_MASK_IMAGE|The *m_image*
field is valid.|
</span><span class="lines">@@ -831,8 +819,6 @@
</span><span class="cx">
</span><span class="cx"> The *m_stateMask* and *m_state*
members take flags from the following:
</span><span class="cx">
</span><del>-
-
</del><span class="cx">
|LIST_STATE_DONTCARE|Don''t care what the state is. Win32 only. |
</span><span class="cx"> |LIST_STATE_DROPHILITED|The item
is highlighted to receive a drop event. Win32 only. |
</span><span class="cx"> |LIST_STATE_FOCUSED|The item has
the focus.|
</span><span class="lines">@@ -846,13 +832,6 @@
</span><span class="cx"> to use. If the colour/font is not
specified, the default list control
</span><span class="cx"> colour/font is used.
</span><span class="cx">
</span><del>- Integer *set_item*(%(arg-type)Integer% index,
%(arg-type)Integer% col, %(arg-type)String% label,
- %(arg-type)Integer% imageId = -1)
-
-Sets a string field at a particular column.
-
-
-
</del><span class="cx">
h3(#ListCtrl_setitembackgroundcolour). ListCtrl#set_item_background_colour
</span><span class="cx">
</span><span class="cx">
*set_item_background_colour*(%(arg-type)Integer% item, %(arg-type)Colour% col)
</span></span></pre></div>
<a id="trunkwxruby2samplescontrolsget_item_samplerb"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/samples/controls/get_item_sample.rb (739 => 740)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/samples/controls/get_item_sample.rb        2006-11-13
22:32:58 UTC (rev 739)
+++
trunk/wxruby2/samples/controls/get_item_sample.rb        2006-11-15
18:41:10 UTC (rev 740)
</span><span class="lines">@@ -3,13 +3,13 @@
</span><span class="cx">
</span><span class="cx"> require ''wx''
</span><span class="cx">
</span><del>-ID = 1
-
</del><span class="cx"> class ListctrlFrame < Wx::Frame
</span><span class="cx"> def initialize(title,pos,size)
</span><span class="cx">
super(nil,-1,title,pos,size,Wx::DEFAULT_FRAME_STYLE)
</span><span class="cx">
</span><del>- list = Wx::ListCtrl.new(self, ID,
Wx::DEFAULT_POSITION,Wx::DEFAULT_SIZE,Wx::LC_REPORT)
</del><ins>+ list = Wx::ListCtrl.new(self, -1,
Wx::DEFAULT_POSITION,
+ Wx::DEFAULT_SIZE,
+ Wx::LC_REPORT)
</ins><span class="cx">
list.insert_column(0,"column0",Wx::LIST_FORMAT_LEFT, -1)
</span><span class="cx">
list.insert_column(1,"column1",Wx::LIST_FORMAT_LEFT, -1)
</span><span class="cx"> list.insert_item(0,
''line0:column0'')
</span><span class="lines">@@ -32,12 +32,10 @@
</span><span class="cx">
item.set_font(Wx::ITALIC_FONT)
</span><span class="cx">
item.set_background_colour(Wx::LIGHT_GREY)
</span><span class="cx"> list.set_item( item )
</span><del>-
</del><ins>+
</ins><span class="cx"> # test of get_item method
</span><span class="cx"> 0.upto(2) do |i|
</span><del>- item = Wx::ListItem.new()
- item.set_id(i)
- if list.get_item(item)
</del><ins>+ if item = list.get_item(i)
</ins><span class="cx"> print
"ID:",item.get_id,"\n"
</span><span class="cx"> print "column:
",item.get_column,"\n"
</span><span class="cx"> print "text:
",item.get_text,"\n"
</span><span class="lines">@@ -46,10 +44,9 @@
</span><span class="cx"> print "font:
",show_font(item.get_font),"\n\n"
</span><span class="cx"> end
</span><span class="cx"> end
</span><ins>+ # test other column
</ins><span class="cx"> 0.upto(2) do |i|
</span><del>- item = Wx::ListItem.new()
- item.set_id(i)
- if list.get_item(item)
</del><ins>+ if item = list.get_item(i, 1)
</ins><span class="cx"> print
"ID:",item.get_id,"\n"
</span><span class="cx"> print "column:
",item.get_column,"\n"
</span><span class="cx"> print "text:
",item.get_text,"\n"
</span><span class="lines">@@ -61,14 +58,15 @@
</span><span class="cx"> end
</span><span class="cx">
</span><span class="cx"> def show_color(color)
</span><del>- red = color.red
- green = color.green
- blue = color.blue
- return "(#{red}, #{green}, #{blue})"
</del><ins>+ if color.ok
+ return ''(%i, %i, %i)'' % [color.red, color.green,
color.blue]
+ else
+ return ''(N/A)''
+ end
</ins><span class="cx"> end
</span><span class="cx">
</span><span class="cx"> def show_font(font)
</span><del>- if(font.get_style == Wx::ITALIC)
</del><ins>+ if font.get_style == Wx::ITALIC
</ins><span class="cx"> return "Italic"
</span><span class="cx"> end
</span><span class="cx"> return "Normal"
</span></span></pre></div>
<a id="trunkwxruby2swigclassesListCtrli"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/swig/classes/ListCtrl.i (739 => 740)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/ListCtrl.i        2006-11-13
22:32:58 UTC (rev 739)
+++
trunk/wxruby2/swig/classes/ListCtrl.i        2006-11-15
18:41:10 UTC (rev 740)
</span><span class="lines">@@ -19,16 +19,30 @@
</span><span class="cx"> # deprecated:
</span><span class="cx"> %ignore
wxListCtrl::GetItemSpacing(bool isSmall) const;
</span><span class="cx">
</span><ins>+%ignore wxListCtrl::GetItem(wxListItem& info)
const;
</ins><span class="cx">
</span><ins>+%extend wxListCtrl {
+ VALUE get_item(int row, int col = -1)
+ {
+        VALUE
returnVal = Qnil;
+        wxListItem
*list_item = new wxListItem();
+        list_item->SetId(row);
+        if (
col != -1 )
+        
list_item->SetColumn(col);
+        
+        bool
success = self->GetItem(*list_item);
+        if (
success )
+        
returnVal = SWIG_NewPointerObj(list_item, SWIGTYPE_p_wxListItem, 1);
</ins><span class="cx">
</span><ins>+        return
returnVal;
+ }
+}
+
+
+
</ins><span class="cx"> %import
"include/wxObject.h"
</span><span class="cx"> %import
"include/wxEvtHandler.h"
</span><span class="cx"> %import
"include/wxWindow.h"
</span><span class="cx"> %import
"include/wxControl.h"
</span><span class="cx">
</span><span class="cx"> %include
"include/wxListCtrl.h"
</span><del>-
-// TODO: Make this its own class!
-//
-// There is no record of this class in the XML file
-//
</del></span></pre>
</div>
</div>
</body>
</html>
Apparently Analagous Threads
- [735] trunk/wxruby2: Got the ''get_item_sample'' sample working had to add some missing ListCtrl constants.
- Problem with ListCtrl#get_item
- FW: Wx::ListCtrl#get_item method
- Working with ListCtrl and ListItem
- [1050] trunk/wxruby2/doc/textile: Delete doc references to remove assign_image_list methods in Tree/ListCtrl
