Ejemplo n.º 1
0
//删除所有
BOOL CListCtrlEx::DeleteAllItems()
{
	map<long,sItemStyle>::iterator it=m_ItemStyleMap.begin();
	for(it; it != m_ItemStyleMap.end(); )
	{
		switch(it->second.m_ItemType)
		{
		case IMGE_TYPE:
		//	SAFE_DELETE(it->second.m_DrawData.m_ImageData.m_ActiveImage);
		//	SAFE_DELETE(it->second.m_DrawData.m_ImageData.m_NormalImage);
			break;
		case CHECKBOX_IMAGE_AND_TEXT_TYPE:
			{
				int Row=LOWORD(it->first);
				int Column=HIWORD(it->first);
				if( it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_IsDeleteNormalImage)
				{
					DeleteImage(it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage);
					it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_IsDeleteNormalImage = false;
				}

				if( it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_IsDeleteActiveImage)
				{
					DeleteImage(it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage);
					it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_IsDeleteActiveImage = false;
				}
				sItemStyle Style;
			/*	GetColumStyle(Column,Style);
				if(Style.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage != it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage)
					DeleteImage(it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage);
				if(Style.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage != it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage)
					DeleteImage(it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage);*/
			}
		//	it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage->
			//SAFE_DELETE(it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage);
		//	SAFE_DELETE(it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage);
			break;
		case IMAGE_AND_TEXT_TYPE:  
		//	DeleteImage(it->second.m_DrawData.m_ImageAndTextData.m_ImageData.m_ActiveImage);
		//	DeleteImage(it->second.m_DrawData.m_ImageAndTextData.m_ImageData.m_NormalImage);
		//	SAFE_DELETE(it->second.m_DrawData.m_ImageAndTextData.m_ImageData.m_ActiveImage);
			//SAFE_DELETE(it->second.m_DrawData.m_ImageAndTextData.m_ImageData.m_NormalImage);
			break;

		}
		it=m_ItemStyleMap.erase(it);
	}

	m_RowIndex.clear();
	m_RowCount = -1;
	return CListCtrl::DeleteAllItems();
}
Ejemplo n.º 2
0
//清除风格
void CListCtrlEx::CleanStyle(int ColumnIndex,sItemStyle* pStyle)
{
	if(pStyle == NULL)
		return;

	switch(pStyle->m_ItemType)
	{
	case IMGE_TYPE:
	//	SAFE_DELETE(it->second.m_DrawData.m_ImageData.m_ActiveImage);
	//	SAFE_DELETE(it->second.m_DrawData.m_ImageData.m_NormalImage);
		break;
	case CHECKBOX_IMAGE_AND_TEXT_TYPE:
		{
			sItemStyle Style;
			GetColumStyle(ColumnIndex,Style);
			if(pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage == pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage 
				&& Style.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage != pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage
				&& Style.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage != pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage)
			{
				DeleteImage(pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage);
				pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage = NULL;
				pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage = NULL;

			}
			if(Style.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage != pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage)
			{
				DeleteImage(pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage);
				pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage = NULL;

			}
			if(Style.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage != pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage)
			{
				DeleteImage(pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage);
				pStyle->m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage = NULL;
			}
		}
	//	it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage->
		//SAFE_DELETE(it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_ActiveImage);
	//	SAFE_DELETE(it->second.m_DrawData.m_CheckBoxImageAndTextData.m_ImageData.m_NormalImage);
		break;
	case IMAGE_AND_TEXT_TYPE:  
	//	DeleteImage(it->second.m_DrawData.m_ImageAndTextData.m_ImageData.m_ActiveImage);
	//	DeleteImage(it->second.m_DrawData.m_ImageAndTextData.m_ImageData.m_NormalImage);
	//	SAFE_DELETE(it->second.m_DrawData.m_ImageAndTextData.m_ImageData.m_ActiveImage);
		//SAFE_DELETE(it->second.m_DrawData.m_ImageAndTextData.m_ImageData.m_NormalImage);
		break;

	}
}
Ejemplo n.º 3
0
void 
calImageWindow::clearAll()
{
  DeleteImage();
  num_pts2D = 0;
  imWindow::redraw();
  redraw();
}
void mxBitmapButton::SetImage( const char *bitmapname )
{
	if ( m_bmImage.valid )
	{
		DeleteImage();
	}

	LoadBitmapFromFile( va( "%s/%s", GetGameDirectory(), bitmapname ), m_bmImage );
}
Ejemplo n.º 5
0
/**
 * Dequeues images upon notification that processing is done. If there are
 * additional images in the queue, sends the next one for processing.
 */
