nobody at rubyforge.org
2007-Jan-25 18:19 UTC
[Wxruby-development] [854] trunk/wxruby2/swig/classes: Add support for GridBagSizer
<!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>[854] trunk/wxruby2/swig/classes: Add support for GridBagSizer</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>854</dd> <dt>Author</dt> <dd>brokentoy</dd> <dt>Date</dt> <dd>2007-01-25 13:19:11 -0500 (Thu, 25 Jan 2007)</dd> </dl> <h3>Log Message</h3> <pre>Add support for GridBagSizer</pre> <h3>Added Paths</h3> <ul> <li><a href="#trunkwxruby2swigclassesGBPositioni">trunk/wxruby2/swig/classes/GBPosition.i</a></li> <li><a href="#trunkwxruby2swigclassesGBSpani">trunk/wxruby2/swig/classes/GBSpan.i</a></li> <li><a href="#trunkwxruby2swigclassesGridBagSizeri">trunk/wxruby2/swig/classes/GridBagSizer.i</a></li> <li><a href="#trunkwxruby2swigclassesincludewxGBPositionh">trunk/wxruby2/swig/classes/include/wxGBPosition.h</a></li> <li><a href="#trunkwxruby2swigclassesincludewxGBSpanh">trunk/wxruby2/swig/classes/include/wxGBSpan.h</a></li> <li><a href="#trunkwxruby2swigclassesincludewxGridBagSizerh">trunk/wxruby2/swig/classes/include/wxGridBagSizer.h</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="trunkwxruby2swigclassesGBPositioni"></a> <div class="addfile"><h4>Added: trunk/wxruby2/swig/classes/GBPosition.i (0 => 854)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/GBPosition.i         (rev 0) +++ trunk/wxruby2/swig/classes/GBPosition.i        2007-01-25 18:19:11 UTC (rev 854) </span><span class="lines">@@ -0,0 +1,12 @@ </span><ins>+# Copyright 2004-2007 by Kevin Smith +# released under the MIT-style wxruby2 license + +%include "../common.i" + +%module(directors="1") wxGBPosition + +%{ +#include <wx/gbsizer.h> +%} + +%include "include/wxGBPosition.h" </ins></span></pre></div> <a id="trunkwxruby2swigclassesGBSpani"></a> <div class="addfile"><h4>Added: trunk/wxruby2/swig/classes/GBSpan.i (0 => 854)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/GBSpan.i         (rev 0) +++ trunk/wxruby2/swig/classes/GBSpan.i        2007-01-25 18:19:11 UTC (rev 854) </span><span class="lines">@@ -0,0 +1,14 @@ </span><ins>+# Copyright 2004-2007 by Kevin Smith +# released under the MIT-style wxruby2 license + +%include "../common.i" + +%module(directors="1") wxGBSpan + +%{ +#include <wx/gbsizer.h> +%} + +%constant const wxGBSpan DEFAULT_SPAN = wxDefaultSpan; + +%include "include/wxGBSpan.h" </ins></span></pre></div> <a id="trunkwxruby2swigclassesGridBagSizeri"></a> <div class="addfile"><h4>Added: trunk/wxruby2/swig/classes/GridBagSizer.i (0 => 854)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/GridBagSizer.i         (rev 0) +++ trunk/wxruby2/swig/classes/GridBagSizer.i        2007-01-25 18:19:11 UTC (rev 854) </span><span class="lines">@@ -0,0 +1,23 @@ </span><ins>+# Copyright 2004-2007 by Kevin Smith +# released under the MIT-style wxruby2 license + +%include "../common.i" + +%module(directors="1") wxGridBagSizer + +%{ +#include <wx/gbsizer.h> +%} + +// ignore these for now - are they useful? +// require GBSizerItem to be wrapped +%ignore wxGridBagSizer::FindItemWithData; +%ignore wxGridBagSizer::FindItemAtPoint; +%ignore wxGridBagSizer::FindItemAtPosition; + +%import "include/wxObject.h" +%import "include/wxSizer.h" +%import "include/wxGridSizer.h" +%import "include/wxFlexGridSizer.h" + +%include "include/wxGridBagSizer.h" </ins></span></pre></div> <a id="trunkwxruby2swigclassesincludewxGBPositionh"></a> <div class="addfile"><h4>Added: trunk/wxruby2/swig/classes/include/wxGBPosition.h (0 => 854)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/include/wxGBPosition.h         (rev 0) +++ trunk/wxruby2/swig/classes/include/wxGBPosition.h        2007-01-25 18:19:11 UTC (rev 854) </span><span class="lines">@@ -0,0 +1,23 @@ </span><ins>+// Copyright 2004-2007 by Kevin Smith +// released under the MIT-style wxruby2 license + +class wxGBPosition +{ +public: + wxGBPosition() : m_row(0), m_col(0) {} + wxGBPosition(int row, int col) : m_row(row), m_col(col) {} + + // default copy ctor and assignment operator are okay. + + int GetRow() const { return m_row; } + int GetCol() const { return m_col; } + void SetRow(int row) { m_row = row; } + void SetCol(int col) { m_col = col; } + + bool operator==(const wxGBPosition& p) const { return m_row == p.m_row && m_col == p.m_col; } + bool operator!=(const wxGBPosition& p) const { return !(*this == p); } + +private: + int m_row; + int m_col; +}; </ins></span></pre></div> <a id="trunkwxruby2swigclassesincludewxGBSpanh"></a> <div class="addfile"><h4>Added: trunk/wxruby2/swig/classes/include/wxGBSpan.h (0 => 854)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/include/wxGBSpan.h         (rev 0) +++ trunk/wxruby2/swig/classes/include/wxGBSpan.h        2007-01-25 18:19:11 UTC (rev 854) </span><span class="lines">@@ -0,0 +1,20 @@ </span><ins>+class wxGBSpan +{ +public: + wxGBSpan() : m_rowspan(1), m_colspan(1) {} + wxGBSpan(int rowspan, int colspan) : m_rowspan(rowspan), m_colspan(colspan) {} + + // default copy ctor and assignment operator are okay. + + int GetRowspan() const { return m_rowspan; } + int GetColspan() const { return m_colspan; } + void SetRowspan(int rowspan) { m_rowspan = rowspan; } + void SetColspan(int colspan) { m_colspan = colspan; } + + bool operator==(const wxGBSpan& o) const { return m_rowspan == o.m_rowspan && m_colspan == o.m_colspan; } + bool operator!=(const wxGBSpan& o) const { return !(*this == o); } + +private: + int m_rowspan; + int m_colspan; +}; </ins></span></pre></div> <a id="trunkwxruby2swigclassesincludewxGridBagSizerh"></a> <div class="addfile"><h4>Added: trunk/wxruby2/swig/classes/include/wxGridBagSizer.h (0 => 854)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/include/wxGridBagSizer.h         (rev 0) +++ trunk/wxruby2/swig/classes/include/wxGridBagSizer.h        2007-01-25 18:19:11 UTC (rev 854) </span><span class="lines">@@ -0,0 +1,126 @@ </span><ins>+// Copyright 2004-2007 by Kevin Smith +// released under the MIT-style wxruby2 license + +class wxGridBagSizer : public wxFlexGridSizer +{ +public: + wxGridBagSizer(int vgap = 0, int hgap = 0 ); + + // The Add methods return true if the item was successfully placed at the + // given position, false if something was already there. + wxSizerItem* Add( wxWindow *window, + const wxGBPosition& pos, + const wxGBSpan& span = wxDefaultSpan, + int flag = 0, + int border = 0, + wxObject* userData = NULL ); + wxSizerItem* Add( wxSizer *sizer, + const wxGBPosition& pos, + const wxGBSpan& span = wxDefaultSpan, + int flag = 0, + int border = 0, + wxObject* userData = NULL ); + wxSizerItem* Add( int width, + int height, + const wxGBPosition& pos, + const wxGBSpan& span = wxDefaultSpan, + int flag = 0, + int border = 0, + wxObject* userData = NULL ); + wxSizerItem* Add( wxGBSizerItem *item ); + + + // Get/Set the size used for cells in the grid with no item. + wxSize GetEmptyCellSize() const { return m_emptyCellSize; } + void SetEmptyCellSize(const wxSize& sz) { m_emptyCellSize = sz; } + + // Get the size of the specified cell, including hgap and vgap. Only + // valid after a Layout. + wxSize GetCellSize(int row, int col) const; + + // Get the grid position of the specified item (non-recursive) + wxGBPosition GetItemPosition(wxWindow *window); + wxGBPosition GetItemPosition(wxSizer *sizer); + wxGBPosition GetItemPosition(size_t index); + + // Set the grid position of the specified item. Returns true on success. + // If the move is not allowed (because an item is already there) then + // false is returned. (non-recursive) + bool SetItemPosition(wxWindow *window, const wxGBPosition& pos); + bool SetItemPosition(wxSizer *sizer, const wxGBPosition& pos); + bool SetItemPosition(size_t index, const wxGBPosition& pos); + + // Get the row/col spanning of the specified item (non-recursive) + wxGBSpan GetItemSpan(wxWindow *window); + wxGBSpan GetItemSpan(wxSizer *sizer); + wxGBSpan GetItemSpan(size_t index); + + // Set the row/col spanning of the specified item. Returns true on + // success. If the move is not allowed (because an item is already there) + // then false is returned. (non-recursive) + bool SetItemSpan(wxWindow *window, const wxGBSpan& span); + bool SetItemSpan(wxSizer *sizer, const wxGBSpan& span); + bool SetItemSpan(size_t index, const wxGBSpan& span); + + + // Find the sizer item for the given window or subsizer, returns NULL if + // not found. (non-recursive) + wxGBSizerItem* FindItem(wxWindow* window); + wxGBSizerItem* FindItem(wxSizer* sizer); + + + // Return the sizer item for the given grid cell, or NULL if there is no + // item at that position. (non-recursive) + wxGBSizerItem* FindItemAtPosition(const wxGBPosition& pos); + + + // Return the sizer item located at the point given in pt, or NULL if + // there is no item at that point. The (x,y) coordinates in pt correspond + // to the client coordinates of the window using the sizer for + // layout. (non-recursive) + wxGBSizerItem* FindItemAtPoint(const wxPoint& pt); + + + // Return the sizer item that has a matching user data (it only compares + // pointer values) or NULL if not found. (non-recursive) + wxGBSizerItem* FindItemWithData(const wxObject* userData); + + + // These are what make the sizer do size calculations and layout + virtual void RecalcSizes(); + virtual wxSize CalcMin(); + + // Look at all items and see if any intersect (or would overlap) the given + // item. Returns true if so, false if there would be no overlap. If an + // excludeItem is given then it will not be checked for intersection, for + // example it may be the item we are checking the position of. + bool CheckForIntersection(wxGBSizerItem* item, wxGBSizerItem* excludeItem = NULL); + bool CheckForIntersection(const wxGBPosition& pos, const wxGBSpan& span, wxGBSizerItem* excludeItem = NULL); + + + // The Add base class virtuals should not be used with this class, but + // we''ll try to make them automatically select a location for the item + // anyway. + virtual wxSizerItem* Add( wxWindow *window, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); + virtual wxSizerItem* Add( wxSizer *sizer, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); + virtual wxSizerItem* Add( int width, int height, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); + + // The Insert and Prepend base class virtuals that are not appropriate for + // this class and should not be used. Their implementation in this class + // simply fails. + virtual wxSizerItem* Add( wxSizerItem *item ); + virtual wxSizerItem* Insert( size_t index, wxWindow *window, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); + virtual wxSizerItem* Insert( size_t index, wxSizer *sizer, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); + virtual wxSizerItem* Insert( size_t index, int width, int height, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); + virtual wxSizerItem* Insert( size_t index, wxSizerItem *item ); + virtual wxSizerItem* Prepend( wxWindow *window, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); + virtual wxSizerItem* Prepend( wxSizer *sizer, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); + virtual wxSizerItem* Prepend( int width, int height, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); + virtual wxSizerItem* Prepend( wxSizerItem *item ); + + +protected: + wxGBPosition FindEmptyCell(); + wxSize m_emptyCellSize; + +}; </ins></span></pre> </div> </div> </body> </html>
Possibly Parallel Threads
- [1108] trunk/wxruby2/swig: Revised mem mgmt for Sizers to address more GC crashes in Sizers demo
- [855] trunk/wxruby2/swig/classes/include/parents.rb: Parenting for GridBagSizer
- [1033] trunk/wxruby2/swig: GC fixes for nested sizers; fix crashes in html.rb demo
- Can''t compile the cvs-tree
- wxSizerItem show() method