kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #03878
Re: layer_widget_test [1 Attachment]
-
To:
kicad-devel@xxxxxxxxxxxxxxx
-
From:
"jean-pierre.charras@..." <jean-pierre.charras@...>
-
Date:
Sun, 10 Jan 2010 10:37:45 +0100
-
In-reply-to:
<4B4975E9.4040008@...>
-
User-agent:
Thunderbird 2.0.0.23 (Windows/20090812)
--------------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 écrit :
<blockquote cite="mid:4B4975E9.4040008@..." type="cite">
<meta http-equiv="Context-Type"
content="text/html; charset=ISO-8859-1">
<span> </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> <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 (revision 2209)<br>
+++ pcbnew/layer_widget.cpp (working copy)<br>
@@ -217,9 +217,10 @@<br>
}<br>
<br>
// all nested controls on a given row will have the layer
index as their ID<br>
+ // modulo m_LayersFlexGridSizer->GetCols()<br>
else<br>
{<br>
- int layer = ((wxWindow*)eventSource)->GetId();<br>
+ int layer =
((wxWindow*)eventSource)->GetId()/m_LayersFlexGridSizer->GetCols();<br>
row = findLayerRow( layer );<br>
}<br>
<br>
@@ -287,7 +288,7 @@<br>
// column 0 in the layer scroll window has a
wxStaticBitmap, get its ID.<br>
wxStaticBitmap* bm = (wxStaticBitmap*) getLayerComp( row *
LAYER_COLUMN_COUNT + 0 );<br>
<br>
- if( aLayer == bm->GetId() )<br>
+ if( aLayer ==
(bm->GetId()/m_LayersFlexGridSizer->GetCols()) )<br>
return row;<br>
}<br>
<br>
@@ -308,28 +309,33 @@<br>
<br>
flags.Align(wxALIGN_CENTER_HORIZONTAL |
wxALIGN_CENTER_VERTICAL);<br>
<br>
+ // Calculate an event id for each widget.<br>
+ // they could be the same for each layer, but wxMSW does not
like 2 identical id<br>
+ // (does not display all widgets if they have the same id)<br>
+ int evt_id_base = m_LayersFlexGridSizer->GetCols() *
aSpec.layer;<br>
+<br>
// column 0<br>
- m_Bitmaps[aRow] = new wxStaticBitmap( m_LayerScrolledWindow,
aSpec.layer, *m_BlankBitmap,<br>
+ m_Bitmaps[aRow] = new wxStaticBitmap( m_LayerScrolledWindow,
evt_id_base, *m_BlankBitmap,<br>
wxDefaultPosition, m_BitmapSize );<br>
m_Bitmaps[aRow]->Connect( wxEVT_LEFT_DOWN,
wxMouseEventHandler( LAYER_WIDGET::OnLeftDownLayers ), NULL, this );<br>
m_LayersFlexGridSizer->Insert( index+0,<br>
new wxSizerItem( m_Bitmaps[aRow], wxSizerFlags().Align(
wxALIGN_CENTER_VERTICAL ) ) );<br>
<br>
// column 1<br>
- wxBitmapButton* bmb = makeColorButton( aSpec.color,
aSpec.layer );<br>
+ wxBitmapButton* bmb = makeColorButton( aSpec.color,
evt_id_base + 1 );<br>
bmb->SetToolTip( _("Right click to change layer color, left
click to select layer" ) );<br>
m_LayersFlexGridSizer->Insert( index+1,<br>
new wxSizerItem( bmb, flags ) );<br>
<br>
// column 2<br>
- wxStaticText* st = new wxStaticText( m_LayerScrolledWindow,
aSpec.layer, aSpec.layerName );<br>
+ wxStaticText* st = new wxStaticText( m_LayerScrolledWindow,
evt_id_base + 2, aSpec.layerName );<br>
st->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(
LAYER_WIDGET::OnLeftDownLayers ), NULL, this );<br>
st->SetToolTip( _( "Click here to select this layer" ) );<br>
m_LayersFlexGridSizer->Insert( index+2,<br>
new wxSizerItem( st, wxSizerFlags().Align(
wxALIGN_CENTER_VERTICAL )) );<br>
<br>
// column 3<br>
- wxCheckBox* cb = new wxCheckBox( m_LayerScrolledWindow,
aSpec.layer, wxEmptyString );<br>
+ wxCheckBox* cb = new wxCheckBox( m_LayerScrolledWindow,
evt_id_base + 3, wxEmptyString );<br>
cb->SetToolTip( _( "Enable this for visibility" ) );<br>
m_LayersFlexGridSizer->Insert( index+3, new wxSizerItem(
cb, flags ) );<br>
}<br>
<br>
<br>
<pre class="moz-signature" cols="72">--
Jean-Pierre CHARRAS
Maître de conférences
Directeur d'études 2ieme année.
Gé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