void ImageHandler::DequeueImagesThread()
{
    Print::Blue("Starting image dequeue thread\n");

    int pipe;
    unsigned char processing_done;

    while(true)
    {
        //Named pipe must be reopened every time or it will still
        //have the previous data
        //Always use open instead of fopen for named pipes to avoid deadlocks
        pipe = open("/usr/local/share/MotionHandler/processing_done_pipe",
                    O_RDONLY);
        if(pipe < 0)
        {
            Print::Err("Image dequeue - Can't open pipe\n"
                       "       Terminating image dequeue thread.\n");
            pthread_exit(NULL);
        }
        (void)read(pipe, &processing_done, 1);
        (void)read(pipe, NULL, 3);
        close(pipe);

        if(processing_done == 0x01)
        {
            if(image_queue.size() == 0)
            {
                Print::Err("Image dequeue - No images in queue\n");
                continue;
            }

            Print::Blue("Processing done. Popping the image queue.\n");

            DeleteImage(image_queue.front());

            //Image processing is finished.
            //Pop the queue and send off the next image
            (void)pthread_mutex_lock(&image_queue_lock);
            image_queue.pop();

            if(image_queue.size() > 0)
            {
                Print::Blue("Another image is in the queue. Processing.\n");
                ProcessImage(image_queue.front());
            }
            (void)pthread_mutex_unlock(&image_queue_lock);
        }
        else if(processing_done != 0x42)
        {
        //    Print::Err("Image dequeue - Received unexpected "
        //               "data from the pipe. Verify that only one instance "
        //               "of this program is running.\n");
        }
    }
}
Ejemplo n.º 6
0
//===========================================================================
bool igApp::GenerateImage( int frameIndex /*= 0*/, bool giveProgress /*= true*/, bool animating /*= false*/ )
{
	bool success = false;

	do
	{
		if( !plugin )
			break;

		DeleteImage();

		imageData = new unsigned char[ options.imageSize.GetWidth() * options.imageSize.GetHeight() * COMPONENTS_PER_PIXEL ];
		if( !imageData )
			break;

		image = new wxImage( options.imageSize, imageData, true );

		igPlugin::AnimationData animationData;
		animationData.animating = animating;
		animationData.frameIndex = frameIndex;
		animationData.frameCount = options.frameCount;
		animationData.frameRate = options.frameRate;

		if( !plugin->PreImageGeneration( image, &animationData ) )
			break;

		igThread::Manager manager;
		if( !manager.GenerateImage( options.threadCount, &animationData, 100, giveProgress ) )
			break;

		if( !plugin->PostImageGeneration( image, &animationData ) )
			break;

		success = true;
	}
	while( false );

	if( !success )
		DeleteImage();

	return success;
}
Ejemplo n.º 7
0
static int
CreateImage(
    Tcl_Interp *interp,		/* Interpreter for error reporting. */
    Tk_Canvas canvas,		/* Canvas to hold new item. */
    Tk_Item *itemPtr,		/* Record to hold new item; header has been
				 * initialized by caller. */
    int objc,			/* Number of arguments in objv. */
    Tcl_Obj *const objv[])	/* Arguments describing rectangle. */
{
    ImageItem *imgPtr = (ImageItem *) itemPtr;
    int i;

    if (objc == 0) {
        Tcl_Panic("canvas did not pass any coords");
    }

    /*
     * Initialize item's record.
     */

    imgPtr->canvas = canvas;
    imgPtr->anchor = TK_ANCHOR_CENTER;
    imgPtr->imageString = NULL;
    imgPtr->activeImageString = NULL;
    imgPtr->disabledImageString = NULL;
    imgPtr->image = NULL;
    imgPtr->activeImage = NULL;
    imgPtr->disabledImage = NULL;

    /*
     * Process the arguments to fill in the item record. Only 1 (list) or 2 (x
     * y) coords are allowed.
     */

    if (objc == 1) {
        i = 1;
    } else {
        const char *arg = Tcl_GetString(objv[1]);
        i = 2;
        if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) {
            i = 1;
        }
    }
    if ((ImageCoords(interp, canvas, itemPtr, i, objv) != TCL_OK)) {
        goto error;
    }
    if (ConfigureImage(interp, canvas, itemPtr, objc-i, objv+i, 0) == TCL_OK) {
        return TCL_OK;
    }

