Some more reformatting and adding copyright notices.

This commit is contained in:
Maciej Suminski 2013-08-07 11:20:12 +02:00
parent 62ea71fcae
commit ee80c7f674
9 changed files with 444 additions and 342 deletions

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <wx/wx.h>
#include <wx/menu.h>
@ -41,12 +65,14 @@ CONTEXT_MENU::CONTEXT_MENU ( )
m_titleSet = false;
}
CONTEXT_MENU::~CONTEXT_MENU()
{
delete m_menu;
delete m_handler;
}
void CONTEXT_MENU::SetTitle( const wxString& aTitle )
{
if( m_titleSet )
@ -60,11 +86,13 @@ void CONTEXT_MENU::SetTitle( const wxString& aTitle )
m_titleSet = true;
}
void CONTEXT_MENU::Add ( const wxString& aItem, int aId )
{
m_menu->Append( new wxMenuItem( m_menu, aId, aItem, wxEmptyString, wxITEM_NORMAL ) );
}
void CONTEXT_MENU::Clear()
{
m_titleSet = false;

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <tool/tool_event.h>
#include <tool/tool_manager.h>
@ -6,16 +30,19 @@ KiGfx::VIEW *TOOL_BASE::getView()
return m_toolMgr->GetView();
}
KiGfx::VIEW_CONTROLS* TOOL_BASE::getViewControls()
{
return m_toolMgr->GetViewControls();
}
wxWindow* TOOL_BASE::getEditFrameInt()
{
return m_toolMgr->GetEditFrame();
}
EDA_ITEM* TOOL_BASE::getModelInt()
{
return m_toolMgr->GetModel();

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <cstring>
#include <string>
@ -10,11 +34,13 @@
using namespace std;
struct FlagString {
struct FlagString
{
int flag;
std::string str;
};
static const std::string flag2string( int flag, const FlagString* exps )
{
std::string rv;
@ -24,6 +50,7 @@ static const std::string flag2string(int flag, const FlagString *exps)
return rv;
}
const std::string TOOL_EVENT::Format() const
{
std::string ev;
@ -90,6 +117,7 @@ const std::string TOOL_EVENT::Format() const
return ev;
}
const std::string TOOL_EVENT_LIST::Format() const
{
string s;

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <string>
#include <tool/tool_event.h>
@ -9,6 +33,7 @@ TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ):
TOOL_BASE( TOOL_Interactive, aId, aName )
{};
TOOL_INTERACTIVE::TOOL_INTERACTIVE( const std::string& aName ) :
TOOL_BASE( TOOL_Interactive, TOOL_MANAGER::MakeToolId( aName ), aName )
{};
@ -16,24 +41,26 @@ TOOL_INTERACTIVE::TOOL_INTERACTIVE( const std::string& aName ):
TOOL_INTERACTIVE::~TOOL_INTERACTIVE()
{
}
OPT_TOOL_EVENT TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST & aEventList )
{
return m_toolMgr->ScheduleWait( this, aEventList );
}
void TOOL_INTERACTIVE::goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIST& aConditions )
{
m_toolMgr->ScheduleNextState( this, aState, aConditions );
}
void TOOL_INTERACTIVE::Reset()
{
}
void TOOL_INTERACTIVE::SetContextMenu( CONTEXT_MENU *aMenu, TOOL_ContextMenuTrigger aTrigger )
{
aMenu->setTool( this );

View File

@ -58,7 +58,6 @@ public:
}
private:
class CMEventHandler;
friend class TOOL_INTERACTIVE;

View File

