KiCad PCB EDA Suite
trace_helpers.cpp File Reference

wxLogTrace helper implementation. More...

#include <wx/defs.h>
#include <wx/string.h>
#include <wx/event.h>
#include <wx/arrstr.h>
#include <trace_helpers.h>

Go to the source code of this file.

Macros

#define WXK_(x)   case WXK_##x: return #x;
 

Functions

wxString dump (const wxArrayString &aArray)
 Debug helper for printing wxArrayString contents. More...
 
const char * GetVirtualKeyCodeName (int keycode)
 
wxString GetKeyName (const wxKeyEvent &aEvent)
 
wxString dump (const wxKeyEvent &aEvent)
 Debug helper for printing wxKeyEvent information. More...
 

Variables

const wxChar *const traceFindReplace = wxT( "KICAD_FIND_REPLACE" )
 Flag to enable find and replace debug tracing. More...
 
const wxChar *const kicadTraceCoords = wxT( "KICAD_COORDS" )
 Flag to enable draw panel coordinate debug tracing. More...
 
const wxChar *const kicadTraceKeyEvent = wxT( "KICAD_KEY_EVENTS" )
 Flag to enable wxKeyEvent debug tracing. More...
 
const wxChar *const traceSchLibMem = wxT( "KICAD_SCH_LIB_MEM" )
 Flag to enable schematic library memory deletion debug output. More...
 
const wxChar *const traceFindItem = wxT( "KICAD_FIND_ITEM" )
 Flag to enable find debug tracing. More...
 
const wxChar *const traceSchLegacyPlugin = wxT( "KICAD_SCH_LEGACY_PLUGIN" )
 Flag to enable legacy schematic plugin debug output. More...
 
const wxChar *const traceGedaPcbPlugin = wxT( "KICAD_GEDA_PLUGIN" )
 Flag to enable GEDA PCB plugin debug output. More...
 
const wxChar *const traceKicadPcbPlugin = wxT( "KICAD_PCB_PLUGIN" )
 Flag to enable GEDA PCB plugin debug output. More...
 
const wxChar *const tracePrinting = wxT( "KICAD_PRINT" )
 Flag to enable print controller debug output. More...
 
const wxChar *const traceAutoSave = wxT( "KICAD_AUTOSAVE" )
 Flag to enable auto save feature debug tracing. More...
 
const wxChar *const tracePathsAndFiles = wxT( "KICAD_PATHS_AND_FILES" )
 Flag to enable path and file name debug output. More...
 
const wxChar *const traceLocale = wxT( "KICAD_LOCALE" )
 Flag to enable locale debug output. More...
 
const wxChar *const traceScreen = wxT( "KICAD_SCREEN" )
 Flag to enable debug output of BASE_SCREEN and it's derivatives. More...
 

Detailed Description

wxLogTrace helper implementation.

Definition in file trace_helpers.cpp.

Macro Definition Documentation

#define WXK_ (   x)    case WXK_##x: return #x;

Referenced by GetVirtualKeyCodeName().

Function Documentation

wxString dump ( const wxArrayString &  aArray)

Debug helper for printing wxArrayString contents.

Parameters
aArrayis the string array to output.
Returns
the wxArrayString contents in a formatted string for debugging output.

Definition at line 53 of file trace_helpers.cpp.

References i.

Referenced by SCH_FIND_COLLECTOR::Collect(), TOOL_DISPATCHER::DispatchWxEvent(), EDA_DRAW_FRAME::OnCharHook(), EDA_DRAW_PANEL::OnCharHook(), EDA_DRAW_PANEL::OnKeyEvent(), GPCB_FPL_CACHE::parseParameters(), and SCH_FIND_COLLECTOR::PassedEnd().

