//Shows the "Pen and brush settings" dialog
void ShowPenBrushSettings(HWND hParent, PBTabs tabToShow)
{
	PenBrushSettingsDlgParam pbsdp(fgColor,bgColor,tabToShow);
	//Show the dialog box
	if(DialogBoxParam(hCurInstance,MAKEINTRESOURCE(IDD_PENBRUSHSETTINGS),hParent,PBDialogProc,(LPARAM)&pbsdp)==IDABORT)
		CleanUp();
	//Refresh the color pane
	InvalidateRect(GetDlgItem(hToolBoxWindow,IDC_TB_COLORPAL),NULL,FALSE);
	//Update the updown
	SetPenWidth(fgColor.GetPenWidth());
	return;
}
示例#2
0
void WinEDA_PrintFrame::OnPrintPreview(wxCommandEvent& event)
/************************************************************/
/* Open and display a previewer frame for printing
*/
{
wxSize WSize;
wxPoint WPos;
int x, y;
bool print_ref = TRUE;

wxSpinEvent spinevent;

	SetScale(event);
	SetPenWidth(spinevent);

	if ( m_PagesOption )
		s_OptionPrintPage = m_PagesOption->GetSelection();

	if ( (m_Print_Sheet_Ref == NULL) || (m_Print_Sheet_Ref->GetValue() == FALSE) )
		print_ref = FALSE;

	// Pass two printout objects: for preview, and possible printing.
wxString title = BuildPrintTitle();
	wxPrintPreview *preview =
		new wxPrintPreview(new EDA_Printout(this, m_Parent, title, print_ref),
				new EDA_Printout(this, m_Parent, title, print_ref), g_PrintData);
	if ( preview == NULL )
		{
		DisplayError(this, _("There was a problem previewing"));
		return;
		}
#ifdef PCBNEW
	if ( s_OptionPrintPage ) SetLayerMaskFromListSelection();
#endif

	m_Parent->GetPosition(&x, &y);
	WPos.x = x + 4;
	WPos.y = y + 25;

	WSize = m_Parent->GetSize();
	WSize.x -= 3;
	WSize.y += 6;
	preview->SetZoom(50);

	wxPreviewFrame *frame = new wxPreviewFrame(preview, (wxFrame*)this,
					title, WPos, WSize);
	if( frame == NULL ) return;

	frame->Initialize();
	frame->Show(TRUE);
}
示例#3
0
EXPORT_C void CHuiCanvasGc::SetDefaults()
	{
	SetTextStyle(0);
    SetPenColor(TRgb(255,255,255));
	SetPenWidth(1.0);
	SetOpacity(1.0);
	SetPolygonDrawMode(EHuiNoFill);
	SetTextAlign(EHuiAlignHLeft, EHuiAlignVTop);
    SetDrawMode(EHuiCanvasDrawModeBlend);
    EnableEffectiveOpacity(ETrue);    
    SetPolygonFillTexture(NULL);
    SetPolygonFillTextureOrigin(TPoint(0,0));
	CancelClipping();
	}
