1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2009-2016 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
24  */
25 
26 /**
27  * @file id.h
28  */
29 
30 
31 #ifndef ID_H_
32 #define ID_H_
33 
34 #include <wx/defs.h>
35 
36 /**
37  * Common command IDs shared by more than one of the KiCad applications.
38  *
39  * Only place command IDs used in base window class event tables or shared
40  * across multiple applications such as the zoom, grid, and language IDs.
41  * Application specific IDs should be defined in the appropriate header
42  * file to prevent the entire project from being rebuilt.
43  *
44  * However, we must avoid duplicate IDs in menus and toolbar items, when wxUpdateUIEvent
45  * are associated to menuitems and/or toolbar items
46  * The reason is the fact wxWidgets try to send a wxUpdateUIEvent event to a given window and,
47  * if a wxUpdateUIEvent event function is not defined for a menuitem, wxWidgets
48  * propagates this event ID to parents of the given window.
49  * Therefore duplicate IDs could create strange behavior in menus and subtle bugs, depending
50  * on the code inside the wxUpdateUIEvent event functions called in parent frames.
51  * I did not seen this propagation to child frames, only to parent frames
52  *
53  * Issues exist only if 2 menus have the same ID, and only one menu is associated to
54  * a wxUpdateUIEvent event, and this one is defined in a parent Window.
55  * The probability it happens is low, but not null.
56  *
57  * Therefore we reserve room in ID list for each sub application.
58  * Please, change these values if needed
59  */
60 
61 // Define room for IDs, for each sub application
62 #define ROOM_FOR_KICADMANAGER 50
63 #define ROOM_FOR_3D_VIEWER 100
64 #define ROOM_FOR_PANEL_PREV_MODEL 50
65 
66 
67 /// IDs range for menuitems file history:
68 /// The default range file history size is 9 (compatible with default wxWidget range).
69 #define DEFAULT_FILE_HISTORY_SIZE 9
70 #define MAX_FILE_HISTORY_SIZE 99
71 
72 enum main_id
73 {
74     ID_RUN_PCB                  = wxID_HIGHEST,
75 
76     ID_APPEND_PROJECT,
77     ID_LOAD_FILE,
78     ID_NEW_BOARD,
79     ID_SAVE_BOARD,
80     ID_SAVE_BOARD_AS,
81     ID_AUTO_SAVE_TIMER,
82 
83     // ID for menuitems used in our file history management,
84     // when we do not use wxFILE_ID (restricted to 9 items)
85     ID_FILE,
86     ID_FILE1,
87     ID_FILEMAX = ID_FILE + MAX_FILE_HISTORY_SIZE,
88     ID_FILE_LIST_EMPTY,
89     ID_FILE_LIST_CLEAR,
90 
91     ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
92     ID_PREFERENCES_CONFIGURE_PATHS,
93     ID_EDIT_SYMBOL_LIBRARY_TABLE,
94     ID_EDIT_FOOTPRINT_LIBRARY_TABLE,
95 
96     ID_GEN_PLOT,
97     ID_GEN_PLOT_PS,
98     ID_GEN_PLOT_HPGL,
99     ID_GEN_PLOT_GERBER,
100     ID_GEN_PLOT_SVG,
101     ID_GEN_PLOT_DXF,
102     ID_GEN_PLOT_PDF,
103 
104     ID_GEN_EXPORT_FILE,
105     ID_GEN_IMPORT_FILE,
106 
107     // id for toolbars
108     ID_H_TOOLBAR,
109     ID_V_TOOLBAR,
110     ID_OPT_TOOLBAR,
111     ID_AUX_TOOLBAR,
112 
113     ID_EDIT_HOTKEY,
114     ID_NO_TOOL_SELECTED,
115 
116     ID_LANGUAGE_CHOICE,
117     ID_LANGUAGE_DANISH,
118     ID_LANGUAGE_DEFAULT,
119     ID_LANGUAGE_ENGLISH,
120     ID_LANGUAGE_FRENCH,
121     ID_LANGUAGE_FINNISH,
122     ID_LANGUAGE_SPANISH,
123     ID_LANGUAGE_SPANISH_MEXICAN,
124     ID_LANGUAGE_GERMAN,
125     ID_LANGUAGE_GREEK,
126     ID_LANGUAGE_NORWEGIAN,
127     ID_LANGUAGE_RUSSIAN,
128     ID_LANGUAGE_PORTUGUESE,
129     ID_LANGUAGE_PORTUGUESE_BRAZILIAN,
130     ID_LANGUAGE_TURKISH,
131     ID_LANGUAGE_INDONESIAN,
132     ID_LANGUAGE_ITALIAN,
133     ID_LANGUAGE_SLOVENIAN,
134     ID_LANGUAGE_SLOVAK,
135     ID_LANGUAGE_HUNGARIAN,
136     ID_LANGUAGE_POLISH,
137     ID_LANGUAGE_CZECH,
138     ID_LANGUAGE_KOREAN,
139     ID_LANGUAGE_CATALAN,
140     ID_LANGUAGE_CHINESE_SIMPLIFIED,
141     ID_LANGUAGE_CHINESE_TRADITIONAL,
142     ID_LANGUAGE_DUTCH,
143     ID_LANGUAGE_JAPANESE,
144     ID_LANGUAGE_BULGARIAN,
145     ID_LANGUAGE_LATVIAN,
146     ID_LANGUAGE_LITHUANIAN,
147     ID_LANGUAGE_VIETNAMESE,
148     ID_LANGUAGE_SERBIAN,
149     ID_LANGUAGE_THAI,
150     ID_LANGUAGE_SWEDISH,
151     ID_LANGUAGE_CHOICE_END,
152 
153     // Popup Menu (mouse Right button) (id consecutifs)
154 
155     ID_ON_ZOOM_SELECT,
156     ID_POPUP_ZOOM_START_RANGE,       // first zoom id
157     ID_POPUP_CANCEL,
158     ID_POPUP_ZOOM_IN,
159     ID_POPUP_ZOOM_OUT,
160     ID_POPUP_ZOOM_SELECT,
161     ID_POPUP_ZOOM_CENTER,
162     ID_POPUP_ZOOM_PAGE,
163     ID_POPUP_ZOOM_REDRAW,
164 
165     /* Reserve IDs for popup menu zoom levels.  If you need more
166      * levels of zoom, change ID_POPUP_ZOOM_LEVEL_END.  Note that more
167      * than 15 entries in a context submenu may get too large to display
168      * cleanly.  Add any additional popup zoom IDs above here or the
169      * zoom event handler will not work properly.
170      */
171     ID_POPUP_ZOOM_LEVEL_START,
172     ID_POPUP_ZOOM_LEVEL_END = ID_POPUP_ZOOM_LEVEL_START + 99,
173 
174     ID_POPUP_GRID_START,
175     ID_POPUP_GRID_END = ID_POPUP_ZOOM_LEVEL_START + 99,
176 
177     ID_ON_GRID_SELECT,
178     ID_GRID_SETTINGS,
179 
180     ID_ZOOM_BEGIN,
181     ID_VIEWER_ZOOM_IN = ID_ZOOM_BEGIN,
182     ID_VIEWER_ZOOM_OUT,
183     ID_VIEWER_ZOOM_PAGE,
184     ID_VIEWER_ZOOM_REDRAW,
185     // zoom commands for non center zooming
186     ID_OFFCENTER_ZOOM_IN,
187     ID_OFFCENTER_ZOOM_OUT,
188     ID_ZOOM_END,
189 
190     // KiFace server for standalone operation
191     ID_EDA_SOCKET_EVENT_SERV,
192     ID_EDA_SOCKET_EVENT,
193 
194     // IDs specifics to a sub-application (Eeschema, Kicad manager....) start here
195     //
196     // We reserve here Ids for each sub-application, to avoid duplicate IDs
197     // between them.
198     // mainly we experienced issues related to wxUpdateUIEvent calls when 2 (or more) wxFrames
199     // share the same ID in menus, mainly in menubars/toolbars
200     // The reason is the fact wxWidgets propagates the wxUpdateUIEvent to all parent windows
201     // to find wxUpdateUIEvent event functions matching the menuitem IDs found when activate a
202     // menu in the first frame.
203 
204     // Reserve ROOM_FOR_KICADMANAGER IDs, for Kicad manager
205     // Change it if this count is too small.
206     ID_KICAD_MANAGER_START,
207     ID_KICAD_MANAGER_END = ID_KICAD_MANAGER_START + ROOM_FOR_KICADMANAGER,
208 
209     // Reserve ROOM_FOR_KICADMANAGER IDs, for Kicad manager
210     // Change it if this count is too small.
211     ID_KICAD_3D_VIEWER_START,
212     ID_KICAD_3D_VIEWER_END = ID_KICAD_3D_VIEWER_START + ROOM_FOR_3D_VIEWER,
213 
214     ID_KICAD_PANEL_PREV_MODEL_START,
215     ID_KICAD_PANEL_PREV_MODEL_END = ID_KICAD_PANEL_PREV_MODEL_START + ROOM_FOR_PANEL_PREV_MODEL,
216 
217     // Reseve ID for popup menus, when we need to know a menu item is inside a popup menu
218     ID_POPUP_MENU_START,
219     ID_POPUP_MENU_END = ID_POPUP_MENU_START + 1000,
220 
221     ID_END_LIST
222 };
223 
224 #endif  // ID_H_
225