Fix typing problems with GR_KB_* constants

This commit is contained in:
Chris Pavlina 2016-01-20 07:11:17 -05:00
parent cf9a9a09ad
commit c490e7dd06
26 changed files with 70 additions and 50 deletions

View File

@ -594,7 +594,7 @@ void EDA_DRAW_FRAME::SetPresetGrid( int aIndex )
} }
int EDA_DRAW_FRAME::BlockCommand( int key ) int EDA_DRAW_FRAME::BlockCommand( EDA_KEY key )
{ {
return 0; return 0;
} }
@ -767,7 +767,7 @@ wxString EDA_DRAW_FRAME::LengthDoubleToString( double aValue, bool aConvertToMil
} }
bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, int aKey, const wxPoint& aPosition ) bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition )
{ {
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;

View File

@ -315,7 +315,8 @@ void DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
} }
bool DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) bool DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
EDA_KEY aHotKey )
{ {
bool eventHandled = true; bool eventHandled = true;

View File

@ -92,7 +92,7 @@ public:
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
bool GeneralControl( wxDC* DC, const wxPoint& aPosition, int aHotKey = 0 ); bool GeneralControl( wxDC* DC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 );
void InstallOptionsDisplay( wxCommandEvent& event ); void InstallOptionsDisplay( wxCommandEvent& event );
MODULE* Get_Module( const wxString& CmpName ); MODULE* Get_Module( const wxString& CmpName );

View File

@ -62,7 +62,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase ); const wxPoint& aPosition, bool aErase );
int SCH_EDIT_FRAME::BlockCommand( int key ) int SCH_EDIT_FRAME::BlockCommand( EDA_KEY key )
{ {
int cmd = BLOCK_IDLE; int cmd = BLOCK_IDLE;

View File

@ -41,7 +41,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
bool aErase ); bool aErase );
int LIB_EDIT_FRAME::BlockCommand( int key ) int LIB_EDIT_FRAME::BlockCommand( EDA_KEY key )
{ {
int cmd = BLOCK_IDLE; int cmd = BLOCK_IDLE;
@ -51,11 +51,18 @@ int LIB_EDIT_FRAME::BlockCommand( int key )
cmd = key & 0xFF; cmd = key & 0xFF;
break; break;
case -1: case EDA_KEY_C( 0xffffffff ): // -1
// Historically, -1 has been used as a key, which can cause bit flag
// clashes with unaware code. On debug builds, catch any old code that
// might still be doing this. TODO: remove if sure all this old code is gone.
wxFAIL_MSG( "negative EDA_KEY value should be converted to GR_KEY_INVALID" );
// fall through on release builds
case GR_KEY_INVALID:
cmd = BLOCK_PRESELECT_MOVE; cmd = BLOCK_PRESELECT_MOVE;
break; break;
case 0: case GR_KEY_NONE:
cmd = BLOCK_MOVE; cmd = BLOCK_MOVE;
break; break;

View File

@ -202,7 +202,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aF
} }
bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{ {
bool eventHandled = true; bool eventHandled = true;
@ -249,7 +249,7 @@ bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
} }
bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{ {
bool eventHandled = true; bool eventHandled = true;
@ -291,7 +291,7 @@ bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
} }
bool LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) bool LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{ {
bool eventHandled = true; bool eventHandled = true;

View File

@ -332,7 +332,7 @@ public:
bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ); bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 );
void LoadSettings( wxConfigBase* aCfg ); void LoadSettings( wxConfigBase* aCfg );
@ -606,7 +606,7 @@ public:
* returns the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to * returns the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
* the \a aKey (ALT, SHIFT ALT ..) * the \a aKey (ALT, SHIFT ALT ..)
*/ */
virtual int BlockCommand( int aKey ); virtual int BlockCommand( EDA_KEY aKey );
/** /**
* Function HandleBlockPlace * Function HandleBlockPlace

View File

@ -269,7 +269,7 @@ public:
void Process_Config( wxCommandEvent& event ); void Process_Config( wxCommandEvent& event );
void OnSelectTool( wxCommandEvent& aEvent ); void OnSelectTool( wxCommandEvent& aEvent );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 );
/** /**
* Function GetProjectFileParametersList * Function GetProjectFileParametersList
@ -1228,7 +1228,7 @@ public:
* @param aKey = the key modifiers (Alt, Shift ...) * @param aKey = the key modifiers (Alt, Shift ...)
* @return the block command id (BLOCK_MOVE, BLOCK_COPY...) * @return the block command id (BLOCK_MOVE, BLOCK_COPY...)
*/ */
virtual int BlockCommand( int aKey ); virtual int BlockCommand( EDA_KEY aKey );
/** /**
* Function HandleBlockPlace * Function HandleBlockPlace

View File

@ -87,7 +87,7 @@ public:
void ClickOnCmpList( wxCommandEvent& event ); void ClickOnCmpList( wxCommandEvent& event );
void OnSetRelativeOffset( wxCommandEvent& event ); void OnSetRelativeOffset( wxCommandEvent& event );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 );
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const; EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const;

View File

@ -47,7 +47,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
bool erase ); bool erase );
int GERBVIEW_FRAME::BlockCommand( int key ) int GERBVIEW_FRAME::BlockCommand( EDA_KEY key )
{ {
int cmd = 0; int cmd = 0;

View File

@ -33,7 +33,7 @@
#include <gerbview_frame.h> #include <gerbview_frame.h>
bool GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) bool GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{ {
bool eventHandled = true; bool eventHandled = true;

View File

@ -546,7 +546,7 @@ public:
* returns the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to * returns the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
* the \a aKey (ALT, SHIFT ALT ..) * the \a aKey (ALT, SHIFT ALT ..)
*/ */
virtual int BlockCommand( int key ); virtual int BlockCommand( EDA_KEY key );
/** /**
* Function HandleBlockPlace * Function HandleBlockPlace
@ -631,7 +631,7 @@ public:
bool LoadExcellonFiles( const wxString& aFileName ); bool LoadExcellonFiles( const wxString& aFileName );
bool Read_EXCELLON_File( const wxString& aFullFileName ); bool Read_EXCELLON_File( const wxString& aFullFileName );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 );
/** /**
* Set Size Items (Lines, Flashes) from DCodes List * Set Size Items (Lines, Flashes) from DCodes List

View File

@ -4,7 +4,7 @@
* Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2007-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2007-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -33,6 +33,7 @@
#define INCLUDE__COMMON_H_ #define INCLUDE__COMMON_H_
#include <vector> #include <vector>
#include <boost/cstdint.hpp>
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/confbase.h> #include <wx/confbase.h>
@ -49,17 +50,21 @@ class REPORTER;
// Flag for special keys // Flag for special keys
#define GR_KB_RIGHTSHIFT 0x10000000 /* Keybd states: right // This type could be extended to 64 bits to add room for more flags.
* shift key depressed */ // For compatibility with old code, keep flag bits out of the least
#define GR_KB_LEFTSHIFT 0x20000000 /* left shift key depressed // significant nibble (0xF).
*/ typedef uint32_t EDA_KEY;
#define GR_KB_CTRL 0x40000000 // CTRL depressed #define EDA_KEY_C UINT32_C
#define GR_KB_ALT 0x80000000 // ALT depressed
#define GR_KB_SHIFT (GR_KB_LEFTSHIFT | GR_KB_RIGHTSHIFT) static const EDA_KEY GR_KB_RIGHTSHIFT = EDA_KEY_C( 0x01000000 );
#define GR_KB_SHIFTCTRL (GR_KB_SHIFT | GR_KB_CTRL) static const EDA_KEY GR_KB_LEFTSHIFT = EDA_KEY_C( 0x02000000 );
#define MOUSE_MIDDLE 0x08000000 /* Middle button mouse static const EDA_KEY GR_KB_CTRL = EDA_KEY_C( 0x04000000 );
* flag for block commands static const EDA_KEY GR_KB_ALT = EDA_KEY_C( 0x08000000 );
*/ static const EDA_KEY GR_KB_SHIFT = GR_KB_LEFTSHIFT | GR_KB_RIGHTSHIFT;
static const EDA_KEY GR_KB_SHIFTCTRL = GR_KB_SHIFT | GR_KB_CTRL;
static const EDA_KEY MOUSE_MIDDLE = EDA_KEY_C( 0x10000000 );
static const EDA_KEY GR_KEY_INVALID = EDA_KEY_C( 0x80000000 );
static const EDA_KEY GR_KEY_NONE = EDA_KEY_C( 0 );
/// default name for nameless projects /// default name for nameless projects
#define NAMELESS_PROJECT wxT( "noname" ) #define NAMELESS_PROJECT wxT( "noname" )