示例#4
0
void WinEDA_PrintFrame::EDA_PrintPage(wxCommandEvent& event)
/**********************************************************/
/* Called on activate "Print CURRENT" button
*/
{
bool print_ref = TRUE;

	SetScale(event);

	s_OptionPrintPage = 0;
	if ( m_PagesOption )
		s_OptionPrintPage = m_PagesOption->GetSelection();

	if ( (m_Print_Sheet_Ref == NULL) || (m_Print_Sheet_Ref->GetValue() == FALSE) )
		print_ref = FALSE;

#ifdef PCBNEW
	if ( s_OptionPrintPage ) SetLayerMaskFromListSelection();
#endif

wxSpinEvent spinevent;
	SetPenWidth(spinevent);

	wxPrintDialogData printDialogData( * g_PrintData);

	wxPrinter printer(& printDialogData);

wxString title = BuildPrintTitle();
	EDA_Printout printout(this, m_Parent, title, print_ref);

#ifndef __WINDOWS__
	wxDC * dc = printout.GetDC();
	((wxPostScriptDC*)dc)->SetResolution(600);	// Postscript DC resolution is 600 ppi
#endif

	if (!printer.Print(this, &printout, TRUE))
		{
        if (wxPrinter::GetLastError() == wxPRINTER_ERROR)
	    DisplayError(this, _("There was a problem printing") );
        return;
        }
	else
		{
		* g_PrintData = printer.GetPrintDialogData().GetPrintData();
		}
}
void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
{
    PCB_PLOT_PARAMS plot_opts = m_parent->GetPlotSettings();

    s_Parameters.m_PrintMirror = m_Print_Mirror->GetValue();
    s_Parameters.m_Print_Sheet_Ref = m_Print_Sheet_Ref->GetValue();
    s_Parameters.m_Print_Black_and_White =
        m_ModeColorOption->GetSelection() != 0;

    s_Parameters.m_DrillShapeOpt =
        (PRINT_PARAMETERS::DrillShapeOptT) m_Drill_Shape_Opt->GetSelection();

    if( m_PagesOption )
        s_Parameters.m_OptionPrintPage = m_PagesOption->GetSelection() != 0;

    SetLayerSetFromListSelection();

    int idx = m_ScaleOption->GetSelection();
    s_Parameters.m_PrintScale =  s_ScaleList[idx];
    plot_opts.SetScale( s_Parameters.m_PrintScale );

    if( m_FineAdjustXscaleOpt )
    {
        if( s_Parameters.m_XScaleAdjust > MAX_SCALE ||
            s_Parameters.m_YScaleAdjust > MAX_SCALE )
            DisplayInfoMessage( NULL, _( "Warning: Scale option set to a very large value" ) );
        m_FineAdjustXscaleOpt->GetValue().ToDouble( &s_Parameters.m_XScaleAdjust );
    }
    if( m_FineAdjustYscaleOpt )
    {
        // Test for a reasonnable scale value
        if( s_Parameters.m_XScaleAdjust < MIN_SCALE ||
            s_Parameters.m_YScaleAdjust < MIN_SCALE )
            DisplayInfoMessage( NULL, _( "Warning: Scale option set to a very small value" ) );
        m_FineAdjustYscaleOpt->GetValue().ToDouble( &s_Parameters.m_YScaleAdjust );
    }

    plot_opts.SetFineScaleAdjustX( s_Parameters.m_XScaleAdjust );
    plot_opts.SetFineScaleAdjustY( s_Parameters.m_YScaleAdjust );

    m_parent->SetPlotSettings( plot_opts );

    SetPenWidth();
}
示例#6
0
void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
{
    SetPenWidth();
    m_printBW = m_ModeColorOption->GetSelection();
    m_oneFileOnly = m_rbFileOpt->GetSelection() == 1;

    if( m_config )
    {
        m_config->Write( PLOTSVGMODECOLOR_KEY, m_printBW );
        m_config->Write( PLOTSVGPAGESIZEOPT_KEY, m_rbSvgPageSizeOpt->GetSelection() );
        m_config->Write( PLOTSVGPLOT_BRD_EDGE_KEY, m_PrintBoardEdgesCtrl->GetValue() );

        wxString layerKey;

        for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
        {
            if( m_boxSelectLayer[layer] == NULL )
                continue;

            layerKey.Printf( OPTKEY_LAYERBASE, layer );
            m_config->Write( layerKey, m_boxSelectLayer[layer]->IsChecked() );
        }
    }

    // Set output directory and replace backslashes with forward ones
    wxString dirStr;
    dirStr = m_outputDirectoryName->GetValue();
    dirStr.Replace( wxT( "\\" ), wxT( "/" ) );

    if( dirStr != m_parent->GetPlotSettings().GetOutputDirectory() )
    {
        PCB_PLOT_PARAMS tempOptions( m_parent->GetPlotSettings() );
        tempOptions.SetOutputDirectory( dirStr );
        m_parent->SetPlotSettings( tempOptions );
        m_parent->OnModify();
    }

    EndModal( 0 );
}
示例#7
0
void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
{
    m_outputDirectory = m_outputDirectoryName->GetValue();

    // Create output directory if it does not exist (also transform it in
    // absolute form). Bail if it fails
    wxFileName outputDir = wxFileName::DirName( m_outputDirectory );
    wxString boardFilename = m_board->GetFileName();
    WX_TEXT_CTRL_REPORTER reporter( m_messagesBox );

    if( !EnsureOutputDirectory( &outputDir, boardFilename, &reporter ) )
    {
        wxString msg;
        msg.Printf( _( "Could not write plot files to folder \"%s\"." ),
                    GetChars( outputDir.GetPath() ) );
        DisplayError( this, msg );
        return;
    }

    m_printMirror = m_printMirrorOpt->GetValue();
    m_printBW = m_ModeColorOption->GetSelection();
    SetPenWidth();

    // Build layers mask
    LAYER_MSK printMaskLayer = NO_LAYERS;

    for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
    {
        if( m_boxSelectLayer[layer] && m_boxSelectLayer[layer]->GetValue() )
            printMaskLayer |= GetLayerMask( layer );
    }

    wxString    msg;

    for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
    {
        LAYER_MSK currlayer_mask = GetLayerMask( layer );

        if( (printMaskLayer & currlayer_mask ) == 0 )
            continue;

        wxString suffix = m_board->GetStandardLayerName( layer );

        if( aOnlyOneFile )
        {
            m_printMaskLayer = printMaskLayer;
            suffix = wxT( "brd" );
        }
        else
        {
            m_printMaskLayer = currlayer_mask;
            suffix = m_board->GetStandardLayerName( layer );
        }

        wxFileName fn(boardFilename);
        BuildPlotFileName( &fn, outputDir.GetPath(), suffix, SVGFileExtension );

        if( m_PrintBoardEdgesCtrl->IsChecked() )
            m_printMaskLayer |= EDGE_LAYER;

        if( CreateSVGFile( fn.GetFullPath() ) )
            msg.Printf( _( "Plot: %s OK\n" ), GetChars( fn.GetFullPath() ) );
        else    // Error
            msg.Printf( _( "** Unable to create %s **\n" ), GetChars( fn.GetFullPath() ) );
        m_messagesBox->AppendText( msg );

        if( aOnlyOneFile )
            break;
    }
}
void WinEDA_PrintFrame::OnPenWidthUpdated( wxSpinEvent& event )
{
	SetPenWidth(event);
}
示例#9
0
static int FaceEnrollWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int ret=0;
	RECT rect={142,221,180,240};

	switch (message) 
	{
		case MSG_CREATE:
			UpdateFaceRegWindow( hWnd, hdc);
			InitShowFaceImage();
			FaceRegState=FACE_REG_PREPARE;

			SetTimer(hWnd, IDC_FACE_TIMER1, IDC_TIMER_NUM);
			break;
		case MSG_ERASEBKGND:
                {
                        HDC hdc = (HDC)wParam;
                        const RECT* clip = (const RECT*)lParam;
                        BOOL fGetDC = FALSE;
                        RECT rcTemp;
                        if(hdc == 0)
                        {
                                hdc = GetClientDC(hWnd);
                                fGetDC = TRUE;
                        }

                        if(clip)
                        {
                                rcTemp = *clip;
                                ScreenToClient(hWnd, &rcTemp.left, &rcTemp.top);
                                ScreenToClient(hWnd,&rcTemp.right, &rcTemp.bottom);
                                IncludeClipRect(hdc, &rcTemp);
                        }
			UpdateFaceRegWindow(hWnd,hdc);

                        if(fGetDC) ReleaseDC (hdc);
                        	return 0;
                }
			return 0;
		
                case MSG_PAINT:
		{
			char buf[20];
                        hdc = BeginPaint(hWnd);
			SelectFont(hdc,gfont);
			SetTextColor(hdc,PIXEL_lightwhite);
       	 		SetBkMode(hdc,BM_TRANSPARENT);
                        SetPenColor(hdc,PIXEL_black);
    			SetBrushColor(hdc,PIXEL_lightgray);
			SetPenWidth(hdc, 2);
			LineEx(hdc,-1,221,322,222);
			FillBox(hdc,-1,223,322,20);
			if(RegBegin == REG_PREPARE)
			{
				sprintf(buf,"0%%");
				TextOut(hdc,145,225,buf);
			}
			else
			{
                        	SetBrushColor (hdc, PIXEL_blue);
                        	if(FaceCount>=FACE_NUM)  // 0,220,320,20
                        	{
                        	        FillBox(hdc,1,223,318,17);
					sprintf(buf,"100%%");
					TextOut(hdc,145,225,buf);
                        	}
                        	else if(FaceCount>0)
                        	{
                        	        FillBox(hdc,1,223,320*FaceCount/FACE_NUM,17);
					sprintf(buf,"%d%%",100*FaceCount/FACE_NUM);
					TextOut(hdc,145,225,buf);
                        	}
				else
				{
					sprintf(buf,"0%%");
					TextOut(hdc,145,225,buf);
				}
			}
                        EndPaint(hWnd,hdc);
		}
		return 0;
		case MSG_KEYDOWN:
			SetMenuTimeOut(time(NULL));
                        if (gOptions.KeyPadBeep)
                                ExKeyBeep();

			if(LOWORD(wParam) == SCANCODE_ESCAPE)
				PostMessage (hWnd, MSG_CLOSE, 0, 0);
			break;

		case MSG_TIMER:
			if (wParam == IDC_FACE_TIMER1)
			{
				KillTimer(hWnd, IDC_FACE_TIMER1);
				if(ismenutimeout)
				{
					PostMessage(hWnd, MSG_CLOSE, 0, 0);
					return 0;
				}
				hdc=GetClientDC(hWnd);
				if(FaceCount==0 && RegCnt==0 && RegBegin<= REG_PREPARE && gOptions.VoiceOn)
				{
					RegCnt=1;
					FaceRegState=FACE_REG_PREPARE;
					ShowFaceHint(hWnd , FACE_REG_PREPARE , hdc, &fvbg,1);
					if(gOptions.VoiceOn)
						ExPlayVoice(VOICE_FACE_START); //start...
					DelayMS(1000);
				}
				if(ShowCaptureFace( hWnd,HDC_SCREEN ,1)) //Extract face template ok
				{

					SetMenuTimeOut(time(NULL));
					ret=RegFaceTmpProc(f_pin);

					if(RET_SUCCESS==ret) //register success
					{
						SendMessage (hWnd, MSG_PAINT, FACE_NUM, 0) ;
						regok=1;
						if(gOptions.VoiceOn)
                                			ExPlayVoice(VOICE_THANK); 
						DelayMS(500);
						PostMessage (hWnd, MSG_CLOSE, 0, 0);
					}
					else if(RET_FAILED==ret) // register failed
					{
						PostMessage (hWnd, MSG_CLOSE, 0, 0);
					}
					else if(RET_SAME==ret && RegBegin != REG_PREPARE) // move face
					{
						ShowFaceHint(hWnd , HINT_FCHG ,hdc, &fvbg,1);
					}
					else if(RET_CONTINUE==ret)
					{
						if(RegBegin != REG_PREPARE)
						{
							SendMessage (hWnd, MSG_PAINT , FaceCount, 0) ;
							if(FaceCount == 0)
							{
								FaceRegState=FACE_REG_FRONT;
								ShowFaceHint(hWnd , FACE_REG_FRONT , hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_FRONT); 
								DelayMS(600);
							}
							else if(FaceCount == 3)
							{
								FaceRegState=FACE_REG_SCREEN;
								ShowFaceHint(hWnd , FACE_REG_SCREEN ,hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_SCREEN); 
								DelayMS(600);
							}
							else if(FaceCount == 6)
							{
								FaceRegState=FACE_REG_LEFT;
								ShowFaceHint(hWnd , FACE_REG_LEFT ,hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_LEFT); 
								DelayMS(600);
							}
							else if(FaceCount == 9)
							{
								FaceRegState=FACE_REG_RIGHT;
								ShowFaceHint(hWnd , FACE_REG_RIGHT ,hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_RIGHT); 
								DelayMS(600);
							}
							else if(FaceCount == 12)
							{
								FaceRegState=FACE_REG_CAMERA;
								ShowFaceHint(hWnd ,FACE_REG_CAMERA ,hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_CAMERA); 
								DelayMS(600);
							}
							else
							{
			                        		ExBeep(1);
							}
						}
						else
						{
			                        	ExBeep(1);
						}
					}
				}
				ReleaseDC(hdc);
				SetTimer(hWnd, IDC_FACE_TIMER1,IDC_TIMER_NUM );
			}
			break;

		case MSG_IDLE:
			if(FaceCount==0 && RegCnt==0 && RegBegin<= REG_PREPARE && gOptions.VoiceOn)
 		        {
                        	RegCnt=1;
				FaceRegState=FACE_REG_PREPARE;
				hdc=GetClientDC(hWnd);
				ShowFaceHint(hWnd , FACE_REG_PREPARE ,hdc, &fvbg,1);
				if(gOptions.VoiceOn)
                			ExPlayVoice(VOICE_FACE_START); //start...
				DelayMS(1000);
				ReleaseDC(hdc);
                        }
			break;

		case MSG_CLOSE:
			KillTimer(hWnd, IDC_FACE_TIMER1);


         		// MainWindowCleanup(hWnd);
                        DestroyMainWindow(hWnd);
		        return 0;
        
	}
    
	return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
