void PAGE_INFO::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
    throw( IO_ERROR )
{
    aFormatter->Print( aNestLevel, "(page %s", aFormatter->Quotew( GetType() ).c_str() );

    // The page dimensions are only required for user defined page sizes.
    // Internally, the page size is in mils
    if( GetType() == PAGE_INFO::Custom )
        aFormatter->Print( 0, " %g %g",
                           GetWidthMils() * 25.4 / 1000.0,
                           GetHeightMils() * 25.4 / 1000.0 );

    if( !IsCustom() && IsPortrait() )
        aFormatter->Print( 0, " portrait" );

    aFormatter->Print( 0, ")\n" );
}
예제 #2
0
/**
* \author	Paul Henderson (PH, PTJK76)
* \date		August 2006 - Initial Creation, PH
*/
BOOL CALLBACK CSignature::SigProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
	
	P_COORDXY		pPoint;
	CSignature		*pObj;
	HDC				hdc;
	PAINTSTRUCT		ps;
	static			bool bOffScreen;

	switch(message)
	{
	case WM_COMMAND:
		if (HIWORD(wParam) == BN_CLICKED)
		{
			// One of the buttons has been pressed
			pObj = (CSignature *)GetWindowLong(hWnd, GWL_USERDATA);

			if (pObj->m_pCallback)
				pObj->m_pCallback->OnClick (LOWORD(wParam));
		}

		break;
	
	case WM_LBUTTONDOWN:
		//grab a pointer to the object members
		pObj = (CSignature *)GetWindowLong(hWnd, GWL_USERDATA);
		if(LOWORD(lParam) && HIWORD(lParam) ){
			pObj->m_pPrevPos = pObj->AddCoord(LOWORD(lParam),HIWORD(lParam),true);// the 'true' depicts a start line
			pObj->m_pCurrentVector = pObj->m_pCurrentPos;
		}
		pObj->m_bSigning = TRUE;
		break;
	
	case WM_LBUTTONUP:
		pObj = (CSignature *)GetWindowLong(hWnd, GWL_USERDATA);
		if (pObj->m_pCallback) {
			pObj->m_pCallback->MUP();
		}
		//  Allows signature capture to save the vectors and send them using 'VectorNavigate' 
		pObj->SendVectors();
		pObj->m_bSigning = FALSE;
		break;
		
	case WM_MOUSEOUT:
		pObj = (CSignature *)GetWindowLong(hWnd, GWL_USERDATA);
		//  Only send vectors if we are still signing otherwise we send the 
		//  last recorded vectors whenever the user clicks outside the Window.
		if (pObj->m_bSigning)
		{
			pObj->m_bSigning = FALSE;
			if (pObj->m_pCallback) {
				pObj->m_pCallback->MUP();
			}
			pObj->SendVectors();
		}
		break;

	case WM_MOUSEMOVE:
		pObj = (CSignature *)GetWindowLong(hWnd, GWL_USERDATA);
		if(pObj->m_bSigning == FALSE){ //if we went offscreen
			pObj->m_pPrevPos = pObj->AddCoord(LOWORD(lParam),HIWORD(lParam),true);// the 'true' depicts a start line
			pObj->m_bSigning = TRUE;
		}
		
		//otherwise it is a valid onscreen coordinate
		pPoint = pObj->AddCoord(LOWORD(lParam),HIWORD(lParam),pObj->m_bNewLine);
		
		//check to make sure that we have a line to draw
		if(pPoint == NULL || pObj->m_pPrevPos == NULL)
			break;
		
		if(pPoint->bNewLine)
		{
			pObj->m_pPrevPos = 	pPoint;
			break;
		}

		//Draw the line
		hdc = GetDC(hWnd);
		//select the correct coloured pen
		SelectObject(hdc,CreatePen(PS_SOLID,pObj->m_iLineWidth,pObj->m_crLineColor));
				
		MoveToEx(hdc,pObj->m_pPrevPos->XPos,pObj->m_pPrevPos->YPos,NULL);
		LineTo(hdc,LOWORD(lParam),HIWORD(lParam));
		DeleteObject(SelectObject(hdc,GetStockObject(BLACK_PEN)));
		ReleaseDC(hWnd,hdc);
		pObj->m_pPrevPos = pPoint;
		break;	
			
	case WM_PAINT:
		pObj = (CSignature *)GetWindowLong(hWnd, GWL_USERDATA);
		hdc = BeginPaint(hWnd,&ps);
		pObj->RePaintBox(hdc,TRUE,pObj->buttons);// second param paint background
		EndPaint(hWnd, &ps);
		break;
	
	case WM_DESTROY:
		pObj = (CSignature *)GetWindowLong(hWnd, GWL_USERDATA);
		pObj->DeleteSigMem();
		break;
	case WM_SETTINGCHANGE:
		 pObj = (CSignature *)GetWindowLong(hWnd, GWL_USERDATA);
		 if (IsLandScape() && pObj->buttons )
		  {
			int my1=GetSystemMetrics(SM_CYSCREEN);
			int mx1=GetSystemMetrics(SM_CXSCREEN);
			int mx2=(pObj->m_iSigBoxHeight)+(int)(0.17 * (pObj->m_iSigBoxHeight));
			int my2=(pObj->m_iSigBoxWidth)-(int)(0.145 * (pObj->m_iSigBoxWidth));
				
	        // Create child buttons if needed
			if(pObj->buttons)
			{
				RECT rect;
				int width = 128;
				int height = 64;
				int top, left;
				int screenwidth,screenheight;

				// Remember interface to handle callbacks
				//m_pCallback = pcallback;

				// Get the size of the text in the buttons
				HWND hwnd1 = CreateWindow (L"BUTTON", L"", WS_CHILD, 0, 0, 0, 0, hWnd, (HMENU) 0, pObj->m_hInstance, NULL);
				HDC hdc = GetDC (hwnd1);

				SIZE size;
				GetTextExtentPoint32 (hdc, L"Capture", 7, &size);

				ReleaseDC (hwnd1, hdc);
				DestroyWindow (hwnd1);

				DEBUGMSG (TRUE, (L"Button size %d x %d\r\n", size.cx, size.cy));

				width = (size.cx + 18);
				height = size.cy+3;

				// Position buttons near the bottom of the sig cap window
				GetClientRect (hWnd, &rect);
				screenwidth= GetSystemMetrics(SM_CXSCREEN);
				top = rect.bottom - height - 16;
				
				left = (int)(screenwidth*0.10);
				DestroyWindow (pObj->m_hwndClear);

				pObj->m_hwndClear= CreateWindow (L"BUTTON", L"Clear", WS_CHILD | WS_VISIBLE,
					 left, top, width, height, hWnd, (HMENU) IButtonNotification::ID_CLEAR, pObj->m_hInstance, NULL);
				
				left = (int)(screenwidth*0.40);
				DestroyWindow (pObj->m_hwndCapture);

				pObj->m_hwndCapture=CreateWindow (L"BUTTON", L"Capture", WS_CHILD | WS_VISIBLE,
					left, top, width, height, hWnd, (HMENU) IButtonNotification::ID_CAPTURE,pObj->m_hInstance, NULL);
				
				left = (int)(screenwidth*0.70);

				DestroyWindow (pObj->m_hwndCancel);
			
				pObj->m_hwndCancel=CreateWindow (L"BUTTON", L"Cancel", WS_CHILD | WS_VISIBLE,
					left, top, width, height, hWnd, (HMENU) IButtonNotification::ID_CANCEL, pObj->m_hInstance, NULL);
				left += (width + 16);

			}
			SetWindowPos(hWnd,NULL,pObj->m_iCoordX,pObj->m_iCoordY,mx2,my2,SWP_SHOWWINDOW);
		 }
		 else if(IsPortrait() && pObj->buttons)
		 {
			// Create child buttons if needed
			if (pObj->buttons)
			{
				RECT rect;
				int width = 128;
				int height = 64;
				int top, left;
				int screenwidth,screenheight;

				// Remember interface to handle callbacks
				//m_pCallback = pcallback;

				// Get the size of the text in the buttons
				HWND hwnd1 = CreateWindow (L"BUTTON", L"", WS_CHILD, 0, 0, 0, 0, hWnd, (HMENU) 0, pObj->m_hInstance, NULL);
				HDC hdc = GetDC (hwnd1);

				SIZE size;
				GetTextExtentPoint32 (hdc, L"Capture", 7, &size);

				ReleaseDC (hwnd1, hdc);
				DestroyWindow (hwnd1);

				DEBUGMSG (TRUE, (L"Button size %d x %d\r\n", size.cx, size.cy));

				width = (size.cx + 18);
				height = size.cy+3;

				// Position buttons near the bottom of the sig cap window
				GetClientRect (hWnd, &rect);
				screenheight=GetSystemMetrics(SM_CYSCREEN);
				screenwidth= GetSystemMetrics(SM_CXSCREEN);
				if( rect.bottom <= screenheight ){
					top = rect.bottom - height - 16;
				}
				else{
					top = screenheight - height - 16;
				}
				
				left = (int)(screenwidth*0.10);
				DestroyWindow (pObj->m_hwndClear);


				pObj->m_hwndClear= CreateWindow (L"BUTTON", L"Clear", WS_CHILD | WS_VISIBLE,
					 left, top, width, height, hWnd, (HMENU) IButtonNotification::ID_CLEAR, pObj->m_hInstance, NULL);
				
				left = (int)(screenwidth*0.40);
				DestroyWindow (pObj->m_hwndCapture);

				pObj->m_hwndCapture=CreateWindow (L"BUTTON", L"Capture", WS_CHILD | WS_VISIBLE,
					left, top, width, height, hWnd, (HMENU) IButtonNotification::ID_CAPTURE,pObj->m_hInstance, NULL);
				
				left = (int)(screenwidth*0.70);

				DestroyWindow (pObj->m_hwndCancel);
			
				pObj->m_hwndCancel=CreateWindow (L"BUTTON", L"Cancel", WS_CHILD | WS_VISIBLE,
					left, top, width, height, hWnd, (HMENU) IButtonNotification::ID_CANCEL, pObj->m_hInstance, NULL);
				left += (width + 16);
			}
			SetWindowPos(hWnd,NULL,pObj->m_iCoordX,pObj->m_iCoordY,pObj->m_iSigBoxWidth,pObj->m_iSigBoxHeight,SWP_SHOWWINDOW);
		  }
		  else{
			  wprintf(L"NOTHING THIS IS");
		  }
		  break;	
	 default:
		return DefWindowProc(hWnd,message, wParam, lParam);		
  }
  return TRUE;
}