View File

@ -516,7 +516,7 @@ public:
* @param aPosition The current cursor position in logical (drawing) units. * @param aPosition The current cursor position in logical (drawing) units.
* @param aHotKey A key event used for application specific control if not zero. * @param aHotKey A key event used for application specific control if not zero.
*/ */
virtual bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ) virtual bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 )
{ {
return false; return false;
} }
@ -642,7 +642,7 @@ public:
* initializes the block command including the command type, initial position, * initializes the block command including the command type, initial position,
* and other variables. * and other variables.
*/ */
virtual bool HandleBlockBegin( wxDC* aDC, int aKey, const wxPoint& aPosition ); virtual bool HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition );
/** /**
* Function BlockCommand * Function BlockCommand
@ -653,7 +653,7 @@ public:
* @param aKey = the key modifiers (Alt, Shift ...) * @param aKey = the key modifiers (Alt, Shift ...)
* @return the block command id (BLOCK_MOVE, BLOCK_COPY...) * @return the block command id (BLOCK_MOVE, BLOCK_COPY...)
*/ */
virtual int BlockCommand( int aKey ); virtual int BlockCommand( EDA_KEY aKey );
/** /**
* Function HandleBlockPlace( ) * Function HandleBlockPlace( )

View File

@ -620,7 +620,7 @@ public:
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas() ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas()
void UseGalCanvas( bool aEnable ); void UseGalCanvas( bool aEnable );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 );
/** /**
* Function ShowDesignRulesEditor * Function ShowDesignRulesEditor
@ -716,7 +716,7 @@ public:
* @param aKey = the key modifiers (Alt, Shift ...) * @param aKey = the key modifiers (Alt, Shift ...)
* @return the block command id (BLOCK_MOVE, BLOCK_COPY...) * @return the block command id (BLOCK_MOVE, BLOCK_COPY...)
*/ */
virtual int BlockCommand( int aKey ); virtual int BlockCommand( EDA_KEY aKey );
/** /**
* Function HandleBlockPlace() * Function HandleBlockPlace()

View File

@ -32,7 +32,7 @@
#include <pl_editor_frame.h> #include <pl_editor_frame.h>
bool PL_EDITOR_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) bool PL_EDITOR_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{ {
bool eventHandled = true; bool eventHandled = true;

View File

@ -267,7 +267,7 @@ public:
void ToPrinter( wxCommandEvent& event ); void ToPrinter( wxCommandEvent& event );
void Files_io( wxCommandEvent& event ); void Files_io( wxCommandEvent& event );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 );
/** Virtual function PrintPage /** Virtual function PrintPage
* used to print a page * used to print a page

View File

@ -178,7 +178,7 @@ void DIALOG_BLOCK_OPTIONS::ExecuteCommand( wxCommandEvent& event )
} }
int PCB_EDIT_FRAME::BlockCommand( int aKey ) int PCB_EDIT_FRAME::BlockCommand( EDA_KEY aKey )
{ {
int cmd = 0; int cmd = 0;

View File

@ -78,7 +78,7 @@ static void MoveMarkedItems( MODULE* module, wxPoint offset );
static void DeleteMarkedItems( MODULE* module ); static void DeleteMarkedItems( MODULE* module );
int FOOTPRINT_EDIT_FRAME::BlockCommand( int key ) int FOOTPRINT_EDIT_FRAME::BlockCommand( EDA_KEY key )
{ {
int cmd; int cmd;
@ -88,7 +88,14 @@ int FOOTPRINT_EDIT_FRAME::BlockCommand( int key )
cmd = key & 0xFF; cmd = key & 0xFF;
break; break;
case - 1: case EDA_KEY_C( 0xffffffff ): // -1
// Historically, -1 has been used as a key, which can cause bit flag
// clashes with unaware code. On debug builds, catch any old code that
// might still be doing this. TODO: remove if sure all this old code is gone.
wxFAIL_MSG( "negative EDA_KEY value should be converted to GR_KEY_INVALID" );
// fall through on release builds
case GR_KEY_INVALID:
cmd = BLOCK_PRESELECT_MOVE; cmd = BLOCK_PRESELECT_MOVE;
break; break;

View File

@ -282,7 +282,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
} }
bool PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) bool PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{ {
bool eventHandled = true; bool eventHandled = true;

View File

@ -452,7 +452,7 @@ void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event )
} }
bool FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) bool FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{ {
bool eventHandled = true; bool eventHandled = true;

View File

@ -151,7 +151,7 @@ private:
void ClickOnPageList( wxCommandEvent& event ); void ClickOnPageList( wxCommandEvent& event );
void OnSetRelativeOffset( wxCommandEvent& event ); void OnSetRelativeOffset( wxCommandEvent& event );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 );
void LoadSettings( wxConfigBase* aCfg ); // override virtual void LoadSettings( wxConfigBase* aCfg ); // override virtual
void SaveSettings( wxConfigBase* aCfg ); // override virtual void SaveSettings( wxConfigBase* aCfg ); // override virtual

View File

@ -167,7 +167,7 @@ public:
*/ */
void Show3D_Frame( wxCommandEvent& event ); void Show3D_Frame( wxCommandEvent& event );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 );
void OnVerticalToolbar( wxCommandEvent& aEvent ); void OnVerticalToolbar( wxCommandEvent& aEvent );
void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent ); void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent );
@ -242,7 +242,7 @@ public:
bool Clear_Pcb( bool aQuery ); bool Clear_Pcb( bool aQuery );
/* handlers for block commands */ /* handlers for block commands */
virtual int BlockCommand( int key ); virtual int BlockCommand( EDA_KEY key );
/** /**
* Function HandleBlockPlace * Function HandleBlockPlace

View File

@ -696,7 +696,7 @@ void FOOTPRINT_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
} }
bool FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) bool FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{ {
bool eventHandled = true; bool eventHandled = true;

View File

@ -591,7 +591,7 @@ void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
} }
bool FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) bool FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{ {
bool eventHandled = true; bool eventHandled = true;

View File

@ -104,7 +104,7 @@ private:
void DClickOnFootprintList( wxCommandEvent& event ); void DClickOnFootprintList( wxCommandEvent& event );
void OnSetRelativeOffset( wxCommandEvent& event ); void OnSetRelativeOffset( wxCommandEvent& event );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 );
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const; EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const;