Merge lp:~mark-roszko/kicad/hotkey into lp:kicad/product

Proposed by Mark Roszko
Status: Merged
Merged at revision: 5196
Proposed branch: lp:~mark-roszko/kicad/hotkey
Merge into: lp:kicad/product
Diff against target: 1880 lines (+736/-674)
13 files modified
common/CMakeLists.txt (+0/-1)
common/dialogs/dialog_hotkeys_editor.cpp (+318/-209)
common/dialogs/dialog_hotkeys_editor_base.cpp (+12/-37)
common/dialogs/dialog_hotkeys_editor_base.fbp (+105/-79)
common/dialogs/dialog_hotkeys_editor_base.h (+9/-10)
common/hotkey_grid_table.cpp (+0/-220)
common/hotkeys_basic.cpp (+12/-2)
eeschema/hotkeys.cpp (+14/-14)
include/dialog_hotkeys_editor.h (+226/-12)
include/hotkey_grid_table.h (+0/-57)
include/hotkeys_basic.h (+7/-1)
pagelayout_editor/hotkeys.cpp (+5/-4)
pcbnew/hotkeys.cpp (+28/-28)
To merge this branch: bzr merge lp:~mark-roszko/kicad/hotkey
Reviewer Review Type Date Requested Status
KiCad Lead Developers Pending
Review via email: mp+238225@code.launchpad.net

Description of the change

Hotkey editor restyled to have tabs instead of one huge max height window.
Tabs represent an hotkey section.
wxListCtrl usage allowed capturing of "navigation" keys that wxGrid prevented, no more right click menu needed for Arrow, Home, End, Tab, Space keys.
Proper key conflict detection with prompt to user between sections and within the same hotkey section.
Edited several hotkey titles to match capitalization.
Add proper section titles, removed "comment" field for sections.

To post a comment you must log in.
Revision history for this message
Mark Roszko (mark-roszko) wrote :

For some reason bazaar lost track of the master branch which I can't figure out.

Only 5188 and 5187 in this pull are real changes.

I have no clue how to fix launchpad/bazaar's brokenness

Revision history for this message
Mark Roszko (mark-roszko) wrote :

Ah, there we go, had to destroy the branch locally and repatch master.

lp:~mark-roszko/kicad/hotkey updated
5187. By Konstantin Baranovskiy

Fix CvPcb menu accelerator bug in Linux. (fixes lp:1375232)

5188. By Mark Roszko

Add select footprint feature to Eeschema field properties dialog.

5189. By jean-pierre charras

Libview and Modview: fix issues relative to hotkeys (hardcoded keys instead of user defined keys and not working tools and popup menus).
Add menubars (can be disabled)
Fix also some minor coding style issues.

5190. By jean-pierre charras

Add missing search paths in kicad help doc search paths ( only noticeable for non English users ). Sometimes the translated doc was not found, and the English doc was displayed.

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

This will not merge cleanly with the head of the product branch due to commit r5189. Please sync with product head and fix the conflicts so I can merge and test this. Also, I saw a few coding policy issues. Mostly with missing spaces in using the wxT() macro but a few other places as well. I saw at least one switch statement that was not indented correctly. Please let me know when you've corrected these issues.

lp:~mark-roszko/kicad/hotkey updated
5191. By Brian Sidebotham

Enhance EESCHEMA Options Dialog

  * Include new field template editor
    - Removes 10 template limitation
    - Adds ability to set default value
    - Adds ability to set default visibility
  * Documentation to follow
  * Tested in Linux (Ubuntu 14.04) + Windows, Windows has issue with displaying highlight for selected template, fix to follow

Revision history for this message
Mark Roszko (mark-roszko) wrote :

Rebased on r5189.
I've nuked trailing whitespaced.
I fixed the one wxT macro I should have fixed and two others I noticed nearby.

I removed some whitespace in the switch statement. The case statements were aligned with the switch per coding policy...

lp:~mark-roszko/kicad/hotkey updated
5192. By Mark Roszko

Hotkey Editor Polishing

Refactor hotkey editor to use tab control instead of one giant list.
Each tab is a separate hotkey section.
Modify EDA_HOTKEY_CONFIG to change the m_Comment member to m_Title for a new purpose.
We want a pretty title in the hotkey editor. We use m_Title for the key export comment which
still conveys the purpose just as easily.
Refactored usage of wxGrid into wxListCtrl which allows capturing navigation characters
and also works better (single selection is built in).
Add hotkey overwrite prompts that are paired with "Common" section. It will check if a hotkey
overlaps with the proper sections. i.e. Common with the all other sections; or Section 1 with just Common.
Right-click menu removed due to wxListCtrl being able to catch the special keys properly.

5193. By Mark Roszko

Make hotkey command titles use consistent capitalization.
Rename "Switch highcontrast" to "Toggle High Contrast".
Eliminate most of the abbreviated hotkey titles.
Doxygenize dialog_hotkeys_editor.h and add missing license block.
Display <unassigned> if key code is 0 (NULL).

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

On windows using wxWidgets 3.0.0, the wxListCtrl does not expand to fill
the dialog panel. See attached image. I'll go ahead and commit the
merge request but this should be fixed unless it's a problem with
wxWidgets 3.0.0.

On 10/15/2014 9:05 PM, Mark Roszko wrote:
> Rebased on r5189.
> I've nuked trailing whitespaced.
> I fixed the one wxT macro I should have fixed and two others I noticed nearby.
>
> I removed some whitespace in the switch statement. The case statements were aligned with the switch per coding policy...
>
>

Revision history for this message
Mark Roszko (mark-roszko) wrote :

I have a fix for it I will commit to the branch shortly

lp:~mark-roszko/kicad/hotkey updated
5194. By Mark Roszko

Fix hotkey editor on Windows not using max height of the dialog for the list control.
Set wxNO_BORDER for the tab page.

Revision history for this message
Mark Roszko (mark-roszko) wrote :

Ok, patch committed to the branch, I did test it on Windows 7. Yuo can to.

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

I just finished testing this and it looks good. I like the changes you
made the hot key editing dialog. One thing I missed during my first
review of this code is that you added several global variables. I will
give you a free pass time because I know that the hot key base code is
very poorly designed. In the future, I can tell you that I will almost
without exception reject code with global variables without a doctoral
thesis on why that global variable should be allowed in KiCad. I've
spent the last 8 years removing dozens of global variables and I'm not
interested in removing any new ones. In the future, please fix the
underlying code rather than add more global variable on top of poorly
designed code.

On 10/16/2014 11:19 PM, Mark Roszko wrote:
> Ok, patch committed to the branch, I did test it on Windows 7. Yuo can to.
>

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

Merge request committed in product branch r5196. Thank you for you contribution to KiCad. Do you know if there are any bugs related to this merge request? If so, please tag them as "Fix Committed".

Revision history for this message
Mark Roszko (mark-roszko) wrote :

That's what I get for conforming to existing code.

By global do you mean global between all the applications? Or global
to a specific project? Or both? Yea the only variable that needs to be
global to the entire between applications is g_CommonSectionTag/Title.
The rest don't need to be.

I can submit a patch to clean the hotkey globals up.

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

Both. Hot key variables global to all applications could be made static
variable in the EDA_HOTKEY class or maybe the BASE_FRAME class where the
hot keys are loaded and saved. The application specific global
variables probably should be defined in the class derived from the
BASE_FRAME class where hot keys are used are.