54 {
55  wxString tmp;
56 
57  for( unsigned i = 0; i < aArray.GetCount(); i++ )
58  {
59  if( aArray[i].IsEmpty() )
60  tmp << wxT( "\"\" " );
61  else
62  tmp << aArray[i] << wxT( " " );
63  }
64 
65  return tmp;
66 }
size_t i
Definition: json11.cpp:597
wxString dump ( const wxKeyEvent &  aEvent)

Debug helper for printing wxKeyEvent information.

Parameters
aEventis the wxKeyEvent to generate the print string from.
Returns
the wxKeyEvent information.

Definition at line 227 of file trace_helpers.cpp.

References GetKeyName().

228 {
229  wxString msg;
230  wxString eventType = "unknown";
231 
232  if( aEvent.GetEventType() == wxEVT_KEY_DOWN )
233  eventType = "KeyDown";
234  else if( aEvent.GetEventType() == wxEVT_KEY_UP )
235  eventType = "KeyUp";
236  else if( aEvent.GetEventType() == wxEVT_CHAR )
237  eventType = "Char";
238  else if( aEvent.GetEventType() == wxEVT_CHAR_HOOK )
239  eventType = "Hook";
240 
241  // event key_name KeyCode modifiers Unicode raw_code raw_flags pos
242  msg.Printf( "%7s %15s %5d %c%c%c%c"
243 #if wxUSE_UNICODE
244  "%5d (U+%04x)"
245 #else
246  " none "
247 #endif
248 #ifdef wxHAS_RAW_KEY_CODES
249  " %7lu 0x%08lx"
250 #else
251  " not-set not-set"
252 #endif
253  " (%5d,%5d)"
254  "\n",
255  eventType,
256  GetKeyName( aEvent ),
257  aEvent.GetKeyCode(),
258  aEvent.ControlDown() ? 'C' : '-',
259  aEvent.AltDown() ? 'A' : '-',
260  aEvent.ShiftDown() ? 'S' : '-',
261  aEvent.MetaDown() ? 'M' : '-'
262 #if wxUSE_UNICODE
263  , aEvent.GetUnicodeKey()
264  , aEvent.GetUnicodeKey()
265 #endif
266 #ifdef wxHAS_RAW_KEY_CODES
267  , (unsigned long) aEvent.GetRawKeyCode()
268  , (unsigned long) aEvent.GetRawKeyFlags()
269 #endif
270  , aEvent.GetX()
271  , aEvent.GetY()
272  );
273 
274  return msg;
275 }
wxString GetKeyName(const wxKeyEvent &aEvent)
wxString GetKeyName ( const wxKeyEvent &  aEvent)

Definition at line 202 of file trace_helpers.cpp.

References Format(), and GetVirtualKeyCodeName().

Referenced by dump().

203 {
204  int keycode = aEvent.GetKeyCode();
205  const char* virt = GetVirtualKeyCodeName( keycode );
206 
207  if( virt )
208  return virt;
209 
210  if( keycode > 0 && keycode < 32 )
211  return wxString::Format( "Ctrl-%c", (unsigned char)('A' + keycode - 1) );
212 
213  if( keycode >= 32 && keycode < 128 )
214  return wxString::Format( "'%c'", (unsigned char)keycode );
215 
216 #if wxUSE_UNICODE
217  int uc = aEvent.GetUnicodeKey();
218 
219  if( uc != WXK_NONE )
220  return wxString::Format( "'%c'", uc );
221 #endif
222 
223  return "unknown";
224 }
const char * GetVirtualKeyCodeName(int keycode)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
const char* GetVirtualKeyCodeName ( int  keycode)

Definition at line 81 of file trace_helpers.cpp.

References ADD, DIVIDE, and WXK_.

Referenced by GetKeyName().

