Exemple #1
0
static void
autoscroll_thread(void *unused)
{
    DWORD status;

    for_ever {
	status = WaitForSingleObject(hAsMutex, AS_TMOUT);
	if (!buttondown) {
	    (void) ReleaseMutex(hAsMutex);
	    break;		/* button no longer held down, die */
	}
	if (status == WAIT_ABANDONED) {
	    /* main thread closed thread handle or ??? */

	    (void) ReleaseMutex(hAsMutex);
	    break;
	}
	if (status == WAIT_OBJECT_0) {
	    /* thread got mutex and "owns" the display. */

	    AutoScroll(mouse_wp);
	}
	(void) ReleaseMutex(hAsMutex);
	Sleep(25);		/* Don't hog the processor */
    }
}
Exemple #2
0
int Scroller::OnEvent(Event* e)
{
	TouchData* t = (TouchData*)e->Data;
	switch (e->Type)
	{
		case Event::TouchDown:
			_dragy = t->y;	// Drag in progress
			break;

		case Event::TouchMove:
			if (_dragy != -1 && _dragy != (short)t->y)
			{
				int delta = -_dragy + t->y;
				if (delta >= -2 && delta <= 2)
					break;
				ScrollBy(delta);        // Also velocity
				_dragy = t->y;
				_velocity = delta << 4; // 12:4 fixed point
			}
			break;

		case Event::TouchUp:
			_dragy = -1;
			break;

		case Event::None:
			AutoScroll();
			break;

		default:;
	}
	return 0;
}
void wxJigsawEditorCanvas::OnIdle( wxIdleEvent& event )
{	
	do
	{
		if(!HasCapture()) break;

		// get mouse in client coordinates
		wxPoint currentPos = ScreenToClient(wxGetMousePosition());

		//Update the offset to the next mouse down event
		if(m_View->GetSelectedObject())
		{
			wxPoint diagramPoint = PointToViewPoint(currentPos);
			wxPoint groupPosition = m_View->GetRealGroupPosition(m_View->GetSelectedObject());
			m_SelectedObjectOffset = wxSize(
				diagramPoint.x - groupPosition.x,
				diagramPoint.y - groupPosition.y);
		}

		// get scroll position
		wxPoint scrollPos = GetScrollPosition();
		

		// auto scroll
		// check current drag position and update scroll regularly
		if(AutoScroll(currentPos, scrollPos))
		{
			event.RequestMore();
		}
		FixViewOffset();
	}
	while(false);
}
void CDragVirtualListCtrl::OnMouseMove(UINT nFlags, CPoint point) 
{
	if (m_Dragging) {
		UpdateCursor(point);
		AutoScroll(point);
	}
	CListCtrl::OnMouseMove(nFlags, point);
}
// ----------------------------------------------------
// SelectMatch
//
// SelectMatch will do all the UI work associated with
// selected a manufacturer and model of printer.  It also
// makes sure the printer object is update with the
// latest settings
//
// ----------------------------------------------------
void
CThirdPage::SelectMatch(Printer * printer, Service * service, Manufacturer * manufacturer, Model * model)
{
    LVFINDINFO	info;
    int			nIndex;

    check( printer != NULL );
    check( manufacturer != NULL );
    check( model != NULL );

    //
    // select the manufacturer
    //
    info.flags	= LVFI_STRING;
    info.psz	= manufacturer->name;

    nIndex = m_manufacturerListCtrl.FindItem(&info);

    if (nIndex != -1)
    {
        m_manufacturerListCtrl.SetItemState(nIndex, LVIS_SELECTED, LVIS_SELECTED);
        //
        //<rdar://problem/4528853> mDNS: When auto-highlighting items in lists, scroll list so highlighted item is in the middle
        //
        AutoScroll(m_manufacturerListCtrl, nIndex);
    }

    //
    // select the model
    //
    info.flags	= LVFI_STRING;
    info.psz	= model->displayName;

    nIndex = m_modelListCtrl.FindItem(&info);

    if (nIndex != -1)
    {
        m_modelListCtrl.SetItemState(nIndex, LVIS_SELECTED, LVIS_SELECTED);
        AutoScroll( m_modelListCtrl, nIndex );

        m_modelListCtrl.SetFocus();
    }

    CopyPrinterSettings( printer, service, manufacturer, model );
}
void wxJigsawEditorCanvas::MotionUpdate(wxPoint currentPos)
{		
	// get scroll position
	wxPoint scrollPos = GetScrollPosition();
	wxPoint viewPos = PointToViewPoint(currentPos);
	AutoScroll(currentPos, scrollPos);
	FixViewOffset();
	FixActiveHotSpot(viewPos);
	RefreshBuffer();
}
RtListBox::RtListBox(QWidget *parent,int iX, int iY, int iWidth, int iHeight)
:QWidget(parent),
m_HeightUsed(0),
m_iItems(0),
m_iItemSelect(-1),
m_iBoxHeight(0),
m_iPressY(0),
m_iLastScroll(0)
{
    setGeometry(iX, iY, iWidth, iHeight);

    for (int i=0; i<__MAX_ITEMS__; i++)
	{
        m_pButtonList[i] = NULL;
	}

    m_pQTimerScroll = new QTimer(this);
    connect(m_pQTimerScroll, SIGNAL(timeout()), this, SLOT(AutoScroll()));

    m_pQTimerReset = new QTimer(this);
    connect(m_pQTimerReset, SIGNAL(timeout()), this, SLOT(ResetLastScroll()));

}
OSStatus CThirdPage::MatchPrinter(Manufacturers & manufacturers, Printer * printer, Service * service, bool useCUPSWorkaround)
{
    CString					normalizedProductName;
    Manufacturer		*	manufacturer		=	NULL;
    Manufacturer		*	genericManufacturer	=	NULL;
    Model				*	model				=	NULL;
    Model				*	genericModel		=	NULL;
    bool					found				=	false;
    CString					text;
    OSStatus				err					=	kNoErr;

    check( printer );
    check( service );

    Queue * q = service->SelectedQueue();

    check( q );

    //
    // first look to see if we have a usb_MFG descriptor
    //
    if ( q->usb_MFG.GetLength() > 0)
    {
        manufacturer = MatchManufacturer( manufacturers, ConvertToManufacturerName ( q->usb_MFG ) );
    }

    if ( manufacturer == NULL )
    {
        q->product.Remove('(');
        q->product.Remove(')');

        manufacturer = MatchManufacturer( manufacturers, ConvertToManufacturerName ( q->product ) );
    }

    //
    // if we found the manufacturer, then start looking for the model
    //
    if ( manufacturer != NULL )
    {
        if ( q->usb_MDL.GetLength() > 0 )
        {
            model = MatchModel ( manufacturer, ConvertToModelName ( q->usb_MDL ) );
        }

        if ( ( model == NULL ) && ( q->product.GetLength() > 0 ) )
        {
            q->product.Remove('(');
            q->product.Remove(')');

            model = MatchModel ( manufacturer, ConvertToModelName ( q->product ) );
        }

        if ( model != NULL )
        {
            // <rdar://problem/4124524> Offer Generic printers if printer advertises Postscript or PCL.  Workaround
            // bug in OS X CUPS printer sharing by selecting Generic driver instead of matched printer.

            bool hasGenericDriver = false;

            if ( MatchGeneric( manufacturers, printer, service, &genericManufacturer, &genericModel ) )
            {
                hasGenericDriver = true;
            }

            // <rdar://problem/4190104> Use "application/octet-stream" to determine if CUPS
            // shared queue supports raw

            if ( q->pdl.Find( L"application/octet-stream" ) != -1 )
            {
                useCUPSWorkaround = false;
            }

            if ( useCUPSWorkaround && printer->isCUPSPrinter && hasGenericDriver )
            {
                //
                // <rdar://problem/4496652> mDNS: Don't allow user to choose non-working driver
                //
                Manufacturers genericManufacturers;

                LoadGenericPrintDriverDefs( genericManufacturers );

                SelectMatch( genericManufacturers, printer, service, genericManufacturer, genericModel );

                FreeManufacturers( genericManufacturers );
            }
            else
            {
                SelectMatch(manufacturers, printer, service, manufacturer, model);
            }

            found = true;
        }
    }

    //
    // display a message to the user based on whether we could match
    // this printer
    //
    if (found)
    {
        text.LoadString(IDS_PRINTER_MATCH_GOOD);
        err = kNoErr;
    }
    else if ( MatchGeneric( manufacturers, printer, service, &genericManufacturer, &genericModel ) )
    {
        if ( printer->isCUPSPrinter )
        {
            //
            // <rdar://problem/4496652> mDNS: Don't allow user to choose non-working driver
            //
            Manufacturers genericManufacturers;

            LoadGenericPrintDriverDefs( genericManufacturers );

            SelectMatch( genericManufacturers, printer, service, genericManufacturer, genericModel );

            text.LoadString(IDS_PRINTER_MATCH_GOOD);

            FreeManufacturers( genericManufacturers );
        }
        else
        {
            SelectMatch( manufacturers, printer, service, genericManufacturer, genericModel );
            text.LoadString(IDS_PRINTER_MATCH_MAYBE);
        }

        err = kNoErr;
    }
    else
    {
        text.LoadString(IDS_PRINTER_MATCH_BAD);

        //
        // if there was any crud in this list from before, get rid of it now
        //
        m_modelListCtrl.DeleteAllItems();

        //
        // select the manufacturer if we found one
        //
        if (manufacturer != NULL)
        {
            LVFINDINFO	info;
            int			nIndex;

            //
            // select the manufacturer
            //
            info.flags	= LVFI_STRING;
            info.psz	= manufacturer->name;

            nIndex = m_manufacturerListCtrl.FindItem(&info);

            if (nIndex != -1)
            {
                m_manufacturerListCtrl.SetItemState(nIndex, LVIS_SELECTED, LVIS_SELECTED);

                //
                //<rdar://problem/4528853> mDNS: When auto-highlighting items in lists, scroll list so highlighted item is in the middle
                //
                AutoScroll(m_manufacturerListCtrl, nIndex);
            }
        }

        err = kUnknownErr;
    }

    m_printerSelectionText.SetWindowText(text);

    return err;
}
void CWFView::ApplyTool(CPoint point,BOOL JustPressed)
{
	static SDWORD LastSelected = -1;
	static SDWORD LastSelTexture = -1;
	static SDWORD LastSelType = -1;

	CBTEditDoc* pDoc = GetDocument();
	D3DVECTOR CameraPosition,CameraRotation;
	CPoint ScrollPos = GetScrollPosition();
	ScrollPos.x -= pDoc->GetTextureWidth()*OVERSCAN;
	ScrollPos.y -= pDoc->GetTextureHeight()*OVERSCAN;

	int Selected;

	CHeightMap *HeightMap = pDoc->GetHeightMap();

	if(pDoc->InLocator(m_MouseX,m_MouseY)) {
		pDoc->GetCamera(CameraRotation,CameraPosition);
		CameraPosition.x = (float)(( ((SLONG)(m_MouseX-OVERSCAN)/pDoc->GetRadarScale()) -((SLONG)pDoc->GetMapWidth()/2)) * (SLONG)pDoc->GetTileWidth());
		CameraPosition.z = -(float)(( ((SLONG)(m_MouseY-OVERSCAN)/pDoc->GetRadarScale()) -((SLONG)pDoc->GetMapHeight()/2)) * (SLONG)pDoc->GetTileHeight());
		if(pDoc->GetCameraMode() == MCAM_ISOMETRIC) {
//			CameraPosition.y = pDoc->GetHeightAt(CameraPosition)+CAM_HEIGHT;
			CameraPosition.y = (float)CAM_HEIGHT;
		}
		SyncPosition(CameraPosition);
		UpdateAndValidate();

		if(pDoc->GetAutoSync()) {
			pDoc->RegisterCamera(CameraRotation,CameraPosition);	// Bind views.
			pDoc->Invalidate3D();
		}

		return;
	}

	if(pDoc->InLocatorBorder(m_MouseX,m_MouseY)) {
		return;
	}

	Selected = pDoc->Select2DFace(point.x,point.y,ScrollPos.x,ScrollPos.y);

	DWORD EditTool = pDoc->GetEditTool();

	if((EditTool >= ET_TYPESFIRST) && (EditTool <= ET_TYPESLAST)) {
		if(Selected >= 0) {
			if( (Selected != LastSelected) ||
				((SDWORD)pDoc->m_SelType  != LastSelType) ) {

				LastSelected = Selected;
				LastSelTexture = -1;
				LastSelType = pDoc->m_SelType;

  				g_UndoRedo->AddUndo(&(HeightMap->GetMapTiles()[Selected]));

				HeightMap->SetTileType(Selected,pDoc->GetSelectedType());
				UpdateAndValidate();
			}
		}
	} else {
		switch(EditTool) {
			case ET_GET:
				if(Selected >= 0) {
					pDoc->m_SelTexture = HeightMap->GetTextureID(Selected);
					pDoc->GetTextureSelector()->SetSelectedTexture(pDoc->m_SelTexture);
					pDoc->UpdateTextureView();
				}
				break;

			case ET_PAINT:
   				if(Selected >= 0) {
					AutoScroll(point);
					if(pDoc->m_SelIsTexture) {
						if( (Selected != LastSelected) || (JustPressed) ||
							((SDWORD)pDoc->m_SelTexture != LastSelTexture) ||
							((SDWORD)pDoc->m_SelType  != LastSelType) ) {

							LastSelected = Selected;
							LastSelTexture = pDoc->m_SelTexture;
							LastSelType = pDoc->m_SelType;

							if(pDoc->m_SelType == TF_TYPEWATER) {
								if(pDoc->GetAutoHeight()) {
									g_UndoRedo->BeginGroup();
								}
								g_UndoRedo->AddUndo(&(HeightMap->GetMapTiles()[Selected]));
								HeightMap->SetTextureID(Selected,pDoc->m_SelTexture);
								HeightMap->SetTileType(Selected,pDoc->m_SelType);

								HeightMap->ApplyRandomness(Selected,pDoc->m_SelFlags);

//								DWORD Flags = HeightMap->GetTileFlags(Selected);
//								Flags &= TF_GEOMETRYMASK | TF_TYPEMASK;
//								Flags |= pDoc->m_SelFlags;
//								HeightMap->SetTileFlags(Selected,Flags);

								if(pDoc->GetAutoHeight()) {
									HeightMap->SetTileHeightUndo(Selected,(float)HeightMap->GetSeaLevel());
									g_UndoRedo->EndGroup();
									m_HeightsChanged = TRUE;
								}
								pDoc->Invalidate3D();
							} else {
								g_UndoRedo->AddUndo(&(HeightMap->GetMapTiles()[Selected]));
								HeightMap->SetTextureID(Selected,pDoc->m_SelTexture);
								HeightMap->SetTileType(Selected,pDoc->m_SelType);

								HeightMap->ApplyRandomness(Selected,pDoc->m_SelFlags);

//								DWORD Flags = HeightMap->GetTileFlags(Selected);
//								Flags &= TF_GEOMETRYMASK | TF_TYPEMASK;
//								Flags |= pDoc->m_SelFlags;
//								HeightMap->SetTileFlags(Selected,Flags);

								pDoc->RedrawFace(Selected);
							}
							UpdateAndValidate();
						}
					}
  				}
				break;

			case ET_EDGEPAINT:
				if(Selected >= 0) {
					AutoScroll(point);
					if(Selected != LastSelected) {
						LastSelected = Selected;

						int mw = pDoc->GetMapWidth();
						int y = Selected / mw;
						int x = Selected - (y*mw);
						if(pDoc->GetEdgeBrush()->Paint(x,y,pDoc->GetAutoHeight())) {
							m_HeightsChanged = TRUE;
						}

						UpdateAndValidate();
						pDoc->Invalidate3D();
					}
				}
				break;

			case ET_EDGEFILL:
   				if(Selected >= 0) {
					pDoc->GetEdgeBrush()->FillMap(Selected,pDoc->m_SelTexture,pDoc->m_SelType,pDoc->m_SelFlags);
					m_HeightsChanged = TRUE;
					UpdateAndValidate();
					pDoc->Invalidate3D();
				}
				break;

			case ET_BRUSHPAINT:
				break;

			case ET_HIDETILE:
				if(Selected >= 0) {
					if(Selected != LastSelected) {
						LastSelected = Selected;

						g_UndoRedo->AddUndo(&(HeightMap->GetMapTiles()[Selected]));
						AutoScroll(point);
   						pDoc->GetHeightMap()->SetTileVisible(Selected,TF_HIDE);
						UpdateAndValidate();
						pDoc->Invalidate3D();
					}
  				}
				break;

			case ET_SHOWTILE:
   				if(Selected >= 0) {
					if(Selected != LastSelected) {
						LastSelected = Selected;

						g_UndoRedo->AddUndo(&(HeightMap->GetMapTiles()[Selected]));
						AutoScroll(point);
   						pDoc->GetHeightMap()->SetTileVisible(Selected,TF_SHOW);
						UpdateAndValidate();
						pDoc->Invalidate3D();
					}
  				}
				break;

			case ET_FILL:
   				if(Selected >= 0) {
					g_UndoRedo->AddUndo(&(HeightMap->GetMapTiles()[Selected]));
					if(pDoc->m_SelIsTexture) {
   						pDoc->FillMap(Selected,pDoc->m_SelTexture,pDoc->m_SelType,pDoc->m_SelFlags);
						UpdateAndValidate();
						pDoc->Invalidate3D();
					}
   				}
				break;

			case ET_COPYRECT:
				switch(CopyRectCorners) {
					case	0:
					case	2:
		   				CopyRect0 = pDoc->Select2DFace(point.x,point.y,ScrollPos.x,ScrollPos.y);
						CopyRectCorners=1;
						break;
					case	1:
						AutoScroll(point);
		   				CopyRect1 = pDoc->Select2DFace(point.x,point.y,ScrollPos.x,ScrollPos.y);
						pDoc->Update2DView(-1,CopyRect0,CopyRect1);
						ValidateRect(NULL);
						break;
				}
				break;

			case ET_MARKRECT:
				switch(MarkRectCorners) {
					case	0:
					case	2:
		   				MarkRect0 = pDoc->Select2DFace(point.x,point.y,ScrollPos.x,ScrollPos.y);
						HeightMap->SetSelectionBox0(MarkRect0);
						MarkRectCorners=1;
						break;
					case	1:
						AutoScroll(point);
		   				MarkRect1 = pDoc->Select2DFace(point.x,point.y,ScrollPos.x,ScrollPos.y);
						HeightMap->SetSelectionBox1(MarkRect1);
						UpdateAndValidate();
//						pDoc->Update2DView(-1,MarkRect0,MarkRect1);
//						ValidateRect(NULL);
						break;
				}
				break;

//			case ET_PASTERECT:
//				if(Selected != LastSelected) {
//					LastSelected = Selected;
//
//					AutoScroll(point);
//					pDoc->PasteTileRect(Selected);
//					m_HeightsChanged = TRUE;
//					UpdateAndValidate();
//  					pDoc->Invalidate3D();
//				}
//				break;
		}
	}
}
Exemple #10
0
void CWFView::OnMouseMove(UINT nFlags, CPoint point) 
{
	static BOOL OldPosValid = FALSE;
	static CPoint OldPos(0,0);
	int XVel=0;
	int YVel=0;
	CBTEditDoc* pDoc = GetDocument();
	CHeightMap *HeightMap = pDoc->GetHeightMap();

	if(OldPosValid) {
		XVel = point.x - OldPos.x;
		YVel = point.y - OldPos.y;
	}
	OldPos = point;
	OldPosValid = TRUE;

	m_MouseX = point.x;
	m_MouseY = point.y;

	if(pDoc->Get2DMode() == M2D_WORLD) {
		BOOL UpdateStatus = TRUE;
		CPoint ScrollPos = GetScrollPosition();
		ScrollPos.x -= pDoc->GetTextureWidth()*OVERSCAN;
		ScrollPos.y -= pDoc->GetTextureHeight()*OVERSCAN;

		if(pDoc->ProcessButtonLapse()) {
			if((pDoc->GetEditTool() == ET_GATEWAY) && m_GotFocus) {
				if(GateMode == GATE_POSEND) {
					int Selected = pDoc->Select2DFace(point.x,point.y,ScrollPos.x,ScrollPos.y);

					GateX1 = Selected%pDoc->GetMapWidth();
					GateY1 = Selected/pDoc->GetMapWidth();
					pDoc->GetHeightMap()->SetGateway(GateIndex,GateX0,GateY0,GateX1,GateY1);

					UpdateAndValidate();
				}
			} else if( nFlags & MK_LBUTTON ) {
				if(m_DragMode == DM_DRAGOBJECT) {
					if((m_MouseX > (SLONG)pDoc->GetMapWidth()) ||
						(m_MouseY > (SLONG)pDoc->GetMapHeight())) {
						switch(pDoc->GetEditTool()) {
							case ET_MOVE:
								UpdateStatus = FALSE;
								AutoScroll(point);
								PositionSelectedObjects(point);
								break;

							case ET_ROTATEOBJECT:
								if(m_ObjectID >= 0) {
									D3DVECTOR Rotation;

									UpdateStatus = FALSE;
									HeightMap->Select3DObject(m_ObjectID);

									HeightMap->Get3DObjectRotation(m_ObjectID,Rotation);
									Rotation.y += XVel;
									if(Rotation.y >= 360.0F) {
										Rotation.y -= 360.0F;
									}
									if(Rotation.y < 0.0F) {
										Rotation.y += 360.0F;
									}
									HeightMap->Set3DObjectRotation(m_ObjectID,Rotation);

									UpdateAndValidate();
									pDoc->Invalidate3D();
								}
								break;
						}
					} else {
						UpdateStatus = FALSE;
						ApplyTool(point);
					}
				} else {
					UpdateStatus = FALSE;
					ApplyTool(point);
				}
			} else {
				if( (pDoc->GetEditTool() == ET_PASTERECT) && pDoc->ClipboardIsValid() ) {
   					int Selected = pDoc->Select2DFace(point.x,point.y,ScrollPos.x,ScrollPos.y);
					if(Selected >= 0) {
						HeightMap->SetSelectionBox(Selected,pDoc->m_TileBufferWidth-1,pDoc->m_TileBufferHeight-1);
						HeightMap->ClipSelectionBox();
						UpdateAndValidate();
					}
				}
			}
		}

		if(UpdateStatus) {
			// Update the status bar.
			int Selected = pDoc->Select2DFace(point.x,point.y,ScrollPos.x,ScrollPos.y);
			if(Selected >= 0) {
				g_CursorTileX = Selected % pDoc->GetMapWidth();
				g_CursorTileZ = Selected / pDoc->GetMapWidth();
			} else {
				g_CursorTileX = -1;
				g_CursorTileZ = -1;
			}
			pDoc->UpdateStatusBar();
		}

	}

	CScrollView::OnMouseMove(nFlags, point);
}
void CAutoScrollView::OnLButtonDown(UINT nFlags, CPoint point)
   {
   CScrollView::OnLButtonDown(nFlags, point);
   AutoScroll(WM_LBUTTONUP);
   }
