← Back to team overview

kicad-developers team mailing list archive

Re: layer_widget_test [1 Attachment]

 

--------------040707040301090800050603 Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Dick Hollenbeck a &eacute;crit&nbsp;:
<blockquote cite="mid:4B4975E9.4040008@..." type="cite">
<meta http-equiv="Context-Type"
content="text/html; charset=ISO-8859-1">
<span>&nbsp;</span>
<div>
<div>
<div> <span>[<a moz-do-not-send="true" href="#TopText">Attachment(s)</a>
from Dick Hollenbeck included below]</span><br>
Just an observation, Windows is the only OS for which this is not
working.<br>
<br>
Somebody else will have to call Bill Gates.</div>
</div>
</div>
</blockquote>
Do you know he? Is he a skilled programmer ?<br>
<blockquote cite="mid:4B4975E9.4040008@..." type="cite">
<div>
<div>
<div>&nbsp; <br>
<br>
It compiles now on 2.9.<br>
<br>
<br>
</div>
</div>
</div>
</blockquote>
I found the problem: all widgets in the same line in the wxFlexGridSize
have the same event id.<br>
wxMSW does not like that.<br>
I already found this problem in menus and toolbars.<br>
<br>
Here is a screen copy:<br>
<br>
<img src="cid:part1.02030506.01060109@..." alt=""><br>
<br>
and here is the patch i used to calculate an unique event id for each
widget:<br>
<br>
Index: pcbnew/layer_widget.cpp<br>
===================================================================<br>
--- pcbnew/layer_widget.cpp&nbsp;&nbsp;&nbsp; (revision 2209)<br>
+++ pcbnew/layer_widget.cpp&nbsp;&nbsp;&nbsp; (working copy)<br>
@@ -217,9 +217,10 @@<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // all nested controls on a given row will have the layer
index as their ID<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // modulo m_LayersFlexGridSizer-&gt;GetCols()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int layer = ((wxWindow*)eventSource)-&gt;GetId();<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int layer =
((wxWindow*)eventSource)-&gt;GetId()/m_LayersFlexGridSizer-&gt;GetCols();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; row&nbsp;&nbsp; = findLayerRow( layer );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;<br>
@@ -287,7 +288,7 @@<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // column 0 in the layer scroll window has a
wxStaticBitmap, get its ID.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxStaticBitmap* bm = (wxStaticBitmap*) getLayerComp( row *
LAYER_COLUMN_COUNT + 0 );<br>
&nbsp;<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( aLayer == bm-&gt;GetId() )<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( aLayer ==
(bm-&gt;GetId()/m_LayersFlexGridSizer-&gt;GetCols()) )<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return row;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;<br>
@@ -308,28 +309,33 @@<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flags.Align(wxALIGN_CENTER_HORIZONTAL |
wxALIGN_CENTER_VERTICAL);<br>
&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Calculate an event id for each widget.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // they could be the same for each layer, but wxMSW does not
like 2 identical id<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // (does not display all widgets if they have the same id)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int evt_id_base = m_LayersFlexGridSizer-&gt;GetCols() *
aSpec.layer;<br>
+<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // column 0<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Bitmaps[aRow] = new wxStaticBitmap( m_LayerScrolledWindow,
aSpec.layer, *m_BlankBitmap,<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Bitmaps[aRow] = new wxStaticBitmap( m_LayerScrolledWindow,
evt_id_base, *m_BlankBitmap,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxDefaultPosition, m_BitmapSize );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Bitmaps[aRow]-&gt;Connect( wxEVT_LEFT_DOWN,
wxMouseEventHandler( LAYER_WIDGET::OnLeftDownLayers ), NULL, this );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_LayersFlexGridSizer-&gt;Insert( index+0,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new wxSizerItem( m_Bitmaps[aRow], wxSizerFlags().Align(
wxALIGN_CENTER_VERTICAL ) ) );<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // column 1<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxBitmapButton* bmb = makeColorButton( aSpec.color,
aSpec.layer );<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxBitmapButton* bmb = makeColorButton( aSpec.color,
evt_id_base + 1 );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bmb-&gt;SetToolTip( _("Right click to change layer color, left
click to select layer" ) );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_LayersFlexGridSizer-&gt;Insert( index+1,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new wxSizerItem( bmb, flags ) );<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // column 2<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxStaticText* st = new wxStaticText( m_LayerScrolledWindow,
aSpec.layer, aSpec.layerName );<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxStaticText* st = new wxStaticText( m_LayerScrolledWindow,
evt_id_base + 2, aSpec.layerName );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; st-&gt;Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(
LAYER_WIDGET::OnLeftDownLayers ), NULL, this );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; st-&gt;SetToolTip( _( "Click here to select this layer" ) );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_LayersFlexGridSizer-&gt;Insert( index+2,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new wxSizerItem( st, wxSizerFlags().Align(
wxALIGN_CENTER_VERTICAL )) );<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // column 3<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxCheckBox* cb = new wxCheckBox( m_LayerScrolledWindow,
aSpec.layer, wxEmptyString );<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxCheckBox* cb = new wxCheckBox( m_LayerScrolledWindow,
evt_id_base + 3, wxEmptyString );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cb-&gt;SetToolTip( _( "Enable this for visibility" ) );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_LayersFlexGridSizer-&gt;Insert( index+3, new wxSizerItem(
cb, flags ) );<br>
&nbsp;&nbsp;&nbsp;&nbsp; }<br>
<br>
<br>
<pre class="moz-signature" cols="72">-- 
Jean-Pierre CHARRAS

Ma&icirc;tre de conf&eacute;rences
Directeur d'&eacute;tudes 2ieme ann&eacute;e.
G&eacute;nie Electrique et Informatique Industrielle 2
Institut Universitaire de Technologie 1 de Grenoble
BP 67, 38402 St Martin d'Heres Cedex

Recherche :
GIPSA-LAB - INPG
Rue de la Houille Blanche
38400 Saint Martin d'Heres
</pre>
</body>
</html>
 --------------040707040301090800050603 Content-Type: image/jpeg;
name="moz-screenshot-2.jpg"
Content-Transfer-Encoding: base64
Content-ID: <part1.02030506.01060109@...>
Content-Disposition: inline;
filename="moz-screenshot-2.jpg"

[Attachment content not displayed.] --------------040707040301090800050603----------------000100090805060609010806 Content-Type: text/plain;
name="layer_widget.patch"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="layer_widget.patch"

[Attachment content not displayed.] --------------000100090805060609010806-- 




Follow ups

References