82 {
83  switch ( keycode )
84  {
85 #define WXK_(x) \
86  case WXK_##x: return #x;
87 
88  WXK_(BACK)
89  WXK_(TAB)
90  WXK_(RETURN)
91  WXK_(ESCAPE)
92  WXK_(SPACE)
93  WXK_(DELETE)
94  WXK_(START)
95  WXK_(LBUTTON)
96  WXK_(RBUTTON)
97  WXK_(CANCEL)
98  WXK_(MBUTTON)
99  WXK_(CLEAR)
100  WXK_(SHIFT)
101  WXK_(ALT)
102  WXK_(CONTROL)
103  WXK_(MENU)
104  WXK_(PAUSE)
105  WXK_(CAPITAL)
106  WXK_(END)
107  WXK_(HOME)
108  WXK_(LEFT)
109  WXK_(UP)
110  WXK_(RIGHT)
111  WXK_(DOWN)
112  WXK_(SELECT)
113  WXK_(PRINT)
114  WXK_(EXECUTE)
115  WXK_(SNAPSHOT)
116  WXK_(INSERT)
117  WXK_(HELP)
118  WXK_(NUMPAD0)
119  WXK_(NUMPAD1)
120  WXK_(NUMPAD2)
121  WXK_(NUMPAD3)
122  WXK_(NUMPAD4)
123  WXK_(NUMPAD5)
124  WXK_(NUMPAD6)
125  WXK_(NUMPAD7)
126  WXK_(NUMPAD8)
127  WXK_(NUMPAD9)
128  WXK_(MULTIPLY)
129  WXK_(ADD)
130  WXK_(SEPARATOR)
131  WXK_(SUBTRACT)
132  WXK_(DECIMAL)
133  WXK_(DIVIDE)
134  WXK_(F1)
135  WXK_(F2)
136  WXK_(F3)
137  WXK_(F4)
138  WXK_(F5)
139  WXK_(F6)
140  WXK_(F7)
141  WXK_(F8)
142  WXK_(F9)
143  WXK_(F10)
144  WXK_(F11)
145  WXK_(F12)
146  WXK_(F13)
147  WXK_(F14)
148  WXK_(F15)
149  WXK_(F16)
150  WXK_(F17)
151  WXK_(F18)
152  WXK_(F19)
153  WXK_(F20)
154  WXK_(F21)
155  WXK_(F22)
156  WXK_(F23)
157  WXK_(F24)
158  WXK_(NUMLOCK)
159  WXK_(SCROLL)
160  WXK_(PAGEUP)
161  WXK_(PAGEDOWN)
162  WXK_(NUMPAD_SPACE)
163  WXK_(NUMPAD_TAB)
164  WXK_(NUMPAD_ENTER)
165  WXK_(NUMPAD_F1)
166  WXK_(NUMPAD_F2)
167  WXK_(NUMPAD_F3)
168  WXK_(NUMPAD_F4)
169  WXK_(NUMPAD_HOME)
170  WXK_(NUMPAD_LEFT)
171  WXK_(NUMPAD_UP)
172  WXK_(NUMPAD_RIGHT)
173  WXK_(NUMPAD_DOWN)
174  WXK_(NUMPAD_PAGEUP)
175  WXK_(NUMPAD_PAGEDOWN)
176  WXK_(NUMPAD_END)
177  WXK_(NUMPAD_BEGIN)
178  WXK_(NUMPAD_INSERT)
179  WXK_(NUMPAD_DELETE)
180  WXK_(NUMPAD_EQUAL)
181  WXK_(NUMPAD_MULTIPLY)
182  WXK_(NUMPAD_ADD)
183  WXK_(NUMPAD_SEPARATOR)
184  WXK_(NUMPAD_SUBTRACT)
185  WXK_(NUMPAD_DECIMAL)
186  WXK_(NUMPAD_DIVIDE)
187 
188  WXK_(WINDOWS_LEFT)
189  WXK_(WINDOWS_RIGHT)
190 #ifdef __WXOSX__
191  WXK_(RAW_CONTROL)
192 #endif
193 #undef WXK_
194 
195  default:
196  return NULL;
197  }
198 }
#define WXK_(x)
#define DIVIDE
Definition: am_param.h:150