Exemple #12
0
long DoCommand( HWND hWindow, WPARAM wParam, LPARAM lParam )
/***********************************************************************/
{
FNAME szFileName;
LPFRAME lpFrame;
LPOBJECT lpObject, lpBase;
RECT rect, rMask, rTemp, rAll;
HWND hWnd;
STRING szString;
int i, idFileType, x, y, dx, dy;
BOOL fDoZoom, bPrint, fHasZoom;
LPSTR lpszCmdLine;
HGLOBAL hMem;
ITEMID idDataType;
DWORD dwReturn;
int NewShape;
UINT wID;

SoundStartID( wParam, NO/*bLoop*/, NULL/*hInstance*/ );
/*
	WIN16:	ID          = wParam
			ctrl handle = LOWORD(lParam)
			notify code = HIWORD(lParam)

	WIN32:	ID          = LOWORD(wParam)
			ctrl handle = lParam
			notify code = HIWORD(wParam)
*/

#ifdef WIN32
	wID = LOWORD(wParam);
#else
	wID = wParam;
#endif

switch (wID)
	{
	case IDM_EXIT:
	DeactivateTool();
	PostMessage( hWndAstral, WM_CLOSE, 0, 0L);
    Delay (750);
	break;

	case IDM_CLOSE:
	DeactivateTool();
	/* Check to see if the image needs to be saved */
	if ( !ConfirmClose(NO,NO) )
		break;
	CloseImage( NO, lpImage ); // Close the active image
	break;

	case IDM_ABOUT:
	/* Bring up the modal 'About' dialog box */
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_ABOUT, DlgAboutProc);
	break;

	case IDM_NEXTPAGE:
	if ( !lpImage )
		break;
	DeactivateTool();
	SendMessage( lpImage->hWnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0L );
	break;

	case IDM_NEW:
	DeactivateTool();
	SoundStartResource( "magic01", NO, NULL );
	AstralCursor( IDC_WAIT );
	New( Control.NewWidth, Control.NewHeight, Control.NewResolution,
		Control.NewDepth );
	AstralCursor( NULL );
	break;

	case IDM_OPEN:
	DeactivateTool();
	/* Bring up the modal 'File Open' box */
	if ( !(dwReturn = DoOpenDlg( hWindow, IDD_OPEN,
		Save.FileType, szFileName, NO )) )
		break;
	idFileType = LOWORD( dwReturn );
	Save.FileType = idFileType;
	PutDefaultInt( "FileType", idFileType - IDN_TIFF );
	AstralImageLoad( idFileType, szFileName, MAYBE, YES );
	break;

	case IDM_ALTOPEN:
	DeactivateTool();
	// Command line sent from a second instance prior to it closing
	/* If the caller passed in a file name, try to load it or print it */
	if ( !(lpszCmdLine = (LPSTR)lParam) )
		break;
	HandleCommandLine( hWindow, lpszCmdLine, &bPrint );
	break;

	case IDM_SAVE:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVEAS:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVESPECIAL:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVEWALLPAPER:
	DeactivateTool();
	SaveWallpaper( "CRAYOLA", NO/*fTiled*/ );
	break;

	case IDM_REVERT:
	if ( !lpImage )
		break;
	DeactivateTool();
	if ( lpImage->fUntitled ) // If the picture doesn't have a name, get out
		break;
	if ( ImgChanged(lpImage) )
		{
		/* Check to see if its OK to trash changes */
		if ( AstralOKCancel(IDS_OKTOREVERT,
				(LPSTR)lpImage->CurFile) == IDCANCEL )
			break;
		}
	lstrcpy( szFileName, lpImage->CurFile );
	idFileType = lpImage->FileType;
	fDoZoom = IsZoomed(lpImage->hWnd);
	fHasZoom = Window.fHasZoom;
	CloseImage( NO, lpImage ); // Close the active image
	if ( !AstralImageLoad( idFileType, szFileName, fDoZoom, YES ) )
		break;
	break;

	case IDM_RECALLIMAGE0:
	case IDM_RECALLIMAGE1:
	case IDM_RECALLIMAGE2:
	case IDM_RECALLIMAGE3:
	case IDM_RECALLIMAGE4:
	case IDM_RECALLIMAGE5:
	case IDM_RECALLIMAGE6:
	case IDM_RECALLIMAGE7:
	case IDM_RECALLIMAGE8:
	case IDM_RECALLIMAGE9:
	DeactivateTool();
	GetMenuString( GetMenu(hWindow), wID,
		szFileName, sizeof(szFileName), MF_BYCOMMAND );
	i = 0;
	while ( szFileName[i] && szFileName[i] != ' ' )
		i++; // Skip over the numeric id in the string (3. junk.tif)
	lstrcpy(szString, &szFileName[i+1]);
	GetRecallFileName(szString);
	AstralImageLoad( NULL, szString, MAYBE, YES );
	break;

	case IDM_PRINT:
	if ( !lpImage )
		break;
	DeactivateTool();
	AstralCursor( IDC_WAIT );
	DoPrintSizeInits();
	SoundStartResource( "print", YES, NULL );
	PrintFile( hWindow, filename(lpImage->CurFile), YES, lpImage, NULL );
	SoundStop();
	AstralCursor( NULL );
	break;

	case IDM_PRINTSETUP:
	/* Bring up the setup dialog box for the active printer */
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_PRINTSETUP,
		DlgPrintSetupProc);
	break;

	case IDC_SOUND:
	SoundToggle();
	break;

	case IDM_UNDO:
	if ( !lpImage )
		break;
	DeactivateTool();
	ImgEditUndo(lpImage, YES, NO);
	break;

	case IDM_CUT:
	case IDM_COPY:
	if ( !lpImage )
		break;
	DeactivateTool();

	// Create the clipboard files from the image
	ProgressBegin(1, IDS_PROGCOPY);
	if ( !ImgWriteClipOut( lpImage, NULL, NULL, &rMask, lpImage->DataType ) )
		{
		ProgressEnd();
		Message(IDS_EMEMALLOC);
		break;
		}
	ProgressEnd();

	OpenClipboard(hWindow);
	EmptyClipboard();

	// Passing a NULL data handle in SetClipboardData() means that
	// the data will be requested in a WM_RENDERFORMAT message
	hMem = ConstructObject( lpImage,
		IsRectEmpty(&rMask)? (LPRECT)NULL : (LPRECT)&rMask );
	if ( pOLE )
		{ // Any data put on before Native will become staticly copied
		SetClipboardData( pOLE->cfNative, NULL );
		SetClipboardData( pOLE->cfOwnerLink, hMem );
		}
	SetClipboardData( CF_DIB, NULL );
	if ( Control.DoPicture )
		SetClipboardData( CF_METAFILEPICT, NULL );
	if ( Control.DoBitmap )
		SetClipboardData( CF_BITMAP, NULL );
	SetClipboardData( CF_PALETTE, NULL );
	SetClipboardData( Control.cfImage, NULL );
	if ( pOLE && wID == IDM_COPY && !lpImage->fUntitled )
		{ // ObjectLink is retrieved during a Paste Link...
		SetClipboardData( pOLE->cfObjectLink, hMem );
		}
	CloseClipboard();
	if ( wID == IDM_COPY )
		break;

	// else fall through to IDM_DELETE

	case IDM_DELETE:
	if ( !lpImage )
		break;
	{
	COLORINFO ColorInfo;

	DeactivateTool();
	ColorInfo.gray   = 255;
	SetColorInfo( &ColorInfo, &ColorInfo, CS_GRAY );
	TintFill( lpImage, &ColorInfo, 255, MM_NORMAL,
		wID == IDM_CUT ? IDS_UNDOCUT : IDS_UNDODELETE );
	}
	break;

	case IDM_PASTE:
	if ( !lpImage )
		break;

	case IDM_PASTEASNEW:
	if ( !OpenClipboard(hWndAstral) )
		{
		Message( IDS_ECLIPOPEN );
		break;
		}
	if ( !IsClipboardFormatAvailable(CF_DIB) &&
	     !IsClipboardFormatAvailable(CF_BITMAP) &&
	     !IsClipboardFormatAvailable(Control.cfImage) )
		{
		Message( IDS_ECLIPOPEN );
		CloseClipboard();
		break;
		}
	CloseClipboard();

	DeactivateTool();
	// First put clipboard contents into a file(s)
	AstralCursor(IDC_WAIT);
	if ( !PasteFromClipboard( hWindow, (wID == IDM_PASTE) /*fNeedMask*/ ) )
		{
		AstralCursor(NULL);
		Message(IDS_EMEMALLOC);
		break;
		}
	if ( wID == IDM_PASTE )
		{
		ProgressBegin(1, IDS_PROGPASTECLIP);
		TransformObjectsStart( YES/*fNewObject*/ );
        if ( ImgCreateClipInObject( lpImage, NO ) )
			;
		ProgressEnd();
		}
	else
	if ( wID == IDM_PASTEASNEW )
		{
		if ( lpFrame = AstralFrameLoad( Names.PasteImageFile, -1,
			 &idDataType, &idFileType) )
			{
			if ( NewImageWindow(
				NULL,			// lpOldFrame
				NULL,			// Name
				lpFrame, 		// lpNewFrame
				idFileType,		// lpImage->FileType
				idDataType,		// lpImage->DataType
				FALSE,			// New view?
				IMG_DOCUMENT,	// lpImage->DocumentType
				NULL,			// lpImage->ImageName
				MAYBE
				) )
					lpImage->fChanged = YES;
			}
		}
	break;

	case IDM_ESCAPE:
	if (!lpImage)
		break;
	if (lpImage->hWnd == hZoomWindow)
		break;
	if ( Tool.bActive && Tool.lpToolProc )
		DestroyProc( lpImage->hWnd, 1L );
	break;

	case IDM_SIZEUP:
	case IDM_SIZEDOWN:
	if (!Retouch.hBrush)
		break;				 
	SetFocus( hWindow ); // Take focus away from any controls
	if ( Retouch.BrushShape == IDC_BRUSHCUSTOM )
		break;
	if ( wID == IDM_SIZEUP )
    {
    	if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 ))
    		Retouch.BrushSize += 2;
        else        
    		Retouch.BrushSize++;
    }
	else	
    {
    	if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 )) 
    		Retouch.BrushSize -= 2;
        else        
    		Retouch.BrushSize--;
    }
	if ( Retouch.BrushSize < 1 || Retouch.BrushSize > MAX_BRUSH_SIZE )
		{
		Retouch.BrushSize = bound( Retouch.BrushSize, 1,MAX_BRUSH_SIZE);
		MessageBeep(0);
		break;
		}
	if (lpImage)
		DisplayBrush(0, 0, 0, OFF);
	SetMgxBrushSize(Retouch.hBrush, Retouch.BrushSize);
	if (lpImage && Window.hCursor == Window.hNullCursor)
		DisplayBrush(lpImage->hWnd, 32767, 32767, ON);
	if ( Tool.hRibbon )
		SetSlide( Tool.hRibbon, IDC_BRUSHSIZE, Retouch.BrushSize );
	break;

	case IDM_SHAPEUP:
	case IDM_SHAPEDOWN:
	if (!Retouch.hBrush)
		break;
	SetFocus( hWindow ); // Take focus away from any controls
	NewShape = Retouch.BrushShape;
	if ( wID == IDM_SHAPEUP )
		NewShape++;
	else	NewShape--;
	if ( NewShape > IDC_BRUSHCUSTOM )
		NewShape = IDC_BRUSHCIRCLE;
	if ( NewShape < IDC_BRUSHCIRCLE )
		NewShape = IDC_BRUSHCUSTOM;
	if (lpImage)
	 	DisplayBrush(0, 0, 0, OFF);
	if (!SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush))
		{
		NewShape = IDC_BRUSHCIRCLE;
		SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush);
		}
	Retouch.BrushShape = NewShape;
	if (lpImage && Window.hCursor == Window.hNullCursor)
	 	DisplayBrush(lpImage->hWnd, 32767, 32767, ON);
	if ( Tool.hRibbon )
		{
		CheckComboItem( Tool.hRibbon, IDC_BRUSHSHAPE, IDC_BRUSHCIRCLE,
			IDC_BRUSHCUSTOMNEW, Retouch.BrushShape );
		SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L );
		}
	break;

	case IDM_MOVEUP:
	case IDM_MOVEDOWN:
	case IDM_MOVELEFT:
	case IDM_MOVERIGHT:
	if (!lpImage)
		break;
	lpBase = ImgGetBase(lpImage);
	if (ImgGetSelObject(lpImage, NULL) == lpBase)
		break;
	dx = dy = 0;
	if (wID == IDM_MOVEUP)
		--dy;
	if (wID == IDM_MOVEDOWN)
		++dy;
	if (wID == IDM_MOVELEFT)
		--dx;
	if (wID == IDM_MOVERIGHT)
		++dx;
	lpObject = NULL;
	while (lpObject = ImgGetSelObject(lpImage, lpObject))
		{
		rect = lpObject->rObject;
		OffsetRect(&rect, dx, dy);
		if (!AstralIntersectRect(&rTemp, &lpBase->rObject, &rect))
			break;
		}
	if (lpObject)
		break;
	AstralSetRectEmpty(&rAll);
	lpObject = NULL;
	while (lpObject = ImgGetSelObject(lpImage, lpObject))
		{
		rect = lpObject->rObject;
		OffsetRect(&lpObject->rObject, dx, dy);
		AstralUnionRect(&rAll, &rAll, &lpObject->rObject);
		if (!lpObject->Pixmap.fNewFrame &&
				EqualRect(&rect, &lpObject->rUndoObject))
			lpObject->rUndoObject = lpObject->rObject;
		UpdateImage(&rect, TRUE);
		UpdateImage(&lpObject->rObject, TRUE);
		}
	if (wID == IDM_MOVEUP)
		{
		x = (rAll.left + rAll.right)/2;
		y = rAll.top;
		}
	else
	if (wID == IDM_MOVEDOWN)
		{
		x = (rAll.left + rAll.right)/2;
		y = rAll.bottom;
		}
	else
	if (wID == IDM_MOVELEFT)
		{
		x = rAll.left;
		y = (rAll.top + rAll.bottom)/2;
		}
	else
	if (wID == IDM_MOVERIGHT)
		{
		x = rAll.right;
		y = (rAll.top + rAll.bottom)/2;
		}
	File2Display(&x, &y);
	AutoScroll(lpImage->hWnd, x, y);
	AstralUpdateWindow(lpImage->hWnd);
	DisplayInfo(-1, &rAll);
	break;

	case IDM_LASTTOOL:
	DeactivateTool();
	if ( Tool.idLast && (hWnd = AstralDlgGet(IDD_MAIN)) )
		SendMessage( hWnd, WM_COMMAND, Tool.idLast, 2L);
	break;

	case IDM_PREF:
	// prevent problems if running animations and they change
	// the wave mix dll setting in preferences
	StopAnimation();
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_PREF, DlgPrefProc );
	break;

	case IDC_VIEWLAST: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;
	RevertLastView();
	break;

