Exemple #1
0
/*--------------------------------------------------------------------------*/
void PegGroup::Draw(void)
{
    #ifdef PEG_UNICODE
    PEGCHAR cTest[2] = {'E', '\0'};
    #else
    PEGCHAR cTest[] = "E";
    #endif

    if (Parent())
    {
        muColors[PCI_NORMAL] = Parent()->muColors[PCI_NORMAL];
    }
    BeginDraw();

    PegColor Color(muColors[PCI_NORMAL], muColors[PCI_NORMAL], CF_FILL);
    Rectangle(mClient, Color, 0);

    Color.Set(PCLR_LOWLIGHT, PCLR_LOWLIGHT, CF_NONE);
    
    Color.uForeground = PCLR_LOWLIGHT;
    SIGNED iTextLeft = mReal.wLeft + TextWidth(cTest, mpFont);
    SIGNED iTextRight = iTextLeft + TextWidth(mpText, mpFont) + 4;

    if(mpText)
    {
        Line(mReal.wLeft, mClient.wTop - 2, iTextLeft,
            mClient.wTop - 2, Color);
        Line(iTextRight, mClient.wTop - 2, mReal.wRight,
            mClient.wTop - 2, Color);
    }
    else
    {
        Line(mReal.wLeft, mClient.wTop - 2, mReal.wRight,
             mClient.wTop - 2, Color);
    }
    Line(mReal.wLeft, mClient.wTop - 1, mReal.wLeft,
        mReal.wBottom, Color);
    Line(mReal.wLeft + 1, mReal.wBottom - 1,
        mReal.wRight - 1, mReal.wBottom - 1, Color);
    Line(mReal.wRight - 1, mClient.wTop - 2,
        mReal.wRight - 1, mReal.wBottom - 1, Color);

    Color.uForeground = PCLR_HIGHLIGHT;
    if(mpText)
    {
        Line(mReal.wLeft + 1, mClient.wTop - 1, iTextLeft,
            mClient.wTop - 1, Color);
        Line(iTextRight, mClient.wTop - 1, mReal.wRight - 2,
            mClient.wTop - 1, Color);
    }
    else
    {
        Line(mReal.wLeft + 1, mClient.wTop - 1, mReal.wRight - 2,
             mClient.wTop - 1, Color);
    }
    Line(mReal.wLeft + 1, mClient.wTop, mReal.wLeft + 1,
        mReal.wBottom - 1, Color);
    Line(mReal.wLeft, mReal.wBottom, mReal.wRight,
        mReal.wBottom, Color);
    Line(mReal.wRight, mClient.wTop - 2, mReal.wRight,
        mReal.wBottom, Color);

    if(mpText)
    {
        if (mwStyle & AF_ENABLED)
        {
            Color.uForeground = muColors[PCI_NTEXT];
        }
        else
        {
            Color.uForeground = PCLR_LOWLIGHT;
        }
        PegPoint Put;
        Put.x = iTextLeft + 2;
        Put.y = mReal.wTop;

        DrawText(Put, mpText, Color, mpFont);
    }

    PegThing::Draw();       // to draw children
    EndDraw();
}
Exemple #2
0
 CTaxon1Node*          GetParent()
 {
     return static_cast<CTaxon1Node*>(Parent());
 }
