2009-01-19 19:08:42 +00:00
|
|
|
/**
|
2009-11-23 20:18:47 +00:00
|
|
|
* This file is part of the common library.
|
2009-01-19 19:08:42 +00:00
|
|
|
* @file block_commande.h
|
|
|
|
* @see common.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE__BLOCK_COMMANDE_H__
|
|
|
|
#define __INCLUDE__BLOCK_COMMANDE_H__ 1
|
|
|
|
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
#include "base_struct.h"
|
|
|
|
#include "class_undoredo_container.h"
|
2009-01-19 19:08:42 +00:00
|
|
|
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
// Forward declarations:
|
|
|
|
|
|
|
|
|
|
|
|
/**************************/
|
|
|
|
/* class BLOCK_SELECTOR */
|
|
|
|
/**************************/
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
/**
|
|
|
|
* class BLOCK_SELECTOR is used to handle block selection and commands
|
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
|
|
|
|
/* Block state codes. */
|
2009-07-25 04:53:39 +00:00
|
|
|
typedef enum {
|
2009-11-23 20:18:47 +00:00
|
|
|
STATE_NO_BLOCK,
|
|
|
|
STATE_BLOCK_INIT,
|
|
|
|
STATE_BLOCK_END,
|
|
|
|
STATE_BLOCK_MOVE,
|
|
|
|
STATE_BLOCK_STOP
|
2009-07-25 04:53:39 +00:00
|
|
|
} BlockState;
|
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
|
|
|
|
/* Block command codes. */
|
2009-07-25 04:53:39 +00:00
|
|
|
typedef enum {
|
|
|
|
BLOCK_IDLE,
|
|
|
|
BLOCK_MOVE,
|
|
|
|
BLOCK_COPY,
|
|
|
|
BLOCK_SAVE,
|
|
|
|
BLOCK_DELETE,
|
|
|
|
BLOCK_PASTE,
|
|
|
|
BLOCK_DRAG,
|
|
|
|
BLOCK_ROTATE,
|
2009-08-12 10:40:01 +00:00
|
|
|
BLOCK_FLIP,
|
2009-07-25 04:53:39 +00:00
|
|
|
BLOCK_ZOOM,
|
|
|
|
BLOCK_ABORT,
|
|
|
|
BLOCK_PRESELECT_MOVE,
|
|
|
|
BLOCK_SELECT_ITEMS_ONLY,
|
|
|
|
BLOCK_MIRROR_X,
|
|
|
|
BLOCK_MIRROR_Y
|
|
|
|
} CmdBlockType;
|
|
|
|
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
class BLOCK_SELECTOR : public EDA_ITEM, public EDA_RECT
|
2009-07-25 04:53:39 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-11-23 20:18:47 +00:00
|
|
|
BlockState m_State; /* State (enum BlockState)
|
|
|
|
* of the block */
|
|
|
|
CmdBlockType m_Command; /* Type (enum CmdBlockType)
|
|
|
|
* operation */
|
|
|
|
PICKED_ITEMS_LIST m_ItemsSelection; /* list of items selected
|
|
|
|
* in this block */
|
|
|
|
int m_Color; /* Block Color (for
|
|
|
|
* drawings) */
|
|
|
|
wxPoint m_MoveVector; /* Move distance in move,
|
|
|
|
* drag, copy ... command */
|
|
|
|
wxPoint m_BlockLastCursorPosition; /* Last Mouse position in
|
|
|
|
* block command
|
|
|
|
* = last cursor position in
|
|
|
|
* move commands
|
|
|
|
* = 0,0 in block paste */
|
2009-07-25 04:53:39 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
BLOCK_SELECTOR();
|
|
|
|
~BLOCK_SELECTOR();
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function InitData
|
2010-11-12 17:33:20 +00:00
|
|
|
* sets the initial values of a BLOCK_SELECTOR, before starting a block
|
|
|
|
* command
|
2009-07-25 04:53:39 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void InitData( EDA_DRAW_PANEL* Panel, const wxPoint& startpos );
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function SetMessageBlock
|
2009-07-25 04:53:39 +00:00
|
|
|
* Displays the type of block command in the status bar of the window
|
2009-11-23 20:18:47 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void SetMessageBlock( EDA_DRAW_FRAME* frame );
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void Draw( EDA_DRAW_PANEL* aPanel,
|
2009-11-23 20:18:47 +00:00
|
|
|
wxDC* aDC, const wxPoint& aOffset,
|
|
|
|
int aDrawMode,
|
|
|
|
int aColor );
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function PushItem
|
2010-11-12 17:33:20 +00:00
|
|
|
* adds aItem to the list of items
|
2009-07-25 04:53:39 +00:00
|
|
|
* @param aItem = an ITEM_PICKER to add to the list
|
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
void PushItem( ITEM_PICKER& aItem );
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function ClearListAndDeleteItems
|
2010-12-08 20:12:46 +00:00
|
|
|
* deletes only the list of EDA_ITEM * pointers, AND the data printed
|
2009-11-23 20:18:47 +00:00
|
|
|
* by m_Item
|
2009-07-25 04:53:39 +00:00
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
void ClearListAndDeleteItems();
|
|
|
|
|
|
|
|
void ClearItemsList();
|
2009-07-25 04:53:39 +00:00
|
|
|
|
|
|
|
unsigned GetCount()
|
|
|
|
{
|
|
|
|
return m_ItemsSelection.GetCount();
|
|
|
|
}
|
2010-11-11 21:46:55 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function SetLastCursorPosition
|
2010-11-11 21:46:55 +00:00
|
|
|
* sets m_BlockLastCursorPosition
|
|
|
|
* @param aPosition = new position
|
|
|
|
**/
|
|
|
|
void SetLastCursorPosition( wxPoint aPosition )
|
|
|
|
{
|
|
|
|
m_BlockLastCursorPosition = aPosition;
|
|
|
|
}
|
2011-01-07 19:24:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IsDragging
|
|
|
|
* returns true if the current block command is a drag operation.
|
|
|
|
*/
|
|
|
|
bool IsDragging() const { return m_Command == BLOCK_DRAG; }
|
2011-02-05 19:22:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IsIdle
|
|
|
|
* returns true if there is currently no block operation in progress.
|
|
|
|
*/
|
|
|
|
inline bool IsIdle() const { return m_Command == BLOCK_IDLE; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Clear
|
|
|
|
* clears the block selector by setting the command to idle, the state to no block,
|
|
|
|
* and clears the selected item list.
|
|
|
|
*/
|
|
|
|
void Clear();
|
2009-07-25 04:53:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Cancel Current block operation.
|
2009-11-23 20:18:47 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void AbortBlockCurrentCommand( EDA_DRAW_PANEL* Panel, wxDC* DC );
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
/* Redraw the outlines of the block which shows the search area for block
|
|
|
|
* commands
|
|
|
|
* The first point of the rectangle showing the area is initialized
|
2009-01-19 19:08:42 +00:00
|
|
|
* by InitBlockLocateDatas().
|
2009-07-25 04:53:39 +00:00
|
|
|
* The other point of the rectangle is the mouse cursor
|
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase );
|
2009-01-19 19:08:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* __INCLUDE__BLOCK_COMMANDE_H__ */
|