//	case IDC_VIEWFULL: // duplicate of function in the view ribbon
//	if ( !lpImage )
//		break;
//	AstralDlg( NO, hInstAstral, hWindow, IDD_VIEWFULL, DlgFullScreenViewProc );
//	break;

	case IDC_VIEWALL: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;
	ViewAll();
	break;

	case IDC_ZOOMIN: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;

	if (!lpImage->lpDisplay)
		break;

	if (!lpImage->lpDisplay->ViewPercentage)
		break;

	x = ( lpImage->lpDisplay->FileRect.left
			+ lpImage->lpDisplay->FileRect.right ) / 2;
	y = ( lpImage->lpDisplay->FileRect.top
			+ lpImage->lpDisplay->FileRect.bottom ) / 2;
	SaveLastView();
	Zoom(x,y, +100, YES, ( View.ZoomWindow ^ CONTROL ) );
	break;

	case IDC_ZOOMOUT: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;

	if (!lpImage->lpDisplay)
		break;

	if (!lpImage->lpDisplay->ViewPercentage)
		break;

	x = ( lpImage->lpDisplay->FileRect.left
			+ lpImage->lpDisplay->FileRect.right ) / 2;
	y = ( lpImage->lpDisplay->FileRect.top
			+ lpImage->lpDisplay->FileRect.bottom ) / 2;
	SaveLastView();
	Zoom(x,y, -100, YES,( View.ZoomWindow ^ CONTROL ) );
	break;

	case IDM_HELP:
	Control.Hints = !Control.Hints;
	PutDefInt (Control.Hints,Control.Hints);
	break;

	default:
	return( FALSE );
	}

return( TRUE );
}