@ -26,9 +26,7 @@
#define __TOOL_BASE_H
#include <cassert>
// for KICAD_T.
#include <base_struct.h>
#include <base_struct.h> // for KICAD_T
#include <tool/tool_event.h>
#include <tool/delegate.h>
@ -36,13 +34,14 @@
class EDA_ITEM;
class TOOL_MANAGER;
namespace KiGfx {
namespace KiGfx
{
class VIEW;
class VIEW_CONTROLS;
};
enum TOOL_Type {
enum TOOL_Type
{
TOOL_Interactive = 0x1,
TOOL_Batch = 0x2
};
@ -88,7 +87,6 @@ public:
}
protected:
friend class TOOL_MANAGER;
/**
@ -128,20 +126,16 @@ protected:
}
protected:
TOOL_Type m_type;
TOOL_ID m_toolId;
std::string m_toolName;
TOOL_MANAGER* m_toolMgr;
private:
// hide the implementation to avoid spreading half of
// kicad and wxWidgets headers to the tools that may not need them at all!
EDA_ITEM* getModelInt();
wxWindow* getEditFrameInt();
};
#endif

View File

@ -38,7 +38,8 @@ class TOOL_MANAGER;
* Internal (GUI-independent) event definitions.
* Enums are mostly self-explanatory.
*/
enum TOOL_EventCategory {
enum TOOL_EventCategory
{
TC_None = 0x0,
TC_Mouse = 0x1,
TC_Command = 0x2,
@ -47,7 +48,8 @@ enum TOOL_EventCategory {
TC_Any = 0xffffffff
};
enum TOOL_Actions {
enum TOOL_Actions
{
TA_None = 0x0,
TA_MouseClick = 0x1,
TA_MouseUp = 0x2,
@ -77,7 +79,8 @@ enum TOOL_Actions {
TA_Any = 0xffffffff
};
enum TOOL_MouseButtons {
enum TOOL_MouseButtons
{
MB_None = 0x0,
MB_Left = 0x1,
MB_Right = 0x2,
@ -92,7 +95,8 @@ enum TOOL_MouseButtons {
// Defines when a context menu is opened.
enum TOOL_ContextMenuTrigger {
enum TOOL_ContextMenuTrigger
{
CMENU_BUTTON = 0, // On the right button
CMENU_NOW, // Right now (after TOOL_INTERACTIVE::SetContxtMenu)
CMENU_OFF // Never
@ -106,13 +110,12 @@ enum TOOL_ContextMenuTrigger {
class TOOL_EVENT
{
public:
const std::string Format() const;
TOOL_EVENT( TOOL_EventCategory aCategory = TC_None, TOOL_Actions aAction = TA_None ):
m_category( aCategory ),
m_actions( aAction ),
m_mouseButtons(0) {};
m_mouseButtons( 0 ) {}
TOOL_EVENT( TOOL_EventCategory aCategory, TOOL_Actions aAction, int aExtraParam ):
m_category( aCategory ),
@ -122,7 +125,7 @@ class TOOL_EVENT
m_mouseButtons = aExtraParam;
else if ( aCategory == TC_Command )
m_commandId = aExtraParam;
};
}
TOOL_EVENT( TOOL_EventCategory aCategory, TOOL_Actions aAction, const std::string& aExtraParam ):
m_category( aCategory ),
@ -166,7 +169,8 @@ class TOOL_EVENT
bool IsClick( int aButtonMask = MB_Any ) const
{
return (m_actions == TA_MouseClick) && ((m_mouseButtons & aButtonMask) == aButtonMask);
return ( m_actions == TA_MouseClick )
&& ( ( m_mouseButtons & aButtonMask ) == aButtonMask );
}
bool IsDrag( int aButtonMask = MB_Any ) const
@ -194,7 +198,6 @@ class TOOL_EVENT
return ( m_mouseButtons & aMask );
}
void Ignore();
void SetMouseDragOrigin( const VECTOR2D &aP )
@ -236,9 +239,7 @@ class TOOL_EVENT
return m_commandId;
}
private:
friend class TOOL_MANAGER;
TOOL_EventCategory m_category;
@ -251,9 +252,6 @@ class TOOL_EVENT
int m_mouseButtons;
boost::optional<int> m_commandId;
boost::optional<std::string> m_commandStr;
};
typedef boost::optional<TOOL_EVENT> OPT_TOOL_EVENT;
@ -265,7 +263,6 @@ typedef boost::optional<TOOL_EVENT> OPT_TOOL_EVENT;
* concatenating TOOL_EVENTs with little code.
*/
class TOOL_EVENT_LIST {
public:
typedef TOOL_EVENT value_type;
typedef std::deque<TOOL_EVENT>::iterator iterator;
@ -325,8 +322,13 @@ class TOOL_EVENT_LIST {
TOOL_EVENT_LIST& operator=( const TOOL_EVENT_LIST& b )
{
m_events.clear();
for(std::deque<TOOL_EVENT>::const_iterator i = b.m_events.begin(); i != b.m_events.end(); ++i)
for( std::deque<TOOL_EVENT>::const_iterator i = b.m_events.begin();
i != b.m_events.end(); ++i )
{
m_events.push_back(*i);
}
return *this;
}
@ -345,7 +347,6 @@ class TOOL_EVENT_LIST {
TOOL_EVENT_LIST& operator||( const TOOL_EVENT_LIST& b )
{
return *this;
}

View File

@ -32,9 +32,9 @@
class CONTEXT_MENU;
class TOOL_INTERACTIVE : public TOOL_BASE {
class TOOL_INTERACTIVE : public TOOL_BASE
{
public:
TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName );
/**
@ -87,7 +87,6 @@ public:
void Yield ( const T& returnValue );
protected:
/* helper functions for constructing events for Wait() and Go() with
less typing */
const TOOL_EVENT evActivate( std::string aToolName = "" );
@ -100,7 +99,6 @@ protected:
const TOOL_EVENT evButtonDown(int aButton = MB_Any );
private:
void goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIST& aConditions );
};