Exemple #3
0
float IGradientModificationStrategy::QValue(int i, int j) {
    return Parent()->QValue(i, j);
}
void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
{
    static wxFileName fn;                 // Remember path between saves during this session only.
    wxString          FullFileName;
    wxString          file_ext, mask;
    bool              fmt_is_jpeg = false;

    // First time path is set to the project path.
    if( !fn.IsOk() )
        fn = Parent()->Prj().GetProjectFullName();

    if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
        fmt_is_jpeg = true;

    if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
    {
        file_ext     = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
        mask         = wxT( "*." ) + file_ext;
        fn.SetExt( file_ext );

        FullFileName = EDA_FileSelector( _( "3D Image File Name:" ), fn.GetPath(),
                                         fn.GetFullName(), file_ext, mask, this,
                                         wxFD_SAVE | wxFD_OVERWRITE_PROMPT, true );

        if( FullFileName.IsEmpty() )
            return;

        fn = FullFileName;

        // Be sure the screen area destroyed by the file dialog is redrawn before making
        // a screen copy.
        // Without this call, under Linux the screen refresh is made to late.
        wxYield();
    }

    struct viewport_params
    {
        GLint originx;
        GLint originy;
        GLint x;
        GLint y;
    } viewport;

    // Be sure we have the latest 3D view (remember 3D view is buffered)
    Refresh();
    wxYield();

    // Build image from the 3D buffer
    wxWindowUpdateLocker noUpdates( this );
    glGetIntegerv( GL_VIEWPORT, (GLint*) &viewport );

    unsigned char*       pixelbuffer = (unsigned char*) malloc( viewport.x * viewport.y * 3 );
    unsigned char*       alphabuffer = (unsigned char*) malloc( viewport.x * viewport.y );
    wxImage image( viewport.x, viewport.y );

    glPixelStorei( GL_PACK_ALIGNMENT, 1 );
    glReadBuffer( GL_BACK_LEFT );
    glReadPixels( viewport.originx, viewport.originy,
                  viewport.x, viewport.y,
                  GL_RGB, GL_UNSIGNED_BYTE, pixelbuffer );
    glReadPixels( viewport.originx, viewport.originy,
                  viewport.x, viewport.y,
                  GL_ALPHA, GL_UNSIGNED_BYTE, alphabuffer );

    image.SetData( pixelbuffer );
    image.SetAlpha( alphabuffer );
    image = image.Mirror( false );
    wxBitmap bitmap( image );

    if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
    {
        if( wxTheClipboard->Open() )
        {
            wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );

            if( !wxTheClipboard->SetData( dobjBmp ) )
                wxMessageBox( _( "Failed to copy image to clipboard" ) );

            wxTheClipboard->Flush();    /* the data in clipboard will stay
                                         * available after the application exits */
            wxTheClipboard->Close();
        }
    }
    else
    {
        wxImage image = bitmap.ConvertToImage();

        if( !image.SaveFile( FullFileName,
                             fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
            wxMessageBox( _( "Can't save file" ) );

        image.Destroy();
    }
}
Exemple #5
0
	virtual void AttachedToWindow()
	{
		SetViewColor(Parent()->ViewColor());
	}
INFO3D_VISU& EDA_3D_CANVAS::GetPrm3DVisu() const
{
    return Parent()->GetPrm3DVisu();
}
Exemple #7
0
// Update
void
ColorSlider::Update(int depth)
{
	// depth: 0 = onscreen only, 1 = bitmap 1, 2 = bitmap 0
	if (depth == 2) {
		write_port(fUpdatePort, MSG_UPDATE, NULL, 0);
		return;
	}

	if (!Parent())
		return;
	
	fBgBitmap->Lock();

//	BRect r(fBgView->Bounds());
	BRect r(Bounds());
	BRect bounds(r);
	if (fOrientation == B_VERTICAL) {
//		r.OffsetBy(-8.0, -2.0);
		r.InsetBy(6.0, 3.0);
//		bounds.Set(-8.0, -2.0, r.right - 8.0, r.bottom - 2.0);
//		bounds.OffsetBy(8.0, 2.0);
	} else {
//		r.OffsetBy(-2.0, -2.0);
//		bounds.Set(-2.0, -2.0, r.right - 2.0, r.bottom - 2.0);
//		bounds.OffsetBy(2.0, 2.0);
	}

	fBgBitmap->Unlock();

	rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color shadow = tint_color(background, B_DARKEN_1_TINT);
	rgb_color darkShadow = tint_color(background, B_DARKEN_3_TINT);
	rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT);

	if (depth >= 1) {

		fBgBitmap->Lock();
	

		// frame
		stroke_frame(fBgView, r, shadow, shadow, light, light);
		r.InsetBy(1.0, 1.0);
		stroke_frame(fBgView, r, darkShadow, darkShadow, background, background);

		if (fOrientation == B_VERTICAL) {
			// clear area left and right from slider
			fBgView->SetHighColor( background );
			fBgView->FillRect( BRect(bounds.left, bounds.top, bounds.left + 5.0, bounds.bottom) );
			fBgView->FillRect( BRect(bounds.right - 5.0, bounds.top, bounds.right, bounds.bottom) );
		}
/*
		// marker
		if (fOrientation == B_VERTICAL) {
			// clear area left and right from slider
			fBgView->SetHighColor( background );
			fBgView->FillRect( BRect(bounds.left, bounds.top, bounds.left + 5.0, bounds.bottom) );
			fBgView->FillRect( BRect(bounds.right - 5.0, bounds.top, bounds.right, bounds.bottom) );
			// draw the triangle markers
			fBgView->SetHighColor( 0, 0, 0 );
			float value = Value();
			fBgView->StrokeLine( BPoint(bounds.left, value - 2.0), BPoint(bounds.left + 5.0, value + 3.0));
			fBgView->StrokeLine( BPoint(bounds.left, value + 8.0));
			fBgView->StrokeLine( BPoint(bounds.left, value - 2.0));
	
			fBgView->StrokeLine( BPoint(bounds.right, value - 2.0), BPoint(bounds.right - 5.0, value + 3.0));
			fBgView->StrokeLine( BPoint(bounds.right, value + 8.0));
			fBgView->StrokeLine( BPoint(bounds.right, value - 2.0));
		} else {
			r.InsetBy(1.0, 1.0);
			float value = (Value() / 255.0) * (bounds.Width() - 4.0);
			if (value - 2 > r.left) {
				fBgView->SetHighColor( 255, 255, 255 );
				fBgView->StrokeLine( BPoint(value - 2, bounds.top + 2.0),
									 BPoint(value - 2, bounds.bottom - 2.0));
			}
			if (value - 1 > r.left) {
				fBgView->SetHighColor( 0, 0, 0 );
				fBgView->StrokeLine( BPoint(value - 1, bounds.top + 2.0),
									 BPoint(value - 1, bounds.bottom - 2.0));
			}
			if (value + 1 < r.right) {
				fBgView->SetHighColor( 0, 0, 0 );
				fBgView->StrokeLine( BPoint(value + 1, bounds.top + 2.0),
									 BPoint(value + 1, bounds.bottom - 2.0));
			}
			if (value + 2 < r.right) {
				fBgView->SetHighColor( 255, 255, 255 );
				fBgView->StrokeLine( BPoint(value + 2, bounds.top + 2.0),
									 BPoint(value + 2, bounds.bottom - 2.0));
			}
		}*/

		fBgView->Sync();

		fBgBitmap->Unlock();
	} else
		r.InsetBy(1.0, 1.0);

	DrawBitmap(fBgBitmap, BPoint(0.0, 0.0));

	// marker
	if (fOrientation == B_VERTICAL) {
		// draw the triangle markers
		SetHighColor( 0, 0, 0 );
		float value = Value();
		StrokeLine( BPoint(bounds.left, value),
					BPoint(bounds.left + 5.0, value + 5.0));
		StrokeLine( BPoint(bounds.left, value + 10.0));
		StrokeLine( BPoint(bounds.left, value));

		StrokeLine( BPoint(bounds.right, value),
					BPoint(bounds.right - 5.0, value + 5.0));
		StrokeLine( BPoint(bounds.right, value + 10.0));
		StrokeLine( BPoint(bounds.right, value));
	} else {
		r.InsetBy(1.0, 1.0);
		float value = (Value() / 255.0) * (bounds.Width() - 4.0);
		if (value > r.left) {
			SetHighColor( 255, 255, 255 );
			StrokeLine( BPoint(value, bounds.top + 2.0),
						BPoint(value, bounds.bottom - 2.0));
		}
		if (value + 1 > r.left) {
			SetHighColor( 0, 0, 0 );
			StrokeLine( BPoint(value + 1, bounds.top + 2.0),
						BPoint(value + 1, bounds.bottom - 2.0));
		}
		if (value + 3 < r.right) {
			SetHighColor( 0, 0, 0 );
			StrokeLine( BPoint(value + 3, bounds.top + 2.0),
						BPoint(value + 3, bounds.bottom - 2.0));
		}
		if (value + 4 < r.right) {
			SetHighColor( 255, 255, 255 );
			StrokeLine( BPoint(value + 4, bounds.top + 2.0),
						BPoint(value + 4, bounds.bottom - 2.0));
		}
	}
	SetOrigin(0.0, 0.0);
}
Exemple #8
0
void IconsView::AttachedToWindow() {
	if( Parent() )
		SetViewColor( Parent()->ViewColor() );
	else
		SetViewColor( 255, 255, 255 );
}
void
_MediaSlider_::AttachedToWindow()
{
	SetViewColor(Parent()->ViewColor());
}
Exemple #10
0
void FarDlgNode::BeforeLoad()
{
  getPayload().setDialog(Parent()->getPayload().getDialog());
}
void RenderTreeUpdater::pushParent(Element& element, Style::Change changeType)
{
    m_parentStack.append(Parent(element, changeType));

    updateBeforeOrAfterPseudoElement(element, BEFORE);
}
void
ConnectionOptionsView::AttachedToWindow()
{
	SetViewColor(Parent()->ViewColor());
	fDialOnDemand->SetTarget(this);
}
// ----------------------------------------------------------------------------
//
// ----------------------------------------------------------------------------
void ConfigGroup::SetDirty()
{
  m_bDirty = TRUE;
  if ( Parent() != NULL )             // propagate upwards
    Parent()->SetDirty();
}
Exemple #14
0
void
PowerStatusView::Draw(BRect updateRect)
{
	bool drawBackground = Parent() == NULL
		|| (Parent()->Flags() & B_DRAW_ON_CHILDREN) == 0;
	if (drawBackground)
		FillRect(updateRect, B_SOLID_LOW);

	float aspect = Bounds().Width() / Bounds().Height();
	bool below = aspect <= 1.0f;

	font_height fontHeight;
	GetFontHeight(&fontHeight);
	float baseLine = ceilf(fontHeight.ascent);

	char text[64];
	_SetLabel(text, sizeof(text));

	float textHeight = ceilf(fontHeight.descent + fontHeight.ascent);
	float textWidth = StringWidth(text);
	bool showLabel = fShowLabel && text[0];

	BRect iconRect;

	if (fShowStatusIcon) {
		iconRect = Bounds();
		if (showLabel) {
			if (below)
				iconRect.bottom -= textHeight + 4;
			else
				iconRect.right -= textWidth + 4;
		}

		// make a square
		iconRect.bottom = min_c(iconRect.bottom, iconRect.right);
		iconRect.right = iconRect.bottom;

		if (iconRect.Width() + 1 >= kMinIconWidth
			&& iconRect.Height() + 1 >= kMinIconHeight) {
			_DrawBattery(iconRect);
		} else {
			// there is not enough space for the icon
			iconRect.Set(0, 0, -1, -1);
		}
	}

	if (showLabel) {
		BPoint point(0, baseLine);

		if (iconRect.IsValid()) {
			if (below) {
				point.x = (iconRect.Width() - textWidth) / 2;
				point.y += iconRect.Height() + 2;
			} else {
				point.x = iconRect.Width() + 2;
				point.y += (iconRect.Height() - textHeight) / 2;
			}
		} else {
			point.x = (Bounds().Width() - textWidth) / 2;
			point.y += (Bounds().Height() - textHeight) / 2;
		}

		if (drawBackground)
			SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
		else {
			SetDrawingMode(B_OP_OVER);
			rgb_color c = Parent()->LowColor();
			if (c.red + c.green + c.blue > 128 * 3)
				SetHighColor(0, 0, 0);
			else
				SetHighColor(255, 255, 255);
		}

		DrawString(text, point);
	}
}
Exemple #15
0
void
IPCPView::AttachedToWindow()
{
	SetViewColor(Parent()->ViewColor());
	fIsEnabled->SetTarget(this);
}
void ArpTwoStateButton::AttachedToWindow()
{
	inherited::AttachedToWindow();
	if( Parent() ) SetViewColor( Parent()->ViewColor() );
}
Exemple #17
0
void EDA_3D_VIEWER::takeScreenshot( wxCommandEvent& event )
{
    wxString   fullFileName;
    bool       fmt_is_jpeg = false;

    if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
        fmt_is_jpeg = true;

    if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
    {
        // Remember path between saves during this session only.
        static wxFileName fn;
        const wxString file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
        const wxString mask     = wxT( "*." ) + file_ext;

        // First time path is set to the project path.
        if( !fn.IsOk() )
            fn = Parent()->Prj().GetProjectFullName();

        fn.SetExt( file_ext );

        fullFileName = EDA_FILE_SELECTOR( _( "3D Image File Name:" ), fn.GetPath(),
                                          m_defaultFileName, file_ext, mask, this,
                                          wxFD_SAVE | wxFD_OVERWRITE_PROMPT, true );

        if( fullFileName.IsEmpty() )
            return;

        fn = fullFileName;

        // Be sure the screen area destroyed by the file dialog is redrawn
        // before making a screen copy.
        // Without this call, under Linux the screen refresh is made to late.
        wxYield();
    }

    // Be sure we have the latest 3D view (remember 3D view is buffered)
    Refresh();
    wxYield();

    // Build image from the 3D buffer
    wxWindowUpdateLocker noUpdates( this );

    wxImage screenshotImage;

    if( m_canvas )
        m_canvas->GetScreenshot( screenshotImage );

    if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
    {
        wxBitmap bitmap( screenshotImage );

        if( wxTheClipboard->Open() )
        {
            wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );

            if( !wxTheClipboard->SetData( dobjBmp ) )
                wxMessageBox( _( "Failed to copy image to clipboard" ) );

            wxTheClipboard->Flush();    /* the data in clipboard will stay
                                         * available after the application exits */
            wxTheClipboard->Close();
        }
    }
    else
    {
        if( !screenshotImage.SaveFile( fullFileName,
                             fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
            wxMessageBox( _( "Can't save file" ) );

        screenshotImage.Destroy();
    }

}
Exemple #18
0
int QuickView::ProcessKey(const Manager::Key& Key)
{
	int LocalKey=Key.FarKey;
	if (!IsVisible())
		return FALSE;

	if (LocalKey>=KEY_RCTRL0 && LocalKey<=KEY_RCTRL9)
	{
		ExecShortcutFolder(LocalKey-KEY_RCTRL0);
		return TRUE;
	}

	if (LocalKey == KEY_F1)
	{
		Help::create(L"QViewPanel");
		return TRUE;
	}

	if (LocalKey==KEY_F3 || LocalKey==KEY_NUMPAD5 || LocalKey == KEY_SHIFTNUMPAD5)
	{
		auto AnotherPanel = Parent()->GetAnotherPanel(this);

		if (AnotherPanel->GetType()==FILE_PANEL)
			AnotherPanel->ProcessKey(Manager::Key(KEY_F3));

		return TRUE;
	}

	if (LocalKey==KEY_ADD || LocalKey==KEY_SUBTRACT)
	{
		auto AnotherPanel = Parent()->GetAnotherPanel(this);

		if (AnotherPanel->GetType()==FILE_PANEL)
			AnotherPanel->ProcessKey(Manager::Key(LocalKey==KEY_ADD?KEY_DOWN:KEY_UP));

		return TRUE;
	}

	if (QView && !Directory && LocalKey>=256)
	{
		int ret = QView->ProcessKey(Manager::Key(LocalKey));

		if (LocalKey == KEY_F2 || LocalKey == KEY_SHIFTF2
		 || LocalKey == KEY_F4 || LocalKey == KEY_SHIFTF4
		 || LocalKey == KEY_F8 || LocalKey == KEY_SHIFTF8)
		{
			DynamicUpdateKeyBar();
			Parent()->GetKeybar().Redraw();
		}

		if (LocalKey == KEY_F7 || LocalKey == KEY_SHIFTF7)
		{
			//__int64 Pos;
			//int Length;
			//DWORD Flags;
			//QView->GetSelectedParam(Pos,Length,Flags);
			Redraw();
			Parent()->GetAnotherPanel(this)->Redraw();
			//QView->SelectText(Pos,Length,Flags|1);
		}

		return ret;
	}

	return FALSE;
}
void EDA_3D_CANVAS::Redraw()
{
    // SwapBuffer requires the window to be shown before calling
    if( !IsShownOnScreen() )
        return;

    wxString err_messages;
    WX_STRING_REPORTER errorReporter( &err_messages );
    STATUS_TEXT_REPORTER activityReporter( Parent(), 0 );

    // Display build time at the end of build
    unsigned strtime = GetRunningMicroSecs();

    GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );

    // Set the OpenGL viewport according to the client size of this canvas.
    // This is done here rather than in a wxSizeEvent handler because our
    // OpenGL rendering context (and thus viewport setting) is used with
    // multiple canvases: If we updated the viewport in the wxSizeEvent
    // handler, changing the size of one canvas causes a viewport setting that
    // is wrong when next another canvas is repainted.
    wxSize size = GetClientSize();

    InitGL();

    if( isRealisticMode() && isEnabled( FL_RENDER_SHADOWS ) )
    {
        generateFakeShadowsTextures( &errorReporter, &activityReporter );
    }

    // *MUST* be called *after* GL_CONTEXT_MANAGER::LockCtx():
    glViewport( 0, 0, size.x, size.y );

    // clear color and depth buffers
    glClearColor( 0.95, 0.95, 1.0, 1.0 );
    glClearStencil( 0 );
    glClearDepth( 1.0 );
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );

    glShadeModel( GL_SMOOTH );

    // Draw background
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();

    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    glDisable( GL_LIGHTING );
    glDisable( GL_COLOR_MATERIAL );
    glDisable( GL_DEPTH_TEST );
    glDisable( GL_TEXTURE_2D );

    // Draw the background ( rectangle with color gradient)
    glBegin( GL_QUADS );
    SetGLColor( GetPrm3DVisu().m_BgColor_Top, 1.0 );
    glVertex2f( -1.0, 1.0 );    // Top left corner

    SetGLColor( GetPrm3DVisu().m_BgColor, 1.0 );
    glVertex2f( -1.0,-1.0 );    // bottom left corner
    glVertex2f( 1.0,-1.0 );     // bottom right corner

    SetGLColor( GetPrm3DVisu().m_BgColor_Top, 1.0 );
    glVertex2f( 1.0, 1.0 );     // top right corner

    glEnd();
    glEnable( GL_DEPTH_TEST );


    // set viewing projection
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();

