Пример #1
0
 virtual bool GetString(CTSTR lpName, String &strVal) const {return globalSource->GetString(lpName, strVal);}
Пример #2
0
 virtual bool GetFloat(CTSTR lpName, float &fValue)   const {return globalSource->GetFloat(lpName, fValue);}
Пример #3
0
 virtual bool GetInt(CTSTR lpName, int &iValue)       const {return globalSource->GetInt(lpName, iValue);}
Пример #4
0
 virtual void SetVector4(CTSTR lpName, const Vect4 &value)   {globalSource->SetVector4(lpName, value);}
Пример #5
0
 virtual void SetMatrix(CTSTR lpName, const Matrix &mat)     {globalSource->SetMatrix(lpName, mat);}
Пример #6
0
 virtual void SetInt(CTSTR lpName, int iValue)               {globalSource->SetInt(lpName, iValue);}
Пример #7
0
 virtual void SetString(CTSTR lpName, CTSTR lpVal)           {globalSource->SetString(lpName, lpVal);}
Пример #8
0
 virtual void SetFloat(CTSTR lpName, float fValue)           {globalSource->SetFloat(lpName, fValue);}
Пример #9
0
 Vect2 GetSize() const {return globalSource->GetSize();}
Пример #10
0
 void Render(const Vect2 &pos, const Vect2 &size) {globalSource->Render(pos, size);}
Пример #11
0
void
Image::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
{
	if (args->GetProperty ()->GetOwnerType() != Type::IMAGE) {
		MediaBase::OnPropertyChanged (args, error);
		return;
	}
	
	if (args->GetId () == Image::SourceProperty) {
		ImageSource *source = args->GetNewValue () ? args->GetNewValue ()->AsImageSource () : NULL; 
		ImageSource *old = args->GetOldValue () ? args->GetOldValue ()->AsImageSource () : NULL;

		if (old) {
			if (old->Is(Type::BITMAPSOURCE)) {
				old->RemoveHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this);
			}

			if (old->Is(Type::BITMAPIMAGE)) {
				old->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
				old->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
				old->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this);
			}			
		}
		
		if (source) {
			if (source->Is(Type::BITMAPSOURCE)) {
				source->AddHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this);
			}

		        if (source->Is(Type::BITMAPIMAGE)) {
				source->AddHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
				source->AddHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
				source->AddHandler (BitmapImage::ImageFailedEvent, image_failed, this);
			}

			if (source->GetPixelWidth () > 0 && source->GetPixelHeight () > 0) {
				RoutedEventArgs *args = MoonUnmanagedFactory::CreateRoutedEventArgs ();
				ImageOpened (args);
				args->unref ();
			}
		} else {
			UpdateBounds ();
			Invalidate ();
		}

		InvalidateMeasure ();
	}
	
	// we need to notify attachees if our DownloadProgress changed.
	NotifyListenersOfPropertyChange (args, error);
}
Пример #12
0
void
Image::Render (cairo_t *cr, Region *region, bool path_only)
{
	ImageSource *source = GetSource ();
	cairo_pattern_t *pattern = NULL;
	cairo_matrix_t matrix;
	
	if (!source)
		return;

	source->Lock ();

	cairo_save (cr);
       
	Size specified (GetActualWidth (), GetActualHeight ());
	Size stretched = ApplySizeConstraints (specified);
	bool adjust = specified != GetRenderSize ();

	if (GetStretch () != StretchUniformToFill)
		specified = specified.Min (stretched);

	Rect paint = Rect (0, 0, specified.width, specified.height);
	
	if (!path_only) {
		Rect image = Rect (0, 0, source->GetPixelWidth (), source->GetPixelHeight ());

		if (GetStretch () == StretchNone)
			paint = paint.Union (image);

		if (image.width == 0.0 && image.height == 0.0)
			goto cleanup;

		pattern = cairo_pattern_create_for_surface (source->GetSurface (cr));
		image_brush_compute_pattern_matrix (&matrix, paint.width, paint.height, 
						    image.width, image.height,
						    GetStretch (), 
						    AlignmentXCenter, AlignmentYCenter, NULL, NULL);
		
		cairo_pattern_set_matrix (pattern, &matrix);
#if MAKE_EVERYTHING_SLOW_AND_BUGGY
		cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
#endif
		if (cairo_pattern_status (pattern) == CAIRO_STATUS_SUCCESS) {
			cairo_set_source (cr, pattern);
		}
		cairo_pattern_destroy (pattern);
	}

	if (adjust) {
		// FIXME: Propagate error properly
		MoonError error;
		specified = MeasureOverrideWithError (specified, &error);
		paint = Rect ((stretched.width - specified.width) * 0.5, (stretched.height - specified.height) * 0.5, specified.width, specified.height);
	}
	
	if (!path_only)
		RenderLayoutClip (cr);

	paint = paint.Intersection (Rect (0, 0, stretched.width, stretched.height));
	paint.Draw (cr);
	
	if (!path_only)
		cairo_fill (cr);

cleanup:
	cairo_restore (cr);
	source->Unlock ();
}