error:
    DeleteImage(canvas, itemPtr, Tk_Display(Tk_CanvasTkwin(canvas)));
    return TCL_ERROR;
}
Ejemplo n.º 8
0
//===========================================================================
/*virtual*/ int igApp::OnExit( void )
{
	if( plugin || pluginHandle != NULL )
		UnloadPlugin( true );

	DeleteImage();

	SaveConfiguration();

	return wxApp::OnExit();
}
Ejemplo n.º 9
0
/* -------------------------------------------------------------------------- */
void ImageManager::DeleteImage(string imgPath, tVecStr* imgErasedList, bool filterAll, bool removetoTree)
{
	KeyStr key(imgPath);
	if(!imgTree.empty())
	{
		if(imgTree.exists(key))
		{
			ValueInt* vInt = dynamic_cast<ValueInt*>(imgTree.find(key));
			DeleteImage(vInt->getValue(), imgErasedList, filterAll, removetoTree);
			delete vInt;
		}
	}
}
Ejemplo n.º 10
0
//================================================================================================================
void HUDEditorSystem::OnMouseDown(WPARAM btnState, int x, int y)
{
	// Start a left button drag of an item
	if ((btnState & MK_LBUTTON) != 0)
	{
		stampPressed = true;
		
		CalculateSelectedMousePosition(x, y);
		
		// Adds a new image to the hud from the selected image image in the image cache if in image
		// place mode
		AddImage();
		
		// Selects a image so it can be moved, if it is moving then this will be skipped
		// so that the image can be placed back on the hud with a left click
		bool goingToMove = MoveImageStart();
		// If a image is being moved place the image at the clicked position if in image move mode
		if (!goingToMove) MoveImageEnd();
		
		// Selects a image so it can be cloned, if it is moving then this will be skipped
		// so that the image clone can be added to the hud with a left click
		bool goingToClone = CloneImageStart();
		// If a image is being moved place the image at the clicked position if in image clone mode
		if (!goingToClone) CloneImageEnd();
		
		// Selects a image on the hud and deletes it if in image delete mode
		DeleteImage();
		
		// Selects the button to be resized if in button resize mode
		ResizeImageStart();
		
		// If applicable, Add a text if in text mode
		AddText();
		
		// Selects a text so it can be moved, if it is moving then this will be skipped
		// so that the text can be placed back on the hud with a left click
		goingToMove = MoveTextStart();
		// If a text is being moved place the text at the clicked position if in text move mode
		if (!goingToMove) MoveTextEnd();
		
		// Selects a text so it can be cloned, if it is moving then this will be skipped
		// so that the text clone can be added to the hud with a left click
		goingToClone = CloneTextStart();
		// If a text is being moved place the text at the clicked position if in text clone mode
		if (!goingToClone) CloneTextEnd();
		
		// Selects a text on the hud and deletes it if in text delete mode
		DeleteText();
	}
}
Ejemplo n.º 11
0
Bool32 CTIImageList::AddImage(const char *lpName, Handle hDIB, uint32_t wFlag)
{
	CTIImageHeader * NewImage = NULL;
	CTIImageHeader * LastImage = NULL;

/* commented by Andrey
    if ( FindImage(lpName, &LastImage) )
	{
		SetReturnCode_cimage(IDS_CIMAGE_IMAGE_NAME_REPEATED);
		return FALSE;
	}
*/
    while (FindImage(lpName, &LastImage))
    {
        LastImage = NULL;
        DeleteImage(lpName);
    }

	if ( lpName == NULL && lpName[0] == 0x0 )
	{
		SetReturnCode_cimage(IDS_CIMAGE_INVALID_IMAGE_NAME);
		return FALSE;
	}

	if ( hDIB == NULL )
	{
		SetReturnCode_cimage(IDS_CIMAGE_INVALID_IMAGE_INFO);
		return FALSE;
	}

	if ( LastImage == NULL )
	{
		SetReturnCode_cimage(IDS_CIMAGE_INVALID_IMAGES_CONTAINER);
		return FALSE;
	}

	NewImage = new CTIImageHeader(lpName, hDIB, wFlag);


	if ( NewImage == NULL )
	{
		SetReturnCode_cimage(IDS_CIMAGE_INVALID_IMAGE_INFO);
		return FALSE;
	}

	NewImage->SetNext(LastImage->GetNext());
	LastImage->SetNext(NewImage);

	return TRUE;
}
Ejemplo n.º 12
0
Archivo: tkImage.c Proyecto: tcltk/tk
void
Tk_DeleteImage(
    Tcl_Interp *interp,		/* Interpreter in which the image was
				 * created. */
    const char *name)		/* Name of image. */
{
    Tcl_HashEntry *hPtr;
    TkWindow *winPtr;

    winPtr = (TkWindow *) Tk_MainWindow(interp);
    if (winPtr == NULL) {
	return;
    }
    hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, name);
    if (hPtr == NULL) {
	return;
    }
    DeleteImage(Tcl_GetHashValue(hPtr));
}
Ejemplo n.º 13
0
/* -------------------------------------------------------------------------- */
pListUpdate ImageManager::UpdateImages()
{
	pListUpdate updatesList;
	tVecStr* imgErasedList = GetUpdatedList(Erased);
	for(size_t i=0; i < imgErasedList->size(); i++)
	{
		string path = (*imgErasedList)[i];
		DeleteImage(path,imgErasedList);
	}
	
	tVecStr* imgAddList = GetUpdatedList(Added);
	for(size_t i=0; i < imgAddList->size(); i++)
	{
		string path = (*imgAddList)[i];
		AddImage(path.c_str());
	}
	updatesList.first = imgErasedList;
	updatesList.second = imgAddList;
	return updatesList;
}
Ejemplo n.º 14
0
int FResizeImage( struct ImageLibrary *im, Image **image, int w, int h )
{
	if( image != NULL )
	{
		ExceptionInfo *ei=AcquireExceptionInfo();
		
		///filters are in resamples.h
		Image* newImage = ResizeImage( *image, w, h, LanczosFilter, 1.0, ei );
		if( newImage != NULL )
		{
			DeleteImage( *image );
			*image = newImage;
		}
		
		DestroyExceptionInfo( ei );
	}
	else
	{
		ERROR("Cannot resize empty image\n");
	}
	
	return 0;
}
Ejemplo n.º 15
0
// ######################################################################
Image<PixRGB<byte> > AutomateXWin::getImage()
{


  DeleteImage();
#ifdef USE_SHM
  if(!itsImage)
  {
    itsImage = XShmCreateImage(itsDisplay, itsVInfo.visual,
        itsDepth,
        ZPixmap,
        NULL,
        &itsShminfo,
        itsWidth,
        itsHeight);
    if(!itsImage)
    {
      LERROR("XShmCreateImage");
      return Image<PixRGB<byte> >();
    }

    itsShminfo.shmid = shmget(IPC_PRIVATE,
        itsImage->bytes_per_line * itsImage->height,
        IPC_CREAT | 0777);
    if(itsShminfo.shmid < 0)
    {
      LERROR("shmget");
      XDestroyImage(itsImage);
      itsImage=NULL;
      return Image<PixRGB<byte> >();
    }
    itsShminfo.shmaddr = (char *) shmat(itsShminfo.shmid, 0, 0);
    if(itsShminfo.shmaddr == (char *)-1)
    {
      LERROR("shmat");
      XDestroyImage(itsImage);
      return Image<PixRGB<byte> >();
    }
    shmctl(itsShminfo.shmid, IPC_RMID, 0),
      itsImage->data = itsShminfo.shmaddr;
    itsShminfo.readOnly = False;
    XShmAttach(itsDisplay, &itsShminfo);

    XSync(itsDisplay, False);
  }
#endif
  /* If SHM failed or was disabled, try non-SHM way */
  if(!itsImage)
  {
    itsImage = XGetImage(itsDisplay, itsWindow,
        0, 0,
        itsWidth,
        itsHeight,
        AllPlanes,
        XYPixmap);
    if(!itsImage)
      LERROR("XGetImage\n");
  }
#ifdef USE_SHM
  if(!XShmGetImage(itsDisplay, itsWindow, itsImage,
        0, 0,
        AllPlanes))
    LERROR("XSHMGetImage");
#endif

  Image<PixRGB<byte> > img(itsWidth,itsHeight,NO_INIT);
  int rshift = 7 - getHighBitIndex (itsImage->red_mask);
  int gshift = 7 - getHighBitIndex (itsImage->green_mask);
  int bshift = 7 - getHighBitIndex (itsImage->blue_mask);

  for (int y=0; y<itsImage->height; y++) {
    for (int x=0; x<itsImage->width; x++) {
      unsigned long pixel = XGetPixel (itsImage,x,y);
      PixRGB<byte> pixVal(
       SHIFTL(pixel & itsImage->red_mask,rshift),
       SHIFTL(pixel & itsImage->green_mask,gshift),
       SHIFTL(pixel & itsImage->blue_mask,bshift)
      );
      img.setVal(x,y, pixVal);
    }
  }

  return img;

}
Ejemplo n.º 16
0
mxBitmapButton::~mxBitmapButton( void )
{
	DeleteImage();
}
Ejemplo n.º 17
0
Archivo: tkImage.c Proyecto: tcltk/tk
int
Tk_ImageObjCmd(
    ClientData clientData,	/* Main window associated with interpreter. */
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *const objv[])	/* Argument strings. */
{
    static const char *const imageOptions[] = {
	"create", "delete", "height", "inuse", "names", "type", "types",
	"width", NULL
    };
    enum options {
	IMAGE_CREATE, IMAGE_DELETE, IMAGE_HEIGHT, IMAGE_INUSE, IMAGE_NAMES,
	IMAGE_TYPE, IMAGE_TYPES, IMAGE_WIDTH
    };
    TkWindow *winPtr = clientData;
    int i, isNew, firstOption, index;
    Tk_ImageType *typePtr;
    ImageMaster *masterPtr;
    Image *imagePtr;
    Tcl_HashEntry *hPtr;
    Tcl_HashSearch search;
    char idString[16 + TCL_INTEGER_SPACE];
    TkDisplay *dispPtr = winPtr->dispPtr;
    const char *arg, *name;
    Tcl_Obj *resultObj;
    ThreadSpecificData *tsdPtr =
            Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));

    if (objc < 2) {
	Tcl_WrongNumArgs(interp, 1, objv, "option ?args?");
	return TCL_ERROR;
    }

    if (Tcl_GetIndexFromObjStruct(interp, objv[1], imageOptions,
	    sizeof(char *), "option", 0, &index) != TCL_OK) {
	return TCL_ERROR;
    }
    switch ((enum options) index) {
    case IMAGE_CREATE: {
	Tcl_Obj **args;
	int oldimage = 0;

	if (objc < 3) {
	    Tcl_WrongNumArgs(interp, 2, objv,
		    "type ?name? ?-option value ...?");
	    return TCL_ERROR;
	}

	/*
	 * Look up the image type.
	 */

	arg = Tcl_GetString(objv[2]);
	for (typePtr = tsdPtr->imageTypeList; typePtr != NULL;
		typePtr = typePtr->nextPtr) {
	    if ((*arg == typePtr->name[0])
		    && (strcmp(arg, typePtr->name) == 0)) {
		break;
	    }
	}
	if (typePtr == NULL) {
	    oldimage = 1;
	    for (typePtr = tsdPtr->oldImageTypeList; typePtr != NULL;
		    typePtr = typePtr->nextPtr) {
		if ((*arg == typePtr->name[0])
			&& (strcmp(arg, typePtr->name) == 0)) {
		    break;
		}
	    }
	}
	if (typePtr == NULL) {
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
		    "image type \"%s\" doesn't exist", arg));
	    Tcl_SetErrorCode(interp, "TK", "LOOKUP", "IMAGE_TYPE", arg, NULL);
	    return TCL_ERROR;
	}

	/*
	 * Figure out a name to use for the new image.
	 */

	if ((objc == 3) || (*(arg = Tcl_GetString(objv[3])) == '-')) {
	    do {
		dispPtr->imageId++;
		sprintf(idString, "image%d", dispPtr->imageId);
		name = idString;
	    } while (Tcl_FindCommand(interp, name, NULL, 0) != NULL);
	    firstOption = 3;
	} else {
	    TkWindow *topWin;

	    name = arg;
	    firstOption = 4;

	    /*
	     * Need to check if the _command_ that we are about to create is
	     * the name of the current master widget command (normally "." but
	     * could have been renamed) and fail in that case before a really
	     * nasty and hard to stop crash happens.
	     */

	    topWin = (TkWindow *) TkToplevelWindowForCommand(interp, name);
	    if (topWin != NULL && winPtr->mainPtr->winPtr == topWin) {
		Tcl_SetObjResult(interp, Tcl_NewStringObj(
			"images may not be named the same as the main window",
			-1));
		Tcl_SetErrorCode(interp, "TK", "IMAGE", "SMASH_MAIN", NULL);
		return TCL_ERROR;
	    }
	}

	/*
	 * Create the data structure for the new image.
	 */

	hPtr = Tcl_CreateHashEntry(&winPtr->mainPtr->imageTable, name, &isNew);
	if (isNew) {
	    masterPtr = ckalloc(sizeof(ImageMaster));
	    masterPtr->typePtr = NULL;
	    masterPtr->masterData = NULL;
	    masterPtr->width = masterPtr->height = 1;
	    masterPtr->tablePtr = &winPtr->mainPtr->imageTable;
	    masterPtr->hPtr = hPtr;
	    masterPtr->instancePtr = NULL;
	    masterPtr->deleted = 0;
	    masterPtr->winPtr = winPtr->mainPtr->winPtr;
	    Tcl_Preserve(masterPtr->winPtr);
	    Tcl_SetHashValue(hPtr, masterPtr);
	} else {
	    /*
	     * An image already exists by this name. Disconnect the instances
	     * from the master.
	     */

	    masterPtr = Tcl_GetHashValue(hPtr);
	    if (masterPtr->typePtr != NULL) {
		for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
			imagePtr = imagePtr->nextPtr) {
		    masterPtr->typePtr->freeProc(imagePtr->instanceData,
			    imagePtr->display);
		    imagePtr->changeProc(imagePtr->widgetClientData, 0, 0,
			    masterPtr->width, masterPtr->height,
			    masterPtr->width, masterPtr->height);
		}
		masterPtr->typePtr->deleteProc(masterPtr->masterData);
		masterPtr->typePtr = NULL;
	    }
	    masterPtr->deleted = 0;
	}

	/*
	 * Call the image type manager so that it can perform its own
	 * initialization, then re-"get" for any existing instances of the
	 * image.
	 */

	objv += firstOption;
	objc -= firstOption;
	args = (Tcl_Obj **) objv;
	if (oldimage) {
	    int i;

	    args = ckalloc((objc+1) * sizeof(char *));
	    for (i = 0; i < objc; i++) {
		args[i] = (Tcl_Obj *) Tcl_GetString(objv[i]);
	    }
	    args[objc] = NULL;
	}
	Tcl_Preserve(masterPtr);
	if (typePtr->createProc(interp, name, objc, args, typePtr,
		(Tk_ImageMaster)masterPtr, &masterPtr->masterData) != TCL_OK){
	    EventuallyDeleteImage(masterPtr, 0);
	    Tcl_Release(masterPtr);
	    if (oldimage) {
		ckfree(args);
	    }
	    return TCL_ERROR;
	}
	Tcl_Release(masterPtr);
	if (oldimage) {
	    ckfree(args);
	}
	masterPtr->typePtr = typePtr;
	for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
		imagePtr = imagePtr->nextPtr) {
	    imagePtr->instanceData = typePtr->getProc(imagePtr->tkwin,
		    masterPtr->masterData);
	}
	Tcl_SetObjResult(interp, Tcl_NewStringObj(
		Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1));
	break;
    }
    case IMAGE_DELETE:
	for (i = 2; i < objc; i++) {
	    arg = Tcl_GetString(objv[i]);
	    hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg);
	    if (hPtr == NULL) {
		goto alreadyDeleted;
	    }
	    masterPtr = Tcl_GetHashValue(hPtr);
	    if (masterPtr->deleted) {
		goto alreadyDeleted;
	    }
	    DeleteImage(masterPtr);
	}
	break;
    case IMAGE_NAMES:
	if (objc != 2) {
	    Tcl_WrongNumArgs(interp, 2, objv, NULL);
	    return TCL_ERROR;
	}
	hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search);
	resultObj = Tcl_NewObj();
	for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
	    masterPtr = Tcl_GetHashValue(hPtr);
	    if (masterPtr->deleted) {
		continue;
	    }
	    Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
		    Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1));
	}
	Tcl_SetObjResult(interp, resultObj);
	break;
    case IMAGE_TYPES:
	if (objc != 2) {
	    Tcl_WrongNumArgs(interp, 2, objv, NULL);
	    return TCL_ERROR;
	}
	resultObj = Tcl_NewObj();
	for (typePtr = tsdPtr->imageTypeList; typePtr != NULL;
		typePtr = typePtr->nextPtr) {
	    Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
		    typePtr->name, -1));
	}
	for (typePtr = tsdPtr->oldImageTypeList; typePtr != NULL;
		typePtr = typePtr->nextPtr) {
	    Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
		    typePtr->name, -1));
	}
	Tcl_SetObjResult(interp, resultObj);
	break;

    case IMAGE_HEIGHT:
    case IMAGE_INUSE:
    case IMAGE_TYPE:
    case IMAGE_WIDTH:
	/*
	 * These operations all parse virtually identically. First check to
	 * see if three args are given. Then get a non-deleted master from the
	 * third arg.
	 */

	if (objc != 3) {
	    Tcl_WrongNumArgs(interp, 2, objv, "name");
	    return TCL_ERROR;
	}

	arg = Tcl_GetString(objv[2]);
	hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg);
	if (hPtr == NULL) {
	    goto alreadyDeleted;
	}
	masterPtr = Tcl_GetHashValue(hPtr);
	if (masterPtr->deleted) {
	    goto alreadyDeleted;
	}

	/*
	 * Now we read off the specific piece of data we were asked for.
	 */

	switch ((enum options) index) {
	case IMAGE_HEIGHT:
	    Tcl_SetObjResult(interp, Tcl_NewWideIntObj(masterPtr->height));
	    break;
	case IMAGE_INUSE:
	    Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
		    masterPtr->typePtr && masterPtr->instancePtr));
	    break;
	case IMAGE_TYPE:
	    if (masterPtr->typePtr != NULL) {
		Tcl_SetObjResult(interp,
			Tcl_NewStringObj(masterPtr->typePtr->name, -1));
	    }
	    break;
	case IMAGE_WIDTH:
	    Tcl_SetObjResult(interp, Tcl_NewWideIntObj(masterPtr->width));
	    break;
	default:
	    Tcl_Panic("can't happen");
	}
	break;
    }
    return TCL_OK;

  alreadyDeleted:
    Tcl_SetObjResult(interp, Tcl_ObjPrintf("image \"%s\" doesn't exist",arg));
    Tcl_SetErrorCode(interp, "TK", "LOOKUP", "IMAGE", arg, NULL);
    return TCL_ERROR;
}
Ejemplo n.º 18
0
//================================================================================================================
void HUDEditorSystem::OnMouseMove(WPARAM btnState, int x, int y)
{
	if (gridMode == GM_Snap)
	{
		XMFLOAT2 selToolPoint = SnapToGrid(x, y);
		
		m_StampNormal->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0);
		m_StampHighlight->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0);
		
		// Move a image display cover if in image mode
		UpdateDisplaySprite(selToolPoint.x, selToolPoint.y);
		
		// If a image or text is being moved then continue to move it
		MoveImage(selToolPoint.x, selToolPoint.y);
		MoveText(selToolPoint.x, selToolPoint.y);
		
		HighlightImage(selToolPoint.x, selToolPoint.y);
		HighlightText(selToolPoint.x, selToolPoint.y);
	}
	else
	{
		// Move a image display cover if in image mode
		UpdateDisplaySprite(x, y);
		
		// If a image or text is being moved then continue to move it
		MoveImage(x, y);
		MoveText(x, y);
		
		HighlightImage(x, y);
		HighlightText(x, y);
	}
	
	// Start a left button drag of an item
	if ((btnState & MK_LBUTTON) != 0)
	{
		CalculateSelectedMousePosition(x, y);
		
		stampPressed = true;
		
		// If applicable, Add a image
		AddImage();
		
		// If applicable, Add a text
		AddText();
		
		// Selects a image on the map and deletes it if in image delete mode
		DeleteImage();
		
		// Selects a text on the map and deletes it if in text delete mode
		DeleteText();
	}
	
	// Move a button or text display cover
	/*if (editMode == ET_Button && (action == A_Place || action == A_Move))
	{
		XMFLOAT2 selToolPoint = SnapToGrid(x, y);
		
		m_StampNormal->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0);
		m_StampHighlight->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0);
	}*/
}
Ejemplo n.º 19
0
tVecStr ImageManager::DeleteDirectory(const char* dirPath){
	bool end=false;

	string dir=string (dirPath);
	tVecStr fileList=FileSystem::GetFiles(dirPath,File);
	tVecStr tokensDir=StrToken::getStrTokens(dirPath,"/");
	StrToken::FormatPath(dir);

	KeyStr kDirDir(dir);
	dir.append(END_DIRECTORY);
	KeyStr kDir(dir.c_str());
	vector<string> vkFile;
	vector<string> vkDir;
	tVecStr ans;

	if ( (dirTree.empty()) || (!dirTree.exists(kDirDir)))
		return ans;

	TreeIterator& it = imgTree.iterator(kDir);
	while ( (!it.end()) && (end==false) )
	{
		KeyStr* kStr=dynamic_cast<KeyStr*>(it.getKey());
		string pathFile=(kStr->getKey());
		tVecStr tokens=StrToken::getStrTokens(kStr->getKey(),"/");
		if ((strcmp(tokens[tokens.size()-1].c_str(),END_DIRECTORY)) )
		{
			ValueInt* vInt=(ValueInt*)it.getValue();
			DeleteImage(vInt->getValue(),NULL,true,false);
			string pathFile=(kStr->getKey());
			vkFile.push_back(kStr->getKey());
			delete vInt;
		}
		else if (isSubDirectoryOrSubFile(&tokensDir,&tokens)||(!strcmp(dir.c_str(),(kStr->getKey()).c_str())))
		{
			string strDir=kStr->getKey();
			TransformKeyImgToKeyDir(strDir);
			ans.push_back(strDir);
			vkDir.push_back(strDir);
		}
		else
		{
			end=true;
		}
		delete kStr;
		++it;
	}
	imgTree.deleteIterator(it);
	for(unsigned int u=0;u<vkDir.size();u++)
	{
		string path=vkDir[u];
		KeyStr keyDir(path);
		string pathDi=path +END_DIRECTORY;
		KeyStr keyImg(pathDi);
		dirTree.remove(keyDir);
		if (imgTree.exists(keyImg)) //Esto para debuggear
			imgTree.remove(keyImg);
	}
	for(unsigned int u=0;u<vkFile.size();u++)
	{
		string k=vkFile[u];
		KeyStr key(k);
		imgTree.remove(key);
	}
	return ans;
}