#define MAX_VIEW_ANGLE 160.0 / 45.0

    if( GetPrm3DVisu().m_Zoom > MAX_VIEW_ANGLE )
        GetPrm3DVisu().m_Zoom = MAX_VIEW_ANGLE;

     if( Parent()->ModeIsOrtho() )
     {
         // OrthoReductionFactor is chosen to provide roughly the same size as
         // Perspective View
         const double orthoReductionFactor = 400 / GetPrm3DVisu().m_Zoom;

         // Initialize Projection Matrix for Ortographic View
         glOrtho( -size.x / orthoReductionFactor, size.x / orthoReductionFactor,
                  -size.y / orthoReductionFactor, size.y / orthoReductionFactor, 1, 100 );
     }
     else
     {
         // Ratio width / height of the window display
         double ratio_HV = (double) size.x / size.y;

         // Initialize Projection Matrix for Perspective View
         gluPerspective( 45.0f * GetPrm3DVisu().m_Zoom, ratio_HV, 1, 100 );
     }

    // position viewer
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    glTranslatef( 0.0f, 0.0f, -(m_ZBottom + m_ZTop) / 2.0f );

    // Setup light sources:
    SetLights();

    CheckGLError( __FILE__, __LINE__ );

    glMatrixMode( GL_MODELVIEW );    // position viewer

    // transformations
    GLfloat mat[4][4];

    // Translate motion first, so rotations don't mess up the orientation...
    glTranslatef( m_draw3dOffset.x, m_draw3dOffset.y, 0.0F );

    build_rotmatrix( mat, GetPrm3DVisu().m_Quat );
    glMultMatrixf( &mat[0][0] );

    glRotatef( GetPrm3DVisu().m_Rot[0], 1.0, 0.0, 0.0 );
    glRotatef( GetPrm3DVisu().m_Rot[1], 0.0, 1.0, 0.0 );
    glRotatef( GetPrm3DVisu().m_Rot[2], 0.0, 0.0, 1.0 );


    if( ! m_glLists[GL_ID_BOARD] || ! m_glLists[GL_ID_TECH_LAYERS] )
        CreateDrawGL_List( &errorReporter, &activityReporter );

    if( isEnabled( FL_AXIS ) && m_glLists[GL_ID_AXIS] )
        glCallList( m_glLists[GL_ID_AXIS] );

    // move the board in order to draw it with its center at 0,0 3D coordinates
    glTranslatef( -GetPrm3DVisu().m_BoardPos.x * GetPrm3DVisu().m_BiuTo3Dunits,
                  -GetPrm3DVisu().m_BoardPos.y * GetPrm3DVisu().m_BiuTo3Dunits,
                  0.0f );

    if( isEnabled( FL_MODULE ) )
    {
        if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] )
            CreateDrawGL_List( &errorReporter, &activityReporter );
    }

    glEnable( GL_LIGHTING );

    glEnable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

    if( isRealisticMode() && isEnabled( FL_RENDER_TEXTURES ) )
        glEnable( GL_TEXTURE_2D );
    else
        glDisable( GL_TEXTURE_2D );

    // Set material for the board
    glEnable( GL_COLOR_MATERIAL );
    SetOpenGlDefaultMaterial();

    //glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, FALSE );

    // Board Body

    GLint shininess_value = 32;
    glMateriali( GL_FRONT_AND_BACK, GL_SHININESS, shininess_value );

    if( isEnabled( FL_SHOW_BOARD_BODY ) )
    {
        if( m_glLists[GL_ID_BODY] )
        {
            glCallList( m_glLists[GL_ID_BODY] );
        }
    }


    // Board

    // specify material parameters for the lighting model.
    shininess_value = 52;
    glMateriali( GL_FRONT_AND_BACK, GL_SHININESS, shininess_value );

    glm::vec4 specular( GetPrm3DVisu().m_CopperColor.m_Red   * 0.20f,
                        GetPrm3DVisu().m_CopperColor.m_Green * 0.20f,
                        GetPrm3DVisu().m_CopperColor.m_Blue  * 0.20f, 1.0f );
    glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.x );

    if( m_glLists[GL_ID_BOARD] )
    {
        glCallList( m_glLists[GL_ID_BOARD] );
    }


    // Tech layers

    shininess_value = 32;
    glMateriali( GL_FRONT_AND_BACK, GL_SHININESS, shininess_value );

    glm::vec4 specularTech( 0.0f, 0.0f, 0.0f, 1.0f );
    glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specularTech.x );

    if( m_glLists[GL_ID_TECH_LAYERS] )
    {
        glCallList( m_glLists[GL_ID_TECH_LAYERS] );
    }

    if( isEnabled( FL_COMMENTS ) || isEnabled( FL_ECO )  )
    {
        if( ! m_glLists[GL_ID_AUX_LAYERS] )
            CreateDrawGL_List( &errorReporter, &activityReporter );

        glCallList( m_glLists[GL_ID_AUX_LAYERS] );
    }

    //glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, TRUE );

    // Draw Component Shadow

    if( isEnabled( FL_MODULE )  && isRealisticMode() &&
        isEnabled( FL_RENDER_SHADOWS ) )
    {
        glEnable( GL_CULL_FACE );
        glDisable( GL_DEPTH_TEST );

        glEnable( GL_COLOR_MATERIAL ) ;
        SetOpenGlDefaultMaterial();
        glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );

        glEnable( GL_TEXTURE_2D );

        glEnable( GL_BLEND );
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

        if( m_glLists[GL_ID_SHADOW_FRONT] )
        {
            glBindTexture( GL_TEXTURE_2D, m_text_fake_shadow_front );
            glCallList( m_glLists[GL_ID_SHADOW_FRONT] );
        }

        if( m_glLists[GL_ID_SHADOW_BACK] )
        {
            glBindTexture( GL_TEXTURE_2D, m_text_fake_shadow_back );
            glCallList( m_glLists[GL_ID_SHADOW_BACK] );
        }
        glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );

        glEnable( GL_DEPTH_TEST );
        glDisable( GL_TEXTURE_2D );
        glDisable( GL_CULL_FACE );
    }

    glEnable( GL_COLOR_MATERIAL );
    SetOpenGlDefaultMaterial();

    glDisable( GL_BLEND );


    // Draw Solid Shapes

    if( isEnabled( FL_MODULE ) )
    {
        if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] )
            CreateDrawGL_List( &errorReporter, &activityReporter );

        glCallList( m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] );
    }

    glEnable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );


    // Grid uses transparency: draw it after all objects

    if( isEnabled( FL_GRID ) )
    {
        if( ! m_glLists[GL_ID_GRID] )
            CreateDrawGL_List( &errorReporter, &activityReporter );

        glCallList( m_glLists[GL_ID_GRID] );
    }


    // Draw Board Shadow

    if( isRealisticMode() && isEnabled( FL_RENDER_SHADOWS ) )
    {
        if( m_glLists[GL_ID_SHADOW_BOARD] )
        {
            glEnable( GL_BLEND );
            glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
            glColor4f( 1.0, 1.0, 1.0, 0.75f );
            glEnable( GL_CULL_FACE );
            glDisable( GL_COLOR_MATERIAL );
            glEnable( GL_TEXTURE_2D );
            glBindTexture( GL_TEXTURE_2D, m_text_fake_shadow_board );
            glCallList( m_glLists[GL_ID_SHADOW_BOARD] );
            glDisable( GL_CULL_FACE );
            glDisable( GL_TEXTURE_2D );
        }
    }

    // This list must be drawn last, because it contains the
    // transparent gl objects, which should be drawn after all
    // non transparent objects
    if(  isEnabled( FL_MODULE ) && m_glLists[GL_ID_3DSHAPES_TRANSP_FRONT] )
    {
        glEnable( GL_COLOR_MATERIAL );
        SetOpenGlDefaultMaterial();
        glEnable( GL_BLEND );
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        glCallList( m_glLists[GL_ID_3DSHAPES_TRANSP_FRONT] );
    }

    // Debug bounding boxes
    /*
    glDisable( GL_BLEND );
    glDisable( GL_COLOR_MATERIAL );
    glDisable( GL_LIGHTING );
    glColor4f( 1.0f, 0.0f, 1.0f, 1.0f );
    m_fastAABBox_Shadow.GLdebug();

    glColor4f( 0.0f, 1.0f, 1.0f, 1.0f );
    m_boardAABBox.GLdebug();
    */

    SwapBuffers();
    GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );

    // Show calculation time if some activity was reported
    if( activityReporter.HasMessage() )
    {
        // Calculation time in seconds
        double calculation_time = (double)( GetRunningMicroSecs() - strtime) / 1e6;

        activityReporter.Report( wxString::Format( _( "Build time %.3f s" ),
                                 calculation_time ) );
    }
    else
        activityReporter.Report( wxEmptyString );

    if( !err_messages.IsEmpty() )
        wxLogMessage( err_messages );

}
Exemple #20
0
void QuickView::ShowFile(const string& FileName, bool TempFile, PluginHandle* hDirPlugin)
{
	CloseFile();

	if (!IsVisible())
		return;

	if (FileName.empty())
	{
		ProcessingPluginCommand++;
		Show();
		ProcessingPluginCommand--;
		return;
	}

	string FileFullName = FileName;
	if (!hDirPlugin) ConvertNameToFull(FileFullName, FileFullName);

	bool SameFile = strCurFileName == FileFullName;
	strCurFileName = FileFullName;

	size_t pos = strCurFileName.rfind(L'.');
	if (pos != string::npos)
	{
		string strValue;

		if (GetShellType(strCurFileName.data()+pos, strValue))
		{
			api::reg::GetValue(HKEY_CLASSES_ROOT, strValue, L"", strCurFileType);
		}
	}

	if (hDirPlugin || api::fs::is_directory(strCurFileName))
	{
		// Не показывать тип файла для каталогов в "Быстром просмотре"
		strCurFileType.clear();

		if (SameFile && !hDirPlugin)
		{
			Directory=1;
		}
		else if (hDirPlugin)
		{
			int ExitCode=GetPluginDirInfo(hDirPlugin,strCurFileName,Data.DirCount,
			                              Data.FileCount,Data.FileSize,Data.AllocationSize);
			Directory = (ExitCode ? 4 : 3);
			uncomplete_dirscan = (ExitCode == 0);
		}
		else
		{
			int ExitCode=GetDirInfo(MSG(MQuickViewTitle), strCurFileName, Data, getdirinfo_default_delay, nullptr, GETDIRINFO_ENHBREAK|GETDIRINFO_SCANSYMLINKDEF|GETDIRINFO_NOREDRAW);
			Directory = (ExitCode == -1 ? 2 : 1); // ExitCode: 1=done; 0=Esc,CtrlBreak; -1=Other
			uncomplete_dirscan = ExitCode != 1;
		}
	}
	else
	{
		if (!strCurFileName.empty())
		{
			QView.reset(new Viewer(GetOwner(), true));
			QView->SetRestoreScreenMode(false);
			QView->SetPosition(m_X1+1,m_Y1+1,m_X2-1,m_Y2-3);
			QView->SetStatusMode(0);
			QView->EnableHideCursor(0);
			OldWrapMode = QView->GetWrapMode();
			OldWrapType = QView->GetWrapType();
			QView->SetWrapMode(LastWrapMode);
			QView->SetWrapType(LastWrapType);
			QView->OpenFile(strCurFileName,FALSE);
		}
	}
	if (this->Destroyed())
		return;

	m_TemporaryFile = TempFile;

	Redraw();

	if (Parent()->ActivePanel() == this)
	{
		DynamicUpdateKeyBar();
		Parent()->GetKeybar().Redraw();
	}
}
Exemple #21
0
void
BComboBox::TextInput::KeyDown(const char *bytes, int32 numBytes)
{
	BComboBox* cb;
	uchar aKey = bytes[0];

	switch (aKey) {
		case B_RETURN:
			cb = dynamic_cast<BComboBox*>(Parent());
			ASSERT(cb);

			if (!cb->IsEnabled())
				break;

			ASSERT(fInitialText);
			if (strcmp(fInitialText, Text()) != 0)
				cb->CommitValue();
			free(fInitialText);
			fInitialText = strdup(Text());
			{
				int32 end = TextLength();
				Select(end, end);
			}
			// hide popup window if it's showing when the user presses the
			// enter key
			if (cb->fPopupWindow && cb->fPopupWindow->Lock()) {
				if (!cb->fPopupWindow->IsHidden()) {
					cb->HidePopupWindow();
				}
				cb->fPopupWindow->Unlock();
			}
			break;
		case B_TAB:
//			cb = dynamic_cast<BComboBox*>Parent());
//			ASSERT(cb);
//			if (cb->fAutoComplete && cb->fCompletionIndex >= 0) {	
//				int32 from, to;
//				cb->fText->GetSelection(&from, &to);
//				if (from == to) {
//					// HACK: this should never happen.  The rest of the class
//					// should be fixed so that fCompletionIndex is set to -1 if the
//					// text is modified
//					printf("BComboBox::TextInput::KeyDown() -- HACK! this shouldn't happen!");
//					cb->fCompletionIndex = -1;
//				}
//				
//				const char *text = cb->fText->Text();
//				BString prefix;
//				prefix.Append(text, from);
//				
//				int32 match;
//				const char *completion;
//				if (cb->fChoiceList->GetMatch(	prefix.String(),
//											  	cb->fCompletionIndex + 1,
//												&match,
//												&completion) == B_OK)
//				{
//					cb->fText->Delete(); 			// delete the selection
//					cb->fText->Insert(completion);
//					cb->fText->Select(from, from + strlen(completion));
//					cb->fCompletionIndex = match;
//					cb->Select(cb->fCompletionIndex);
//				} else {
//					//system_beep();
//				}	
//			} else {
				BView::KeyDown(bytes, numBytes);
//			}
			break;
#if 0
		case B_UP_ARROW:		// fall through
		case B_DOWN_ARROW:
			cb = dynamic_cast<BComboBox*>(Parent());
			ASSERT(cb);
			if (cb->fChoiceList) {
				cb = dynamic_cast<BComboBox*>(Parent());
				ASSERT(cb);
				if (!(cb->fPopupWindow)) {
					cb->fPopupWindow = cb->CreatePopupWindow();
				}
				if (cb->fPopupWindow->Lock()) {
					// show popup window, if needed
					if (cb->fPopupWindow->IsHidden()) {
						cb->ShowPopupWindow();
					} else {
						printf("Whoa!!! Erroneously got up/down arrow key down in TextInput::KeyDown()!\n");
					}
					int32 index = cb->CurrentSelection();
					int32 choices = cb->fChoiceList->CountChoices();
					// select something, if no selection
					if (index < 0 && choices > 0) {
						if (aKey == B_UP_ARROW) {
							cb->Select(choices - 1);
						} else {
							cb->Select(0);
						}
					}
					cb->fPopupWindow->Unlock();
				}
			}
			break;
#endif
		case B_ESCAPE:
			cb = dynamic_cast<BComboBox*>(Parent());
			ASSERT(cb);
			if (cb->fChoiceList)
			{
				cb = dynamic_cast<BComboBox*>(Parent());
				ASSERT(cb);
				if (cb->fPopupWindow && cb->fPopupWindow->Lock())
				{
					if (!cb->fPopupWindow->IsHidden())
						cb->HidePopupWindow();

					cb->fPopupWindow->Unlock();
				}
			}
			break;
		case ',':
			{
				int32 startSel, endSel;
				GetSelection(&startSel, &endSel);
				int32 length = TextLength();
				if (endSel == length)
					Select(endSel, endSel);
				BTextView::KeyDown(bytes, numBytes);
			}
			break;
		default:
			BTextView::KeyDown(bytes, numBytes);
			break;
	}
}
Exemple #22
0
void QuickView::UpdateKeyBar()
{
	Parent()->GetKeybar().SetLabels(MQViewF1);
	DynamicUpdateKeyBar();
}
Exemple #23
0
void BamKeysKeyView::AttachedToWindow() {
	BView::AttachedToWindow();
	if (Parent()) {
		SetViewColor(Parent()->ViewColor());
	}
}
Exemple #24
0
void QuickView::DisplayObject()
{
	if (m_Flags.Check(FSCROBJ_ISREDRAWING))
		return;

	m_Flags.Set(FSCROBJ_ISREDRAWING);

	if (!QView && !ProcessingPluginCommand)
		Parent()->GetAnotherPanel(this)->UpdateViewPanel();

	if (this->Destroyed())
		return;

	if (QView)
		QView->SetPosition(m_X1+1,m_Y1+1,m_X2-1,m_Y2-3);

	Box(m_X1,m_Y1,m_X2,m_Y2,ColorIndexToColor(COL_PANELBOX),DOUBLE_BOX);
	SetScreen(m_X1+1,m_Y1+1,m_X2-1,m_Y2-1,L' ',ColorIndexToColor(COL_PANELTEXT));
	SetColor(m_Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE);

	string strTitle = GetTitle();
	if (!strTitle.empty())
	{
		GotoXY(m_X1+(m_X2-m_X1+1-(int)strTitle.size())/2,m_Y1);
		Text(strTitle);
	}

	DrawSeparator(m_Y2-2);
	SetColor(COL_PANELTEXT);
	GotoXY(m_X1+1,m_Y2-1);
	Global->FS << fmt::LeftAlign()<<fmt::ExactWidth(m_X2-m_X1-1)<<PointToName(strCurFileName);

	if (!strCurFileType.empty())
	{
		string strTypeText=L" ";
		strTypeText+=strCurFileType;
		strTypeText+=L" ";
		TruncStr(strTypeText,m_X2-m_X1-1);
		SetColor(COL_PANELSELECTEDINFO);
		GotoXY(m_X1+(m_X2-m_X1+1-(int)strTypeText.size())/2,m_Y2-2);
		Text(strTypeText);
	}

	if (Directory)
	{
		FormatString FString;
		string DisplayName(strCurFileName);
		TruncPathStr(DisplayName,std::max(0, m_X2-m_X1-1-StrLength(MSG(MQuickViewFolder))-5));
		FString<<MSG(MQuickViewFolder)<<L" \""<<DisplayName<<L"\"";
		SetColor(COL_PANELTEXT);
		GotoXY(m_X1+2,m_Y1+2);
		PrintText(FString);

		DWORD currAttr=api::GetFileAttributes(strCurFileName); // обламывается, если нет доступа
		if (currAttr != INVALID_FILE_ATTRIBUTES && (currAttr&FILE_ATTRIBUTE_REPARSE_POINT))
		{
			string Tmp, Target;
			DWORD ReparseTag=0;
			const wchar_t* PtrName;
			if (GetReparsePointInfo(strCurFileName, Target, &ReparseTag))
			{
				NormalizeSymlinkName(Target);
				switch(ReparseTag)
				{
				// 0xA0000003L = Directory Junction or Volume Mount Point
				case IO_REPARSE_TAG_MOUNT_POINT:
					{
						LNGID ID_Msg = MQuickViewJunction;
						bool Root;
						if(ParsePath(Target, nullptr, &Root) == PATH_VOLUMEGUID && Root)
						{
							ID_Msg=MQuickViewVolMount;
						}
						PtrName = MSG(ID_Msg);
					}
					break;
				// 0xA000000CL = Directory or File Symbolic Link
				case IO_REPARSE_TAG_SYMLINK:
					PtrName = MSG(MQuickViewSymlink);
					break;
				// 0x8000000AL = Distributed File System
				case IO_REPARSE_TAG_DFS:
					PtrName = MSG(MQuickViewDFS);
					break;
				// 0x80000012L = Distributed File System Replication
				case IO_REPARSE_TAG_DFSR:
					PtrName = MSG(MQuickViewDFSR);
					break;
				// 0xC0000004L = Hierarchical Storage Management
				case IO_REPARSE_TAG_HSM:
					PtrName = MSG(MQuickViewHSM);
					break;
				// 0x80000006L = Hierarchical Storage Management2
				case IO_REPARSE_TAG_HSM2:
					PtrName = MSG(MQuickViewHSM2);
					break;
				// 0x80000007L = Single Instance Storage
				case IO_REPARSE_TAG_SIS:
					PtrName = MSG(MQuickViewSIS);
					break;
				// 0x80000008L = Windows Imaging Format
				case IO_REPARSE_TAG_WIM:
					PtrName = MSG(MQuickViewWIM);
					break;
				// 0x80000009L = Cluster Shared Volumes
				case IO_REPARSE_TAG_CSV:
					PtrName = MSG(MQuickViewCSV);
					break;
				case IO_REPARSE_TAG_DEDUP:
					PtrName = MSG(MQuickViewDEDUP);
					break;
				case IO_REPARSE_TAG_NFS:
					PtrName = MSG(MQuickViewNFS);
					break;
				case IO_REPARSE_TAG_FILE_PLACEHOLDER:
					PtrName = MSG(MQuickViewPlaceholder);
					break;
					// 0x????????L = anything else
				default:
					if (Global->Opt->ShowUnknownReparsePoint)
					{
						Tmp = FormatString() << L":" << fmt::Radix(16) << fmt::ExactWidth(8) << fmt::FillChar(L'0') << ReparseTag;
						PtrName = Tmp.data();
					}
					else
					{
						PtrName=MSG(MQuickViewUnknownReparsePoint);
					}
				}
			}
			else
			{
				PtrName = MSG(MQuickViewUnknownReparsePoint);
				Target = MSG(MQuickViewNoData);
			}

			TruncPathStr(Target,std::max(0, m_X2-m_X1-1-StrLength(PtrName)-5));
			FString.clear();
			FString<<PtrName<<L" \""<<Target<<L"\"";
			SetColor(COL_PANELTEXT);
			GotoXY(m_X1+2,m_Y1+3);
			PrintText(FString);
		}

		if (Directory==1 || Directory==4)
		{
			int iColor = uncomplete_dirscan ? COL_PANELHIGHLIGHTTEXT : COL_PANELINFOTEXT;
			const wchar_t *prefix = uncomplete_dirscan ? L"~" : L"";
			GotoXY(m_X1+2,m_Y1+4);
			PrintText(MSG(MQuickViewContains));
			GotoXY(m_X1+2,m_Y1+6);
			PrintText(MSG(MQuickViewFolders));
			SetColor(iColor);
			FString.clear();
			FString<<prefix<<Data.DirCount;
			PrintText(FString);
			SetColor(COL_PANELTEXT);
			GotoXY(m_X1+2,m_Y1+7);
			PrintText(MSG(MQuickViewFiles));
			SetColor(iColor);
			FString.clear();
			FString<<prefix<<Data.FileCount;
			PrintText(FString);
			SetColor(COL_PANELTEXT);
			GotoXY(m_X1+2,m_Y1+8);
			PrintText(MSG(MQuickViewBytes));
			SetColor(iColor);
			string strSize;
			InsertCommas(Data.FileSize,strSize);
			PrintText(prefix+strSize);
			SetColor(COL_PANELTEXT);
			GotoXY(m_X1+2,m_Y1+9);
			PrintText(MSG(MQuickViewAllocated));
			SetColor(iColor);
			InsertCommas(Data.AllocationSize,strSize);
			FString.clear();
			FString << prefix << strSize << L" (" << ToPercent(Data.AllocationSize,Data.FileSize) << L"%)";
			PrintText(FString);

			if (Directory!=4)
			{
				SetColor(COL_PANELTEXT);
				GotoXY(m_X1+2,m_Y1+11);
				PrintText(MSG(MQuickViewCluster));
				SetColor(iColor);
				InsertCommas(Data.ClusterSize,strSize);
				PrintText(prefix+strSize);

				SetColor(COL_PANELTEXT);
				GotoXY(m_X1+2,m_Y1+12);
				PrintText(MSG(MQuickViewSlack));
				SetColor(iColor);
				InsertCommas(Data.FilesSlack, strSize);
				FString.clear();
				FString << prefix << strSize << L" (" << ToPercent(Data.FilesSlack, Data.AllocationSize) << L"%)";
				PrintText(FString);

				SetColor(COL_PANELTEXT);
				GotoXY(m_X1+2,m_Y1+13);
				PrintText(MSG(MQuickViewMFTOverhead));
				SetColor(iColor);
				InsertCommas(Data.MFTOverhead, strSize);
				FString.clear();
				FString<<prefix<<strSize<<L" ("<<ToPercent(Data.MFTOverhead, Data.AllocationSize)<<L"%)";
				PrintText(FString);

			}
		}
	}
	else if (QView)
		QView->Show();

	m_Flags.Clear(FSCROBJ_ISREDRAWING);
}
Exemple #25
0
void SideGrip::Draw(BRect updateRect) {

	BPoint	where;
	uint32	buttons;

	GetMouse( &where, &buttons, false );
	bool drawActive = ((!buttons && Window()->IsActive() && Bounds().Contains(where)) || !Parent()->Parent());
	DrawBitmap( drawActive ? fBitmap1 : fBitmap0 );
}
Exemple #26
0
void
ImageView::_UpdateImage()
{
	// ToDo: add scroller if necessary?!

	BAutolock locker(fEditor);

	// we need all the data...

	size_t viewSize = fEditor.ViewSize();
	// that may need some more memory...
	if ((off_t)viewSize < fEditor.FileSize())
		fEditor.SetViewSize(fEditor.FileSize());

	const char *data;
	if (fEditor.GetViewBuffer((const uint8 **)&data) != B_OK) {
		fEditor.SetViewSize(viewSize);
		return;
	}

	if (fBitmap != NULL && (fEditor.Type() == B_MINI_ICON_TYPE
			|| fEditor.Type() == B_LARGE_ICON_TYPE)) {
		// optimize icon update...
		fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
		fEditor.SetViewSize(viewSize);
		return;
	}
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
	if (fBitmap != NULL && fEditor.Type() == B_VECTOR_ICON_TYPE
		&& fScaleSlider->Value() * 8 - 1 == fBitmap->Bounds().Width()) {
		if (BIconUtils::GetVectorIcon((const uint8 *)data,
				(size_t)fEditor.FileSize(), fBitmap) == B_OK) {
			fEditor.SetViewSize(viewSize);
			return;
		}
	}
#endif

	delete fBitmap;
	fBitmap = NULL;

	switch (fEditor.Type()) {
		case B_MINI_ICON_TYPE:
			fBitmap = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
			if (fBitmap->InitCheck() == B_OK)
				fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
			break;
		case B_LARGE_ICON_TYPE:
			fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8);
			if (fBitmap->InitCheck() == B_OK)
				fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
			break;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
		case B_VECTOR_ICON_TYPE:
			fBitmap = new BBitmap(BRect(0, 0, fScaleSlider->Value() * 8 - 1,
				fScaleSlider->Value() * 8 - 1), B_RGB32);
			if (fBitmap->InitCheck() != B_OK
				|| BIconUtils::GetVectorIcon((const uint8 *)data,
					(size_t)fEditor.FileSize(), fBitmap) != B_OK) {
				delete fBitmap;
				fBitmap = NULL;
			}
			break;
#endif
		case B_PNG_FORMAT:
		{
			BMemoryIO stream(data, fEditor.FileSize());
			fBitmap = BTranslationUtils::GetBitmap(&stream);
			break;
		}
		case B_MESSAGE_TYPE:
		{
			BMessage message;
			// ToDo: this could be problematic if the data is not large
			//		enough to contain the message...
			if (message.Unflatten(data) == B_OK)
				fBitmap = new BBitmap(&message);
			break;
		}
	}

	// Update the bitmap description. If no image can be displayed,
	// we will show our "unsupported" message

	if (fBitmap != NULL && fBitmap->InitCheck() != B_OK) {
		delete fBitmap;
		fBitmap = NULL;
	}

	if (fBitmap != NULL) {
		char buffer[256];
		const char *type = B_TRANSLATE("Unknown type");
		switch (fEditor.Type()) {
			case B_MINI_ICON_TYPE:
			case B_LARGE_ICON_TYPE:
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
			case B_VECTOR_ICON_TYPE:
#endif
				type = B_TRANSLATE("Icon");
				break;
			case B_PNG_FORMAT:
				type = B_TRANSLATE("PNG format");
				break;
			case B_MESSAGE_TYPE:
				type = B_TRANSLATE("Flattened bitmap");
				break;
			default:
				break;
		}
		const char *colorSpace;
		switch (fBitmap->ColorSpace()) {
			case B_GRAY1:
			case B_GRAY8:
				colorSpace = B_TRANSLATE("Grayscale");
				break;
			case B_CMAP8:
				colorSpace = B_TRANSLATE("8 bit palette");
				break;
			case B_RGB32:
			case B_RGBA32:
			case B_RGB32_BIG:
			case B_RGBA32_BIG:
				colorSpace = B_TRANSLATE("32 bit");
				break;
			case B_RGB15:
			case B_RGBA15:
			case B_RGB15_BIG:
			case B_RGBA15_BIG:
				colorSpace = B_TRANSLATE("15 bit");
				break;
			case B_RGB16:
			case B_RGB16_BIG:
				colorSpace = B_TRANSLATE("16 bit");
				break;
			default:
				colorSpace = B_TRANSLATE("Unknown format");
				break;
		}
		snprintf(buffer, sizeof(buffer), "%s, %g x %g, %s", type,
			fBitmap->Bounds().Width() + 1, fBitmap->Bounds().Height() + 1, 
			colorSpace);
		fDescriptionView->SetText(buffer);
	} else
		fDescriptionView->SetText(B_TRANSLATE_COMMENT("Could not read image", 
			"Image means here a picture file, not a disk image."));

	// Update the view size to match the image and its description

	float width, height;
	fDescriptionView->GetPreferredSize(&width, &height);
	fDescriptionView->ResizeTo(width, height);

	BRect rect = fDescriptionView->Bounds();
	if (fBitmap != NULL) {
		BRect bounds = fBitmap->Bounds();
		rect.bottom += bounds.Height() + 5;

		if (fScaleSlider != NULL && rect.Width() < fScaleSlider->Bounds().Width())
			rect.right = fScaleSlider->Bounds().right;
		if (bounds.Width() > rect.Width())
			rect.right = bounds.right;

		// center description below the bitmap
		fDescriptionView->MoveTo((rect.Width() - fDescriptionView->Bounds().Width()) / 2,
			bounds.Height() + 5);

		if (fScaleSlider != NULL) {
			// center slider below description
			rect.bottom += fScaleSlider->Bounds().Height() + 5;
			fScaleSlider->MoveTo((rect.Width() - fScaleSlider->Bounds().Width()) / 2,
				fDescriptionView->Frame().bottom + 5);

			if (fScaleSlider->IsHidden())
				fScaleSlider->Show();
		}
	} else if (fScaleSlider != NULL && !fScaleSlider->IsHidden())
		fScaleSlider->Hide();

	ResizeTo(rect.Width(), rect.Height());
	if (Parent()) {
		// center within parent view
		BRect parentBounds = Parent()->Bounds();
		MoveTo((parentBounds.Width() - rect.Width()) / 2,
			(parentBounds.Height() - rect.Height()) / 2);
	}

	Invalidate();

	// restore old view size
	fEditor.SetViewSize(viewSize);
}
Exemple #27
0
void IGradientModificationStrategy::FinishIteration() {
    for (int i = 0; i < ToUpdate_.size(); ++i) {
        int const idx = ToUpdate_[i];
        Parent()->Sol_.Update(idx, Parent()->Labels_[idx]);
    }
}
/*******************************************************
*   When ready grap the parents color and refreash.
*******************************************************/
void SplitPane::AttachedToWindow(){
   SetViewColor(Parent()->ViewColor());
   attached = true;
   Update();
}
Exemple #29
0
void DefaultGradientModificationStrategy::ReflectAlphaChange(int idx, SVMFloat deltaAlpha) {
    for (int k = 0; k < Parent()->PointCount(); ++k) {
        ModifyGradient(k, Parent()->QValue(idx, k) * deltaAlpha);
    }
}
Exemple #30
0
int main(int argc, char **argv)
{
	printf("*************************************************\n");
	printf("程序名称: Parent Tree\t作者:jasonleakey\n");
	printf("*************************************************\n");
	int menu_sel_num;
	int i;
	char cur_ch;		//current node value
	char newValue;
	PPTree TT;
	PTree T = &TT;
	PRINT_MENU;
	while (scanf("%d", &menu_sel_num) == 1 && menu_sel_num != EOF)
	{
		switch(menu_sel_num)
		{
			case 1:
				InitPTree(&T);
				printf("Init parent tree complete!\n");
				break;
			case 2:
				CLEAR_STDIN;
				CreatePTree(&T);
				printf("Create parent tree complete!\n");
				break;
			case 3:
				printf("T is %s\n",\
						(PTreeEmpty(T)) ? ("Empty") : ("Not Empty"));
				break;
			case 4:
				printf("Parent Tree depth:%d\n", PTreeDepth(T));
				break;
			case 5:
				printf("Root data:%c\n", Root(T));
				break;
			case 6:
				CLEAR_STDIN;
				printf("Input i(0-?):");
				while (scanf("%d", &i) != 1)
				{
					CLEAR_STDIN;
				}
				printf("the i-th node data:%c\n", Value(T, i));
				break;
			case 7:
				CLEAR_STDIN;
				printf("Input data you want to modify:");
				scanf("%c", &cur_ch);
				CLEAR_STDIN;
				printf("Input new data after modification:");
				scanf("%c", &newValue);
				Assign(&T, cur_ch, newValue);
				printf("Assign complete!\n");
				break;
			case 8:
				CLEAR_STDIN;
				printf("Input data:");
				scanf("%c", &cur_ch);
				printf("Its parent's data:%c\n", Parent(T, cur_ch));
				printf("Parent complete!\n");
				break;
			case 9:
				CLEAR_STDIN;
				printf("Input data:");
				scanf("%c", &cur_ch);
				printf("Its left child's data:%c\n", LeftChild(T, cur_ch));
				printf("LeftChlid complete!\n");
				break;
			case 10:
				CLEAR_STDIN;
				printf("Input data:");
				scanf("%c", &cur_ch);
				printf("Its right sibling's data:%c\n", RightSibling(T, cur_ch));
				printf("RightSibling complete!\n");
				break;
			case 11:
				Print(T);
				printf("Print complete!\n");
				break;
			case 12:
				Traverse(T, vi);
				break;
			case 0:
				DestroyPTree(&T);
				exit(EXIT_SUCCESS);
			default:
				printf("Input error!\nInput again:");
		}
		CLEAR_STDIN;
		printf("press Return back to menu:");
		getchar();
		PRINT_MENU;
	}
	DestroyPTree(&T);
	return EXIT_SUCCESS;
}