On 10/17/2014 11:42 AM, Mark Roszko wrote:
> That's what I get for conforming to existing code.
>
> By global do you mean global between all the applications? Or global
> to a specific project? Or both? Yea the only variable that needs to be
> global to the entire between applications is g_CommonSectionTag/Title.
> The rest don't need to be.
>
> I can submit a patch to clean the hotkey globals up.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'common/CMakeLists.txt'
2--- common/CMakeLists.txt 2014-09-07 19:01:26 +0000
3+++ common/CMakeLists.txt 2014-10-17 03:18:31 +0000
4@@ -179,7 +179,6 @@
5 grid_tricks.cpp
6 gr_basic.cpp
7 hotkeys_basic.cpp
8- hotkey_grid_table.cpp
9 html_messagebox.cpp
10 kiface_i.cpp
11 kiway.cpp
12
13=== modified file 'common/dialogs/dialog_hotkeys_editor.cpp'
14--- common/dialogs/dialog_hotkeys_editor.cpp 2014-04-07 16:00:13 +0000
15+++ common/dialogs/dialog_hotkeys_editor.cpp 2014-10-17 03:18:31 +0000
16@@ -5,7 +5,7 @@
17 /*
18 * This program source code file is part of KICAD, a free EDA CAD application.
19 *
20- * Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors.
21+ * Copyright (C) 1992-2014 Kicad Developers, see CHANGELOG.TXT for contributors.
22 *
23 * This program is free software; you can redistribute it and/or
24 * modify it under the terms of the GNU General Public License
25@@ -30,211 +30,133 @@
26 #include <fctsys.h>
27 #include <pgm_base.h>
28 #include <common.h>
29+#include <confirm.h>
30
31 #include <dialog_hotkeys_editor.h>
32
33-void InstallHotkeyFrame( EDA_DRAW_FRAME* parent, EDA_HOTKEY_CONFIG* hotkeys )
34-{
35- HOTKEYS_EDITOR_DIALOG dialog( parent, hotkeys );
36-
37- int diag = dialog.ShowModal();
38- if( diag == wxID_OK )
39- {
40- parent->ReCreateMenuBar();
41- parent->Refresh();
42- }
43-}
44-
45-
46-HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent,
47- EDA_HOTKEY_CONFIG* hotkeys ) :
48- HOTKEYS_EDITOR_DIALOG_BASE( parent )
49-{
50- m_parent = parent;
51- m_hotkeys = hotkeys;
52- m_curEditingRow = -1;
53-
54- m_table = new HOTKEY_EDITOR_GRID_TABLE( hotkeys );
55- m_hotkeyGrid->SetTable( m_table, true );
56-
57- m_hotkeyGrid->AutoSizeColumn( 0 );
58- m_hotkeyGrid->EnableDragGridSize( false );
59-
60- for( int i = 0; i < m_hotkeyGrid->GetNumberRows(); ++i )
61- {
62- m_hotkeyGrid->SetReadOnly( i, 0, true );
63- m_hotkeyGrid->SetReadOnly( i, 1, true );
64- }
65-
66- m_OKButton->SetDefault();
67- m_hotkeyGrid->SetFocus();
68- GetSizer()->SetSizeHints( this );
69- Center();
70-}
71-
72-
73-void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event )
74-{
75- /* edit the live hotkey table */
76- HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys();
77-
78- EDA_HOTKEY_CONFIG* section;
79-
80- for( section = m_hotkeys; section->m_HK_InfoList; section++ )
81- {
82- wxString sectionTag = *section->m_SectionTag;
83-
84- EDA_HOTKEY** info_ptr;
85-
86- for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ )
87- {
88- EDA_HOTKEY* info = *info_ptr;
89-
90- /* find the corresponding hotkey */
91- HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector::iterator i;
92-
93- for( i = hotkey_vec.begin(); i != hotkey_vec.end(); ++i )
94- {
95- if( i->first == sectionTag
96- && i->second
97- && i->second->m_Idcommand == info->m_Idcommand )
98- {
99- info->m_KeyCode = i->second->m_KeyCode;
100- break;
101- }
102- }
103- }
104- }
105-
106- /* save the hotkeys */
107- m_parent->WriteHotkeyConfig( m_hotkeys );
108-
109- EndModal( wxID_OK );
110-}
111-
112-
113-void HOTKEYS_EDITOR_DIALOG::CancelClicked( wxCommandEvent& event )
114-{
115- EndModal( wxID_CANCEL );
116-}
117-
118-
119-/* Reinit the hotkeys to the initial state (remove all pending changes
120- */
121-void HOTKEYS_EDITOR_DIALOG::UndoClicked( wxCommandEvent& event )
122-{
123- m_table->RestoreFrom( m_hotkeys );
124- m_curEditingRow = -1;
125-
126- for( int i = 0; i < m_hotkeyGrid->GetNumberRows(); ++i )
127- SetHotkeyCellState( i, false );
128-
129- m_hotkeyGrid->Refresh();
130- Update();
131-}
132-
133-
134-void HOTKEYS_EDITOR_DIALOG::SetHotkeyCellState( int aRow, bool aHightlight )
135-{
136- if( aHightlight )
137- {
138- m_hotkeyGrid->SetCellTextColour( aRow, 1, *wxRED );
139- wxFont bold_font(m_hotkeyGrid->GetDefaultCellFont() );
140- bold_font.SetWeight(wxFONTWEIGHT_BOLD);
141- m_hotkeyGrid->SetCellFont( aRow, 1, bold_font );
142- }
143- else
144- {
145- m_hotkeyGrid->SetCellTextColour( aRow, 1, m_hotkeyGrid->GetDefaultCellTextColour() );
146- m_hotkeyGrid->SetCellFont( aRow, 1, m_hotkeyGrid->GetDefaultCellFont() );
147- }
148-}
149-
150-
151-void HOTKEYS_EDITOR_DIALOG::OnClickOnCell( wxGridEvent& event )
152-{
153- if( m_curEditingRow != -1 )
154- SetHotkeyCellState( m_curEditingRow, false );
155-
156- int newRow = event.GetRow();
157-
158- if( ( event.GetCol() != 1 ) || ( m_table->IsHeader( newRow ) ) )
159- {
160- m_curEditingRow = -1;
161- }
162- else
163- {
164- m_curEditingRow = newRow;
165- SetHotkeyCellState( m_curEditingRow, true );
166- }
167- m_hotkeyGrid->Refresh();
168- Update();
169-}
170-
171-
172-/** OnRightClickOnCell
173- * If a cell is selected, display a list of keys for selection
174- * The list is restricted to keys that cannot be entered:
175- * tab, home, return ... because these keys have special functions in dialogs
176- */
177-void HOTKEYS_EDITOR_DIALOG::OnRightClickOnCell( wxGridEvent& event )
178-{
179- // Select the new cell if needed
180- OnClickOnCell(event);
181-
182- if( m_curEditingRow == -1 )
183- return;
184-
185- // Do not translate these key names. They are internally used.
186- // See hotkeys_basic.cpp
187- #define C_COUNT 9
188- wxString choices[C_COUNT] =
189- {
190- wxT("End")
191- wxT("Tab"),
192- wxT("Ctrl+Tab"),
193- wxT("Alt+Tab"),
194- wxT("Home"),
195- wxT("Space"),
196- wxT("Ctrl+Space"),
197- wxT("Alt+Space"),
198- wxT("Return")
199- };
200-
201- wxString keyname = wxGetSingleChoice( _( "Special keys only. For others keys, use keyboard" ),
202- _( "Select a key" ), C_COUNT, choices, this );
203- int key = KeyCodeFromKeyName( keyname );
204-
205- if( key == 0 )
206- return;
207-
208- m_table->SetKeyCode( m_curEditingRow, key );
209- m_hotkeyGrid->Refresh();
210- Update();
211-}
212-
213-
214-void HOTKEYS_EDITOR_DIALOG::OnKeyPressed( wxKeyEvent& event )
215-{
216- if( m_curEditingRow != -1 )
217- {
218- long key = event.GetKeyCode();
219+
220+HOTKEY_LIST_CTRL::HOTKEY_LIST_CTRL( wxWindow *aParent, struct EDA_HOTKEY_CONFIG* aSection ) :
221+ wxListCtrl( aParent, wxID_ANY, wxDefaultPosition,
222+ wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VIRTUAL )
223+{
224+ m_sectionTag = aSection->m_SectionTag;
225+ m_curEditingRow = -1;
226+
227+ InsertColumn( 0, _( "Command" ) );
228+ InsertColumn( 1, _( "Hotkey" ) );
229+
230+ // Add a dummy hotkey_spec which is a header before each hotkey list
231+ EDA_HOTKEY** hotkey_descr_list;
232+
233+ // Add a copy of hotkeys to our list
234+ for( hotkey_descr_list = aSection->m_HK_InfoList; *hotkey_descr_list;
235+ hotkey_descr_list++ )
236+ {
237+ EDA_HOTKEY* hotkey_descr = *hotkey_descr_list;
238+ m_hotkeys.push_back( new EDA_HOTKEY( hotkey_descr ) );
239+ }
240+
241+ // Set item count to hotkey size, this gets it to autoload the entries
242+ SetItemCount( m_hotkeys.size() );
243+
244+ SetColumnWidth( 0, wxLIST_AUTOSIZE );
245+ SetColumnWidth( 1, wxLIST_AUTOSIZE );
246+
247+ Bind( wxEVT_CHAR, &HOTKEY_LIST_CTRL::OnChar, this );
248+ Bind( wxEVT_LIST_ITEM_SELECTED, &HOTKEY_LIST_CTRL::OnListItemSelected, this );
249+ Bind( wxEVT_SIZE, &HOTKEY_LIST_CTRL::OnSize, this );
250+}
251+
252+
253+void HOTKEY_LIST_CTRL::OnSize( wxSizeEvent& aEvent )
254+{
255+ recalculateColumns();
256+ aEvent.Skip();
257+}
258+
259+
260+void HOTKEY_LIST_CTRL::recalculateColumns()
261+{
262+ float totalLength = 0;
263+ float scale = 0;
264+
265+ // Find max character length of first column
266+ int maxInfoMsgLength = 0;
267+ for( int i = 0; i < GetItemCount(); i++ )
268+ {
269+ int length = GetItemText( i, 0 ).Length();
270+ if( length > maxInfoMsgLength )
271+ maxInfoMsgLength = length;
272+ }
273+
274+ // Find max character length of second column
275+ int maxKeyCodeLength = 0;
276+ for( int i = 0; i < GetItemCount(); i++ )
277+ {
278+ int length = GetItemText( i, 1 ).Length();
279+ if( length > maxKeyCodeLength )
280+ maxKeyCodeLength = length;
281+ }
282+
283+ // Use the lengths of column texts to create a scale of the max list width
284+ // to set the column widths
285+ totalLength = maxInfoMsgLength + maxKeyCodeLength;
286+
287+ scale = (float) GetClientSize().x / totalLength;
288+
289+ SetColumnWidth( 0, int( maxInfoMsgLength*scale ) - 2 );
290+ SetColumnWidth( 1, int( maxKeyCodeLength*scale ) );
291+}
292+
293+
294+void HOTKEY_LIST_CTRL::OnListItemSelected( wxListEvent& aEvent )
295+{
296+ m_curEditingRow = aEvent.GetIndex();
297+}
298+
299+
300+void HOTKEY_LIST_CTRL::DeselectRow( int aRow )
301+{
302+ SetItemState( aRow, 0, wxLIST_STATE_SELECTED );
303+}
304+
305+
306+wxString HOTKEY_LIST_CTRL::OnGetItemText( long aRow, long aColumn ) const
307+{
308+ EDA_HOTKEY* hotkey_descr = m_hotkeys[aRow];
309+
310+ if( aColumn == 0 )
311+ {
312+ return hotkey_descr->m_InfoMsg;
313+ }
314+ else
315+ {
316+ return KeyNameFromKeyCode( hotkey_descr->m_KeyCode );
317+ }
318+}
319+
320+
321+void HOTKEY_LIST_CTRL::OnChar( wxKeyEvent& aEvent )
322+{
323+ if( m_curEditingRow != -1 )
324+ {
325+ long key = aEvent.GetKeyCode();
326
327 switch( key )
328 {
329 case WXK_ESCAPE:
330- SetHotkeyCellState( m_curEditingRow, false );
331+ // Remove selection
332+ DeselectRow( m_curEditingRow );
333 m_curEditingRow = -1;
334 break;
335-
336 default:
337- if( event.ControlDown() )
338+ if( aEvent.ControlDown() )
339 key |= GR_KB_CTRL;
340
341- if( event.AltDown() )
342+ if( aEvent.AltDown() )
343 key |= GR_KB_ALT;
344
345- if( event.ShiftDown() && (key > 256) )
346+ if( aEvent.ShiftDown() && (key > 256) )
347 key |= GR_KB_SHIFT;
348
349 // Remap Ctrl A (=1+GR_KB_CTRL) to Ctrl Z(=26+GR_KB_CTRL)
350@@ -245,28 +167,215 @@
351 if( key >= 'a' && key <= 'z' ) // convert to uppercase
352 key = key + ('A' - 'a');
353
354-#if 0 // For debug only
355- wxString msg;
356- msg.Printf(wxT("key %X, keycode %X"),event.GetKeyCode(), key);
357- wxMessageBox(msg);
358-#endif
359 // See if this key code is handled in hotkeys names list
360 bool exists;
361 KeyNameFromKeyCode( key, &exists );
362
363- if( !exists ) // not handled, see hotkeys_basic.cpp
364- {
365- wxMessageBox( _( "Hotkey code not handled" ) );
366- }
367- else
368- {
369- m_table->SetKeyCode( m_curEditingRow, key );
370- }
371-
372- break;
373+ if( exists && m_hotkeys[m_curEditingRow]->m_KeyCode != key )
374+ {
375+ bool canUpdate = ((HOTKEY_SECTION_PAGE *)m_parent)->GetDialog()->CanSetKey( key, m_sectionTag );
376+
377+ if( canUpdate )
378+ {
379+ m_hotkeys[m_curEditingRow]->m_KeyCode = key;
380+ recalculateColumns();
381+ }
382+
383+ // Remove selection
384+ DeselectRow( m_curEditingRow );
385+ m_curEditingRow = -1;
386+ }
387 }
388 }
389-
390- m_hotkeyGrid->Refresh();
391+ RefreshItems(0,m_hotkeys.size()-1);
392+}
393+
394+
395+void HOTKEY_LIST_CTRL::RestoreFrom( struct EDA_HOTKEY_CONFIG* aSection )
396+{
397+ int row = 0;
398+
399+ EDA_HOTKEY** info_ptr;
400+
401+ for( info_ptr = aSection->m_HK_InfoList; *info_ptr; info_ptr++ )
402+ {
403+ EDA_HOTKEY* info = *info_ptr;
404+ m_hotkeys[row++]->m_KeyCode = info->m_KeyCode;
405+ }
406+
407+ // Remove selection
408+ DeselectRow( m_curEditingRow );
409+ m_curEditingRow = -1;
410+
411+ RefreshItems( 0, m_hotkeys.size()-1 );
412+}
413+
414+
415+HOTKEY_SECTION_PAGE::HOTKEY_SECTION_PAGE( HOTKEYS_EDITOR_DIALOG* aDialog,
416+ wxNotebook* aParent,
417+ const wxString& aTitle,
418+ EDA_HOTKEY_CONFIG* aSection ) :
419+ wxPanel( aParent, -1, wxDefaultPosition, wxDefaultSize,
420+ wxTAB_TRAVERSAL | wxNO_BORDER ),
421+ m_hotkeySection( aSection ),
422+ m_dialog( aDialog )
423+{
424+ aParent->AddPage( this, aTitle );
425+
426+ wxBoxSizer* bMainSizer = new wxBoxSizer( wxVERTICAL );
427+
428+ SetSizer( bMainSizer );
429+ Layout();
430+ bMainSizer->Fit( this );
431+
432+ m_hotkeyList = new HOTKEY_LIST_CTRL( this, aSection );
433+ bMainSizer->Add( m_hotkeyList, 1, wxALL|wxEXPAND, 5 );
434+}
435+
436+
437+void HOTKEY_SECTION_PAGE::Restore()
438+{
439+ m_hotkeyList->RestoreFrom( m_hotkeySection );
440+
441 Update();
442 }
443+
444+
445+void InstallHotkeyFrame( EDA_DRAW_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys )
446+{
447+ HOTKEYS_EDITOR_DIALOG dialog( aParent, aHotkeys );
448+
449+ int diag = dialog.ShowModal();
450+ if( diag == wxID_OK )
451+ {
452+ aParent->ReCreateMenuBar();
453+ aParent->Refresh();
454+ }
455+}
456+
457+
458+HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* aParent,
459+ EDA_HOTKEY_CONFIG* aHotkeys ) :
460+ HOTKEYS_EDITOR_DIALOG_BASE( aParent ),
461+ m_parent( aParent ),
462+ m_hotkeys( aHotkeys )
463+{
464+ EDA_HOTKEY_CONFIG* section;
465+
466+ for( section = m_hotkeys; section->m_HK_InfoList; section++ )
467+ {
468+ m_hotkeySectionPages.push_back(new HOTKEY_SECTION_PAGE( this, m_hotkeySections, _( *section->m_Title ), section ));
469+ }
470+
471+ m_OKButton->SetDefault();
472+ Center();
473+}
474+
475+
476+void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event )
477+{
478+ std::vector<HOTKEY_SECTION_PAGE*>::iterator i;
479+
480+ for( i = m_hotkeySectionPages.begin(); i != m_hotkeySectionPages.end(); ++i )
481+ {
482+ std::vector<EDA_HOTKEY*>& hotkey_vec = (*i)->GetHotkeys();
483+ EDA_HOTKEY_CONFIG* section = (*i)->GetHotkeySection();
484+
485+ EDA_HOTKEY** info_ptr;
486+
487+ for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ )
488+ {
489+ EDA_HOTKEY* info = *info_ptr;
490+
491+ /* find the corresponding hotkey */
492+ std::vector<EDA_HOTKEY*>::iterator j;
493+
494+ for( j = hotkey_vec.begin(); j != hotkey_vec.end(); ++j )
495+ {
496+ if( (*j) && (*j)->m_Idcommand == info->m_Idcommand )
497+ {
498+ info->m_KeyCode = (*j)->m_KeyCode;
499+ break;
500+ }
501+ }
502+ }
503+ }
504+
505+
506+ /* save the hotkeys */
507+ m_parent->WriteHotkeyConfig( m_hotkeys );
508+
509+ EndModal( wxID_OK );
510+}
511+
512+
513+void HOTKEYS_EDITOR_DIALOG::CancelClicked( wxCommandEvent& event )
514+{
515+ EndModal( wxID_CANCEL );
516+}
517+
518+
519+void HOTKEYS_EDITOR_DIALOG::UndoClicked( wxCommandEvent& aEvent )
520+{
521+ std::vector<HOTKEY_SECTION_PAGE*>::iterator i;
522+
523+ for( i = m_hotkeySectionPages.begin(); i != m_hotkeySectionPages.end(); ++i )
524+ {
525+ (*i)->Restore();
526+ }
527+}
528+
529+
530+bool HOTKEYS_EDITOR_DIALOG::CanSetKey( long aKey, const wxString* sectionTag )
531+{
532+ std::vector<HOTKEY_SECTION_PAGE*>::iterator i;
533+
534+ EDA_HOTKEY* conflictingKey = NULL;
535+ HOTKEY_SECTION_PAGE* conflictingSection = NULL;
536+
537+ for( i = m_hotkeySectionPages.begin(); i != m_hotkeySectionPages.end(); ++i )
538+ {
539+ // Any non Common section can only conflict with itself and Common
540+ if( *sectionTag != g_CommonSectionTag
541+ && *((*i)->GetHotkeySection()->m_SectionTag) != g_CommonSectionTag
542+ && *((*i)->GetHotkeySection()->m_SectionTag) != *sectionTag )
543+ continue;
544+
545+ std::vector<EDA_HOTKEY*>& hotkey_vec = (*i)->GetHotkeys();
546+ /* find the corresponding hotkey */
547+ std::vector<EDA_HOTKEY*>::iterator j;
548+
549+ for( j = hotkey_vec.begin(); j != hotkey_vec.end(); ++j )
550+ {
551+ if( aKey == (*j)->m_KeyCode )
552+ {
553+ conflictingKey = (*j);
554+ conflictingSection = (*i);
555+
556+ break;
557+ }
558+ }
559+ }
560+
561+ if( conflictingKey != NULL )
562+ {
563+ wxString msg = wxString::Format(
564+ _( "<%s> is already assigned to \"%s\" in section \"%s\". Are you sure you want to change its assignment?" ),
565+ KeyNameFromKeyCode( aKey ), conflictingKey->m_InfoMsg, *(conflictingSection->GetHotkeySection()->m_Title)
566+ );
567+
568+ wxMessageDialog dlg( this, msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT );
569+
570+ if( dlg.ShowModal() == wxID_YES )
571+ {
572+ conflictingKey->m_KeyCode = 0;
573+ return true;
574+ }
575+ else
576+ {
577+ return false;
578+ }
579+ }
580+
581+ return true;
582+}
583
584=== modified file 'common/dialogs/dialog_hotkeys_editor_base.cpp'
585--- common/dialogs/dialog_hotkeys_editor_base.cpp 2013-09-21 17:09:08 +0000
586+++ common/dialogs/dialog_hotkeys_editor_base.cpp 2014-10-17 03:18:31 +0000
587@@ -1,5 +1,5 @@
588 ///////////////////////////////////////////////////////////////////////////
589-// C++ code generated with wxFormBuilder (version Oct 8 2012)
590+// C++ code generated with wxFormBuilder (version Jun 6 2014)
591 // http://www.wxformbuilder.org/
592 //
593 // PLEASE DO "NOT" EDIT THIS FILE!
594@@ -14,37 +14,18 @@
595 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
596
597 wxBoxSizer* bMainSizer;
598- bMainSizer = new wxBoxSizer( wxHORIZONTAL );
599-
600- m_hotkeyGrid = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDOUBLE_BORDER|wxTAB_TRAVERSAL|wxWANTS_CHARS );
601-
602- // Grid
603- m_hotkeyGrid->CreateGrid( 1, 2 );
604- m_hotkeyGrid->EnableEditing( false );
605- m_hotkeyGrid->EnableGridLines( true );
606- m_hotkeyGrid->EnableDragGridSize( false );
607- m_hotkeyGrid->SetMargins( 0, 0 );
608-
609- // Columns
610- m_hotkeyGrid->AutoSizeColumns();
611- m_hotkeyGrid->EnableDragColMove( false );
612- m_hotkeyGrid->EnableDragColSize( true );
613- m_hotkeyGrid->SetColLabelSize( 30 );
614- m_hotkeyGrid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
615-
616- // Rows
617- m_hotkeyGrid->EnableDragRowSize( true );
618- m_hotkeyGrid->SetRowLabelSize( 0 );
619- m_hotkeyGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
620-
621- // Label Appearance
622-
623- // Cell Defaults
624- m_hotkeyGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
625- bMainSizer->Add( m_hotkeyGrid, 1, wxALL|wxEXPAND, 5 );
626+ bMainSizer = new wxBoxSizer( wxVERTICAL );
627+
628+ m_staticText1 = new wxStaticText( this, wxID_ANY, _("Select a row and press a new key combination to alter the binding."), wxDefaultPosition, wxDefaultSize, 0 );
629+ m_staticText1->Wrap( 400 );
630+ bMainSizer->Add( m_staticText1, 0, wxALL|wxEXPAND, 5 );
631+
632+ m_hotkeySections = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
633+
634+ bMainSizer->Add( m_hotkeySections, 1, wxEXPAND | wxALL, 5 );
635
636 wxBoxSizer* b_buttonsSizer;
637- b_buttonsSizer = new wxBoxSizer( wxVERTICAL );
638+ b_buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
639
640 m_OKButton = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
641 b_buttonsSizer->Add( m_OKButton, 0, wxALL|wxEXPAND, 5 );
642@@ -56,16 +37,13 @@
643 b_buttonsSizer->Add( m_undoButton, 0, wxALL|wxEXPAND, 5 );
644
645
646- bMainSizer->Add( b_buttonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
647+ bMainSizer->Add( b_buttonsSizer, 0, wxALIGN_CENTER|wxALIGN_RIGHT, 5 );
648
649
650 this->SetSizer( bMainSizer );
651 this->Layout();
652
653 // Connect Events
654- m_hotkeyGrid->Connect( wxEVT_CHAR, wxKeyEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::OnKeyPressed ), NULL, this );
655- m_hotkeyGrid->Connect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::OnRightClickOnCell ), NULL, this );
656- m_hotkeyGrid->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::OnClickOnCell ), NULL, this );
657 m_OKButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::OnOKClicked ), NULL, this );
658 m_cancelButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::CancelClicked ), NULL, this );
659 m_undoButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::UndoClicked ), NULL, this );
660@@ -74,9 +52,6 @@
661 HOTKEYS_EDITOR_DIALOG_BASE::~HOTKEYS_EDITOR_DIALOG_BASE()
662 {
663 // Disconnect Events
664- m_hotkeyGrid->Disconnect( wxEVT_CHAR, wxKeyEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::OnKeyPressed ), NULL, this );
665- m_hotkeyGrid->Disconnect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::OnRightClickOnCell ), NULL, this );
666- m_hotkeyGrid->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::OnClickOnCell ), NULL, this );
667 m_OKButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::OnOKClicked ), NULL, this );
668 m_cancelButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::CancelClicked ), NULL, this );
669 m_undoButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::UndoClicked ), NULL, this );
670
671=== modified file 'common/dialogs/dialog_hotkeys_editor_base.fbp'
672--- common/dialogs/dialog_hotkeys_editor_base.fbp 2013-09-21 17:09:08 +0000
673+++ common/dialogs/dialog_hotkeys_editor_base.fbp 2014-10-17 03:18:31 +0000
674@@ -1,6 +1,6 @@
675 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
676 <wxFormBuilder_Project>
677- <FileVersion major="1" minor="11" />
678+ <FileVersion major="1" minor="13" />
679 <object class="Project" expanded="1">
680 <property name="class_decoration"></property>
681 <property name="code_generation">C++</property>
682@@ -20,8 +20,10 @@
683 <property name="path">.</property>
684 <property name="precompiled_header"></property>
685 <property name="relative_path">1</property>
686+ <property name="skip_lua_events">1</property>
687 <property name="skip_php_events">1</property>
688 <property name="skip_python_events">1</property>
689+ <property name="ui_table">UI</property>
690 <property name="use_enum">0</property>
691 <property name="use_microsoft_bom">0</property>
692 <object class="Dialog" expanded="1">
693@@ -42,7 +44,7 @@
694 <property name="minimum_size"></property>
695 <property name="name">HOTKEYS_EDITOR_DIALOG_BASE</property>
696 <property name="pos"></property>
697- <property name="size">304,235</property>
698+ <property name="size">450,500</property>
699 <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
700 <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
701 <property name="title">Hotkeys Editor</property>
702@@ -89,13 +91,96 @@
703 <object class="wxBoxSizer" expanded="1">
704 <property name="minimum_size"></property>
705 <property name="name">bMainSizer</property>
706- <property name="orient">wxHORIZONTAL</property>
707+ <property name="orient">wxVERTICAL</property>
708 <property name="permission">none</property>
709 <object class="sizeritem" expanded="1">
710 <property name="border">5</property>
711 <property name="flag">wxALL|wxEXPAND</property>
712+ <property name="proportion">0</property>
713+ <object class="wxStaticText" expanded="1">
714+ <property name="BottomDockable">1</property>
715+ <property name="LeftDockable">1</property>
716+ <property name="RightDockable">1</property>
717+ <property name="TopDockable">1</property>
718+ <property name="aui_layer"></property>
719+ <property name="aui_name"></property>
720+ <property name="aui_position"></property>
721+ <property name="aui_row"></property>
722+ <property name="best_size"></property>
723+ <property name="bg"></property>
724+ <property name="caption"></property>
725+ <property name="caption_visible">1</property>
726+ <property name="center_pane">0</property>
727+ <property name="close_button">1</property>
728+ <property name="context_help"></property>
729+ <property name="context_menu">1</property>
730+ <property name="default_pane">0</property>
731+ <property name="dock">Dock</property>
732+ <property name="dock_fixed">0</property>
733+ <property name="docking">Left</property>
734+ <property name="enabled">1</property>
735+ <property name="fg"></property>
736+ <property name="floatable">1</property>
737+ <property name="font"></property>
738+ <property name="gripper">0</property>
739+ <property name="hidden">0</property>
740+ <property name="id">wxID_ANY</property>
741+ <property name="label">Select a row and press a new key combination to alter the binding.</property>
742+ <property name="max_size"></property>
743+ <property name="maximize_button">0</property>
744+ <property name="maximum_size"></property>
745+ <property name="min_size"></property>
746+ <property name="minimize_button">0</property>
747+ <property name="minimum_size"></property>
748+ <property name="moveable">1</property>
749+ <property name="name">m_staticText1</property>
750+ <property name="pane_border">1</property>
751+ <property name="pane_position"></property>
752+ <property name="pane_size"></property>
753+ <property name="permission">protected</property>
754+ <property name="pin_button">1</property>
755+ <property name="pos"></property>
756+ <property name="resize">Resizable</property>
757+ <property name="show">1</property>
758+ <property name="size"></property>
759+ <property name="style"></property>
760+ <property name="subclass"></property>
761+ <property name="toolbar_pane">0</property>
762+ <property name="tooltip"></property>
763+ <property name="window_extra_style"></property>
764+ <property name="window_name"></property>
765+ <property name="window_style"></property>
766+ <property name="wrap">400</property>
767+ <event name="OnChar"></event>
768+ <event name="OnEnterWindow"></event>
769+ <event name="OnEraseBackground"></event>
770+ <event name="OnKeyDown"></event>
771+ <event name="OnKeyUp"></event>
772+ <event name="OnKillFocus"></event>
773+ <event name="OnLeaveWindow"></event>
774+ <event name="OnLeftDClick"></event>
775+ <event name="OnLeftDown"></event>
776+ <event name="OnLeftUp"></event>
777+ <event name="OnMiddleDClick"></event>
778+ <event name="OnMiddleDown"></event>
779+ <event name="OnMiddleUp"></event>
780+ <event name="OnMotion"></event>
781+ <event name="OnMouseEvents"></event>
782+ <event name="OnMouseWheel"></event>
783+ <event name="OnPaint"></event>
784+ <event name="OnRightDClick"></event>
785+ <event name="OnRightDown"></event>
786+ <event name="OnRightUp"></event>
787+ <event name="OnSetFocus"></event>
788+ <event name="OnSize"></event>
789+ <event name="OnUpdateUI"></event>
790+ </object>
791+ </object>
792+ <object class="sizeritem" expanded="1">
793+ <property name="border">5</property>
794+ <property name="flag">wxEXPAND | wxALL</property>
795 <property name="proportion">1</property>
796- <object class="wxGrid" expanded="1">
797+ <object class="wxNotebook" expanded="1">
798 <property name="BottomDockable">1</property>
799 <property name="LeftDockable">1</property>
800 <property name="RightDockable">1</property>
801@@ -104,50 +189,26 @@
802 <property name="aui_name"></property>
803 <property name="aui_position"></property>
804 <property name="aui_row"></property>
805- <property name="autosize_cols">1</property>
806- <property name="autosize_rows">0</property>
807 <property name="best_size"></property>
808 <property name="bg"></property>
809+ <property name="bitmapsize"></property>
810 <property name="caption"></property>
811 <property name="caption_visible">1</property>
812- <property name="cell_bg"></property>
813- <property name="cell_font"></property>
814- <property name="cell_horiz_alignment">wxALIGN_LEFT</property>
815- <property name="cell_text"></property>
816- <property name="cell_vert_alignment">wxALIGN_TOP</property>
817 <property name="center_pane">0</property>
818 <property name="close_button">1</property>
819- <property name="col_label_horiz_alignment">wxALIGN_CENTRE</property>
820- <property name="col_label_size">30</property>
821- <property name="col_label_values"></property>
822- <property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
823- <property name="cols">2</property>
824- <property name="column_sizes"></property>
825 <property name="context_help"></property>
826 <property name="context_menu">1</property>
827 <property name="default_pane">0</property>
828 <property name="dock">Dock</property>
829 <property name="dock_fixed">0</property>
830 <property name="docking">Left</property>
831- <property name="drag_col_move">0</property>
832- <property name="drag_col_size">1</property>
833- <property name="drag_grid_size">0</property>
834- <property name="drag_row_size">1</property>
835- <property name="editing">0</property>
836 <property name="enabled">1</property>
837 <property name="fg"></property>
838 <property name="floatable">1</property>
839 <property name="font"></property>
840- <property name="grid_line_color"></property>
841- <property name="grid_lines">1</property>
842 <property name="gripper">0</property>
843 <property name="hidden">0</property>
844 <property name="id">wxID_ANY</property>
845- <property name="label_bg"></property>
846- <property name="label_font"></property>
847- <property name="label_text"></property>
848- <property name="margin_height">0</property>
849- <property name="margin_width">0</property>
850 <property name="max_size"></property>
851 <property name="maximize_button">0</property>
852 <property name="maximum_size"></property>
853@@ -155,7 +216,7 @@
854 <property name="minimize_button">0</property>
855 <property name="minimum_size"></property>
856 <property name="moveable">1</property>
857- <property name="name">m_hotkeyGrid</property>
858+ <property name="name">m_hotkeySections</property>
859 <property name="pane_border">1</property>
860 <property name="pane_position"></property>
861 <property name="pane_size"></property>
862@@ -163,55 +224,18 @@
863 <property name="pin_button">1</property>
864 <property name="pos"></property>
865 <property name="resize">Resizable</property>
866- <property name="row_label_horiz_alignment">wxALIGN_CENTRE</property>
867- <property name="row_label_size">0</property>
868- <property name="row_label_values"></property>
869- <property name="row_label_vert_alignment">wxALIGN_CENTRE</property>
870- <property name="row_sizes"></property>
871- <property name="rows">1</property>
872 <property name="show">1</property>
873 <property name="size"></property>
874+ <property name="style"></property>
875 <property name="subclass"></property>
876 <property name="toolbar_pane">0</property>
877 <property name="tooltip"></property>
878 <property name="window_extra_style"></property>
879 <property name="window_name"></property>
880- <property name="window_style">wxDOUBLE_BORDER|wxTAB_TRAVERSAL|wxWANTS_CHARS</property>
881- <event name="OnChar">OnKeyPressed</event>
882+ <property name="window_style"></property>
883+ <event name="OnChar"></event>
884 <event name="OnEnterWindow"></event>
885 <event name="OnEraseBackground"></event>
886- <event name="OnGridCellChange"></event>
887- <event name="OnGridCellLeftClick"></event>
888- <event name="OnGridCellLeftDClick"></event>
889- <event name="OnGridCellRightClick">OnRightClickOnCell</event>
890- <event name="OnGridCellRightDClick"></event>
891- <event name="OnGridCmdCellChange"></event>
892- <event name="OnGridCmdCellLeftClick"></event>
893- <event name="OnGridCmdCellLeftDClick"></event>
894- <event name="OnGridCmdCellRightClick"></event>
895- <event name="OnGridCmdCellRightDClick"></event>
896- <event name="OnGridCmdColSize"></event>
897- <event name="OnGridCmdEditorCreated"></event>
898- <event name="OnGridCmdEditorHidden"></event>
899- <event name="OnGridCmdEditorShown"></event>
900- <event name="OnGridCmdLabelLeftClick"></event>
901- <event name="OnGridCmdLabelLeftDClick"></event>
902- <event name="OnGridCmdLabelRightClick"></event>
903- <event name="OnGridCmdLabelRightDClick"></event>
904- <event name="OnGridCmdRangeSelect"></event>
905- <event name="OnGridCmdRowSize"></event>
906- <event name="OnGridCmdSelectCell"></event>
907- <event name="OnGridColSize"></event>
908- <event name="OnGridEditorCreated"></event>
909- <event name="OnGridEditorHidden"></event>
910- <event name="OnGridEditorShown"></event>
911- <event name="OnGridLabelLeftClick"></event>
912- <event name="OnGridLabelLeftDClick"></event>
913- <event name="OnGridLabelRightClick"></event>
914- <event name="OnGridLabelRightDClick"></event>
915- <event name="OnGridRangeSelect"></event>
916- <event name="OnGridRowSize"></event>
917- <event name="OnGridSelectCell">OnClickOnCell</event>
918 <event name="OnKeyDown"></event>
919 <event name="OnKeyUp"></event>
920 <event name="OnKillFocus"></event>
921@@ -225,6 +249,8 @@
922 <event name="OnMotion"></event>
923 <event name="OnMouseEvents"></event>
924 <event name="OnMouseWheel"></event>
925+ <event name="OnNotebookPageChanged"></event>
926+ <event name="OnNotebookPageChanging"></event>
927 <event name="OnPaint"></event>
928 <event name="OnRightDClick"></event>
929 <event name="OnRightDown"></event>
930@@ -236,18 +262,18 @@
931 </object>
932 <object class="sizeritem" expanded="1">
933 <property name="border">5</property>
934- <property name="flag">wxALIGN_CENTER_VERTICAL</property>
935+ <property name="flag">wxALIGN_CENTER|wxALIGN_RIGHT</property>
936 <property name="proportion">0</property>
937- <object class="wxBoxSizer" expanded="1">
938+ <object class="wxBoxSizer" expanded="0">
939 <property name="minimum_size"></property>
940 <property name="name">b_buttonsSizer</property>
941- <property name="orient">wxVERTICAL</property>
942+ <property name="orient">wxHORIZONTAL</property>
943 <property name="permission">none</property>
944- <object class="sizeritem" expanded="1">
945+ <object class="sizeritem" expanded="0">
946 <property name="border">5</property>
947 <property name="flag">wxALL|wxEXPAND</property>
948 <property name="proportion">0</property>
949- <object class="wxButton" expanded="1">
950+ <object class="wxButton" expanded="0">
951 <property name="BottomDockable">1</property>
952 <property name="LeftDockable">1</property>
953 <property name="RightDockable">1</property>
954@@ -331,11 +357,11 @@
955 <event name="OnUpdateUI"></event>
956 </object>
957 </object>
958- <object class="sizeritem" expanded="1">
959+ <object class="sizeritem" expanded="0">
960 <property name="border">5</property>
961 <property name="flag">wxALL|wxEXPAND</property>
962 <property name="proportion">0</property>
963- <object class="wxButton" expanded="1">
964+ <object class="wxButton" expanded="0">
965 <property name="BottomDockable">1</property>
966 <property name="LeftDockable">1</property>
967 <property name="RightDockable">1</property>
968@@ -419,11 +445,11 @@
969 <event name="OnUpdateUI"></event>
970 </object>
971 </object>
972- <object class="sizeritem" expanded="1">
973+ <object class="sizeritem" expanded="0">
974 <property name="border">5</property>
975 <property name="flag">wxALL|wxEXPAND</property>
976 <property name="proportion">0</property>
977- <object class="wxButton" expanded="1">
978+ <object class="wxButton" expanded="0">
979 <property name="BottomDockable">1</property>
980 <property name="LeftDockable">1</property>
981 <property name="RightDockable">1</property>
982
983=== modified file 'common/dialogs/dialog_hotkeys_editor_base.h'
984--- common/dialogs/dialog_hotkeys_editor_base.h 2013-09-21 17:09:08 +0000
985+++ common/dialogs/dialog_hotkeys_editor_base.h 2014-10-17 03:18:31 +0000
986@@ -1,5 +1,5 @@
987 ///////////////////////////////////////////////////////////////////////////
988-// C++ code generated with wxFormBuilder (version Oct 8 2012)
989+// C++ code generated with wxFormBuilder (version Jun 6 2014)
990 // http://www.wxformbuilder.org/
991 //
992 // PLEASE DO "NOT" EDIT THIS FILE!
993@@ -14,12 +14,13 @@
994 class DIALOG_SHIM;
995
996 #include "dialog_shim.h"
997+#include <wx/string.h>
998+#include <wx/stattext.h>
999+#include <wx/gdicmn.h>
1000+#include <wx/font.h>
1001 #include <wx/colour.h>
1002 #include <wx/settings.h>
1003-#include <wx/string.h>
1004-#include <wx/font.h>
1005-#include <wx/grid.h>
1006-#include <wx/gdicmn.h>
1007+#include <wx/notebook.h>
1008 #include <wx/button.h>
1009 #include <wx/sizer.h>
1010 #include <wx/dialog.h>
1011@@ -35,15 +36,13 @@
1012 private:
1013
1014 protected:
1015- wxGrid* m_hotkeyGrid;
1016+ wxStaticText* m_staticText1;
1017+ wxNotebook* m_hotkeySections;
1018 wxButton* m_OKButton;
1019 wxButton* m_cancelButton;
1020 wxButton* m_undoButton;
1021
1022 // Virtual event handlers, overide them in your derived class
1023- virtual void OnKeyPressed( wxKeyEvent& event ) { event.Skip(); }
1024- virtual void OnRightClickOnCell( wxGridEvent& event ) { event.Skip(); }
1025- virtual void OnClickOnCell( wxGridEvent& event ) { event.Skip(); }
1026 virtual void OnOKClicked( wxCommandEvent& event ) { event.Skip(); }
1027 virtual void CancelClicked( wxCommandEvent& event ) { event.Skip(); }
1028 virtual void UndoClicked( wxCommandEvent& event ) { event.Skip(); }
1029@@ -51,7 +50,7 @@
1030
1031 public:
1032
1033- HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Hotkeys Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 304,235 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
1034+ HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Hotkeys Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 450,500 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
1035 ~HOTKEYS_EDITOR_DIALOG_BASE();
1036
1037 };
1038
1039=== removed file 'common/hotkey_grid_table.cpp'
1040--- common/hotkey_grid_table.cpp 2014-04-07 16:00:13 +0000
1041+++ common/hotkey_grid_table.cpp 1970-01-01 00:00:00 +0000
1042@@ -1,220 +0,0 @@
1043-/*
1044- * This program source code file is part of KiCad, a free EDA CAD application.
1045- *
1046- * Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
1047- *
1048- * This program is free software; you can redistribute it and/or
1049- * modify it under the terms of the GNU General Public License
1050- * as published by the Free Software Foundation; either version 2
1051- * of the License, or (at your option) any later version.
1052- *
1053- * This program is distributed in the hope that it will be useful,
1054- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1055- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1056- * GNU General Public License for more details.
1057- *
1058- * You should have received a copy of the GNU General Public License
1059- * along with this program; if not, you may find one here:
1060- * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
1061- * or you may search the http://www.gnu.org website for the version 2 license,
1062- * or you may write to the Free Software Foundation, Inc.,
1063- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
1064- */
1065-
1066-#include <hotkey_grid_table.h>
1067-
1068-/*
1069- * Reads the hotkey table from its stored format into a format suitable
1070- * for a wxGrid.
1071- */
1072-HOTKEY_EDITOR_GRID_TABLE::HOTKEY_EDITOR_GRID_TABLE( struct EDA_HOTKEY_CONFIG* origin ) :
1073- wxGridTableBase(), m_hotkeys()
1074-{
1075- EDA_HOTKEY_CONFIG* section;
1076-
1077- for( section = origin; section->m_HK_InfoList; section++ )
1078- {
1079- // Add a dummy hotkey_spec which is a header before each hotkey list
1080- hotkey_spec spec( *section->m_SectionTag, NULL );
1081- m_hotkeys.push_back( spec );
1082-
1083- EDA_HOTKEY** hotkey_descr_list;
1084-
1085- // Add hotkeys descr
1086- for( hotkey_descr_list = section->m_HK_InfoList; *hotkey_descr_list;
1087- hotkey_descr_list++ )
1088- {
1089- EDA_HOTKEY* hotkey_descr = *hotkey_descr_list;
1090- hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( hotkey_descr ) );
1091- m_hotkeys.push_back( spec );
1092- }
1093- }
1094-}
1095-
1096-
1097-HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector& HOTKEY_EDITOR_GRID_TABLE::getHotkeys()
1098-{
1099- return m_hotkeys;
1100-}
1101-
1102-
1103-int HOTKEY_EDITOR_GRID_TABLE::GetNumberRows()
1104-{
1105- return m_hotkeys.size();
1106-}
1107-
1108-
1109-int HOTKEY_EDITOR_GRID_TABLE::GetNumberCols()
1110-{
1111- return 2;
1112-}
1113-
1114-
1115-bool HOTKEY_EDITOR_GRID_TABLE::IsEmptyCell( int row, int col )
1116-{
1117- return col == 1 && m_hotkeys[row].second == NULL;
1118-}
1119-
1120-
1121-wxString HOTKEY_EDITOR_GRID_TABLE::GetValue( int row, int col )
1122-{
1123- EDA_HOTKEY* hotkey_descr = m_hotkeys[row].second;
1124-
1125- if( col == 0 )
1126- {
1127- if( hotkey_descr == NULL )
1128- {
1129- // section header
1130- return m_hotkeys[row].first;
1131- }
1132- else
1133- {
1134- return hotkey_descr->m_InfoMsg;
1135- }
1136- }
1137- else
1138- {
1139- if( hotkey_descr == NULL )
1140- {
1141- // section header
1142- return wxEmptyString;
1143- }
1144- else
1145- {
1146- return KeyNameFromKeyCode( hotkey_descr->m_KeyCode );
1147- }
1148- }
1149-}
1150-
1151-
1152-void HOTKEY_EDITOR_GRID_TABLE::SetValue( int row, int col, const wxString& value )
1153-{
1154-}
1155-
1156-
1157-wxString HOTKEY_EDITOR_GRID_TABLE::GetTypeName( int row, int col )
1158-{
1159- return wxGRID_VALUE_STRING;
1160-}
1161-
1162-
1163-bool HOTKEY_EDITOR_GRID_TABLE::CanGetValueAs( int row, int col, const wxString& typeName )
1164-{
1165- return typeName == wxGRID_VALUE_STRING && col == 2;
1166-}
1167-
1168-
1169-bool HOTKEY_EDITOR_GRID_TABLE::CanSetValueAs( int row, int col, const wxString& typeName )
1170-{
1171- return false;
1172-}
1173-
1174-
1175-long HOTKEY_EDITOR_GRID_TABLE::GetValueAsLong( int row, int col )
1176-{
1177- return -1L;
1178-}
1179-
1180-
1181-double HOTKEY_EDITOR_GRID_TABLE::GetValueAsDouble( int row, int col )
1182-{
1183- return 0.0;
1184-}
1185-
1186-
1187-bool HOTKEY_EDITOR_GRID_TABLE::GetValueAsBool( int row, int col )
1188-{
1189- return false;
1190-}
1191-
1192-
1193-void HOTKEY_EDITOR_GRID_TABLE::SetValueAsLong( int row, int col, long value )
1194-{
1195-}
1196-
1197-
1198-void HOTKEY_EDITOR_GRID_TABLE::SetValueAsDouble( int row, int col, double value )
1199-{
1200-}
1201-
1202-
1203-void HOTKEY_EDITOR_GRID_TABLE::SetValueAsBool( int row, int col, bool value )
1204-{
1205-}
1206-
1207-
1208-void* HOTKEY_EDITOR_GRID_TABLE::GetValueAsCustom( int row, int col )
1209-{
1210- return 0;
1211-}
1212-
1213-
1214-void HOTKEY_EDITOR_GRID_TABLE::SetValueAsCustom( int row, int col, void* value )
1215-{
1216-}
1217-
1218-
1219-wxString HOTKEY_EDITOR_GRID_TABLE::GetColLabelValue( int col )
1220-{
1221- return col == 0 ? _( "Command" ) : _( "Hotkey" );
1222-}
1223-
1224-
1225-bool HOTKEY_EDITOR_GRID_TABLE::IsHeader( int row )
1226-{
1227- return m_hotkeys[row].second == NULL;
1228-}
1229-
1230-
1231-void HOTKEY_EDITOR_GRID_TABLE::SetKeyCode( int row, long key )
1232-{
1233- m_hotkeys[row].second->m_KeyCode = key;
1234-}
1235-
1236-
1237-void HOTKEY_EDITOR_GRID_TABLE::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin )
1238-{
1239- int row = 0;
1240- EDA_HOTKEY_CONFIG* section;
1241-
1242- for( section = origin; section->m_HK_InfoList; section++ )
1243- {
1244- ++row; // Skip header
1245- EDA_HOTKEY** info_ptr;
1246-
1247- for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ )
1248- {
1249- EDA_HOTKEY* info = *info_ptr;
1250- m_hotkeys[row++].second->m_KeyCode = info->m_KeyCode;
1251- }
1252- }
1253-}
1254-
1255-
1256-HOTKEY_EDITOR_GRID_TABLE::~HOTKEY_EDITOR_GRID_TABLE()
1257-{
1258- hotkey_spec_vector::iterator i;
1259-
1260- for( i = m_hotkeys.begin(); i != m_hotkeys.end(); ++i )
1261- delete i->second;
1262-}
1263
1264=== modified file 'common/hotkeys_basic.cpp'
1265--- common/hotkeys_basic.cpp 2014-09-05 21:12:38 +0000
1266+++ common/hotkeys_basic.cpp 2014-10-17 03:18:31 +0000
1267@@ -52,6 +52,12 @@
1268 wxString g_BoardEditorSectionTag( wxT( "[pcbnew]" ) );
1269 wxString g_ModuleEditSectionTag( wxT( "[footprinteditor]" ) );
1270
1271+wxString g_CommonSectionTitle( wxT( "Common" ) );
1272+wxString g_SchematicSectionTitle( wxT( "Schematic Editor" ) );
1273+wxString g_LibEditSectionTitle( wxT( "Library Editor" ) );
1274+wxString g_BoardEditorSectionTitle( wxT( "Board Editor" ) );
1275+wxString g_ModuleEditSectionTitle( wxT( "Footprint Editor" ) );
1276+
1277
1278 /* Class to handle hotkey commnands. hotkeys have a default value
1279 * This class allows the real key code changed by user from a key code list
1280@@ -161,6 +167,10 @@
1281 int ii;
1282 bool found = false;
1283
1284+ // Assume keycode of 0 is "unassigned"
1285+ if( aKeycode == 0 )
1286+ return wxT( "<unassigned>");
1287+
1288 if( (aKeycode & GR_KB_CTRL) != 0 )
1289 modifier << MODIFIER_CTRL;
1290
1291@@ -490,10 +500,10 @@
1292
1293 for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
1294 {
1295- if( aDescList->m_Comment )
1296+ if( aDescList->m_Title )
1297 {
1298 msg += wxT( "# " );
1299- msg += wxString( aDescList->m_Comment );
1300+ msg += *aDescList->m_Title;
1301 msg += wxT( "\n" );
1302 }
1303
1304
1305=== modified file 'eeschema/hotkeys.cpp'
1306--- eeschema/hotkeys.cpp 2014-10-15 11:40:38 +0000
1307+++ eeschema/hotkeys.cpp 2014-10-17 03:18:31 +0000
1308@@ -131,7 +131,7 @@
1309
1310 // mouse click command:
1311 static EDA_HOTKEY HkMouseLeftClick( wxT( "Mouse Left Click" ), HK_LEFT_CLICK, WXK_RETURN, 0 );
1312-static EDA_HOTKEY HkMouseLeftDClick( wxT( "Mouse Left DClick" ), HK_LEFT_DCLICK, WXK_END, 0 );
1313+static EDA_HOTKEY HkMouseLeftDClick( wxT( "Mouse Left Double Click" ), HK_LEFT_DCLICK, WXK_END, 0 );
1314
1315 // Schematic editor
1316 static EDA_HOTKEY HkBeginWire( wxT( "Begin Wire" ), HK_BEGIN_WIRE, 'W', ID_WIRE_BUTT );
1317@@ -149,7 +149,7 @@
1318 ID_SCH_PLACE_COMPONENT );
1319 static EDA_HOTKEY HkAddPower( wxT( "Add Power" ), HK_ADD_NEW_POWER, 'P',
1320 ID_PLACE_POWER_BUTT );
1321-static EDA_HOTKEY HkAddNoConn( wxT( "Add NoConnected Flag" ), HK_ADD_NOCONN_FLAG, 'Q',
1322+static EDA_HOTKEY HkAddNoConn( wxT( "Add No Connect Flag" ), HK_ADD_NOCONN_FLAG, 'Q',
1323 ID_NOCONN_BUTT );
1324 static EDA_HOTKEY HkAddHierSheet( wxT( "Add Sheet" ), HK_ADD_HIER_SHEET, 'S',
1325 ID_SHEET_SYMBOL_BUTT );
1326@@ -207,7 +207,7 @@
1327 static EDA_HOTKEY HkMoveLibItem( wxT( "Move Library Item" ), HK_LIBEDIT_MOVE_GRAPHIC_ITEM, 'M' );
1328
1329 // Load/save files
1330-static EDA_HOTKEY HkSaveLib( wxT( "Save Lib" ), HK_SAVE_LIB, 'S' + GR_KB_CTRL );
1331+static EDA_HOTKEY HkSaveLib( wxT( "Save Library" ), HK_SAVE_LIB, 'S' + GR_KB_CTRL );
1332 static EDA_HOTKEY HkSaveSchematic( wxT( "Save Schematic" ), HK_SAVE_SCH, 'S' + GR_KB_CTRL );
1333 static EDA_HOTKEY HkLoadSchematic( wxT( "Load Schematic" ), HK_LOAD_SCH, 'L' + GR_KB_CTRL );
1334
1335@@ -305,18 +305,18 @@
1336 // an hotkey config file)
1337 struct EDA_HOTKEY_CONFIG g_Eeschema_Hokeys_Descr[] =
1338 {
1339- { &g_CommonSectionTag, common_Hotkey_List, L"Common keys" },
1340- { &g_SchematicSectionTag, schematic_Hotkey_List, L"Schematic editor keys" },
1341- { &g_LibEditSectionTag, libEdit_Hotkey_List, L"library editor keys" },
1342- { NULL, NULL, NULL }
1343+ { &g_CommonSectionTag, common_Hotkey_List, &g_CommonSectionTitle },
1344+ { &g_SchematicSectionTag, schematic_Hotkey_List, &g_SchematicSectionTitle },
1345+ { &g_LibEditSectionTag, libEdit_Hotkey_List, &g_LibEditSectionTitle },
1346+ { NULL, NULL, NULL }
1347 };
1348
1349 // list of sections and corresponding hotkey list for the schematic editor
1350 // (used to list current hotkeys)
1351 struct EDA_HOTKEY_CONFIG g_Schematic_Hokeys_Descr[] =
1352 {
1353- { &g_CommonSectionTag, common_Hotkey_List, NULL },
1354- { &g_SchematicSectionTag, schematic_Hotkey_List, NULL },
1355+ { &g_CommonSectionTag, common_Hotkey_List, &g_CommonSectionTitle },
1356+ { &g_SchematicSectionTag, schematic_Hotkey_List, &g_SchematicSectionTitle },
1357 { NULL, NULL, NULL }
1358 };
1359
1360@@ -324,17 +324,17 @@
1361 // (used to list current hotkeys)
1362 struct EDA_HOTKEY_CONFIG g_Libedit_Hokeys_Descr[] =
1363 {
1364- { &g_CommonSectionTag, common_Hotkey_List, NULL },
1365- { &g_LibEditSectionTag, libEdit_Hotkey_List, NULL },
1366- { NULL, NULL, NULL }
1367+ { &g_CommonSectionTag, common_Hotkey_List, &g_CommonSectionTitle },
1368+ { &g_LibEditSectionTag, libEdit_Hotkey_List, &g_LibEditSectionTitle },
1369+ { NULL, NULL, NULL }
1370 };
1371
1372 // list of sections and corresponding hotkey list for the component browser
1373 // (used to list current hotkeys)
1374 struct EDA_HOTKEY_CONFIG g_Viewlib_Hokeys_Descr[] =
1375 {
1376- { &g_CommonSectionTag, common_basic_Hotkey_List, NULL },
1377- { NULL, NULL, NULL }
1378+ { &g_CommonSectionTag, common_basic_Hotkey_List, &g_CommonSectionTitle },
1379+ { NULL, NULL, NULL }
1380 };
1381
1382 /*
1383
1384=== modified file 'include/dialog_hotkeys_editor.h'
1385--- include/dialog_hotkeys_editor.h 2014-04-02 13:38:59 +0000
1386+++ include/dialog_hotkeys_editor.h 2014-10-17 03:18:31 +0000
1387@@ -1,3 +1,29 @@
1388+/*
1389+ * This program source code file is part of KiCad, a free EDA CAD application.
1390+ *
1391+ * Copyright (C) 2004-2014 KiCad Developers, see CHANGELOG.TXT for contributors.
1392+ *
1393+ * This program is free software; you can redistribute it and/or
1394+ * modify it under the terms of the GNU General Public License
1395+ * as published by the Free Software Foundation; either version 2
1396+ * of the License, or (at your option) any later version.
1397+ *
1398+ * This program is distributed in the hope that it will be useful,
1399+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1400+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1401+ * GNU General Public License for more details.
1402+ *
1403+ * You should have received a copy of the GNU General Public License
1404+ * along with this program; if not, you may find one here:
1405+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
1406+ * or you may search the http://www.gnu.org website for the version 2 license,
1407+ * or you may write to the Free Software Foundation, Inc.,
1408+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
1409+ */
1410+
1411+/**
1412+ * @file dialog_hotkeys_editor.h
1413+ */
1414
1415 #ifndef __dialog_hotkeys_editor__
1416 #define __dialog_hotkeys_editor__
1417@@ -17,34 +43,222 @@
1418 #include <wx/grid.h>
1419
1420 #include <hotkeys_basic.h>
1421-#include <hotkey_grid_table.h>
1422 #include <draw_frame.h>
1423 #include <../common/dialogs/dialog_hotkeys_editor_base.h>
1424
1425+class HOTKEYS_EDITOR_DIALOG;
1426+
1427+/**
1428+ * Class HOTKEY_LIST_CTRL
1429+ * is a class to contain the contents of a hotkey editor tab page.
1430+ */
1431+class HOTKEY_LIST_CTRL : public wxListCtrl
1432+{
1433+public:
1434+ HOTKEY_LIST_CTRL( wxWindow* aParent, struct EDA_HOTKEY_CONFIG* aSection );
1435+ ~HOTKEY_LIST_CTRL() {};
1436+
1437+ /**
1438+ * Function DeselectRow
1439+ * Deselect the given row
1440+ *
1441+ * @param aRow is the row to deselect
1442+ */
1443+ void DeselectRow( int aRow );
1444+
1445+ /**
1446+ * Function GetHotkeys
1447+ * Access to return the vector used for the list control data. This will contain the
1448+ * "live" state of the user's configuration.
1449+ *
1450+ * @return Pointer to vector of hotkey settings
1451+ */
1452+ std::vector< EDA_HOTKEY* >& GetHotkeys() { return m_hotkeys; }
1453+
1454+ /**
1455+ * Function RestoreFrom
1456+ * Restores list control hotkey keycodes to the keycodes present in the
1457+ * given hotkey configuration array.
1458+ *
1459+ * @param aSection is a pointer to the hotkey configuration array
1460+ */
1461+ void RestoreFrom( struct EDA_HOTKEY_CONFIG* aSection );
1462+
1463+private:
1464+ int m_curEditingRow;
1465+ wxString* m_sectionTag;
1466+ std::vector< EDA_HOTKEY* > m_hotkeys;
1467+
1468+ /**
1469+ * Function recalculateColumns
1470+ * Adjusts the width of grid columns in proportion of the max text length of both
1471+ */
1472+ void recalculateColumns();
1473+
1474+protected:
1475+ /**
1476+ * Function OnGetItemText
1477+ * Returns the requested row, column data to the list control.
1478+ *
1479+ * @param aRow is the row of the data which matches our hotkeys vector as a index
1480+ * @param aColumn is the column of the data which is either Command(0) or KeyCode(1)
1481+ *
1482+ * @return String containing the text for the specified row, column combination
1483+ */
1484+ wxString OnGetItemText( long aRow, long aColumn ) const;
1485+
1486+ /**
1487+ * Function OnChar
1488+ * Decoded key press handler which is used to set key codes in the list control
1489+ *
1490+ * @param aEvent is the key press event, the keycode is retrieved from it
1491+ */
1492+ void OnChar( wxKeyEvent& aEvent );
1493+
1494+ /**
1495+ * Function OnListItemSelected
1496+ * Item selection handler which is used to record what index is selected to alter
1497+ * update with the key press
1498+ *
1499+ * @param aEvent is the button press event, unused
1500+ */
1501+ void OnListItemSelected( wxListEvent& aEvent );
1502+
1503+ /**
1504+ * Function OnSize
1505+ * Sizing update handler to recompute the column widths dynamically and maximize them.
1506+ * Due to wxWidget's broken autosizing support (it's completely inconsistent across
1507+ * platforms), we just do it based on a scale of
1508+ *
1509+ * @param aEvent is the button press event, unused
1510+ */
1511+ void OnSize( wxSizeEvent& aEvent );
1512+};
1513+
1514+/**
1515+ * Class HOTKEY_SECTION_PAGE
1516+ * is a class to contain the contents of a hotkey editor tab page.
1517+ */
1518+class HOTKEY_SECTION_PAGE : public wxPanel
1519+{
1520+public:
1521+private:
1522+ EDA_HOTKEY_CONFIG* m_hotkeySection;
1523+ HOTKEY_LIST_CTRL *m_hotkeyList;
1524+ HOTKEYS_EDITOR_DIALOG* m_dialog;
1525+
1526+public:
1527+ /** Constructor to create a setup page for one netlist format.
1528+ * Used in Netlist format Dialog box creation
1529+ * @param parent = wxNotebook * parent
1530+ * @param title = title (name) of the notebook page
1531+ * @param id_NetType = netlist type id
1532+ */
1533+ HOTKEY_SECTION_PAGE( HOTKEYS_EDITOR_DIALOG* aDialog, wxNotebook* aParent,
1534+ const wxString& aTitle,
1535+ EDA_HOTKEY_CONFIG* aSection );
1536+ ~HOTKEY_SECTION_PAGE() {};
1537+
1538+ /**
1539+ * Function Restore
1540+ * Resets the hotkeys back to their original unedited state
1541+ */
1542+ void Restore();
1543+
1544+ /**
1545+ * Function GetHotkeys
1546+ * Accessor to retrieve hotkeys list from list control
1547+ *
1548+ * @return Pointer to vector used for list control data
1549+ */
1550+ std::vector< EDA_HOTKEY* >& GetHotkeys() { return m_hotkeyList->GetHotkeys(); }
1551+
1552+ /**
1553+ * Function GetHotkeySection
1554+ * Accessor to retrieve hotkey configuration array assigned to a tab control page
1555+ *
1556+ * @return Pointer to hotkey configuration array
1557+ */
1558+ EDA_HOTKEY_CONFIG* GetHotkeySection() { return m_hotkeySection; }
1559+
1560+ /**
1561+ * Function GetDialog
1562+ * Returns pointer to parent dialog window
1563+ *
1564+ * @return Pointer to parent dialog window
1565+ */
1566+ HOTKEYS_EDITOR_DIALOG* GetDialog() { return m_dialog; }
1567+};
1568+
1569+/**
1570+ * Class HOTKEYS_EDITOR_DIALOG
1571+ * is the child class of HOTKEYS_EDITOR_DIALOG_BASE. This is the class
1572+ * used to create a hotkey editor.
1573+ */
1574 class HOTKEYS_EDITOR_DIALOG : public HOTKEYS_EDITOR_DIALOG_BASE
1575 {
1576 protected:
1577 EDA_DRAW_FRAME* m_parent;
1578 struct EDA_HOTKEY_CONFIG* m_hotkeys;
1579- HOTKEY_EDITOR_GRID_TABLE* m_table;
1580
1581- int m_curEditingRow;
1582+ std::vector<HOTKEY_SECTION_PAGE*> m_hotkeySectionPages;
1583
1584 public:
1585- HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent, EDA_HOTKEY_CONFIG* hotkeys );
1586+ HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys );
1587
1588 ~HOTKEYS_EDITOR_DIALOG() {};
1589
1590+ /**
1591+ * Function CanSetKey
1592+ * Check if we can set a hotkey, this will prompt the user if there
1593+ * is a conflict between keys. The key code should have already been
1594+ * checked that it's not for the same entry as its currently in or else
1595+ * it'll prompt the change on itself.
1596+ * The function will do conflict detection depending on aSectionTag.
1597+ * g_CommonSectionTag means the key code must be checked with all sections.
1598+ * While other tags means the key code only must be checked with the aSectionTag
1599+ * section and g_CommonSectionTag section.
1600+ *
1601+ * @param aKey is the key code that wants to be set
1602+ * @param aSectionTag is the section tag that the key code came from
1603+ *
1604+ * @return True if the user accepted the overwrite or no conflict existed
1605+ */
1606+ bool CanSetKey( long aKey, const wxString* aSectionTag );
1607+
1608 private:
1609- void OnOKClicked( wxCommandEvent& event );
1610- void CancelClicked( wxCommandEvent& event );
1611- void UndoClicked( wxCommandEvent& event );
1612- void OnClickOnCell( wxGridEvent& event );
1613- void OnRightClickOnCell( wxGridEvent& event );
1614- void OnKeyPressed( wxKeyEvent& event );
1615- void SetHotkeyCellState( int aRow, bool aHightlight );
1616+ /**
1617+ * Function OnOKClicked
1618+ * Close the dialog and make save all changes to hotkeys
1619+ *
1620+ * @param aEvent is the button press event, unused
1621+ */
1622+ void OnOKClicked( wxCommandEvent& aEvent );
1623+
1624+ /**
1625+ * Function CancelClicked
1626+ * Close the dialog and make no changes to hotkeys
1627+ *
1628+ * @param aEvent is the button press event, unused
1629+ */
1630+ void CancelClicked( wxCommandEvent& aEvent );
1631+
1632+ /**
1633+ * Function UndoClicked
1634+ * Reinit the hotkeys to the initial state (removes all pending changes)
1635+ *
1636+ * @param aEvent is the button press event, unused
1637+ */
1638+ void UndoClicked( wxCommandEvent& aEvent );
1639 };
1640
1641-void InstallHotkeyFrame( EDA_DRAW_FRAME* parent, EDA_HOTKEY_CONFIG* hotkeys );
1642+/**
1643+ * Function InstallHotkeyFrame
1644+ * Create a hotkey editor dialog window with the provided hotkey configuration array
1645+ *
1646+ * @param aParent is the parent window
1647+ * @param aHotkeys is the hotkey configuration array
1648+ */
1649+void InstallHotkeyFrame( EDA_DRAW_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys );
1650
1651 #endif
1652
1653=== removed file 'include/hotkey_grid_table.h'
1654--- include/hotkey_grid_table.h 2014-04-02 13:38:59 +0000
1655+++ include/hotkey_grid_table.h 1970-01-01 00:00:00 +0000
1656@@ -1,57 +0,0 @@
1657-#ifndef __hotkeys_grid_table__
1658-#define __hotkeys_grid_table__
1659-
1660-#include <wx/intl.h>
1661-
1662-#include <wx/string.h>
1663-#include <wx/grid.h>
1664-
1665-#include <vector>
1666-#include <utility>
1667-
1668-#include <fctsys.h>
1669-#include <pgm_base.h>
1670-#include <common.h>
1671-#include <hotkeys_basic.h>
1672-
1673-class HOTKEY_EDITOR_GRID_TABLE : public wxGridTableBase
1674-{
1675-
1676-public:
1677- typedef std::pair< wxString, EDA_HOTKEY* > hotkey_spec;
1678- typedef std::vector< hotkey_spec > hotkey_spec_vector;
1679-
1680- HOTKEY_EDITOR_GRID_TABLE( struct EDA_HOTKEY_CONFIG* origin );
1681- virtual ~HOTKEY_EDITOR_GRID_TABLE();
1682- hotkey_spec_vector& getHotkeys();
1683-
1684-private:
1685- virtual int GetNumberRows();
1686- virtual int GetNumberCols();
1687- virtual bool IsEmptyCell( int row, int col );
1688- virtual wxString GetValue( int row, int col );
1689- virtual void SetValue( int row, int col, const wxString& value );
1690- virtual wxString GetTypeName( int row, int col );
1691- virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
1692- virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
1693- virtual long GetValueAsLong( int row, int col );
1694- virtual double GetValueAsDouble( int row, int col );
1695- virtual bool GetValueAsBool( int row, int col );
1696- virtual void SetValueAsLong( int row, int col, long value );
1697- virtual void SetValueAsDouble( int row, int col, double value );
1698- virtual void SetValueAsBool( int row, int col, bool value );
1699- virtual void* GetValueAsCustom( int row, int col );
1700- virtual void SetValueAsCustom( int row, int col, void* value );
1701- virtual wxString GetColLabelValue( int col );
1702-
1703-public:
1704- virtual bool IsHeader( int row );
1705- virtual void SetKeyCode( int row, long key );
1706- virtual void RestoreFrom( struct EDA_HOTKEY_CONFIG* origin );
1707-
1708-protected:
1709- std::vector< hotkey_spec > m_hotkeys;
1710-
1711-};
1712-
1713-#endif
1714
1715=== modified file 'include/hotkeys_basic.h'
1716--- include/hotkeys_basic.h 2014-04-02 13:38:59 +0000
1717+++ include/hotkeys_basic.h 2014-10-17 03:18:31 +0000
1718@@ -44,6 +44,12 @@
1719 extern wxString g_BoardEditorSectionTag;
1720 extern wxString g_ModuleEditSectionTag;
1721
1722+extern wxString g_CommonSectionTitle;
1723+extern wxString g_SchematicSectionTitle;
1724+extern wxString g_LibEditSectionTitle;
1725+extern wxString g_BoardEditorSectionTitle;
1726+extern wxString g_ModuleEditSectionTitle;
1727+
1728
1729 /**
1730 * class EDA_HOTKEY
1731@@ -81,7 +87,7 @@
1732 public:
1733 wxString* m_SectionTag; // The configuration file section name.
1734 EDA_HOTKEY** m_HK_InfoList; // List of EDA_HOTKEY pointers
1735- const wchar_t* m_Comment; // Will be printed in the config file only.
1736+ wxString* m_Title; // Title displayed in hotkey editor and used as comment in file
1737 };
1738
1739
1740
1741=== modified file 'pagelayout_editor/hotkeys.cpp'
1742--- pagelayout_editor/hotkeys.cpp 2014-08-29 20:23:40 +0000
1743+++ pagelayout_editor/hotkeys.cpp 2014-10-17 03:18:31 +0000
1744@@ -59,7 +59,7 @@
1745
1746 // mouse click command:
1747 static EDA_HOTKEY HkMouseLeftClick( wxT( "Mouse Left Click" ), HK_LEFT_CLICK, WXK_RETURN, 0 );
1748-static EDA_HOTKEY HkMouseLeftDClick( wxT( "Mouse Left DClick" ), HK_LEFT_DCLICK, WXK_END, 0 );
1749+static EDA_HOTKEY HkMouseLeftDClick( wxT( "Mouse Left Double Click" ), HK_LEFT_DCLICK, WXK_END, 0 );
1750
1751 static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ),
1752 HK_RESET_LOCAL_COORD, ' ' );
1753@@ -107,12 +107,13 @@
1754 // list of sections and corresponding hotkey list for Pl_Editor
1755 // (used to create an hotkey config file)
1756 wxString s_PlEditorSectionTag( wxT( "[pl_editor]" ) );
1757+wxString s_PlEditorSectionTitle( wxT( "Part Layout Editor" ) );
1758
1759 struct EDA_HOTKEY_CONFIG s_PlEditor_Hokeys_Descr[] =
1760 {
1761- { &g_CommonSectionTag, s_Common_Hotkey_List, L"Common keys" },
1762- { &s_PlEditorSectionTag, s_PlEditor_Hotkey_List, L"pl_editor keys" },
1763- { NULL, NULL, NULL }
1764+ { &g_CommonSectionTag, s_Common_Hotkey_List, &g_CommonSectionTitle },
1765+ { &s_PlEditorSectionTag, s_PlEditor_Hotkey_List, &s_PlEditorSectionTitle },
1766+ { NULL, NULL, NULL }
1767 };
1768
1769
1770
1771=== modified file 'pcbnew/hotkeys.cpp'
1772--- pcbnew/hotkeys.cpp 2014-10-15 11:40:38 +0000
1773+++ pcbnew/hotkeys.cpp 2014-10-17 03:18:31 +0000
1774@@ -36,7 +36,7 @@
1775 // mouse click command:
1776 static EDA_HOTKEY HkMouseLeftClick( wxT( "Mouse Left Click" ),
1777 HK_LEFT_CLICK, WXK_RETURN, 0 );
1778-static EDA_HOTKEY HkMouseLeftDClick( wxT( "Mouse Left DClick" ),
1779+static EDA_HOTKEY HkMouseLeftDClick( wxT( "Mouse Left Double Click" ),
1780 HK_LEFT_DCLICK, WXK_END, 0 );
1781
1782 static EDA_HOTKEY HkSwitch2CopperLayer( wxT( "Switch to Copper (B.Cu) layer" ),
1783@@ -64,21 +64,21 @@
1784 HK_SWITCH_LAYER_TO_PREVIOUS, '-' );
1785
1786 static EDA_HOTKEY HkSaveModule( wxT( "Save Module" ), HK_SAVE_MODULE, 'S' + GR_KB_CTRL );
1787-static EDA_HOTKEY HkSavefile( wxT( "Save board" ), HK_SAVE_BOARD, 'S' + GR_KB_CTRL );
1788-static EDA_HOTKEY HkSavefileAs( wxT( "Save board as" ), HK_SAVE_BOARD_AS, 'S' + GR_KB_CTRL + GR_KB_SHIFT );
1789-static EDA_HOTKEY HkLoadfile( wxT( "Load board" ), HK_LOAD_BOARD, 'L' + GR_KB_CTRL );
1790+static EDA_HOTKEY HkSavefile( wxT( "Save Board" ), HK_SAVE_BOARD, 'S' + GR_KB_CTRL );
1791+static EDA_HOTKEY HkSavefileAs( wxT( "Save Board As" ), HK_SAVE_BOARD_AS, 'S' + GR_KB_CTRL + GR_KB_SHIFT );
1792+static EDA_HOTKEY HkLoadfile( wxT( "Load Board" ), HK_LOAD_BOARD, 'L' + GR_KB_CTRL );
1793 static EDA_HOTKEY HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL );
1794-static EDA_HOTKEY HkBackspace( wxT( "Delete track segment" ), HK_BACK_SPACE, WXK_BACK );
1795-static EDA_HOTKEY HkAddNewTrack( wxT( "Add new track" ), HK_ADD_NEW_TRACK, 'X' );
1796+static EDA_HOTKEY HkBackspace( wxT( "Delete Track Segment" ), HK_BACK_SPACE, WXK_BACK );
1797+static EDA_HOTKEY HkAddNewTrack( wxT( "Add New Track" ), HK_ADD_NEW_TRACK, 'X' );
1798 static EDA_HOTKEY HkAddThroughVia( wxT( "Add Through Via" ), HK_ADD_THROUGH_VIA, 'V' );
1799-static EDA_HOTKEY HkSelLayerAndAddThroughVia( wxT( "Sel Layer and Add Through Via" ),
1800+static EDA_HOTKEY HkSelLayerAndAddThroughVia( wxT( "Select Layer and Add Through Via" ),
1801 HK_SEL_LAYER_AND_ADD_THROUGH_VIA, '<' );
1802 static EDA_HOTKEY HkAddMicroVia( wxT( "Add MicroVia" ), HK_ADD_MICROVIA, 'V' + GR_KB_CTRL );
1803 static EDA_HOTKEY HkAddBlindBuriedVia( wxT( "Add Blind/Buried Via" ), HK_ADD_BLIND_BURIED_VIA, 'V' + GR_KB_ALT );
1804-static EDA_HOTKEY HkSelLayerAndAddBlindBuriedVia( wxT( "Sel Layer and Add Blind/Buried Via" ),
1805+static EDA_HOTKEY HkSelLayerAndAddBlindBuriedVia( wxT( "Select Layer and Add Blind/Buried Via" ),
1806 HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA, '<' + GR_KB_ALT );
1807 static EDA_HOTKEY HkSwitchTrackPosture( wxT( "Switch Track Posture" ), HK_SWITCH_TRACK_POSTURE, '/' );
1808-static EDA_HOTKEY HkDragTrackKeepSlope( wxT( "Drag track keep slope" ), HK_DRAG_TRACK_KEEP_SLOPE, 'D' );
1809+static EDA_HOTKEY HkDragTrackKeepSlope( wxT( "Drag Track Keep Slope" ), HK_DRAG_TRACK_KEEP_SLOPE, 'D' );
1810 static EDA_HOTKEY HkPlaceItem( wxT( "Place Item" ), HK_PLACE_ITEM, 'P' );
1811 static EDA_HOTKEY HkEditBoardItem( wxT( "Edit Item" ), HK_EDIT_ITEM, 'E' );
1812 static EDA_HOTKEY HkFlipItem( wxT( "Flip Item" ), HK_FLIP_ITEM, 'F' );
1813@@ -90,16 +90,16 @@
1814 static EDA_HOTKEY HkLock_Unlock_Footprint( wxT( "Lock/Unlock Footprint" ), HK_LOCK_UNLOCK_FOOTPRINT, 'L' );
1815 static EDA_HOTKEY HkDelete( wxT( "Delete Track or Footprint" ), HK_DELETE, WXK_DELETE );
1816 static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' );
1817-static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"), HK_SWITCH_HIGHCONTRAST_MODE,'H');
1818-
1819-static EDA_HOTKEY HkSetGridOrigin( wxT("Set Grid Origin"), HK_SET_GRID_ORIGIN, 'S' );
1820-static EDA_HOTKEY HkResetGridOrigin( wxT("Reset Grid Origin"), HK_RESET_GRID_ORIGIN, 'Z' );
1821-
1822-static EDA_HOTKEY HkCanvasDefault( wxT( "Switch to default canvas" ),
1823+static EDA_HOTKEY HkSwitchHighContrastMode( wxT( "Toggle High Contrast Mode" ), HK_SWITCH_HIGHCONTRAST_MODE,'H');
1824+
1825+static EDA_HOTKEY HkSetGridOrigin( wxT( "Set Grid Origin" ), HK_SET_GRID_ORIGIN, 'S' );
1826+static EDA_HOTKEY HkResetGridOrigin( wxT( "Reset Grid Origin" ), HK_RESET_GRID_ORIGIN, 'Z' );
1827+
1828+static EDA_HOTKEY HkCanvasDefault( wxT( "Switch to Default Canvas" ),
1829 HK_CANVAS_DEFAULT, WXK_F9 );
1830-static EDA_HOTKEY HkCanvasOpenGL( wxT( "Switch to OpenGL canvas" ),
1831+static EDA_HOTKEY HkCanvasOpenGL( wxT( "Switch to OpenGL Canvas" ),
1832 HK_CANVAS_OPENGL, WXK_F11 );
1833-static EDA_HOTKEY HkCanvasCairo( wxT( "Switch to Cairo canvas" ),
1834+static EDA_HOTKEY HkCanvasCairo( wxT( "Switch to Cairo Canvas" ),
1835 HK_CANVAS_CAIRO, WXK_F12 );
1836
1837 /* Fit on Screen */
1838@@ -285,33 +285,33 @@
1839 // list of sections and corresponding hotkey list for Pcbnew
1840 // (used to create an hotkey config file, and edit hotkeys )
1841 struct EDA_HOTKEY_CONFIG g_Pcbnew_Editor_Hokeys_Descr[] = {
1842- { &g_CommonSectionTag, common_Hotkey_List, L"Common keys" },
1843- { &g_BoardEditorSectionTag, board_edit_Hotkey_List, L"Board editor keys" },
1844- { &g_ModuleEditSectionTag, module_edit_Hotkey_List, L"Footprint editor keys" },
1845- { NULL, NULL, NULL }
1846+ { &g_CommonSectionTag, common_Hotkey_List, &g_CommonSectionTitle },
1847+ { &g_BoardEditorSectionTag, board_edit_Hotkey_List, &g_BoardEditorSectionTitle },
1848+ { &g_ModuleEditSectionTag, module_edit_Hotkey_List, &g_ModuleEditSectionTitle },
1849+ { NULL, NULL, NULL }
1850 };
1851
1852 // list of sections and corresponding hotkey list for the board editor
1853 // (used to list current hotkeys in the board editor)
1854 struct EDA_HOTKEY_CONFIG g_Board_Editor_Hokeys_Descr[] = {
1855- { &g_CommonSectionTag, common_Hotkey_List, NULL },
1856- { &g_BoardEditorSectionTag, board_edit_Hotkey_List, NULL },
1857+ { &g_CommonSectionTag, common_Hotkey_List, &g_CommonSectionTitle },
1858+ { &g_BoardEditorSectionTag, board_edit_Hotkey_List, &g_BoardEditorSectionTitle },
1859 { NULL, NULL, NULL }
1860 };
1861
1862 // list of sections and corresponding hotkey list for the footprint editor
1863 // (used to list current hotkeys in the module editor)
1864 struct EDA_HOTKEY_CONFIG g_Module_Editor_Hokeys_Descr[] = {
1865- { &g_CommonSectionTag, common_Hotkey_List, NULL },
1866- { &g_ModuleEditSectionTag, module_edit_Hotkey_List, NULL },
1867- { NULL, NULL, NULL }
1868+ { &g_CommonSectionTag, common_Hotkey_List, &g_CommonSectionTitle },
1869+ { &g_ModuleEditSectionTag, module_edit_Hotkey_List, &g_ModuleEditSectionTitle },
1870+ { NULL, NULL, NULL }
1871 };
1872
1873 // list of sections and corresponding hotkey list for the footprint viewer
1874 // (used to list current hotkeys in the module viewer)
1875 struct EDA_HOTKEY_CONFIG g_Module_Viewer_Hokeys_Descr[] = {
1876- { &g_CommonSectionTag, common_basic_Hotkey_List, NULL },
1877- { NULL, NULL, NULL }
1878+ { &g_CommonSectionTag, common_basic_Hotkey_List, &g_CommonSectionTitle },
1879+ { NULL, NULL, NULL }
1880 };
1881
1882