2009-05-08 13:28:41 +00:00
/*
* OpenClonk , http : //www.openclonk.org
*
2013-12-17 20:01:09 +00:00
* Copyright ( c ) 1998 - 2000 , Matthes Bender
* Copyright ( c ) 2001 - 2009 , RedWolf Design GmbH , http : //www.clonk.de/
2016-04-03 18:18:29 +00:00
* Copyright ( c ) 2009 - 2016 , The OpenClonk Team and contributors
2009-05-08 13:28:41 +00:00
*
2013-12-17 20:01:09 +00:00
* Distributed under the terms of the ISC license ; see accompanying file
* " COPYING " for details .
2009-05-08 13:28:41 +00:00
*
2013-12-17 20:01:09 +00:00
* " Clonk " is a registered trademark of Matthes Bender , used with permission .
* See accompanying file " TRADEMARK " for details .
2009-05-08 13:28:41 +00:00
*
2013-12-17 20:01:09 +00:00
* To redistribute this file separately , substitute the full license texts
* for the above references .
2009-05-08 13:28:41 +00:00
*/
/* Handles viewport editing in console mode */
# ifndef INC_C4EditCursor
# define INC_C4EditCursor
2016-04-03 18:07:56 +00:00
# include "object/C4ObjectList.h"
# include "control/C4Control.h"
# include "lib/C4Rect.h"
2012-01-27 22:01:37 +00:00
# include <vector>
2009-05-08 13:28:41 +00:00
2016-01-22 19:05:43 +00:00
# ifdef USE_GTK
2010-09-22 15:11:19 +00:00
# include <gtk/gtk.h>
2009-05-08 13:28:41 +00:00
# endif
class C4EditCursor
2010-03-28 17:58:21 +00:00
{
public :
C4EditCursor ( ) ;
~ C4EditCursor ( ) ;
protected :
bool fAltWasDown ;
2012-04-22 20:09:06 +00:00
bool fShiftWasDown ;
2010-03-28 17:58:21 +00:00
int32_t Mode ;
2010-10-06 23:11:52 +00:00
float X , Y , X2 , Y2 ;
2010-03-28 17:58:21 +00:00
bool Hold , DragFrame , DragLine ;
C4Object * Target , * DropTarget ;
2012-03-15 12:58:56 +00:00
struct ObjselItemDt {
2012-03-20 15:38:45 +00:00
C4EditCursor * EditCursor ;
2012-03-15 12:58:56 +00:00
C4Object * Object ;
2015-01-03 22:21:36 +00:00
StdCopyStrBuf Command ;
2012-03-23 21:53:56 +00:00
# if defined(USE_WIN32_WINDOWS)
2012-03-20 16:30:41 +00:00
UINT_PTR ItemId ;
2016-01-22 19:05:43 +00:00
# elif defined(USE_GTK)
2012-03-20 16:30:41 +00:00
GtkWidget * MenuItem ;
# endif
2012-03-15 12:58:56 +00:00
} ;
std : : vector < ObjselItemDt > itemsObjselect ;
2012-03-23 21:53:56 +00:00
# ifdef USE_WIN32_WINDOWS
2012-03-20 15:38:45 +00:00
HMENU hMenu ;
2016-01-22 19:05:43 +00:00
# elif defined(USE_GTK)
2010-03-28 17:58:21 +00:00
GtkWidget * menuContext ;
GtkWidget * itemDelete ;
GtkWidget * itemDuplicate ;
GtkWidget * itemGrabContents ;
GtkWidget * itemProperties ;
2009-05-08 13:28:41 +00:00
# endif
2010-03-28 17:58:21 +00:00
C4ObjectList Selection ;
public :
void Default ( ) ;
void Clear ( ) ;
void Execute ( ) ;
void ClearPointers ( C4Object * pObj ) ;
bool ToggleMode ( ) ;
2010-09-24 17:51:34 +00:00
void Draw ( C4TargetFacet & cgo ) ;
2010-03-28 17:58:21 +00:00
int32_t GetMode ( ) ;
C4Object * GetTarget ( ) ;
bool SetMode ( int32_t iMode ) ;
bool In ( const char * szText ) ;
bool Duplicate ( ) ;
bool OpenPropTools ( ) ;
bool Delete ( ) ;
2010-12-13 22:29:14 +00:00
void GrabContents ( ) ;
2012-04-22 20:09:06 +00:00
bool LeftButtonUp ( DWORD dwKeyState ) ;
bool LeftButtonDown ( DWORD dwKeyState ) ;
bool RightButtonUp ( DWORD dwKeyState ) ;
bool RightButtonDown ( DWORD dwKeyState ) ;
bool KeyDown ( C4KeyCode KeyCode , DWORD dwKeyState ) ;
bool KeyUp ( C4KeyCode KeyCode , DWORD dwKeyState ) ;
bool Move ( float iX , float iY , DWORD dwKeyState ) ;
2010-03-28 17:58:21 +00:00
bool Init ( ) ;
bool EditingOK ( ) ;
C4ObjectList & GetSelection ( ) { return Selection ; }
void SetHold ( bool fToState ) { Hold = fToState ; }
void OnSelectionChanged ( ) ;
bool AltDown ( ) ;
bool AltUp ( ) ;
protected :
2010-12-14 01:06:23 +00:00
void UpdateStatusBar ( ) ;
2010-03-28 17:58:21 +00:00
void ApplyToolPicker ( ) ;
void ToolFailure ( ) ;
void PutContents ( ) ;
2012-04-22 20:09:06 +00:00
void UpdateDropTarget ( DWORD dwKeyState ) ;
2016-01-10 22:27:23 +00:00
void AppendMenuItem ( int num , const StdStrBuf & label ) ;
2012-04-22 20:09:06 +00:00
bool DoContextMenu ( DWORD dwKeyState ) ;
2010-03-28 17:58:21 +00:00
void ApplyToolFill ( ) ;
void ApplyToolRect ( ) ;
void ApplyToolLine ( ) ;
void ApplyToolBrush ( ) ;
void DrawSelectMark ( C4Facet & cgo , FLOAT_RECT r ) ;
void FrameSelection ( ) ;
2010-10-10 16:46:23 +00:00
void MoveSelection ( C4Real iXOff , C4Real iYOff ) ;
void EMMoveObject ( enum C4ControlEMObjectAction eAction , C4Real tx , C4Real ty , C4Object * pTargetObj , const C4ObjectList * pObjs = NULL , const char * szScript = NULL ) ;
2010-03-28 17:58:21 +00:00
void EMControl ( enum C4PacketType eCtrlType , class C4ControlPacket * pCtrl ) ;
2012-04-22 20:09:06 +00:00
void DoContextObjsel ( C4Object * , bool clear ) ;
2015-01-03 22:21:36 +00:00
void DoContextObjCommand ( C4Object * , const char * cmd ) ;
2012-03-15 12:58:56 +00:00
void ObjselectDelItems ( ) ;
2009-05-08 13:28:41 +00:00
2013-01-15 22:09:43 +00:00
void AddToSelection ( C4Object * add_obj ) ; // add object to selection and do script callback. Doesn't do OnSelectionChanged().
bool RemoveFromSelection ( C4Object * remove_obj ) ; // remove object from selection and do script callback. return true if object was in selection before. Doesn't do OnSelectionChanged().
2015-01-17 19:37:54 +00:00
void ClearSelection ( C4Object * next_selection = NULL ) ; // remove all objects from selection and do script callback. if next_selection is non-null, passes that to the deselection callbacks. Doesn't do OnSelectionChanged().
2013-01-15 22:09:43 +00:00
2016-01-22 19:05:43 +00:00
# ifdef USE_GTK
2010-03-28 17:58:21 +00:00
static void OnDelete ( GtkWidget * widget , gpointer data ) ;
static void OnDuplicate ( GtkWidget * widget , gpointer data ) ;
static void OnGrabContents ( GtkWidget * widget , gpointer data ) ;
2012-01-27 22:01:37 +00:00
static void OnObjselect ( GtkWidget * widget , gpointer data ) ;
2009-05-08 13:28:41 +00:00
# endif
2010-03-28 17:58:21 +00:00
} ;
2009-05-08 13:28:41 +00:00
# endif