示例#10
0
TreeNode* Parser::Statement()
{
	kdDebug(0)<<"Parser::Statement()"<<endl;
	while (currentToken.type == tokEOL) getToken(); // statements can allways start on newlines
	switch (currentToken.type)
	{
		case tokLearn         : return Learn();            break;

		case tokIf            : return If();               break;
		case tokFor           : return For();              break;
		case tokForEach       : return ForEach();          break;
		case tokWhile         : return While();            break;
		case tokRun           : return ExternalRun();      break;
		case tokReturn        : return Return();           break;
		case tokBreak         : return Break();            break;
		case tokUnknown       : return Other();            break; //assignment or function call

		case tokClear         : return Clear();            break;
		case tokGo            : return Go();               break;
		case tokGoX           : return GoX();              break;
		case tokGoY           : return GoY();              break;
		case tokForward       : return Forward();          break;
		case tokBackward      : return Backward();         break;
		case tokDirection     : return Direction();        break;
		case tokTurnLeft      : return TurnLeft();         break;
		case tokTurnRight     : return TurnRight();        break;
		case tokCenter        : return Center();           break;
		case tokSetPenWidth   : return SetPenWidth();      break;
		case tokPenUp         : return PenUp();            break;
		case tokPenDown       : return PenDown();          break;
		case tokSetFgColor    : return SetFgColor();       break;
		case tokSetBgColor    : return SetBgColor();       break;
		case tokResizeCanvas  : return ResizeCanvas();     break;
		case tokSpriteShow    : return SpriteShow();       break;
		case tokSpriteHide    : return SpriteHide();       break;
		case tokSpritePress   : return SpritePress();      break;
		case tokSpriteChange  : return SpriteChange();     break;

		case tokPrint         : return Print();            break;
		case tokInputWindow   : return InputWindow();      break;
		case tokMessage       : return Message();          break;
		case tokFontType      : return FontType();         break;
		case tokFontSize      : return FontSize();         break;
		case tokRepeat        : return Repeat();           break;
		case tokRandom        : return Random();           break;
		case tokWait          : return Wait();             break;
		case tokWrapOn        : return WrapOn();           break;
		case tokWrapOff       : return WrapOff();          break;
		case tokReset         : return Reset();            break;
		
		case tokEOF           : return EndOfFile();        break;
		
		case tokEnd           : Error(currentToken, i18n("Cannot understand ']'"), 1050);
		                        getToken();
		                        return new TreeNode(currentToken, Unknown);
		                        break;

		case tokBegin         : Error(currentToken, i18n("Cannot understand '['"), 1050);
		                        getToken();
		                        return new TreeNode(currentToken, Unknown);
		                        break;

		default               : break;
	}
	if (currentToken.type != tokEnd)
	{
		Error(currentToken, i18n("Cannot understand '%1'").arg(currentToken.look), 1060);
	}

	getToken();
	return new TreeNode(currentToken, Unknown); // fall-though for unknowns
}