void CounterView::Draw (BRect updateRect)
{
  BRect MovingRect (
    m_MovingDotPoint.x,
    m_MovingDotPoint.y,
    m_MovingDotPoint.x + m_MovingDotSize,
    m_MovingDotPoint.y + m_MovingDotSize);
  char TempString [40];

  if (m_BackingBitmap != NULL)
  {
    m_BackingBitmap->Lock ();
    m_BackingView.SetHighColor (60, 60, 255, 8);
    m_BackingView.FillRect (m_BndRect);
    m_BackingView.SetHighColor (255, 255, 0, 255);
    m_BackingView.MovePenTo (m_TextStartPoint);
    sprintf (TempString, "%d", m_CurrentCount);
    m_BackingView.DrawString (TempString);
    m_BackingView.FillRect (MovingRect);
    m_BackingView.Sync ();
    m_BackingBitmap->Unlock ();
    MovePenTo (0, 0);
    DrawBitmap (m_BackingBitmap);
  }
}
BBitmap* MainView::CreateIcon(const rgb_color colorIn)
{
	BRect rect(0, 0, 15, 15);
	BBitmap* toReturn = new BBitmap(rect, B_CMAP8, true);
	BView* drawing = new BView(rect, 
								"drawer", 
								B_FOLLOW_LEFT | B_FOLLOW_TOP,
								B_WILL_DRAW);
	if (!drawing || !toReturn) { return NULL; }	
	toReturn->AddChild(drawing);
	if (toReturn->Lock()) {
		drawing->SetHighColor(kWhite);
		drawing->FillRect(rect);
		drawing->SetHighColor(kBlack);
		drawing->SetPenSize(1);
		drawing->StrokeRect(rect);
		drawing->SetHighColor(colorIn);
		drawing->FillRect(rect.InsetBySelf(1, 1));
		drawing->Sync();
		toReturn->Unlock();			
	}
	toReturn->RemoveChild(drawing);
	delete drawing;
	return toReturn;
}
Example #3
0
/***********************************************************
 * Make down state picture.
 ***********************************************************/
BPicture*
HToolbarButton::MakeDownPicture(BBitmap *in)
{
	HToolbar *toolbar = cast_as(Parent(),HToolbar);
	BRect buttonRect = toolbar->ButtonRect();
	BView *view = new BView(BRect(0,0,buttonRect.Width(),buttonRect.Height())
							,"offview",0,0);
	BBitmap *bitmap = new BBitmap(view->Bounds(), in->ColorSpace(), true);
	BPicture *pict;
	bitmap->AddChild(view);
	bitmap->Lock();
	
	view->SetHighColor(BeLightShadow);
	view->FillRect(view->Bounds());
	
	view->BeginPicture(new BPicture); 
	
	DrawString(view,fName.String(),true);
	view->SetDrawingMode(B_OP_MIN); 
	DrawBitmap(view,in,true);
	
	const float height = view->Bounds().Height();
	view->SetDrawingMode(B_OP_OVER);
	view->SetHighColor(BeShadow);
	view->FillRect(BRect(0,0,0,height));
	view->FillRect(BRect(0,0,height,0));
	view->SetHighColor(White);
	view->FillRect(BRect(height-1,0,height-1,height-1));
	view->FillRect(BRect(0,height-1,height-1,height-1));
	
	pict = view->EndPicture();
	bitmap->Unlock();
	delete bitmap;
	return pict;
}
Example #4
0
/*!
 *	\brief		Create the square icon filled with submitted color.
 *	\param[in]	color		The color of the requested icon.
 *	\param[in]	toChange	If there is an allocated item, it may be changed.
 *							If the submitted pointer is not NULL (which is default),
 *							this BBitmap is tested for dimensions match, and if dimensions
 *							allow, its contents are replaced with new icon. Else, old icon
 *							is deleted, and a new is created. In this case, both the
 *							"toChange" pointer and returned pointer point to the same
 *							BBitmap. 
 */
BBitmap* CategoryMenuItem::CreateIcon(const rgb_color colorIn, BBitmap* toChange )
{
	font_height fh;
	BFont plainFont( be_plain_font );
	plainFont.GetHeight( &fh );
	
	int squareSize = ceilf( fh.ascent + fh.descent + fh.leading - 2 );	//!< Side of the square.
	BRect rect(0, 0, squareSize, squareSize );
	BBitmap* toReturn = NULL;
	if ( !toChange )	// Checking availability of the input
	{
		toReturn = new BBitmap(rect, B_RGB32, true);
	} else {
		// It would be a good idea to check also the color space,
		// but it may be changed by the BBitmap itself, so...
		if ( ceilf ( ( toChange->Bounds() ).Width() ) != squareSize )
		{
			delete toChange;
			toChange = new BBitmap(rect, B_RGB32, true);
			if ( !toChange )
			{
				/* Panic! */
				exit(1);
			}			
		}
		toReturn = toChange;
	}
	
	BView* drawing = new BView( rect, 
								"Drawer", 
								B_FOLLOW_LEFT | B_FOLLOW_TOP,
								B_WILL_DRAW);
	if (!drawing || !toReturn) { return NULL; }	
	toReturn->AddChild(drawing);
	if (toReturn->Lock()) {
		
		// Clean the area
		drawing->SetHighColor( ui_color( B_DOCUMENT_BACKGROUND_COLOR ) );
		drawing->FillRect(rect);
		
		// Draw the black square
		drawing->SetHighColor( ui_color( B_DOCUMENT_TEXT_COLOR ) );
		drawing->SetPenSize(1);
		drawing->StrokeRect(rect);
		
		// Fill the inside of the square
		drawing->SetHighColor( colorIn );
		drawing->FillRect(rect.InsetBySelf(1, 1));
		
		// Flush the actions to BBitmap
		drawing->Sync();
		toReturn->Unlock();
	}
	toReturn->RemoveChild(drawing);			// Cleanup
	delete drawing;
	return toReturn;
}	// <-- end of function CategoryMenuItem::CreateIcon
Example #5
0
BBitmap* SwatchView::make_bitmap(void)
{
	BRect rect(0.0, 0.0, 12.0, 12.0);
	
	BBitmap *bitmap = new BBitmap(rect, B_RGB32, true);
	BView *view = new BView(rect, "", B_FOLLOW_NONE, B_WILL_DRAW);

	bitmap->Lock();

	bitmap->AddChild(view);

	view->SetDrawingMode(B_OP_ALPHA);
	view->SetHighColor(m_color);
	view->FillRect(rect);
	
	view->SetDrawingMode(B_OP_COPY);
	view->SetHighColor(0, 0, 0, 255);
	view->StrokeRect(rect);
	view->Sync();

	bitmap->RemoveChild(view);
	delete view;

	bitmap->Unlock();
	
	return bitmap;
}
Example #6
0
void BochsView::FillRect(BRect r, pattern p)
{
  backing_store->Lock();
  backing_view->FillRect(r,p);
  backing_store->Unlock();
  Invalidate(r);
}
Example #7
0
/***********************************************************
 * Make disable state picture.
 ***********************************************************/
BPicture*
HToolbarButton::MakeDisablePicture(BBitmap *in)
{
	HToolbar *toolbar = cast_as(Parent(),HToolbar);
	BRect buttonRect = toolbar->ButtonRect();
	
	BView *view = new BView(BRect(0,0,buttonRect.Width(),buttonRect.Height())
							,"offview",0,0);
	BBitmap *bitmap = new BBitmap(view->Bounds(), in->ColorSpace(), true);
	BPicture *pict;
	bitmap->AddChild(view);
	bitmap->Lock();

	view->BeginPicture(new BPicture); 
	view->SetHighColor(bgcolor);
	view->FillRect(view->Bounds());
	
	DrawString(view,fName.String(),false,false);
	
	view->SetDrawingMode(B_OP_BLEND); 
	
	DrawBitmap(view,in);
	
	pict = view->EndPicture();
	bitmap->Unlock();
	delete bitmap;
	return pict;
}
static BBitmap*
MakeActuatorBitmap(bool lit)
{
	BBitmap* map = new BBitmap(ICON_BITMAP_RECT, ICON_BITMAP_SPACE, true);
	const rgb_color yellow = {255, 255, 0};
	const rgb_color red = {200, 200, 200};
	const rgb_color black = {0, 0, 0};
	const BPoint points[10] = {
		BPoint(8, 0), BPoint(9.8, 5.8), BPoint(16, 5.8),
		BPoint(11, 9.0), BPoint(13, 16), BPoint(8, 11),
		BPoint(3, 16), BPoint(5, 9.0), BPoint(0, 5.8),
		BPoint(6.2, 5.8) };

	BView* view = new BView(BRect(0, 0, 16, 16), NULL, B_FOLLOW_ALL_SIDES, 0L);
	map->AddChild(view);
	map->Lock();
	view->SetHighColor(B_TRANSPARENT_32_BIT);
	view->FillRect(ICON_BITMAP_RECT);
	view->SetHighColor(lit ? yellow : red);
	view->FillPolygon(points, 10);
	view->SetHighColor(black);
	view->StrokePolygon(points, 10);
	map->Unlock();
	map->RemoveChild(view);
	delete view;
	return map;
}
Example #9
0
// SetIcon
status_t
IconButton::SetIcon(const unsigned char* bitsFromQuickRes,
                    uint32 width, uint32 height, color_space format, bool convertToBW)
{
    status_t status = B_BAD_VALUE;
    if (bitsFromQuickRes && width > 0 && height > 0) {
        BBitmap* quickResBitmap = new(nothrow) BBitmap(BRect(0.0, 0.0, width - 1.0, height - 1.0), format);
        status = quickResBitmap ? quickResBitmap->InitCheck() : B_ERROR;
        if (status >= B_OK) {
            // It doesn't look right to copy BitsLength() bytes, but bitmaps
            // exported from QuickRes still contain their padding, so it is alright.
            memcpy(quickResBitmap->Bits(), bitsFromQuickRes, quickResBitmap->BitsLength());
            if (format != B_RGB32 && format != B_RGBA32 && format != B_RGB32_BIG && format != B_RGBA32_BIG) {
                // colorspace needs conversion
                BBitmap* bitmap = new(nothrow) BBitmap(quickResBitmap->Bounds(), B_RGB32, true);
                if (bitmap && bitmap->IsValid()) {
                    BView* helper = new BView(bitmap->Bounds(), "helper",
                                              B_FOLLOW_NONE, B_WILL_DRAW);
                    if (bitmap->Lock()) {
                        bitmap->AddChild(helper);
                        helper->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
                        helper->FillRect(helper->Bounds());
                        helper->SetDrawingMode(B_OP_OVER);
                        helper->DrawBitmap(quickResBitmap, BPoint(0.0, 0.0));
                        helper->Sync();
                        bitmap->Unlock();
                    }
                    status = _MakeBitmaps(bitmap);
                } else
                    printf("IconButton::SetIcon() - B_RGB32 bitmap is not valid\n");
                delete bitmap;
            } else {
                // native colorspace (32 bits)
                if (convertToBW) {
                    // convert to gray scale icon
                    uint8* bits = (uint8*)quickResBitmap->Bits();
                    uint32 bpr = quickResBitmap->BytesPerRow();
                    for (uint32 y = 0; y < height; y++) {
                        uint8* handle = bits;
                        uint8 gray;
                        for (uint32 x = 0; x < width; x++) {
                            gray = uint8((116 * handle[0] + 600 * handle[1] + 308 * handle[2]) / 1024);
                            handle[0] = gray;
                            handle[1] = gray;
                            handle[2] = gray;
                            handle += 4;
                        }
                        bits += bpr;
                    }
                }
                status = _MakeBitmaps(quickResBitmap);
            }
        } else
            printf("IconButton::SetIcon() - error allocating bitmap: %s\n", strerror(status));
        delete quickResBitmap;
    }
    return status;
}
Example #10
0
void
IconSpewer::DrawSomeOld()
{
#if 0
	if (!oldIconCacheInited)
		BIconCache::InitIconCaches();

	target->Lock();
	target->SetTitle("old cache");
	BView* view = target->FindView("iconView");
	ASSERT(view);

	BRect bounds(target->Bounds());
	view->SetHighColor(Color(255, 255, 255));
	view->FillRect(bounds);

	view->SetHighColor(Color(0, 0, 0));
	char buffer[256];
	if (cycleTime) {
		sprintf(buffer, "last cycle time %Ld ms", cycleTime/1000);
		view->DrawString(buffer, BPoint(20, bounds.bottom - 20));
	}
	if (numDrawn) {
		sprintf(buffer, "average draw time %Ld us per icon",
			watch.ElapsedTime() / numDrawn);
		view->DrawString(buffer, BPoint(20, bounds.bottom - 30));
	}
	sprintf(buffer, "directory: %s", currentPath.Path());
	view->DrawString(buffer, BPoint(20, bounds.bottom - 40));

	target->Unlock();

	for (int32 row = 0; row < kRowCount; row++) {
		for (int32 column = 0; column < kColumnCount; column++) {
			BEntry entry(NextRef());
			BModel model(&entry, true);

			if (!target->Lock())
				return;

			if (model.IsDirectory())
				entry.GetPath(&currentPath);

			BIconCache::LockIconCache();
			BIconCache* iconCache
				= BIconCache::GetIconCache(&model, kIconSize);
			iconCache->Draw(view, BPoint(column * (kIconSize + 2),
				row * (kIconSize + 2)), B_NORMAL_ICON, kIconSize, true);
			BIconCache::UnlockIconCache();

			target->Unlock();
			numDrawn++;
		}
	}
#endif
}
Example #11
0
void
IconView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
{
	if (fTracking && !fDragging && fIcon != NULL
		&& (abs((int32)(where.x - fDragPoint.x)) > 3
			|| abs((int32)(where.y - fDragPoint.y)) > 3)) {
		// Start drag
		BMessage message(B_SIMPLE_DATA);

		::Icon* icon = fIconData;
		if (fHasRef || fHasType) {
			icon = new ::Icon;
			if (fHasRef)
				icon->SetTo(fRef, fType.Type());
			else if (fHasType)
				icon->SetTo(fType);
		}

		icon->CopyTo(message);

		if (icon != fIconData)
			delete icon;

		BBitmap *dragBitmap = new BBitmap(fIcon->Bounds(), B_RGBA32, true);
		dragBitmap->Lock();
		BView *view
			= new BView(dragBitmap->Bounds(), B_EMPTY_STRING, B_FOLLOW_NONE, 0);
		dragBitmap->AddChild(view);

		view->SetHighColor(B_TRANSPARENT_COLOR);
		view->FillRect(dragBitmap->Bounds());
		view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
		view->SetDrawingMode(B_OP_ALPHA);
		view->SetHighColor(0, 0, 0, 160);
		view->DrawBitmap(fIcon);

		view->Sync();
		dragBitmap->Unlock();

		DragMessage(&message, dragBitmap, B_OP_ALPHA,
			fDragPoint - BitmapRect().LeftTop(), this);
		fDragging = true;
		SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
	}

	if (dragMessage != NULL && !fDragging && AcceptsDrag(dragMessage)) {
		bool dropTarget = transit == B_ENTERED_VIEW || transit == B_INSIDE_VIEW;
		if (dropTarget != fDropTarget) {
			fDropTarget = dropTarget;
			Invalidate();
		}
	} else if (fDropTarget) {
		fDropTarget = false;
		Invalidate();
	}
}
Example #12
0
BBitmap *DragonView::_MakeDragBitmap( void )
{
	// If the currently displayed bitmap is too large to drag around,
	// we'll just drag around a rectangle.

	BRect drag_rect = _bits->Bounds();

	if( drag_rect.Width() > _drag_max_size.x ||
		drag_rect.Height() > _drag_max_size.y ) return NULL;

	// If we've got a PNG image, we'll assume that it's got
	// "interesting" alpha information.  The ones that are built
	// into DragonDrop's resources all have "interesting" alpha
	// channels.
			
	if( _image_is_png ) {
		BBitmap *drag_me = new BBitmap( _bits );
		memcpy( drag_me->Bits(), _bits->Bits(), _bits->BitsLength() );
		
		return drag_me;
	}

	// If you've made it here, we'll need to build a semi-transparent image
	// to drag around.  This magic is from Pavel Cisler, and it ensures that
	// you've got a drag bitmap that's translucent.
	
	BRect rect( _bits->Bounds() );
	BBitmap *bitmap = new BBitmap( rect, B_RGBA32, true );
	BView *view = new BView( rect, "drag view", B_FOLLOW_NONE, 0 );

	bitmap->Lock();
	bitmap->AddChild( view );
	
	BRegion new_clip;
	new_clip.Set( rect );
	view->ConstrainClippingRegion( &new_clip );
	
	view->SetHighColor( 0, 0, 0, 0 );
	view->FillRect( rect );
	view->SetDrawingMode( B_OP_ALPHA );
	
	view->SetHighColor( 0, 0, 0, 128 );
	view->SetBlendingMode( B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE );
	
	view->DrawBitmap( _bits );
	
	view->Sync();
	
	bitmap->Unlock();

	return bitmap;
}
Example #13
0
void
KeyboardLayoutView::Draw(BRect updateRect)
{
	if (fOldSize != BSize(Bounds().Width(), Bounds().Height())) {
		_InitOffscreen();
		_LayoutKeyboard();
	}

	BView* view;
	if (fOffscreenBitmap != NULL) {
		view = fOffscreenView;
		view->LockLooper();
	} else
		view = this;

	// Draw background

	if (Parent())
		view->SetLowColor(Parent()->ViewColor());
	else
		view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	view->FillRect(updateRect, B_SOLID_LOW);

	// Draw keys

	for (int32 i = 0; i < fLayout->CountKeys(); i++) {
		Key* key = fLayout->KeyAt(i);

		_DrawKey(view, updateRect, key, _FrameFor(key),
			_IsKeyPressed(key->code));
	}

	// Draw LED indicators

	for (int32 i = 0; i < fLayout->CountIndicators(); i++) {
		Indicator* indicator = fLayout->IndicatorAt(i);

		_DrawIndicator(view, updateRect, indicator, _FrameFor(indicator->frame),
			(fModifiers & indicator->modifier) != 0);
	}

	if (fOffscreenBitmap != NULL) {
		view->Sync();
		view->UnlockLooper();

		DrawBitmapAsync(fOffscreenBitmap, BPoint(0, 0));
	}
}
Example #14
0
void
IconSpewer::DrawSomeNew()
{
	target->Lock();
	BView* view = target->FindView("iconView");
	ASSERT(view);

	BRect bounds(target->Bounds());
	view->SetHighColor(Color(255, 255, 255));
	view->FillRect(bounds);

	view->SetHighColor(Color(0, 0, 0));
	char buffer[256];
	if (cycleTime) {
		sprintf(buffer, "last cycle time %" B_PRId64 " ms", cycleTime/1000);
		view->DrawString(buffer, BPoint(20, bounds.bottom - 20));
	}

	if (numDrawn) {
		sprintf(buffer, "average draw time %" B_PRId64 " us per icon",
			watch.ElapsedTime() / numDrawn);
		view->DrawString(buffer, BPoint(20, bounds.bottom - 30));
	}

	sprintf(buffer, "directory: %s", currentPath.Path());
	view->DrawString(buffer, BPoint(20, bounds.bottom - 40));

	target->Unlock();

	for (int32 row = 0; row < kRowCount; row++) {
		for (int32 column = 0; column < kColumnCount; column++) {
			BEntry entry(NextRef());
			Model model(&entry, true);

			if (!target->Lock())
				return;

			if (model.IsDirectory())
				entry.GetPath(&currentPath);

			IconCache::sIconCache->Draw(&model, view,
				BPoint(column * (kIconSize + 2), row * (kIconSize + 2)),
				kNormalIcon, kIconSize, true);
			target->Unlock();
			numDrawn++;
		}
	}
}
Example #15
0
BBitmap *bitmap (char *title)
{
	strcpy (title, "Grabbed");
	BBitmap *b = new BBitmap (BRect (0, 0, 127, 127), B_RGB_32_BIT, true);
	BView *v = new BView (BRect (0, 0, 127, 127), "bg", 0, 0);
	b->Lock();
	b->AddChild (v);
	rgb_color fg, bg;
	fg.red = 255; fg.green = 255; fg.blue = 255; fg.alpha = 255;
	bg.red = 0;   bg.green = 0;   bg.blue = 0;   bg.alpha = 127;
	v->SetHighColor (fg);
	v->SetLowColor (bg);
	v->FillRect (BRect (0, 0, 127, 127), B_MIXED_COLORS);
	v->Sync();
	b->RemoveChild (v);
	b->Unlock();
	delete v;
	return (b);
}
Example #16
0
BBitmap *DragonView::_MakeNoneImage( void )
{
	// Draw an "empty" bitmap to represent "no image"; we'll use one
	// that tells the user what to do.
	BBitmap *bitmap = new BBitmap( BRect( 0, 0, 319, 199 ),
								   BScreen().ColorSpace(),
								   true );
	BView *view = new BView( bitmap->Bounds(),
							 "not a bitmap",
							 B_FOLLOW_ALL_SIDES, 0 );
	bitmap->AddChild( view );

	DragonApp *app = dynamic_cast<DragonApp *>( be_app );
	
	rgb_color White = { 255, 255, 255, 0 };
	rgb_color Black = { 0, 0, 0, 0 };
	
	bitmap->Lock();

	view->SetLowColor( White );
	view->SetViewColor( White );
	view->SetHighColor( Black );
	view->SetDrawingMode( B_OP_OVER );
	view->FillRect( view->Bounds(), B_SOLID_LOW );

	// Excercise for the reader here:  Read the old newsletter articles
	// about how to use the font metrics to find out how large a font is,
	// then center to font in the window dynamically no matter what font
	// settings the user has.

	view->SetFont( be_plain_font );
	view->MovePenTo( 5, 100 );
	view->DrawString( app->rsrc_strings->FindString( RSRC_Drop_an_image ) );
	view->Sync();
	
	bitmap->Unlock();

	return bitmap;
}
/*!	\function	CategoryMenuItem::CreateIcon
 *	\brief		Create the square icon filled with submitted color.
 *	\param[in]	color		The color of the requested icon.
 *	\param[in]	toChange	If there is an allocated item, it may be changed.
 *							If the submitted pointer is not NULL (which is default),
 *							this BBitmap is tested for dimensions match, and if dimensions
 *							allow, its contents are replaced with new icon. Else, old icon
 *							is deleted, and a new is created. In this case, both the
 *							"toChange" pointer and returned pointer point to the same
 *							BBitmap.
 */
BBitmap*	CategoryMenuItem::CreateIcon( const rgb_color color,
										  BBitmap* toChange )
{
	BBitmap* toReturn = NULL;	//!< This is the value to be returned.
	BRect tempRect;
	float width, height, squareSide;
	
	// Get size of the square
	this->GetContentSize( &width, &height );
	squareSide = ceilf( height ) - 2;
	
	// Compare submitted bitmap to calculated size
	if ( toChange )
	{
		tempRect = toChange->Bounds();
		if ( ( tempRect.Width() != squareSide ) ||
			 ( tempRect.Height() != squareSide ) )
		{
			// Dimensions don't match - need to delete the bitmap and reallocate it
			delete toChange;
			tempRect.Set( 0, 0, squareSide, squareSide );
			toChange = new BBitmap( tempRect, B_RGB32, true );
			if ( !toChange )
			{
				/* Panic! */
				exit(1);
			}
			
			toReturn = toChange;
		}
		else
		{
			/*!	\note	Note about color spaces
			 *			Actually, even if the dimensions are correct, the existing
			 *			BBitmap may be not suitable due to incorrect color space.
			 *			However, BBitmap may change the color space on its own, (and
			 *			probably will, since there's no much sense in having 32 bits
			 *			per pixel for bitmap with only 2 colors - black for the frame
			 *			and Category's color for the inside). Therefore, color space is
			 *			not checked. It's assumed that existing color space is good enough.
			 */
			// Dimensions match, color space is not checked - continuing
			toReturn = toChange;
		}
	}
	else	// No bitmap is submitted
	{
		toReturn = new BBitmap( tempRect, B_RGB32, true );
		if ( !toReturn )
		{
			/* Panic! */
			exit(1);
		}
	}
	
	/* Here toReturn is already set. */
	
	// Add the drawing view to the bitmap
	tempRect.Set( 0, 0, squareSide, squareSide );
	BView* drawing = new BView (tempRect,
								"Drawer", 
								B_FOLLOW_LEFT | B_FOLLOW_TOP,
								B_WILL_DRAW);
	if (!drawing || !toReturn) {
		/* Panic! */
		return NULL;
	}	
	toReturn->AddChild(drawing);
	if (toReturn->Lock()) {

		// Clean the area
		drawing->SetHighColor( ui_color( B_MENU_BACKGROUND_COLOR ) );
		drawing->FillRect( tempRect );
		
		// Draw the black square
		drawing->SetHighColor( ui_color( B_MENU_ITEM_TEXT_COLOR ) );
		drawing->SetPenSize( 1 );
		drawing->StrokeRect( tempRect );
		
		// Fill the inside of the square
		drawing->SetHighColor( color );
		drawing->FillRect( tempRect.InsetBySelf( 1, 1 ) );
		
		// Flush the actions to BBitmap
		drawing->Sync();
		toReturn->Unlock();	
	}

	toReturn->RemoveChild( drawing );
	delete drawing;

	return toReturn;
}	// <-- end of function "CategoryMenuItem::CreateIcon"
Example #18
0
void
ActivityView::_DrawHistory(bool drawBackground)
{
	_UpdateOffscreenBitmap();

	BView* view = this;
	if (fOffscreen != NULL) {
		fOffscreen->Lock();
		view = _OffscreenView();
	}

	BRect frame = _HistoryFrame();
	BRect outerFrame = frame.InsetByCopy(-2, -2);

	// draw the outer frame
	uint32 flags = 0;
	if (!drawBackground)
		flags |= BControlLook::B_BLEND_FRAME;
	be_control_look->DrawTextControlBorder(this, outerFrame,
		outerFrame, fLegendBackgroundColor, flags);

	// convert to offscreen view if necessary
	if (view != this)
		frame.OffsetTo(B_ORIGIN);

	view->SetLowColor(fHistoryBackgroundColor);
	view->FillRect(frame, B_SOLID_LOW);

	uint32 step = 2;
	uint32 resolution = fDrawResolution;
	if (fDrawResolution > 1) {
		step = 1;
		resolution--;
	}

	// We would get a negative number of steps which isn't a good idea.
	if (frame.IntegerWidth() <= 10)
		return;

	uint32 width = frame.IntegerWidth() - 10;
	uint32 steps = width / step;
	bigtime_t timeStep = RefreshInterval() * resolution;
	bigtime_t now = system_time();

	// Draw scale
	// TODO: add second markers?

	view->SetPenSize(1);

	rgb_color scaleColor = view->LowColor();
	uint32 average = (scaleColor.red + scaleColor.green + scaleColor.blue) / 3;
	if (average < 96)
		scaleColor = tint_color(scaleColor, B_LIGHTEN_2_TINT);
	else
		scaleColor = tint_color(scaleColor, B_DARKEN_2_TINT);

	view->SetHighColor(scaleColor);
	view->StrokeLine(BPoint(frame.left, frame.top + frame.Height() / 2),
		BPoint(frame.right, frame.top + frame.Height() / 2));

	// Draw values

	view->SetPenSize(1.5);
	BAutolock _(fSourcesLock);

	for (uint32 i = fSources.CountItems(); i-- > 0;) {
		ViewHistory* viewValues = fViewValues.ItemAt(i);
		DataSource* source = fSources.ItemAt(i);
		DataHistory* values = fValues.ItemAt(i);

		viewValues->Update(values, steps, fDrawResolution, now, timeStep,
			RefreshInterval());

		if (viewValues->Start() >= (int32)steps - 1)
			continue;

		uint32 x = viewValues->Start() * step;

		bool first = true;

		view->SetHighColor(source->Color());
		view->SetLineMode(B_BUTT_CAP, B_ROUND_JOIN);
		view->MovePenTo(B_ORIGIN);

		try {
			view->BeginLineArray(steps - viewValues->Start() - 1);

			BPoint prev;

			for (uint32 j = viewValues->Start(); j < steps; x += step, j++) {
				float y = _PositionForValue(source, values,
					viewValues->ValueAt(j));

				if (first) {
					first = false;
				} else
					view->AddLine(prev, BPoint(x, y), source->Color());

				prev.Set(x, y);
			}

		} catch (std::bad_alloc) {
			// Not enough memory to allocate the line array.
			// TODO we could try to draw using the slower but less memory
			// consuming solution using StrokeLine.
		}

		view->EndLineArray();
	}

	// TODO: add marks when an app started or quit
	view->Sync();
	if (fOffscreen != NULL) {
		fOffscreen->Unlock();
		DrawBitmap(fOffscreen, outerFrame.LeftTop());
	}
}
Example #19
0
void
BSlider::_DrawBlockThumb()
{
	BRect frame = ThumbFrame();
	BView *view = OffscreenView();

	if (be_control_look != NULL) {
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		uint32 flags = be_control_look->Flags(this);
		be_control_look->DrawSliderThumb(view, frame, frame, base, flags,
			fOrientation);
		return;
	}

	rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color lighten2;
	rgb_color lighten1;
	rgb_color darken2;
	rgb_color darken3;
	rgb_color darkenmax;

	if (IsEnabled()) {
		lighten2	= tint_color(no_tint, B_LIGHTEN_2_TINT);
		lighten1	= no_tint;
		darken2		= tint_color(no_tint, B_DARKEN_2_TINT);
		darken3		= tint_color(no_tint, B_DARKEN_3_TINT);
		darkenmax	= tint_color(no_tint, B_DARKEN_MAX_TINT);
	} else {
		lighten2	= tint_color(no_tint, B_LIGHTEN_2_TINT);
		lighten1	= tint_color(no_tint, B_LIGHTEN_1_TINT);
		darken2		= tint_color(no_tint, (B_NO_TINT + B_DARKEN_1_TINT) / 2.0);
		darken3		= tint_color(no_tint, B_DARKEN_1_TINT);
		darkenmax	= tint_color(no_tint, B_DARKEN_3_TINT);
	}

	// blank background for shadow
	// ToDo: this also draws over the hash marks (though it's not *that* noticeable)
	view->SetHighColor(no_tint);
	view->StrokeLine(BPoint(frame.left, frame.top),
					 BPoint(frame.left, frame.top));

	BRect barFrame = BarFrame();
	if (barFrame.right >= frame.right) {
		// leave out barFrame from shadow background clearing
		view->StrokeLine(BPoint(frame.right, frame.top),
						 BPoint(frame.right, barFrame.top - 1.0f));
		view->StrokeLine(BPoint(frame.right, barFrame.bottom + 1.0f),
						 BPoint(frame.right, frame.bottom));
	} else {
		view->StrokeLine(BPoint(frame.right, frame.top),
						 BPoint(frame.right, frame.bottom));
	}

	view->StrokeLine(BPoint(frame.left, frame.bottom),
					 BPoint(frame.right - 1.0f, frame.bottom));
	view->StrokeLine(BPoint(frame.left, frame.bottom - 1.0f),
					 BPoint(frame.left, frame.bottom - 1.0f));
	view->StrokeLine(BPoint(frame.right - 1.0f, frame.top),
					 BPoint(frame.right - 1.0f, frame.top));

	// Outline (top, left)
	view->SetHighColor(darken3);
	view->StrokeLine(BPoint(frame.left, frame.bottom - 2.0f),
					 BPoint(frame.left, frame.top + 1.0f));
	view->StrokeLine(BPoint(frame.left + 1.0f, frame.top),
					 BPoint(frame.right - 2.0f, frame.top));

	// Shadow
	view->SetHighColor(0, 0, 0, IsEnabled() ? 100 : 50);
	view->SetDrawingMode(B_OP_ALPHA);
	view->StrokeLine(BPoint(frame.right, frame.top + 2.0f),
					 BPoint(frame.right, frame.bottom - 1.0f));
	view->StrokeLine(BPoint(frame.left + 2.0f, frame.bottom),
					 BPoint(frame.right - 1.0f, frame.bottom));

	view->SetDrawingMode(B_OP_COPY);
	view->SetHighColor(darken3);
	view->StrokeLine(BPoint(frame.right - 1.0f, frame.bottom - 1.0f),
					 BPoint(frame.right - 1.0f, frame.bottom - 1.0f));


	// First bevel
	frame.InsetBy(1.0f, 1.0f);

	view->SetHighColor(darkenmax);
	view->StrokeLine(BPoint(frame.left, frame.bottom),
					 BPoint(frame.right - 1.0f, frame.bottom));
	view->StrokeLine(BPoint(frame.right, frame.bottom - 1.0f),
					 BPoint(frame.right, frame.top));

	view->SetHighColor(lighten2);
	view->StrokeLine(BPoint(frame.left, frame.top),
					 BPoint(frame.left, frame.bottom - 1.0f));
	view->StrokeLine(BPoint(frame.left + 1.0f, frame.top),
					 BPoint(frame.right - 1.0f, frame.top));

	frame.InsetBy(1.0f, 1.0f);

	view->FillRect(BRect(frame.left, frame.top, frame.right - 1.0f, frame.bottom - 1.0f));

	// Second bevel and center dots
	view->SetHighColor(darken2);
	view->StrokeLine(BPoint(frame.left, frame.bottom),
					 BPoint(frame.right, frame.bottom));
	view->StrokeLine(BPoint(frame.right, frame.bottom - 1.0f),
					 BPoint(frame.right, frame.top));

	if (Orientation() == B_HORIZONTAL) {
		view->StrokeLine(BPoint(frame.left + 6.0f, frame.top + 2.0f),
						 BPoint(frame.left + 6.0f, frame.top + 2.0f));
		view->StrokeLine(BPoint(frame.left + 6.0f, frame.top + 4.0f),
						 BPoint(frame.left + 6.0f, frame.top + 4.0f));
		view->StrokeLine(BPoint(frame.left + 6.0f, frame.top + 6.0f),
						 BPoint(frame.left + 6.0f, frame.top + 6.0f));
	} else {
		view->StrokeLine(BPoint(frame.left + 2.0f, frame.top + 6.0f),
						 BPoint(frame.left + 2.0f, frame.top + 6.0f));
		view->StrokeLine(BPoint(frame.left + 4.0f, frame.top + 6.0f),
						 BPoint(frame.left + 4.0f, frame.top + 6.0f));
		view->StrokeLine(BPoint(frame.left + 6.0f, frame.top + 6.0f),
						 BPoint(frame.left + 6.0f, frame.top + 6.0f));
	}

	frame.InsetBy(1.0f, 1.0f);

	// Third bevel
	view->SetHighColor(lighten1);
	view->StrokeLine(BPoint(frame.left, frame.bottom),
					 BPoint(frame.right, frame.bottom));
	view->StrokeLine(BPoint(frame.right, frame.bottom - 1.0f),
					 BPoint(frame.right, frame.top));
}
Example #20
0
AttribPolygon::AttribPolygon ()
: AttribView (BRect (0, 0, 148, 90), lstring (30, "Polygons"))
{
	SetViewColor (LightGrey);
	lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc'));
	AddChild (lSlid);
	fPenSize = 1;
	fType = POLYGON_OUTFILL;
	BBox *type = new BBox (BRect (18, 32, 130, 82), "type");
	type->SetLabel (lstring (311, "Type"));
	AddChild (type);

	BPoint pointArray[] = {
		BPoint ( 2,  8),
		BPoint ( 9,  2),
		BPoint (27, 12),
		BPoint (19, 28),
		BPoint (14, 20),
		BPoint ( 9, 26)
		};
	BPolygon *poly = new BPolygon();
	poly->AddPoints(pointArray, 6);

	BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL));
	BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL));
	picWindow->AddChild (bg);
	
	BPicture *p10;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (LightGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetLowColor (White);
	bg->FillPolygon (poly, B_SOLID_LOW);
	bg->StrokePolygon (poly);
	p10 = bg->EndPicture();
	
	BPicture *p20;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (LightGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->FillPolygon (poly, B_SOLID_LOW);
	p20 = bg->EndPicture();
	
	BPicture *p30;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (LightGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->StrokePolygon (poly);
	p30 = bg->EndPicture();

	BPicture *p11;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (DarkGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->FillPolygon (poly, B_SOLID_LOW);
	bg->StrokePolygon (poly);
	p11 = bg->EndPicture();
	
	BPicture *p21;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (DarkGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->FillPolygon (poly, B_SOLID_LOW);
	p21 = bg->EndPicture();
	
	BPicture *p31;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (DarkGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->StrokePolygon (poly);
	p31 = bg->EndPicture();
	
	delete poly;
	delete picWindow;
	
	SetViewColor (LightGrey);
	
	pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON);
	pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON);
	pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON);
	type->AddChild (pT1);
	type->AddChild (pT2);
	type->AddChild (pT3);
	pT1->SetValue (B_CONTROL_ON);
	fCurrentProperty = 0;
}
void 
BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly,
	const BColumnTitle *pressedColumn,
	void (*trackRectBlitter)(BView *, BRect), BRect passThru)
{
	BRect bounds(Bounds());
	BView *view;

	if (useOffscreen) {
		ASSERT(sOffscreen);
		BRect frame(bounds);
		frame.right += frame.left;
			// this is kind of messy way of avoiding being clipped by the ammount the
			// title is scrolled to the left
			// ToDo: fix this
		view = sOffscreen->BeginUsing(frame);
		view->SetOrigin(-bounds.left, 0);
		view->SetLowColor(LowColor());
		view->SetHighColor(HighColor());
		BFont font(be_plain_font);
		font.SetSize(9);
		view->SetFont(&font);
	} else
		view = this;

	if (be_control_look != NULL) {
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		view->SetHighColor(tint_color(base, B_DARKEN_2_TINT));
		view->StrokeLine(bounds.LeftBottom(), bounds.RightBottom());
		bounds.bottom--;

		be_control_look->DrawButtonBackground(view, bounds, bounds, base, 0,
			BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER);
	} else {
		// fill background with light gray background
		if (!updateOnly)
			view->FillRect(bounds, B_SOLID_LOW);
	
		view->BeginLineArray(4);
		view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShadowColor);
		view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), sShadowColor);
		// draw lighter gray and white inset lines
		bounds.InsetBy(0, 1);
		view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), sLightShadowColor);
		view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShineColor);
		view->EndLineArray();
	}

	int32 count = fTitleList.CountItems();
	float minx = bounds.right;
	float maxx = bounds.left;
	for (int32 index = 0; index < count; index++) {
		BColumnTitle *title = fTitleList.ItemAt(index);
		title->Draw(view, title == pressedColumn);
		BRect titleBounds(title->Bounds());
		if (titleBounds.left < minx)
			minx = titleBounds.left;
		if (titleBounds.right > maxx)
			maxx = titleBounds.right;
	}

	if (be_control_look != NULL) {
		bounds = Bounds();
		minx--;
		view->SetHighColor(sLightShadowColor);
		view->StrokeLine(BPoint(minx, bounds.top), BPoint(minx, bounds.bottom - 1));
	} else {
		// first and last shades before and after first column
		maxx++;
		minx--;
		view->BeginLineArray(2);
		view->AddLine(BPoint(minx, bounds.top),
					  BPoint(minx, bounds.bottom), sShadowColor);
		view->AddLine(BPoint(maxx, bounds.top),
					  BPoint(maxx, bounds.bottom), sShineColor);
		view->EndLineArray();
	}

#if !(APP_SERVER_CLEARS_BACKGROUND)
	FillRect(BRect(bounds.left, bounds.top + 1, minx - 1, bounds.bottom - 1), B_SOLID_LOW);
	FillRect(BRect(maxx + 1, bounds.top + 1, bounds.right, bounds.bottom - 1), B_SOLID_LOW);
#endif

	if (useOffscreen) {
		if (trackRectBlitter)
			(trackRectBlitter)(view, passThru);
		view->Sync();
		DrawBitmap(sOffscreen->Bitmap());
		sOffscreen->DoneUsing();
	} else if (trackRectBlitter)
		(trackRectBlitter)(view, passThru);
}
Example #22
0
void MonthWindowView::AttachedToWindow(void)
{
 SetFont(be_plain_font);
 
 SetViewColor(VIEW_COLOR);
 
 // Calculate size of cell needed for number of day of month
 font_height h;
 be_plain_font->GetHeight(&h);
 h_cell=(int)(h.ascent+h.descent+h.leading+6);
 w_cell=StringWidth("4")*4;
 
 

#ifdef __LANG_RUSSIAN
 
 BString s("");
 s<<tday;
 s.Append(" ");
 switch(tmonth)
 {
  case 1:
  {
   s.Append("января ");
   break;
  }
  case 2:
  {
   s.Append("февраля ");
   break;
  }
  case 3:
  {
   s.Append("марта ");
   break;
  }
  case 4:
  {
   s.Append("апреля ");
   break;
  }
  case 5:
  {
   s.Append("мая ");
   break;
  }
  case 6:
  {
   s.Append("июня ");
   break;
  }
  case 7:
  {
   s.Append("июля ");
   break;
  }
  case 8:
  {
   s.Append("августа ");
   break;
  }
  case 9:
  {
   s.Append("сентября ");
   break;
  }
  case 10:
  {
   s.Append("октября ");
   break;
  }
  case 11:
  {
   s.Append("ноября ");
   break;
  }
  case 12:
  {
   s.Append("декабря ");
   break;
  }
 }
 s<<tyear;
 s.Append(" г.");

#else // localized, english and french
 
 BString s("");
 s<<tday;
 s.Append(" ");
 s.Append(monthNames[tmonth-1]);
 s.Append(" ");
 s<<tyear;

#endif
 
 msng=new BMessenger(this);
 todayStringView=new MouseSenseStringView(new BMessage('TODA'), msng,
                                          BRect(10,10,100,100),"todayMStringViewAViX",
                                          s.String());
 AddChild(todayStringView);
 todayStringView->ResizeToPreferred();
 todayStringView->SetViewColor(VIEW_COLOR);
 
 monthStringView=new BStringView(BRect(10,10,100,100),"monthStringViewAViX",
                                 monthNames[8]);
 monthStringView->SetAlignment(B_ALIGN_CENTER);
 AddChild(monthStringView);
 monthStringView->ResizeToPreferred();
 monthStringView->SetText(monthNames[cmonth-1]);
 monthStringView->SetViewColor(VIEW_COLOR);
 
 s.SetTo("");
 if(cyear<10) s.Append("000");
 else if(cyear<100) s.Append("00");
 else if(cyear<1000) s.Append("0");
 s<<cyear;
 
 yearStringView=new BStringView(BRect(10,10,100,100),"yearStringViewAViX",
                                "0000");
 AddChild(yearStringView);
 yearStringView->ResizeToPreferred();
 yearStringView->SetText(s.String());
 yearStringView->SetViewColor(VIEW_COLOR);
 
 ResizeTo(w_cell*7+1,h_cell*7+3+16+yearStringView->Bounds().bottom+todayStringView->Bounds().bottom);
 Window()->ResizeTo(Bounds().right, Bounds().bottom);
 
 yearMStringView[0]=new MouseSenseStringView(new BMessage('YEA0'),msng,
                                             BRect(10,10,100,100),
                                             "yearMStringViewAViX0",
                                             "<<");
 AddChild(yearMStringView[0]);
 yearMStringView[0]->ResizeToPreferred();
 yearMStringView[0]->SetViewColor(VIEW_COLOR);
 
 yearMStringView[1]=new MouseSenseStringView(new BMessage('YEA1'),msng,
                                             BRect(10,10,100,100),
                                             "yearMStringViewAViX1",
                                             ">>");
 AddChild(yearMStringView[1]);
 yearMStringView[1]->ResizeToPreferred();
 yearMStringView[1]->SetViewColor(VIEW_COLOR);
 
 monthMStringView[0]=new MouseSenseStringView(new BMessage('MON0'),msng,
                                              BRect(10,10,100,100),
                                              "monthMStringViewAViX0",
                                              "<<");
 AddChild(monthMStringView[0]);
 monthMStringView[0]->ResizeToPreferred();
 monthMStringView[0]->SetViewColor(VIEW_COLOR);
 
 monthMStringView[1]=new MouseSenseStringView(new BMessage('MON1'),msng,
                                              BRect(10,10,100,100),
                                              "monthMStringViewAViX1",
                                              ">>");
 AddChild(monthMStringView[1]);
 monthMStringView[1]->ResizeToPreferred();
 monthMStringView[1]->SetViewColor(VIEW_COLOR);
 
 todayStringView->MoveTo((Bounds().right-todayStringView->Bounds().right)/2,
                         Bounds().bottom-todayStringView->Bounds().bottom-2);
 if(tyear<first_year || tyear>last_year) todayStringView->SetHighColor(NOACTIVE_COLOR);
  
 yearMStringView[1]->MoveTo(Bounds().right-yearMStringView[1]->Bounds().right,5);
 yearStringView->MoveTo(yearMStringView[1]->Frame().left-yearStringView->Bounds().right,5);
 yearMStringView[0]->MoveTo(yearStringView->Frame().left-yearMStringView[0]->Bounds().right,5);
 
 
 monthStringView->MoveTo((yearMStringView[0]->Frame().left-monthStringView->Bounds().right)/2,5);
 monthMStringView[0]->MoveTo(monthStringView->Frame().left-monthMStringView[0]->Bounds().right,5);
 monthMStringView[1]->MoveTo(monthStringView->Frame().right,5);
 
 which_focused=2; // days of month
 
 
 Bmp=new BBitmap(BRect(Frame()),B_RGB32,true);
 BmpView=new BView(Bmp->Bounds(),"BV",0,B_WILL_DRAW);
 Bmp->AddChild(BmpView);
 
 Bmp->Lock();
 BmpView->SetHighColor(VIEW_COLOR);
 BmpView->FillRect(BmpView->Frame());
 
 BmpView->SetHighColor(LINE_COLOR);
 BmpView->StrokeLine(BPoint(3,todayStringView->Frame().top-5),
                     BPoint(Bounds().right-3,todayStringView->Frame().top-5));
 BmpView->StrokeLine(BPoint(3,yearStringView->Frame().bottom+2),
                     BPoint(Bounds().right-3,yearStringView->Frame().bottom+2));
 BmpView->SetHighColor(0,0,0,0);
 
 float y=yearStringView->Frame().bottom+h_cell;
 float x=0;
 for(int i=0;i<7;i++)
 {
  BmpView->DrawString(weekdayNames[i],BPoint(x+(w_cell-StringWidth(weekdayNames[i]))/2,y));
  x+=w_cell;
 }
 
 BmpView->Sync();
 Bmp->Unlock();
 DrawMonth();
}
Example #23
0
// MouseMoved
void
ObjectView::MouseMoved(BPoint where, uint32 transit,
					   const BMessage* dragMessage)
{
//	BRect dirty(where, where);
//	dirty.InsetBy(-10, -10);
//	Invalidate(dirty);
	
if (dragMessage) {
//printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f)) - DRAG MESSAGE\n", where.x, where.y);
//Window()->CurrentMessage()->PrintToStream();
} else {
//printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f))\n", where.x, where.y);
}

	if (fScrolling) {
		BCursor cursor(kGrabCursor);
		SetViewCursor(&cursor);
	
		BPoint offset = fLastMousePos - where;
		ScrollBy(offset.x, offset.y);
		fLastMousePos = where + offset;
	} else if (fInitiatingDrag) {
		BPoint offset = fLastMousePos - where;
		if (sqrtf(offset.x * offset.x + offset.y * offset.y) > 5.0) {
			BMessage newDragMessage('drag');
			BBitmap* dragBitmap = new BBitmap(BRect(0, 0, 40, 40), B_RGBA32,
				true);
			if (dragBitmap->Lock()) {
				BView* helper = new BView(dragBitmap->Bounds(),
					"offscreen view", B_FOLLOW_ALL, B_WILL_DRAW);
				dragBitmap->AddChild(helper);
				helper->SetDrawingMode(B_OP_ALPHA);
				helper->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);

				BRect r(helper->Bounds());
				helper->SetHighColor(0, 0, 0, 128);
				helper->StrokeRect(r);

				helper->SetHighColor(200, 200, 200, 100);
				r.InsetBy(1, 1);
				helper->FillRect(r);

				helper->SetHighColor(0, 0, 0, 255);
				const char* text = B_TRANSLATE("Test");
				float pos = (r.Width() - helper->StringWidth(text)) / 2;
				helper->DrawString(text, BPoint(pos, 25));
				helper->Sync();
			}
			
			DragMessage(&newDragMessage, dragBitmap, B_OP_ALPHA, B_ORIGIN,
				this);
			fInitiatingDrag = false;
		}
	} else {
		BCursor cursor(kMoveCursor);
		SetViewCursor(&cursor);
	
		if (fState && fState->IsTracking()) {
			BRect before = fState->Bounds();
	
			fState->MouseMoved(where);
	
			BRect after = fState->Bounds();
			BRect invalid(before | after);
			Invalidate(invalid);
		}
	}
//	SetViewCursor();
}
//ctor
SpecificColorWindow	::	SpecificColorWindow(	BRect paramBound,
												uint32 paramkind)
				: 
				ScrollingWindow(	paramBound, 
									myPrefs->lvwTitleStr[paramkind], 
									lScrollViewName[paramkind],
									lNamePrefFrame[paramkind],
									myPrefs->mpPreferenceSet,
									true,
									false),
				mui32Kind(paramkind),
				mpViewColorControl(NULL),
				mpHighColorControl(NULL),
				mpLowColorControl(NULL),
				mpBarColorControl(NULL),
				mpFillColorControl(NULL),
				mpViewColorWell(NULL),
				mpHighColorWell(NULL),
				mpLowColorWell(NULL),
				mpBarColorWell(NULL),
				mpFillColorWell(NULL),
				mpBarHeightGadget(NULL),
				mpColorWellWidthGadget(NULL),
				mpColorWellHeightGadget(NULL),
				mpThumbRadioView(NULL),
				mpCCLrv(NULL),
				mpSliderBarCB(NULL),
				mpSliderBarFillCB(NULL),
				mpDemoItem(NULL)
{
	sem_id calc_sem;
	if ((calc_sem = create_sem(1, "calc_sem")) < B_NO_ERROR)
	{
		warning(myPrefs->FailCreateSemaphore);
		return;
	}
	acquire_sem(calc_sem);
	try 
	{
		LayoutMatrix *	pholdTitleLayoutMatrix = new LayoutMatrix(BESTSIZE, 1, 1, this);//rows,columns
/////////////////////////////////////////////////////////////////////////////////////////////
		BFont * pBFont = new BFont(myPrefs->GetPreferredFont());
		float fontSize = pBFont->Size();
		fontSize *= 2;
		if (fontSize > 200)
		{
			fontSize = 200;
		}
		pBFont->SetSize(fontSize);
		pBFont->SetShear(122);
		//will need offset for demo--use a seperate matrix and get it's bottom
		MyStringDrawer * pMyStringDrawer = new MyStringDrawer(	"specificTitleMyStringDrawer", 
																myPrefs->lvwTitleStr[mui32Kind],
																pholdTitleLayoutMatrix, 
																pBFont);
/////////////////////////////
		if (!myPrefs->mbUseColorControl && !myPrefs->mbUseColorWell)
		{
			warning(myPrefs->noCCenabled);
		}
		LayoutMatrix * pholdViewCCLayoutMatrix = NULL;
		LayoutMatrix * pholdHighCCLayoutMatrix = NULL;
		LayoutMatrix * pholdLowCCLayoutMatrix = NULL;
		MyStringDrawer * pMyStringDrawerAXX = NULL;
		MyStringDrawer * pMyStringDrawerBXX = NULL;
		MyStringDrawer * pMyStringDrawerCXX = NULL;
		rgb_color color;//re-use for every setvalue
		if (myPrefs->mbUseColorControl)
		{
			pholdViewCCLayoutMatrix = new LayoutMatrix(BESTSIZE, 2, 1, this);//rows,columns
	/////////////////////////////////////////////////////////////////////////////////////
			pMyStringDrawerAXX = new MyStringDrawer(	"MyStringDrawerAXX", 
														myPrefs->ColorWindowHeading2, 
														pholdViewCCLayoutMatrix);
	////////////////////////////////////////////////////////////////////
			mpViewColorControl = new MyColorControl(	myPrefs->mCCL,
														"ColorControlAXX", 
														COLORCONTROL_VIEW,
														pholdViewCCLayoutMatrix);
			switch (mui32Kind)
			{
				case SPECIFIC_COLOR_BUTTON:
					myPrefs->GetPreferredMyButtonViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_PICTURE:
					myPrefs->GetPreferredMyPictureButtonViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_RADIOVIEW:
					myPrefs->GetPreferredMyRadioViewViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_CHECKBOX:
					myPrefs->GetPreferredMyCheckBoxViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_STATUSBAR:
					myPrefs->GetPreferredMyStatusBarViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_SLIDER:
					myPrefs->GetPreferredMySliderViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_COLORCONTROL:
					myPrefs->GetPreferredMyColorControlViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_TEXTVIEW:
					myPrefs->GetPreferredMyTextViewViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_LISTVIEW:
					myPrefs->GetPreferredMyListViewViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT32CONTROL:
					myPrefs->GetPreferredUInt32ControlViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_INT8GADGET:
					myPrefs->GetPreferredInt8GadgetViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT8GADGET:
					myPrefs->GetPreferredUInt8GadgetViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_INT16GADGET:
					myPrefs->GetPreferredInt16GadgetViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT16GADGET:
					myPrefs->GetPreferredUInt16GadgetViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_INT32GADGET:
					myPrefs->GetPreferredInt32GadgetViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT32GADGET:
					myPrefs->GetPreferredUInt32GadgetViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_INT64GADGET:
					myPrefs->GetPreferredInt64GadgetViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT64GADGET:
					myPrefs->GetPreferredUInt64GadgetViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_FLOATGADGET:
					myPrefs->GetPreferredFloatGadgetViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_STRINGGADGET:
					myPrefs->GetPreferredStringGadgetViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_FLOATCONTROL:
					myPrefs->GetPreferredFloatControlViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_STRINGCONTROL:
					myPrefs->GetPreferredStringControlViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_COLORWELL:
					myPrefs->GetPreferredColorWellViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_STRINGDRAWER:
					myPrefs->GetPreferredMyStringDrawerViewColor(&color);
					mpViewColorControl->SetValue(color);
				break;
				default:
					warning(myPrefs->BadSpecColorKindView);
					throw;
				break;
			}
	/////////////////////
			pholdHighCCLayoutMatrix = new LayoutMatrix(BESTSIZE, 2, 1, this);//rows,columns
	////////////////////////////////
			pMyStringDrawerBXX = new MyStringDrawer(	"MyStringDrawerBXX", 
														myPrefs->ColorWindowHeading3, 
														pholdHighCCLayoutMatrix);
	/////////////////////////////////////////////
			mpHighColorControl = new MyColorControl(	myPrefs->mCCL,
														"HighColorControlBXX", 
														COLORCONTROL_HIGH,
														pholdHighCCLayoutMatrix);
			switch (mui32Kind)
			{
				case SPECIFIC_COLOR_BUTTON:
					myPrefs->GetPreferredMyButtonHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_PICTURE:
					myPrefs->GetPreferredMyPictureButtonHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_RADIOVIEW:
					myPrefs->GetPreferredMyRadioViewHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_CHECKBOX:
					myPrefs->GetPreferredMyCheckBoxHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_STATUSBAR:
					myPrefs->GetPreferredMyStatusBarHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_SLIDER:
					myPrefs->GetPreferredMySliderHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_COLORCONTROL:
					myPrefs->GetPreferredMyColorControlHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_TEXTVIEW:
					myPrefs->GetPreferredMyTextViewHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_LISTVIEW:
					myPrefs->GetPreferredMyListViewHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT32CONTROL:
					myPrefs->GetPreferredUInt32ControlHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_INT8GADGET:
					myPrefs->GetPreferredInt8GadgetHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT8GADGET:
					myPrefs->GetPreferredUInt8GadgetHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_INT16GADGET:
					myPrefs->GetPreferredInt16GadgetHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT16GADGET:
					myPrefs->GetPreferredUInt16GadgetHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_INT32GADGET:
					myPrefs->GetPreferredInt32GadgetHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT32GADGET:
					myPrefs->GetPreferredUInt32GadgetHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_INT64GADGET:
					myPrefs->GetPreferredInt64GadgetHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT64GADGET:
					myPrefs->GetPreferredUInt64GadgetHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_FLOATGADGET:
					myPrefs->GetPreferredFloatGadgetHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_STRINGGADGET:
					myPrefs->GetPreferredStringGadgetHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_FLOATCONTROL:
					myPrefs->GetPreferredFloatControlHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_STRINGCONTROL:
					myPrefs->GetPreferredStringControlHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_COLORWELL:
					myPrefs->GetPreferredColorWellHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_STRINGDRAWER:
					myPrefs->GetPreferredMyStringDrawerHighColor(&color);
					mpHighColorControl->SetValue(color);
				break;
				default:
					warning(myPrefs->BadSpecColorKindHigh);
					throw;
				break;
			}
	//////////////////////////////////////////////////////////////
			pholdLowCCLayoutMatrix = new LayoutMatrix(BESTSIZE, 2, 1, this);//rows,columns
	///////////////////////////////////////////////////
			pMyStringDrawerCXX = new MyStringDrawer(	"MyStringDrawerCXX", 
														myPrefs->ColorWindowHeading4, 
														pholdLowCCLayoutMatrix);
	///////////////////////////////////////////////////////////////////
			mpLowColorControl = new MyColorControl(	myPrefs->mCCL,
													"LowColorControlCXX", 
													COLORCONTROL_LOW,
													pholdLowCCLayoutMatrix);
			switch (mui32Kind)
			{
				case SPECIFIC_COLOR_BUTTON:
					myPrefs->GetPreferredMyButtonLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_PICTURE:
					myPrefs->GetPreferredMyPictureButtonLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_RADIOVIEW:
					myPrefs->GetPreferredMyRadioViewLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_CHECKBOX:
					myPrefs->GetPreferredMyCheckBoxLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_STATUSBAR:
					myPrefs->GetPreferredMyStatusBarLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_SLIDER:
					myPrefs->GetPreferredMySliderLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_COLORCONTROL:
					myPrefs->GetPreferredMyColorControlLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_TEXTVIEW:
					myPrefs->GetPreferredMyTextViewLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_LISTVIEW:
					myPrefs->GetPreferredMyListViewLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT32CONTROL:
					myPrefs->GetPreferredUInt32ControlLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_INT8GADGET:
					myPrefs->GetPreferredInt8GadgetLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT8GADGET:
					myPrefs->GetPreferredUInt8GadgetLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_INT16GADGET:
					myPrefs->GetPreferredInt16GadgetLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT16GADGET:
					myPrefs->GetPreferredUInt16GadgetLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_INT32GADGET:
					myPrefs->GetPreferredInt32GadgetLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT32GADGET:
					myPrefs->GetPreferredUInt32GadgetLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_INT64GADGET:
					myPrefs->GetPreferredInt64GadgetLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_UINT64GADGET:
					myPrefs->GetPreferredUInt64GadgetLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_FLOATGADGET:
					myPrefs->GetPreferredFloatGadgetLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_STRINGGADGET:
					myPrefs->GetPreferredStringGadgetLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_FLOATCONTROL:
					myPrefs->GetPreferredFloatControlLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_STRINGCONTROL:
					myPrefs->GetPreferredStringControlLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_COLORWELL:
					myPrefs->GetPreferredColorWellLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				case SPECIFIC_COLOR_STRINGDRAWER:
					myPrefs->GetPreferredMyStringDrawerLowColor(&color);
					mpLowColorControl->SetValue(color);
				break;
				default:
					warning(myPrefs->BadSpecColorKindLow);
					throw;
				break;
			}
		}
////////////////////////
		LayoutMatrix * pholdColorWellLayoutMatrix = NULL;
		if (myPrefs->mbUseColorWell)
		{
			pholdColorWellLayoutMatrix = new LayoutMatrix(BESTSIZE, 1, 3, this);//rows,columns
	//////////////
			mpViewColorWell = new ColorWell(	"ColorWellViewColorPref", 
												VIEW_COLOR,
												myPrefs->ColorWindowHeading5,
												this,
												pholdColorWellLayoutMatrix);
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			mpHighColorWell = new ColorWell(	"ColorWellHighColorPref", 
												HIGH_COLOR,
												myPrefs->ColorWindowHeading6,
												this,
												pholdColorWellLayoutMatrix);
	////////////////////////////////////////////////////////////////////////////////////////////////////
			mpLowColorWell = new ColorWell(	"ColorWellLowColorPref", 
											LOW_COLOR,
											myPrefs->ColorWindowHeading7,
											this,
											pholdColorWellLayoutMatrix);
		}
///////////////////////////////////////////////////////////////////////
		LayoutMatrix * pholdDemoLayoutMatrix = new LayoutMatrix(BESTSIZE, 1, 1, this);//rows,columns
//////////////////////////////////
		int32 kindDemo;
		void * pholdDemo;
		switch (mui32Kind)
		{
			case SPECIFIC_COLOR_BUTTON:
			{
				MyButton * pholdDemoMyButton = new MyButton(	"demoButton", 
																myPrefs->DemoButtonLabel, 
																DEMOBUTTONMSG,
																pholdDemoLayoutMatrix);
				kindDemo = KIND_MYBUTTON;
				pholdDemo = (void *)pholdDemoMyButton;
			}
			break;
			case SPECIFIC_COLOR_PICTURE:
			{
				BPicture * pOnPicture;
				BPicture * pOnDisabledPicture;
				BPicture * pOffPicture;
				BPicture * pOffDisabledPicture;
				BWindow * bWindow = new BWindow(	BRect(0, 0, 32, 32), //manditory for BPicture
													NULL, 
													B_DOCUMENT_WINDOW, 
													0);
				BView * bView = new BView(	BRect(0, 0, 32, 32), 
											NULL, 
											B_FOLLOW_NONE, 
											0);
//				BWindow bWindow(	BRect(0, 0, 32, 32), //manditory for BPicture
//									NULL, 
//									B_DOCUMENT_WINDOW, 
//									0);
//				BView bView(	BRect(0, 0, 32, 32), 
//								NULL, 
//								B_FOLLOW_NONE, 
//								0);
				bWindow->AddChild(bView);
				bView->BeginPicture(new BPicture);
				bView->MoveTo(5, 5);
				bView->StrokeRect(BRect(0,0,8,8));
				pOffPicture = bView->EndPicture();
				
				bView->BeginPicture(new BPicture);
				bView->MoveTo(10, 5);
				bView->StrokeRect(BRect(0,0,10,15));
				pOnPicture = bView->EndPicture();
				
				bView->BeginPicture(new BPicture);
				bView->MoveTo(2, 5);
				bView->FillRect(BRect(0,0,22,20));
				pOffDisabledPicture = bView->EndPicture();
				
				bView->BeginPicture(new BPicture);
				bView->MoveTo(1, 5);
				bView->FillRect(BRect(0,0,6,15));
				pOnDisabledPicture = bView->EndPicture();
				//bView.RemoveSelf();
				bWindow->Run();
				bWindow->PostMessage(B_QUIT_REQUESTED);
				MyPictureButton * pholdDemoMyPictureButton = new MyPictureButton(	BRect(0, 0, 32, 32),
																					"DemoPictureButton", 
																					pOffPicture,
																					pOnPicture,
																					pOffDisabledPicture,
																					pOnDisabledPicture,
																					DEMOPICTUREBUTTONMSG,
																					B_TWO_STATE_BUTTON,//B_ONE_STATE_BUTTON
																					pholdDemoLayoutMatrix);
				kindDemo = KIND_MYPICTUREBUTTON;
				pholdDemo = (void *)pholdDemoMyPictureButton;
			}
			break;
			case SPECIFIC_COLOR_RADIOVIEW:
			{
				BList * pBList = new BList();
				RadioViewData * pRadioViewDataOne = new RadioViewData(	'_one',
																		myPrefs->DemoRadio1Label,
																		pBList);
				RadioViewData * pRadioViewDataTwo = new RadioViewData(	'_two',
																		myPrefs->DemoRadio2Label,
																		pBList);
				RadioViewData * pRadioViewDataThree = new RadioViewData(	'thre',
																			myPrefs->DemoRadio3Label,
																			pBList);
				MyRadioView * pholdMyRadioView = new MyRadioView(	"demoRadio",
																	false,//true gives vertical orientation
																	pBList,
																	myPrefs->GetPreferredFont(),
																	pholdDemoLayoutMatrix);
				if (!pholdMyRadioView->Initialize())
				{
					warning(myPrefs->RadioViewFailInit);
					throw;
				}
				kindDemo = KIND_MYRADIOVIEW;
				pholdDemo = (void *)pholdMyRadioView;
			}
			break;
			case SPECIFIC_COLOR_CHECKBOX:
			{
				MyCheckBox * pholdCheckBox = new MyCheckBox(	"checkBox", 
																myPrefs->DemoCheckBoxLabel, 
																B_CONTROL_ON,
																'_one',
																pholdDemoLayoutMatrix);
				kindDemo = KIND_MYCHECKBOX;
				pholdDemo = (void *)pholdCheckBox;
			}
			break;
			case SPECIFIC_COLOR_STATUSBAR:
			{
				MyStatusBar * pholdStatusBar = new MyStatusBar(	"StatusBar", 
																myPrefs->DemoStatusBarLeadLabel, 
																myPrefs->DemoStatusBarTrailLabel,
																50,
																10.0,
																pholdDemoLayoutMatrix);
				kindDemo = KIND_MYSTATUSBAR;
				pholdDemo = (void *)pholdStatusBar;
			}
			break;
			case SPECIFIC_COLOR_SLIDER:
			{
				MySlider * pholdSlider = new MySlider(	BRect(1, 1, 65, 32), 
														"Slider",
														"Label",
														'Sldr',
														1,
														10,
														.5,
														pholdDemoLayoutMatrix);
				kindDemo = KIND_MYSLIDER;
				pholdDemo = (void *)pholdSlider;
			}
			break;
			case SPECIFIC_COLOR_COLORCONTROL:
			{
				MyColorControl * pholdColorControl = new MyColorControl(	myPrefs->mCCL,
																			"ColorControl", 
																			DEMOCOLORCONTROLMSG,
																			pholdDemoLayoutMatrix);
			
				kindDemo = KIND_MYCOLORCONTROL;
				pholdDemo = (void *)pholdColorControl;
			}
			break;
			case SPECIFIC_COLOR_TEXTVIEW:
			{
				float leftOffset;
				float baseline;
				float width;
				float height;
				if (!StringBoundsBox(	myPrefs->TextGadgetLabel,
										&width,
										&height,
										&leftOffset,
										&baseline))
				{
					throw;
				}
				MyTextView * pholdTextView = new MyTextView(	"textView", 
																NULL, 
																width,
																6 * height,//allow 6 lines visible
																pholdDemoLayoutMatrix);
				rgb_color textColor;
				myPrefs->GetPreferredMyTextViewHighColor(&textColor);
				pholdTextView->SetFontAndColor(myPrefs->GetPreferredFont(), B_FONT_ALL, &textColor);
				pholdTextView->SetText(myPrefs->TextGadgetLabel);
				kindDemo = KIND_MYTEXTVIEW;
				pholdDemo = (void *)pholdTextView;
			}
			break;
			case SPECIFIC_COLOR_LISTVIEW:
			{
				DataList * dataList = new DataList();
				DataNode * nodeOne = new DataNode(myPrefs->ListViewSample1);
				dataList->AddItem(nodeOne);
				DataNode * nodeTwo = new DataNode(myPrefs->ListViewSample2);
				dataList->AddItem(nodeTwo);
				DataNode * nodeThree = new DataNode(myPrefs->ListViewSample3);
				dataList->AddItem(nodeThree);
				MyListView * mlv = new MyListView(	"mlvTitle",
													dataList,
													'selc',
													'invc',
													B_SINGLE_SELECTION_LIST,
													pholdDemoLayoutMatrix);
				kindDemo = KIND_MYLISTVIEW;
				pholdDemo = (void *)mlv;
			}
			break;
			case SPECIFIC_COLOR_INT8GADGET:
			{
				Int8Gadget * pholdInt8Gadget = new Int8Gadget(	MIN_I8,
																"int8Gadget",
																myPrefs->GetInt8GadgetLabel,
																0,
																this,
																pholdDemoLayoutMatrix);
				kindDemo = KIND_INT8GADGET;
				pholdDemo = (void *)pholdInt8Gadget;
				BMessageFilter * bmfDemo = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
																B_LOCAL_SOURCE, 
																'_KYD', 
																filterIntNumeric);
				pholdInt8Gadget->AddFilter(bmfDemo);
			}
			break;
			case SPECIFIC_COLOR_UINT8GADGET:
			{
				UInt8Gadget * pholdUInt8Gadget = new UInt8Gadget(	MAX_UI8,
																	"uInt8Gadget",
																	myPrefs->GetUInt8GadgetLabel,
																	0,
																	this,
																	pholdDemoLayoutMatrix);
				kindDemo = KIND_UINT8GADGET;
				pholdDemo = (void *)pholdUInt8Gadget;
				BMessageFilter * bmfDemo = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
																B_LOCAL_SOURCE, 
																'_KYD', 
																filterUIntNumeric);
				pholdUInt8Gadget->AddFilter(bmfDemo);
			}
			break;
			case SPECIFIC_COLOR_INT16GADGET:
			{
				Int16Gadget * pholdInt16Gadget = new Int16Gadget(	MIN_I16,
																	"int16Gadget",
																	myPrefs->GetInt16GadgetLabel,
																	0,
																	this,
																	pholdDemoLayoutMatrix);
				kindDemo = KIND_INT16GADGET;
				pholdDemo = (void *)pholdInt16Gadget;
				BMessageFilter * bmfDemo = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
																B_LOCAL_SOURCE, 
																'_KYD', 
																filterIntNumeric);
				pholdInt16Gadget->AddFilter(bmfDemo);
			}
			break;
			case SPECIFIC_COLOR_UINT16GADGET:
			{
				UInt16Gadget * pholdUInt16Gadget = new UInt16Gadget(	MAX_UI16,
																		"uInt16Gadget",
																		myPrefs->GetUInt16GadgetLabel,
																		0,
																		this,
																		pholdDemoLayoutMatrix);
				kindDemo = KIND_UINT16GADGET;
				pholdDemo = (void *)pholdUInt16Gadget;
				BMessageFilter * bmfDemo = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
																B_LOCAL_SOURCE, 
																'_KYD', 
																filterUIntNumeric);
				pholdUInt16Gadget->AddFilter(bmfDemo);
			}
			break;
			case SPECIFIC_COLOR_INT32GADGET:
			{
				Int32Gadget * pholdInt32Gadget = new Int32Gadget(	MIN_I32,
																	"int32Gadget",
																	myPrefs->GetInt32GadgetLabel,
																	0,
																	this,
																	pholdDemoLayoutMatrix);
				kindDemo = KIND_INT32GADGET;
				pholdDemo = (void *)pholdInt32Gadget;
				BMessageFilter * bmfDemo = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
																B_LOCAL_SOURCE, 
																'_KYD', 
																filterIntNumeric);
				pholdInt32Gadget->AddFilter(bmfDemo);
			}
			break;
			case SPECIFIC_COLOR_UINT32GADGET:
			{
				UInt32Gadget * pholdUInt32Gadget = new UInt32Gadget(	MAX_UI32,
																		"uInt32Gadget",
																		myPrefs->GetUInt32GadgetLabel,
																		0,
																		this,
																		pholdDemoLayoutMatrix);
				kindDemo = KIND_UINT32GADGET;
				pholdDemo = (void *)pholdUInt32Gadget;
				BMessageFilter * bmfDemo = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
																B_LOCAL_SOURCE, 
																'_KYD', 
																filterUIntNumeric);
				pholdUInt32Gadget->AddFilter(bmfDemo);
			}
			break;
			case SPECIFIC_COLOR_INT64GADGET:
			{
				Int64Gadget * pholdInt64Gadget = new Int64Gadget(	MIN_I64,
																	"int64Gadget",
																	myPrefs->GetInt64GadgetLabel,
																	0,
																	this,
																	pholdDemoLayoutMatrix);
				kindDemo = KIND_INT64GADGET;
				pholdDemo = (void *)pholdInt64Gadget;
				BMessageFilter * bmfDemo = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
																B_LOCAL_SOURCE, 
																'_KYD', 
																filterIntNumeric);
				pholdInt64Gadget->AddFilter(bmfDemo);
			}
			break;
			case SPECIFIC_COLOR_UINT64GADGET:
			{
				UInt64Gadget * pholdUInt64Gadget = new UInt64Gadget(	MAX_UI64,
																		"uInt64Gadget",
																		myPrefs->GetUInt64GadgetLabel,
																		0,
																		this,
																		pholdDemoLayoutMatrix);
				kindDemo = KIND_UINT64GADGET;
				pholdDemo = (void *)pholdUInt64Gadget;
				BMessageFilter * bmfDemo = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
																B_LOCAL_SOURCE, 
																'_KYD', 
																filterUIntNumeric);
				pholdUInt64Gadget->AddFilter(bmfDemo);
			}
			break;
			case SPECIFIC_COLOR_FLOATGADGET:
			{
				FloatGadget * pholdFloatGadget = new FloatGadget(	(float)12.34,
																	"floatGadget",
																	myPrefs->GetFloatGadgetLabel,
																	0,
																	this,
																	pholdDemoLayoutMatrix);
				kindDemo = KIND_FLOATGADGET;
				pholdDemo = (void *)pholdFloatGadget;
				BMessageFilter * bmfDemo = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
																B_LOCAL_SOURCE, 
																'_KYD', 
																filterFloatNumeric);
				pholdFloatGadget->AddFilter(bmfDemo);
			}
			break;
			case SPECIFIC_COLOR_STRINGGADGET:
			{
				StringGadget * pholdStringGadget = new StringGadget(	myPrefs->GetStringGadgetLabel,
																		"stringGadget",
																		myPrefs->GetStringGadgetLabel,
																		0,
																		this,
																		pholdDemoLayoutMatrix);
				kindDemo = KIND_STRINGGADGET;
				pholdDemo = (void *)pholdStringGadget;
			}
			break;
			case SPECIFIC_COLOR_UINT32CONTROL:
			{
				UInt32Control * pholdUInt32Control = new UInt32Control(	123,
																		"uInt32Control", 
																		myPrefs->UInt32ControlLabel, 
																		DEMOINTCONTROLMSG,
																		0,
																		pholdDemoLayoutMatrix);
				kindDemo = KIND_UINT32CONTROL;
				pholdDemo = (void *)pholdUInt32Control;
			}
			break;
			case SPECIFIC_COLOR_FLOATCONTROL:
			{
				FloatControl * pholdFloatControl = new FloatControl(	(float)1.23,
																		"floatControl", 
																		myPrefs->FloatControlLabel, 
																		DEMOFLOATCONTROLMSG,
																		0,
																		pholdDemoLayoutMatrix);
				kindDemo = KIND_FLOATCONTROL;
				pholdDemo = (void *)pholdFloatControl;
			}
			break;
			case SPECIFIC_COLOR_STRINGCONTROL:
			{
				StringControl * pholdStringControl = new StringControl(	"stringControlName", 
																		myPrefs->StringControlLabel, 
																		NULL, 
																		DEMOSTRINGCONTROLMSG,
																		0,
																		pholdDemoLayoutMatrix);
				kindDemo = KIND_STRINGCONTROL;
				pholdDemo = (void *)pholdStringControl;
			}
			break;
			case SPECIFIC_COLOR_COLORWELL:
			{
				ColorWell * pholdColorWell = new ColorWell(	"colorWell", 
															NO_COLOR,
															myPrefs->DemoRoLabel,
															this,
															pholdDemoLayoutMatrix);
				kindDemo = KIND_COLORWELL;
				pholdDemo = (void *)pholdColorWell;
			}
			break;
			case SPECIFIC_COLOR_STRINGDRAWER:
			{
				MyStringDrawer * pholdMyStringDrawer = new MyStringDrawer(	"stringDrawer", 
																			myPrefs->DemoTextItemText, 
																			pholdDemoLayoutMatrix);
				kindDemo = KIND_STRINGDRAWER;
				pholdDemo = (void *)pholdMyStringDrawer;
			}
			break;
			default:
				warning(myPrefs->BadSpecItemKind);
				throw;
			break;
		}
		mpDemoItem = pholdDemo;
/////////////////////
		LayoutMatrix *	pholdBarTitleLayoutMatrix = NULL;
		LayoutMatrix *	pholdBarCCLayoutMatrix = NULL;
		LayoutMatrix * pholdBarCWLayoutMatrix = NULL;
		LayoutMatrix * pholdBarHLayoutMatrix = NULL;
		LayoutMatrix * pholdColorWellWHLayoutMatrix = NULL;
		LayoutMatrix * pholdSliderLayoutMatrix = NULL;
		LayoutMatrix * pholdFillCCLayoutMatrix = NULL;
		LayoutMatrix * pholdFillCWLayoutMatrix = NULL;
		LayoutMatrix * pholdCCLLayoutMatrix = NULL;
///////////////////////////
		if (mui32Kind == SPECIFIC_COLOR_STATUSBAR)
		{
			pholdBarTitleLayoutMatrix = new LayoutMatrix(BESTSIZE, 1, 1, this);//rows,columns
////////////////////////////////////////////////////////////////
			BFont * pBFontBar = new BFont(myPrefs->GetPreferredFont());
			float fontSize = pBFontBar->Size();
			fontSize *= 2;
			if (fontSize > 200)
			{
				fontSize = 200;
			}
			pBFontBar->SetSize(fontSize);
			pBFontBar->SetShear(122);
			//will need offset for demo--use a seperate matrix and get it's bottom
			MyStringDrawer * pBarMyStringDrawer = new MyStringDrawer(	"specificTitleBarMyStringDrawer", 
																		myPrefs->BarColorTitle,
																		pholdBarTitleLayoutMatrix, 
																		pBFontBar);
//////////////////////////////////////////////////
			if (myPrefs->mbUseColorControl)
			{
				pholdBarCCLayoutMatrix = new LayoutMatrix(BESTSIZE, 2, 1, this);//rows,columns
	///////////////////////////////////////////////////////////////////////////////////
				MyStringDrawer * pBarMyStringDrawerAXX = new MyStringDrawer(	"BarMyStringDrawerAXX", 
																				myPrefs->BarCCLabel, 
																				pholdBarCCLayoutMatrix);
	////////////////////////////////////////////////////////////////////
				mpBarColorControl = new MyColorControl(	myPrefs->mCCL,
														"barColorControl", 
														BARCOLORCONTROL,
														pholdBarCCLayoutMatrix);
				myPrefs->GetPreferredMyBarStatusColor(&color);
				mpBarColorControl->SetValue(color);
			}
//////////////////////////////////////
			if (myPrefs->mbUseColorWell)
			{
				pholdBarCWLayoutMatrix = new LayoutMatrix(BESTSIZE, 1, 1, this);//rows,columns
	///////////////////////////////////////////
				mpBarColorWell = new ColorWell(	"ColorWellViewColorPref", 
												BAR_COLOR,
												myPrefs->BarCWLabel,
												this,
												pholdBarCWLayoutMatrix);
			}
///////////////////////////////////////////
			pholdBarHLayoutMatrix = new LayoutMatrix(BESTSIZE, 1, 1, this);//rows,columns
//////////////////////////////////////////////////////////////////////////
			mpBarHeightGadget = new FloatGadget(	myPrefs->GetPreferredBarHeight(),
													"BarHeightFloatGadget", 
													myPrefs->EnterBarHeightLabel,
													0,
													this,
													pholdBarHLayoutMatrix);
				BMessageFilter * bmfBHDemo = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
																	B_LOCAL_SOURCE, 
																	'_KYD', 
																	filterFloatNumeric);
				mpBarHeightGadget->AddFilter(bmfBHDemo);
		}
/////////////////////////////////////////////////////////////////
		else if (mui32Kind == SPECIFIC_COLOR_COLORCONTROL)
		{
			pholdCCLLayoutMatrix = new LayoutMatrix(BESTSIZE, 2, 1, this);//rows,columns
//////////////////////////////////////////////////////////////////////////
			BFont * pCCLFont = new BFont(myPrefs->GetPreferredFont());
			float fontSize = pCCLFont->Size();
			fontSize *= 1.5;
			if (fontSize > 200)
			{
				fontSize = 200;
			}
			pCCLFont->SetSize(fontSize);
			MyStringDrawer * pCCLMyStringDrawer = new MyStringDrawer(	"CCLMyStringDrawer", 
																		myPrefs->ColorControlKind,
																		pholdCCLLayoutMatrix, 
																		pCCLFont);
			BList * bl = new BList();
			RadioViewData * pRVD4x64 = new RadioViewData(	CCL4x64RV,
															myPrefs->CC_4x64_Cell,
															bl,
															(B_CELLS_4x64 == myPrefs->mCCL));
			RadioViewData * pRVD8x32 = new RadioViewData(	CCL8x32RV,
															myPrefs->CC_8x32_Cell,
															bl,
															(B_CELLS_8x32 == myPrefs->mCCL));
			RadioViewData * pRVD16x16 = new RadioViewData(	CCL16x16RV,
															myPrefs->CC_16x16_Cell,
															bl,
															(B_CELLS_16x16 == myPrefs->mCCL));
			RadioViewData * pRVD32x8 = new RadioViewData(	CCL32x8RV,
															myPrefs->CC_32x8_Cell,
															bl,
															(B_CELLS_32x8 == myPrefs->mCCL));
			RadioViewData * pRVD64x4 = new RadioViewData(	CCL64x4RV,
															myPrefs->CC_64x4_Cell,
															bl,
															(B_CELLS_64x4 == myPrefs->mCCL));
			mpCCLrv = new MyRadioView(	"CCLRadioView",
										false,
										bl,
										myPrefs->GetPreferredFont(),
										pholdCCLLayoutMatrix);
			if (!mpCCLrv->Initialize())
			{
				warning(myPrefs->RadioViewFailInit);
				throw;
			}
//////////////////////////////////////////////////////////////////////////
		}
		else if (mui32Kind == SPECIFIC_COLOR_SLIDER)
		{
			pholdBarTitleLayoutMatrix = new LayoutMatrix(BESTSIZE, 1, 1, this);//rows,columns
////////////////////////////////////////////////////////////////
			BFont * pBFontBar = new BFont(myPrefs->GetPreferredFont());
			float fontSize = pBFontBar->Size();
			fontSize *= 2;
			if (fontSize > 200)
			{
				fontSize = 200;
			}
			pBFontBar->SetSize(fontSize);
			pBFontBar->SetShear(122);
			//will need offset for demo--use a seperate matrix and get it's bottom
			MyStringDrawer * pBarMyStringDrawer = new MyStringDrawer(	"specificTitleBarMyStringDrawer", 
																		myPrefs->BarColorTitle,
																		pholdBarTitleLayoutMatrix, 
																		pBFontBar);
//////////////////////////////////////////////////
			if (myPrefs->mbUseColorControl)
			{
				pholdBarCCLayoutMatrix = new LayoutMatrix(BESTSIZE, 2, 1, this);//rows,columns
	///////////////////////////////////////////////////////////////////////////////////
				MyStringDrawer * pBarMyStringDrawerAXX = new MyStringDrawer(	"BarMyStringDrawerAXX", 
																				myPrefs->BarCCLabel, 
																				pholdBarCCLayoutMatrix);
	////////////////////////////////////////////////////////////////////
				mpBarColorControl = new MyColorControl(	myPrefs->mCCL,
														"barColorControl", 
														BARCOLORCONTROL,
														pholdBarCCLayoutMatrix);
				myPrefs->GetPreferredMyBarStatusColor(&color);
				mpBarColorControl->SetValue(color);
			}
//////////////////////////////////////
			if (myPrefs->mbUseColorWell)
			{
				pholdBarCWLayoutMatrix = new LayoutMatrix(BESTSIZE, 1, 1, this);//rows,columns
	///////////////////////////////////////////
				mpBarColorWell = new ColorWell(	"ColorWellViewColorPref", 
												BAR_COLOR,
												myPrefs->BarCWLabel,
												this,
												pholdBarCWLayoutMatrix);
			}
////////////////////////////////////////
			if (myPrefs->mbUseColorControl)
			{
				pholdFillCCLayoutMatrix = new LayoutMatrix(BESTSIZE, 2, 1, this);//rows,columns
	///////////////////////////////////////////////////////////////////////////////////
				MyStringDrawer * pFillMSD = new MyStringDrawer(	"FillMSD", 
																myPrefs->FillCCLabel, 
																pholdFillCCLayoutMatrix);
	////////////////////////////////////////////////////////////////////
				mpFillColorControl = new MyColorControl(	myPrefs->mCCL,
															"fillColorControl", 
															FILLCOLORCONTROL,
															pholdFillCCLayoutMatrix);
				myPrefs->GetPreferredMyBarFillSliderColor(&color);
				mpFillColorControl->SetValue(color);
			}
//////////////////////////////////////
			if (myPrefs->mbUseColorWell)
			{
				pholdFillCWLayoutMatrix = new LayoutMatrix(BESTSIZE, 1, 1, this);//rows,columns
	///////////////////////////////////////////
				mpFillColorWell = new ColorWell(	"ColorWellViewColorPref", 
													FILL_COLOR,
													myPrefs->FillCWLabel,
													this,
													pholdFillCWLayoutMatrix);
			}
///////////////////////////////////////////
			pholdSliderLayoutMatrix = new LayoutMatrix(BESTSIZE, 3, 1, this);//rows,columns
//////////////////////////////////////
			mpSliderBarCB = new MyCheckBox(	"SliderBarCheckBox", 
											myPrefs->ColorSliderBarCBLabel,
											myPrefs->mui32ColorSliderBar,
											SLIDERBARCB,
											pholdSliderLayoutMatrix);
			mpSliderBarFillCB = new MyCheckBox(	"SliderBarCheckBoxFill", 
												myPrefs->FillSliderBarCBLabel,
												myPrefs->mui32FillSliderBar,
												SLIDERBARFILLCB,
												pholdSliderLayoutMatrix);
			BList * bl = new BList();
			RadioViewData * pRVDOne = new RadioViewData(	THUMB_RECT,
															myPrefs->DemoRadioLabelThumbRect,
															bl,
															(B_BLOCK_THUMB == myPrefs->GetPreferredThumbStyle()));
			RadioViewData * pRVDTwo = new RadioViewData(	THUMB_TRI,
															myPrefs->DemoRadioLabelThumbTri,
															bl,
															(B_TRIANGLE_THUMB == myPrefs->GetPreferredThumbStyle()));
			mpThumbRadioView = new MyRadioView(	"thumbRadioView",
												true,
												bl,
												myPrefs->GetPreferredFont(),
												pholdSliderLayoutMatrix);
			if (!mpThumbRadioView->Initialize())
			{
				warning(myPrefs->RadioViewFailInit);
				throw;
			}
		}
/////////////////////////////////////////////////////////////////////////////////////
		else if (mui32Kind == SPECIFIC_COLOR_COLORWELL)
		{
			pholdColorWellWHLayoutMatrix = new LayoutMatrix(BESTSIZE, 2, 1, this);//rows,columns
////////////////////////////////////////////////////////////////
			mpColorWellWidthGadget = new UInt8Gadget(	myPrefs->GetPreferredColorWellWidth(),
														"ColorWellWidthGadget",
														myPrefs->EnterColorWellWidthLabel,
														0,
														this,
														pholdColorWellWHLayoutMatrix);
			BMessageFilter * bmfW = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
														B_LOCAL_SOURCE, 
														'_KYD', 
														filterUIntNumeric);
			mpColorWellWidthGadget->AddFilter(bmfW);
//////////////////////////////////////////////////////////////
			mpColorWellHeightGadget = new UInt8Gadget(	myPrefs->GetPreferredColorWellHeight(),
														"ColorWellHeightGadget",
														myPrefs->EnterColorWellHeightLabel,
														0,
														this,
														pholdColorWellWHLayoutMatrix);
			BMessageFilter * bmfH = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
														B_LOCAL_SOURCE, 
														'_KYD', 
														filterUIntNumeric);
			mpColorWellHeightGadget->AddFilter(bmfH);
////////////////////
		}
/////////////////////////////////////////////////////////////
		release_sem(calc_sem);
		pholdTitleLayoutMatrix->Calc(MATRIXHORIZONTALOFFSET, MATRIXVERTICALOFFSET, calc_sem);
		float bottom = pholdTitleLayoutMatrix->mfBottom;
		float right = MATRIXHORIZONTALOFFSET;
		if (myPrefs->mbUseColorControl)
		{
			pholdViewCCLayoutMatrix->Calc(right, bottom, calc_sem);
			pholdHighCCLayoutMatrix->Calc(pholdViewCCLayoutMatrix->mfRight, bottom, calc_sem);
			pholdLowCCLayoutMatrix->Calc(pholdHighCCLayoutMatrix->mfRight, bottom, calc_sem);
			bottom = pholdLowCCLayoutMatrix->mfBottom;
			if (bottom < pholdHighCCLayoutMatrix->mfBottom)
			{
				bottom = pholdHighCCLayoutMatrix->mfBottom;
			}
			if (bottom < pholdViewCCLayoutMatrix->mfBottom)
			{
				bottom = pholdViewCCLayoutMatrix->mfBottom;
			}
			right = pholdLowCCLayoutMatrix->mfRight;
		}
		float cwRight = MATRIXHORIZONTALOFFSET;
		if (myPrefs->mbUseColorWell)
		{
			pholdColorWellLayoutMatrix->Calc(cwRight, bottom, calc_sem);
			bottom = pholdColorWellLayoutMatrix->mfBottom;
			cwRight = pholdColorWellLayoutMatrix->mfRight;
		}
		if (cwRight > right)
		{
			right = cwRight;
		}
		pholdDemoLayoutMatrix->Calc(right, pholdTitleLayoutMatrix->mfBottom, calc_sem);
		if (	(mui32Kind == SPECIFIC_COLOR_STATUSBAR)
				||
				(mui32Kind == SPECIFIC_COLOR_SLIDER))
		{
			pholdBarTitleLayoutMatrix->Calc(MATRIXHORIZONTALOFFSET, bottom, calc_sem);
			if (myPrefs->mbUseColorControl)
			{
				pholdBarCCLayoutMatrix->Calc(MATRIXHORIZONTALOFFSET, pholdBarTitleLayoutMatrix->mfBottom, calc_sem);
				bottom = pholdBarCCLayoutMatrix->mfBottom;
			}
			if (myPrefs->mbUseColorWell)
			{
				pholdBarCWLayoutMatrix->Calc(MATRIXHORIZONTALOFFSET, bottom, calc_sem);
				bottom = pholdBarCWLayoutMatrix->mfBottom;
			}
			float ccRightSB = cwRight;
			float cwRightSB = cwRight;
			if (myPrefs->mbUseColorControl)
			{
				ccRightSB = pholdBarCCLayoutMatrix->mfRight;
			}
			if (myPrefs->mbUseColorWell)
			{
				cwRightSB = pholdBarCWLayoutMatrix->mfRight;
			}
			if (ccRightSB > cwRightSB)
			{
				cwRightSB = ccRightSB;
			}
			if (mui32Kind == SPECIFIC_COLOR_STATUSBAR)
			{
				pholdBarHLayoutMatrix->Calc(cwRightSB, pholdBarTitleLayoutMatrix->mfBottom, calc_sem);
			}
			else //if (mui32Kind == SPECIFIC_COLOR_SLIDER)
			{
				if (myPrefs->mbUseColorControl)
				{
					pholdFillCCLayoutMatrix->Calc(cwRightSB, pholdBarTitleLayoutMatrix->mfBottom, calc_sem);
					bottom = pholdFillCCLayoutMatrix->mfBottom;
				}
				else
				{
					bottom = pholdBarTitleLayoutMatrix->mfBottom;
				}
				if (myPrefs->mbUseColorWell)
				{
					pholdFillCWLayoutMatrix->Calc(cwRightSB, bottom, calc_sem);
				}
				float fccRightSB = cwRightSB;
				float fcwRightSB = cwRightSB;
				if (myPrefs->mbUseColorControl)
				{
					fccRightSB = pholdFillCCLayoutMatrix->mfRight;
				}
				if (myPrefs->mbUseColorWell)
				{
					fcwRightSB = pholdFillCWLayoutMatrix->mfRight;
				}
				if (fccRightSB > fcwRightSB)
				{
					fcwRightSB = fccRightSB;
				}
				pholdSliderLayoutMatrix->Calc(fcwRightSB + 3, pholdBarTitleLayoutMatrix->mfBottom, calc_sem);
			}
		}
		else if (mui32Kind == SPECIFIC_COLOR_COLORWELL)
		{
			pholdColorWellWHLayoutMatrix->Calc(MATRIXHORIZONTALOFFSET, bottom, calc_sem);
		}
		else if (mui32Kind == SPECIFIC_COLOR_COLORCONTROL)
		{
			pholdCCLLayoutMatrix->Calc(MATRIXHORIZONTALOFFSET, bottom + 3, calc_sem);
		}
	}
	catch (...)
	{
		warning(myPrefs->CaughtSpecificColorWindowCTOR);
		release_sem(calc_sem);
		throw;
	}
	try 
	{
		BMenuItem *	menuItem;
		BMenu * APPMenu = new BMenu(myPrefs->AppMenuLabel);
		menuItem = new BMenuItem(	myPrefs->AboutMenuLabel, 
									new BMessage(ABOUT_SPECIFICCOLORWINDOW));
		APPMenu->AddItem(menuItem);
		menuItem = new BMenuItem(	myPrefs->CloseWindow, 
									new BMessage(B_QUIT_REQUESTED));
		APPMenu->AddItem(menuItem);
		menuItem = new BMenuItem(	myPrefs->QuitMenuLabel, 
									new BMessage(QUIT_APP));
		APPMenu->AddItem(menuItem);
		mpMenuBar->AddItem(APPMenu);
	}
	catch(...) 
	{
		throw;
	}
}//end
Example #25
0
void BitmapView::MouseMoved( BPoint cNewPos, uint32 nCode, const BMessage* pcData )
{
	int32       nButtons = 0x01;

	Window()->CurrentMessage()->FindInt32("buttons", &nButtons);

	m_cLastPos = cNewPos;

    if ( (nButtons & 0x01) == 0 )
	{
        return;
    }
  
    if ( m_bSelRectActive )
	{
        SetDrawingMode( B_OP_INVERT );
        DrawFrame( m_cSelRect, FRAME_TRANSPARENT | FRAME_THIN );
        m_cSelRect.right = cNewPos.x;
        m_cSelRect.bottom = cNewPos.y;

        BRect cSelRect = m_cSelRect;
        if ( cSelRect.left > cSelRect.right )
		{
            float nTmp = cSelRect.left;
            cSelRect.left = cSelRect.right;
            cSelRect.right = nTmp;
        }

        if ( cSelRect.top > cSelRect.bottom )
		{
            float nTmp = cSelRect.top;
            cSelRect.top = cSelRect.bottom;
            cSelRect.bottom = nTmp;
        }
        BFont* pcFont = GetFont();
        SetDrawingMode( B_OP_COPY );
        for ( uint i = 0 ; i < m_cIcons.size() ; ++i )
		{
            m_cIcons[i]->Select( this, cSelRect.Contains( m_cIcons[i]->GetFrame( pcFont ) ) );
        }

        SetDrawingMode( B_OP_INVERT );
        DrawFrame( m_cSelRect, FRAME_TRANSPARENT | FRAME_THIN );
    
        Flush();
        return;
    }
  
    if ( m_bCanDrag )
    {
        Flush();
    
        Icon* pcSelIcon = NULL;

        BRect cSelFrame( 1000000, 1000000, -1000000, -1000000 );
    
        BFont* pcFont = GetFont();
        BMessage cData(1234);
        for ( uint i = 0 ; i < m_cIcons.size() ; ++i ) {
            if ( m_cIcons[i]->m_bSelected ) {
                cData.AddString( "file/path", m_cIcons[i]->GetName().c_str() );
                cSelFrame = cSelFrame | m_cIcons[i]->GetFrame( pcFont );
                pcSelIcon = m_cIcons[i];
            }
        }
        if ( pcSelIcon != NULL ) {
            m_cDragStartPos = cNewPos; // + cSelFrame.LeftTop() - cNewPos;

            if ( (cSelFrame.Width()+1.0f) * (cSelFrame.Height()+1.0f) < 12000 )
            {
                BBitmap cDragBitmap( cSelFrame, B_RGB32, true );

                BView* pcView = new BView( cSelFrame.OffsetToCopy(0,0), "", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW );
                cDragBitmap.AddChild( pcView );

                pcView->SetHighColor( 255, 255, 255, 0 );
                pcView->FillRect( cSelFrame.OffsetToCopy(0,0) );


                for ( uint i = 0 ; i < m_cIcons.size() ; ++i ) {
                    if ( m_cIcons[i]->m_bSelected ) {
                        m_cIcons[i]->Draw( pcView, -cSelFrame.LeftTop(), true, false );
                    }
                }
                cDragBitmap.Sync();

                uint32* pRaster = (uint32*)cDragBitmap.Bits();

                for ( int y = 0 ; y < cSelFrame.Height() + 1.0f ; ++y ) {
                    for ( int x = 0 ; x < cSelFrame.Width()+1.0f ; ++x ) {
                        if ( pRaster[x + y * int(cSelFrame.Width()+1.0f)] != 0x00ffffff &&
                             (pRaster[x + y * int(cSelFrame.Width()+1.0f)] & 0xff000000) == 0xff000000 ) {
                            pRaster[x + y * int(cSelFrame.Width()+1.0f)] = (pRaster[x + y * int(cSelFrame.Width()+1.0f)] & 0x00ffffff) | 0xb0000000;
                        }
                    }
                }
                DragMessage( &cData, &cDragBitmap, cNewPos - cSelFrame.LeftTop() );

            } else {
                DragMessage( &cData, cNewPos - cSelFrame.LeftTop(), cSelFrame.OffsetToCopy(0,0) );
            }
        }
        m_bCanDrag = false;
    }
    Flush();
}
Example #26
0
void
BSlider::DrawBar()
{
	BRect frame = BarFrame();
	BView *view = OffscreenView();

	if (be_control_look != NULL) {
		uint32 flags = be_control_look->Flags(this);
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		rgb_color rightFillColor = fBarColor;
		rgb_color leftFillColor = fUseFillColor ? fFillColor : fBarColor;
		be_control_look->DrawSliderBar(view, frame, frame, base, leftFillColor,
			rightFillColor, Position(), flags, fOrientation);
		return;
	}

	rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color lightenmax;
	rgb_color darken1;
	rgb_color darken2;
	rgb_color darkenmax;

	rgb_color barColor;
	rgb_color fillColor;

	if (IsEnabled()) {
		lightenmax	= tint_color(no_tint, B_LIGHTEN_MAX_TINT);
		darken1		= tint_color(no_tint, B_DARKEN_1_TINT);
		darken2		= tint_color(no_tint, B_DARKEN_2_TINT);
		darkenmax	= tint_color(no_tint, B_DARKEN_MAX_TINT);
		barColor	= fBarColor;
		fillColor	= fFillColor;
	} else {
		lightenmax	= tint_color(no_tint, B_LIGHTEN_MAX_TINT);
		darken1		= no_tint;
		darken2		= tint_color(no_tint, B_DARKEN_1_TINT);
		darkenmax	= tint_color(no_tint, B_DARKEN_3_TINT);

		barColor.red	= (fBarColor.red + no_tint.red) / 2;
		barColor.green	= (fBarColor.green + no_tint.green) / 2;
		barColor.blue	= (fBarColor.blue + no_tint.blue) / 2;
		barColor.alpha	= 255;

		fillColor.red	= (fFillColor.red + no_tint.red) / 2;
		fillColor.green	= (fFillColor.green + no_tint.green) / 2;
		fillColor.blue	= (fFillColor.blue + no_tint.blue) / 2;
		fillColor.alpha	= 255;
	}

	// exclude the block thumb from the bar filling

	BRect lowerFrame = frame.InsetByCopy(1, 1);
	lowerFrame.top++;
	lowerFrame.left++;
	BRect upperFrame = lowerFrame;
	BRect thumbFrame;

	if (Style() == B_BLOCK_THUMB) {
		thumbFrame = ThumbFrame();

		if (fOrientation == B_HORIZONTAL) {
			lowerFrame.right = thumbFrame.left;
			upperFrame.left = thumbFrame.right;
		} else {
			lowerFrame.top = thumbFrame.bottom;
			upperFrame.bottom = thumbFrame.top;
		}
	} else if (fUseFillColor) {
		if (fOrientation == B_HORIZONTAL) {
			lowerFrame.right = floor(lowerFrame.left - 1 + Position()
				* (lowerFrame.Width() + 1));
			upperFrame.left = lowerFrame.right;
		} else {
			lowerFrame.top = floor(lowerFrame.bottom + 1 - Position()
				* (lowerFrame.Height() + 1));
			upperFrame.bottom = lowerFrame.top;
		}
	}

	view->SetHighColor(barColor);
	view->FillRect(upperFrame);

	if (Style() == B_BLOCK_THUMB || fUseFillColor) {
		if (fUseFillColor)
			view->SetHighColor(fillColor);
		view->FillRect(lowerFrame);
	}

	if (Style() == B_BLOCK_THUMB) {
		// We don't want to stroke the lines over the thumb

		PushState();

		BRegion region;
		GetClippingRegion(&region);
		region.Exclude(thumbFrame);
		ConstrainClippingRegion(&region);
	}

	view->SetHighColor(darken1);
	view->StrokeLine(BPoint(frame.left, frame.top),
					 BPoint(frame.left + 1.0f, frame.top));
	view->StrokeLine(BPoint(frame.left, frame.bottom),
					 BPoint(frame.left + 1.0f, frame.bottom));
	view->StrokeLine(BPoint(frame.right - 1.0f, frame.top),
					 BPoint(frame.right, frame.top));

	view->SetHighColor(darken2);
	view->StrokeLine(BPoint(frame.left + 1.0f, frame.top),
					 BPoint(frame.right - 1.0f, frame.top));
	view->StrokeLine(BPoint(frame.left, frame.bottom - 1.0f),
					 BPoint(frame.left, frame.top + 1.0f));

	view->SetHighColor(lightenmax);
	view->StrokeLine(BPoint(frame.left + 1.0f, frame.bottom),
					 BPoint(frame.right, frame.bottom));
	view->StrokeLine(BPoint(frame.right, frame.bottom - 1.0f),
					 BPoint(frame.right, frame.top + 1.0f));

	frame.InsetBy(1.0f, 1.0f);

	view->SetHighColor(darkenmax);
	view->StrokeLine(BPoint(frame.left, frame.bottom),
					 BPoint(frame.left, frame.top));
	view->StrokeLine(BPoint(frame.left + 1.0f, frame.top),
					 BPoint(frame.right, frame.top));

	if (Style() == B_BLOCK_THUMB)
		PopState();
}
Example #27
0
void MonthWindowView::DrawMonth()
{
 Bmp->Lock();
 
 float y=yearStringView->Frame().bottom+h_cell;
 float x=0;
 
 if(NewMonth)
 {
  BmpView->SetHighColor(VIEW_COLOR);
  BmpView->FillRect(BRect(0,y+1,
                    BmpView->Bounds().right,todayStringView->Frame().top-6));
  BmpView->SetHighColor(0,0,0,0);
  NewMonth=false;
 }
 
 int byear=cyear; // base year
 if(tyear<byear) byear=tyear;
  
 int day1=0, m=0, k=byear;
 
 while(k<cyear)
 {
  day1++;

  if(k%4==0) // leap year?
   if((k%100!=0) || (k%400==0)) day1++; // yes
  
  k++;
 }
 while(++m<cmonth)
 {
  day1+=(monthDays[m-1]-28);
  if(m==2) if((cyear%4)==0) if((cyear%100!=0) || (cyear%400==0)) day1++;
 }
 day1++; // day1 is number of 1st day of chosen month in chosen year
 day1=day1%7;
 
 int day2=0;
 m=0;
 k=byear;
 while(k<tyear)
 {
  day2++;
  if((k%4)==0) if((k%100!=0) || (k%400==0)) day2++;
  k++;
 }
 while(++m<tmonth)
 {
  day2+=(monthDays[m-1]-28);
  if(m==2) if((tyear%4)==0) if((tyear%100!=0) || (tyear%400==0)) day2++;
 }
 day2+=tday; // day2 - number of today's day in today's year
 day2=day2%7;
 
 k=(twday==0) ? 6 : twday-1;
 
 k=k-day2+day1;
 while(k<0) k+=7;
 k=k%7;
 cwday1=k;
 
 x=w_cell*k+1;
 y+=h_cell;
 
 int qu_days=monthDays[cmonth-1]; // quantity of days in month
 
 if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
 
 BString s;
 int t=0;
 while(t<qu_days)
 {
  t++;
  
  s<<t;
  
  if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(200,0,0,0);
  BmpView->DrawString(s.String(),BPoint(x+(w_cell-StringWidth(s.String()))/2,y));
  if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(0,0,0,0);
  
  if(t==cday)
  {
   cwday=k;
   if(which_focused==2) BmpView->SetHighColor(ACTIVE_COLOR);
   else BmpView->SetHighColor(NOACTIVE_COLOR);
   cursor.Set(x,y-h_cell+5,x+w_cell-1,y+4);
   BmpView->StrokeRect(cursor);
   BmpView->SetHighColor(0,0,0,0);
  }
  
  x+=w_cell;
  k++;
  s.SetTo("");
  
  if(k==7)
  {
   k=0;
   y+=h_cell;
   x=1;
  }
 }
 
 BmpView->Sync();
 Bmp->Unlock();
 Draw(Bounds());
}
Example #28
0
void
TouchpadView::DrawSliders()
{
	BView* view;
	if (fOffScreenView != NULL)
		view = fOffScreenView;
	else
		view = this;

	if (!LockLooper())
		return;

	if (fOffScreenBitmap->Lock()) {
		view->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
		view->FillRect(Bounds());
		view->SetHighColor(100, 100, 100);
		view->FillRoundRect(fPadRect, 4, 4);

		int32 dragSize = 3; // half drag size

		// scroll areas
		view->SetHighColor(145, 100, 100);
		BRect rightRect(fPadRect.left + fXScrollRange,  fPadRect.top,
			fPadRect.right, fPadRect.bottom);
		view->FillRoundRect(rightRect, 4, 4);

		BRect bottomRect(fPadRect.left, fPadRect.top + fYScrollRange,
			fPadRect.right, fPadRect.bottom);
		view->FillRoundRect(bottomRect, 4, 4);

		// Stroke Rect
		view->SetHighColor(100, 100, 100);
		view->SetPenSize(2);
		view->StrokeRoundRect(fPadRect, 4, 4);

		// x scroll range line
		view->SetHighColor(200, 0, 0);
		view->StrokeLine(BPoint(fPadRect.left + fXScrollRange, fPadRect.top),
			BPoint(fPadRect.left + fXScrollRange, fPadRect.bottom));

		fXScrollDragZone = BRect(fPadRect.left + fXScrollRange - dragSize,
			fPadRect.top - dragSize, fPadRect.left + fXScrollRange + dragSize,
			fPadRect.bottom + dragSize);
		fXScrollDragZone1 = BRect(fPadRect.left + fXScrollRange - dragSize,
			fPadRect.top - dragSize, fPadRect.left + fXScrollRange + dragSize,
			fPadRect.top + dragSize);
		view->FillRect(fXScrollDragZone1);
		fXScrollDragZone2 = BRect(fPadRect.left + fXScrollRange - dragSize,
			fPadRect.bottom - dragSize,
			fPadRect.left + fXScrollRange + dragSize,
			fPadRect.bottom + dragSize);
		view->FillRect(fXScrollDragZone2);

		// y scroll range line
		view->StrokeLine(BPoint(fPadRect.left, fPadRect.top + fYScrollRange),
			BPoint(fPadRect.right, fPadRect.top  + fYScrollRange));

		fYScrollDragZone = BRect(fPadRect.left - dragSize,
			fPadRect.top + fYScrollRange - dragSize,
			fPadRect.right  + dragSize,
			fPadRect.top + fYScrollRange + dragSize);
		fYScrollDragZone1 = BRect(fPadRect.left - dragSize,
			fPadRect.top + fYScrollRange - dragSize, fPadRect.left  + dragSize,
			fPadRect.top + fYScrollRange + dragSize);
		view->FillRect(fYScrollDragZone1);
		fYScrollDragZone2 = BRect(fPadRect.right - dragSize,
			fPadRect.top + fYScrollRange - dragSize, fPadRect.right  + dragSize,
			fPadRect.top + fYScrollRange + dragSize);
		view->FillRect(fYScrollDragZone2);

		fOffScreenView->Sync();
		fOffScreenBitmap->Unlock();
		DrawBitmap(fOffScreenBitmap, B_ORIGIN);
	}

	UnlockLooper();
}
void
RemoteView::_DrawThread()
{
	RemoteMessage reply(NULL, fSendBuffer);
	RemoteMessage message(fReceiveBuffer, NULL);

	// cursor
	BPoint cursorHotSpot(0, 0);

	while (!fStopThread) {
		uint16 code;
		status_t status = message.NextMessage(code);
		if (status != B_OK) {
			TRACE_ERROR("failed to read message from receiver\n");
			break;
		}

		TRACE("code %u with %ld bytes data\n", code, message.DataLeft());

		BAutolock locker(this->Looper());
		if (!locker.IsLocked())
			break;

		// handle stuff that doesn't go to a specicifc engine
		switch (code) {
			case RP_INIT_CONNECTION:
			{
				uint16 port;
				status_t result = message.Read(port);
				if (result != B_OK) {
					TRACE_ERROR("failed to read remote port\n");
					continue;
				}

				BNetEndpoint *endpoint = fReceiver->Endpoint();
				if (endpoint == NULL) {
					TRACE_ERROR("receiver not connected anymore\n");
					continue;
				}

				in_addr remoteHost;
				char hostName[MAXHOSTNAMELEN + 1];
				BNetAddress address(endpoint->RemoteAddr());
				address.GetAddr(remoteHost);
				address.GetAddr(hostName, NULL);
				address.SetTo(remoteHost, port);

				TRACE("connecting to host \"%s\" port %u\n", hostName, port);
				result = fSendEndpoint->Connect(address);
				if (result != B_OK) {
					TRACE_ERROR("failed to connect to host \"%s\" port %u\n",
						hostName, port);
					continue;
				}

				BRect bounds = fOffscreenBitmap->Bounds();
				reply.Start(RP_UPDATE_DISPLAY_MODE);
				reply.Add(bounds.IntegerWidth() + 1);
				reply.Add(bounds.IntegerHeight() + 1);
				if (reply.Flush() == B_OK)
					fIsConnected = true;

				continue;
			}

			case RP_CLOSE_CONNECTION:
			{
				be_app->PostMessage(B_QUIT_REQUESTED);
				continue;
			}

			case RP_CREATE_STATE:
			case RP_DELETE_STATE:
			{
				uint32 token;
				message.Read(token);

				if (code == RP_CREATE_STATE)
					_CreateState(token);
				else
					_DeleteState(token);

				continue;
			}

			case RP_SET_CURSOR:
			{
				BBitmap *bitmap;
				BPoint oldHotSpot = cursorHotSpot;
				message.Read(cursorHotSpot);
				if (message.ReadBitmap(&bitmap) != B_OK)
					continue;

				delete fCursorBitmap;
				fCursorBitmap = bitmap;

				Invalidate(fCursorFrame);

				BRect bounds = fCursorBitmap->Bounds();
				fCursorFrame.right = fCursorFrame.left
					+ bounds.IntegerWidth() + 1;
				fCursorFrame.bottom = fCursorFrame.bottom
					+ bounds.IntegerHeight() + 1;

				fCursorFrame.OffsetBy(oldHotSpot - cursorHotSpot);

				Invalidate(fCursorFrame);
				continue;
			}

			case RP_SET_CURSOR_VISIBLE:
			{
				bool wasVisible = fCursorVisible;
				message.Read(fCursorVisible);
				if (wasVisible != fCursorVisible)
					Invalidate(fCursorFrame);
				continue;
			}

			case RP_MOVE_CURSOR_TO:
			{
				BPoint position;
				message.Read(position);

				if (fCursorVisible)
					Invalidate(fCursorFrame);

				fCursorFrame.OffsetTo(position - cursorHotSpot);

				Invalidate(fCursorFrame);
				continue;
			}

			case RP_INVALIDATE_RECT:
			{
				BRect rect;
				if (message.Read(rect) != B_OK)
					continue;

				Invalidate(rect);
				continue;
			}

			case RP_INVALIDATE_REGION:
			{
				BRegion region;
				if (message.ReadRegion(region) != B_OK)
					continue;

				Invalidate(&region);
				continue;
			}

			case RP_FILL_REGION_COLOR_NO_CLIPPING:
			{
				BRegion region;
				rgb_color color;

				message.ReadRegion(region);
				if (message.Read(color) != B_OK)
					continue;

				fOffscreen->LockLooper();
				fOffscreen->SetHighColor(color);
				fOffscreen->FillRegion(&region);
				fOffscreen->UnlockLooper();
				Invalidate(&region);
				continue;
			}

			case RP_COPY_RECT_NO_CLIPPING:
			{
				int32 xOffset, yOffset;
				BRect rect;

				message.Read(xOffset);
				message.Read(yOffset);
				if (message.Read(rect) != B_OK)
					continue;

				BRect dest = rect.OffsetByCopy(xOffset, yOffset);
				fOffscreen->LockLooper();
				fOffscreen->CopyBits(rect, dest);
				fOffscreen->UnlockLooper();
				continue;
			}
		}

		uint32 token;
		message.Read(token);

		engine_state *state = _FindState(token);
		if (state == NULL) {
			TRACE_ERROR("didn't find state for token %lu\n", token);
			continue;
		}

		BView *offscreen = state->view;
		::pattern &pattern = state->pattern;
		BRegion &clippingRegion = state->clipping_region;
		float &penSize = state->pen_size;
		bool &syncDrawing = state->sync_drawing;
		BRegion invalidRegion;

		BAutolock offscreenLocker(offscreen->Looper());
		if (!offscreenLocker.IsLocked())
			break;

		switch (code) {
			case RP_ENABLE_SYNC_DRAWING:
				syncDrawing = true;
				continue;

			case RP_DISABLE_SYNC_DRAWING:
				syncDrawing = false;
				continue;

			case RP_SET_OFFSETS:
			{
				int32 xOffset, yOffset;
				message.Read(xOffset);
				if (message.Read(yOffset) != B_OK)
					continue;

				offscreen->MovePenTo(xOffset, yOffset);
				break;
			}

			case RP_SET_HIGH_COLOR:
			case RP_SET_LOW_COLOR:
			{
				rgb_color color;
				if (message.Read(color) != B_OK)
					continue;

				if (code == RP_SET_HIGH_COLOR)
					offscreen->SetHighColor(color);
				else
					offscreen->SetLowColor(color);

				break;
			}

			case RP_SET_PEN_SIZE:
			{
				float newPenSize;
				if (message.Read(newPenSize) != B_OK)
					continue;

				offscreen->SetPenSize(newPenSize);
				penSize = newPenSize / 2;
				break;
			}

			case RP_SET_STROKE_MODE:
			{
				cap_mode capMode;
				join_mode joinMode;
				float miterLimit;

				message.Read(capMode);
				message.Read(joinMode);
				if (message.Read(miterLimit) != B_OK)
					continue;

				offscreen->SetLineMode(capMode, joinMode, miterLimit);
				break;
			}

			case RP_SET_BLENDING_MODE:
			{
				source_alpha sourceAlpha;
				alpha_function alphaFunction;

				message.Read(sourceAlpha);
				if (message.Read(alphaFunction) != B_OK)
					continue;

				offscreen->SetBlendingMode(sourceAlpha, alphaFunction);
				break;
			}

			case RP_SET_PATTERN:
			{
				if (message.Read(pattern) != B_OK)
					continue;
				break;
			}

			case RP_SET_DRAWING_MODE:
			{
				drawing_mode drawingMode;
				if (message.Read(drawingMode) != B_OK)
					continue;

				offscreen->SetDrawingMode(drawingMode);
				break;
			}

			case RP_SET_FONT:
			{
				BFont font;
				if (message.ReadFontState(font) != B_OK)
					continue;

				offscreen->SetFont(&font);
				break;
			}

			case RP_CONSTRAIN_CLIPPING_REGION:
			{
				if (message.ReadRegion(clippingRegion) != B_OK)
					continue;

				offscreen->ConstrainClippingRegion(&clippingRegion);
				break;
			}

			case RP_INVERT_RECT:
			{
				BRect rect;
				if (message.Read(rect) != B_OK)
					continue;

				offscreen->InvertRect(rect);
				invalidRegion.Include(rect);
				break;
			}

			case RP_DRAW_BITMAP:
			{
				BBitmap *bitmap;
				BRect bitmapRect, viewRect;
				uint32 options;

				message.Read(bitmapRect);
				message.Read(viewRect);
				message.Read(options);
				if (message.ReadBitmap(&bitmap) != B_OK || bitmap == NULL)
					continue;

				offscreen->DrawBitmap(bitmap, bitmapRect, viewRect, options);
				invalidRegion.Include(viewRect);
				delete bitmap;
				break;
			}

			case RP_DRAW_BITMAP_RECTS:
			{
				color_space colorSpace;
				int32 rectCount;
				uint32 flags, options;

				message.Read(options);
				message.Read(colorSpace);
				message.Read(flags);
				message.Read(rectCount);
				for (int32 i = 0; i < rectCount; i++) {
					BBitmap *bitmap;
					BRect viewRect;

					message.Read(viewRect);
					if (message.ReadBitmap(&bitmap, true, colorSpace,
							flags) != B_OK || bitmap == NULL) {
						continue;
					}

					offscreen->DrawBitmap(bitmap, bitmap->Bounds(), viewRect,
						options);
					invalidRegion.Include(viewRect);
					delete bitmap;
				}

				break;
			}

			case RP_STROKE_ARC:
			case RP_FILL_ARC:
			case RP_FILL_ARC_GRADIENT:
			{
				BRect rect;
				float angle, span;

				message.Read(rect);
				message.Read(angle);
				if (message.Read(span) != B_OK)
					continue;

				if (code == RP_STROKE_ARC) {
					offscreen->StrokeArc(rect, angle, span, pattern);
					rect.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_ARC)
					offscreen->FillArc(rect, angle, span, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillArc(rect, angle, span, *gradient);
					delete gradient;
				}

				invalidRegion.Include(rect);
				break;
			}

			case RP_STROKE_BEZIER:
			case RP_FILL_BEZIER:
			case RP_FILL_BEZIER_GRADIENT:
			{
				BPoint points[4];
				if (message.ReadList(points, 4) != B_OK)
					continue;

				BRect bounds = _BuildInvalidateRect(points, 4);
				if (code == RP_STROKE_BEZIER) {
					offscreen->StrokeBezier(points, pattern);
					bounds.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_BEZIER)
					offscreen->FillBezier(points, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillBezier(points, *gradient);
					delete gradient;
				}

				invalidRegion.Include(bounds);
				break;
			}

			case RP_STROKE_ELLIPSE:
			case RP_FILL_ELLIPSE:
			case RP_FILL_ELLIPSE_GRADIENT:
			{
				BRect rect;
				if (message.Read(rect) != B_OK)
					continue;

				if (code == RP_STROKE_ELLIPSE) {
					offscreen->StrokeEllipse(rect, pattern);
					rect.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_ELLIPSE)
					offscreen->FillEllipse(rect, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillEllipse(rect, *gradient);
					delete gradient;
				}

				invalidRegion.Include(rect);
				break;
			}

			case RP_STROKE_POLYGON:
			case RP_FILL_POLYGON:
			case RP_FILL_POLYGON_GRADIENT:
			{
				BRect bounds;
				bool closed;
				int32 numPoints;

				message.Read(bounds);
				message.Read(closed);
				if (message.Read(numPoints) != B_OK)
					continue;

				BPoint points[numPoints];
				for (int32 i = 0; i < numPoints; i++)
					message.Read(points[i]);

				if (code == RP_STROKE_POLYGON) {
					offscreen->StrokePolygon(points, numPoints, bounds, closed,
						pattern);
					bounds.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_POLYGON)
					offscreen->FillPolygon(points, numPoints, bounds, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillPolygon(points, numPoints, bounds,
						*gradient);
					delete gradient;
				}

				invalidRegion.Include(bounds);
				break;
			}

			case RP_STROKE_RECT:
			case RP_FILL_RECT:
			case RP_FILL_RECT_GRADIENT:
			{
				BRect rect;
				if (message.Read(rect) != B_OK)
					continue;

				if (code == RP_STROKE_RECT) {
					offscreen->StrokeRect(rect, pattern);
					rect.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_RECT)
					offscreen->FillRect(rect, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillRect(rect, *gradient);
					delete gradient;
				}

				invalidRegion.Include(rect);
				break;
			}

			case RP_STROKE_ROUND_RECT:
			case RP_FILL_ROUND_RECT:
			case RP_FILL_ROUND_RECT_GRADIENT:
			{
				BRect rect;
				float xRadius, yRadius;

				message.Read(rect);
				message.Read(xRadius);
				if (message.Read(yRadius) != B_OK)
					continue;

				if (code == RP_STROKE_ROUND_RECT) {
					offscreen->StrokeRoundRect(rect, xRadius, yRadius,
						pattern);
					rect.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_ROUND_RECT)
					offscreen->FillRoundRect(rect, xRadius, yRadius, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillRoundRect(rect, xRadius, yRadius,
						*gradient);
					delete gradient;
				}

				invalidRegion.Include(rect);
				break;
			}

			case RP_STROKE_SHAPE:
			case RP_FILL_SHAPE:
			case RP_FILL_SHAPE_GRADIENT:
			{
				BRect bounds;
				int32 opCount, pointCount;

				message.Read(bounds);
				if (message.Read(opCount) != B_OK)
					continue;

				BMessage archive;
				for (int32 i = 0; i < opCount; i++) {
					int32 op;
					message.Read(op);
					archive.AddInt32("ops", op);
				}

				if (message.Read(pointCount) != B_OK)
					continue;

				for (int32 i = 0; i < pointCount; i++) {
					BPoint point;
					message.Read(point);
					archive.AddPoint("pts", point);
				}

				BPoint offset;
				message.Read(offset);

				float scale;
				if (message.Read(scale) != B_OK)
					continue;

				offscreen->PushState();
				offscreen->MovePenTo(offset);
				offscreen->SetScale(scale);

				BShape shape(&archive);
				if (code == RP_STROKE_SHAPE) {
					offscreen->StrokeShape(&shape, pattern);
					bounds.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_SHAPE)
					offscreen->FillShape(&shape, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK) {
						offscreen->PopState();
						continue;
					}

					offscreen->FillShape(&shape, *gradient);
					delete gradient;
				}

				offscreen->PopState();
				invalidRegion.Include(bounds);
				break;
			}

			case RP_STROKE_TRIANGLE:
			case RP_FILL_TRIANGLE:
			case RP_FILL_TRIANGLE_GRADIENT:
			{
				BRect bounds;
				BPoint points[3];

				message.ReadList(points, 3);
				if (message.Read(bounds) != B_OK)
					continue;

				if (code == RP_STROKE_TRIANGLE) {
					offscreen->StrokeTriangle(points[0], points[1], points[2],
						bounds, pattern);
					bounds.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_TRIANGLE) {
					offscreen->FillTriangle(points[0], points[1], points[2],
						bounds, pattern);
				} else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillTriangle(points[0], points[1], points[2],
						bounds, *gradient);
					delete gradient;
				}

				invalidRegion.Include(bounds);
				break;
			}

			case RP_STROKE_LINE:
			{
				BPoint points[2];
				if (message.ReadList(points, 2) != B_OK)
					continue;

				offscreen->StrokeLine(points[0], points[1], pattern);

				BRect bounds = _BuildInvalidateRect(points, 2);
				invalidRegion.Include(bounds.InsetBySelf(-penSize, -penSize));
				break;
			}

			case RP_STROKE_LINE_ARRAY:
			{
				int32 numLines;
				if (message.Read(numLines) != B_OK)
					continue;

				BRect bounds;
				offscreen->BeginLineArray(numLines);
				for (int32 i = 0; i < numLines; i++) {
					rgb_color color;
					BPoint start, end;
					message.ReadArrayLine(start, end, color);
					offscreen->AddLine(start, end, color);

					bounds.left = min_c(bounds.left, min_c(start.x, end.x));
					bounds.top = min_c(bounds.top, min_c(start.y, end.y));
					bounds.right = max_c(bounds.right, max_c(start.x, end.x));
					bounds.bottom = max_c(bounds.bottom, max_c(start.y, end.y));
				}

				offscreen->EndLineArray();
				invalidRegion.Include(bounds);
				break;
			}

			case RP_FILL_REGION:
			case RP_FILL_REGION_GRADIENT:
			{
				BRegion region;
				if (message.ReadRegion(region) != B_OK)
					continue;

				if (code == RP_FILL_REGION)
					offscreen->FillRegion(&region, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillRegion(&region, *gradient);
					delete gradient;
				}

				invalidRegion.Include(&region);
				break;
			}

			case RP_STROKE_POINT_COLOR:
			{
				BPoint point;
				rgb_color color;

				message.Read(point);
				if (message.Read(color) != B_OK)
					continue;

				rgb_color oldColor = offscreen->HighColor();
				offscreen->SetHighColor(color);
				offscreen->StrokeLine(point, point);
				offscreen->SetHighColor(oldColor);

				invalidRegion.Include(
					BRect(point, point).InsetBySelf(-penSize, -penSize));
				break;
			}

			case RP_STROKE_LINE_1PX_COLOR:
			{
				BPoint points[2];
				rgb_color color;

				message.ReadList(points, 2);
				if (message.Read(color) != B_OK)
					continue;

				float oldSize = offscreen->PenSize();
				rgb_color oldColor = offscreen->HighColor();
				drawing_mode oldMode = offscreen->DrawingMode();
				offscreen->SetPenSize(1);
				offscreen->SetHighColor(color);
				offscreen->SetDrawingMode(B_OP_OVER);

				offscreen->StrokeLine(points[0], points[1]);

				offscreen->SetDrawingMode(oldMode);
				offscreen->SetHighColor(oldColor);
				offscreen->SetPenSize(oldSize);

				invalidRegion.Include(_BuildInvalidateRect(points, 2));
				break;
			}

			case RP_STROKE_RECT_1PX_COLOR:
			case RP_FILL_RECT_COLOR:
			{
				BRect rect;
				rgb_color color;

				message.Read(rect);
				if (message.Read(color) != B_OK)
					continue;

				rgb_color oldColor = offscreen->HighColor();
				offscreen->SetHighColor(color);

				if (code == RP_STROKE_RECT_1PX_COLOR) {
					float oldSize = PenSize();
					offscreen->SetPenSize(1);
					offscreen->StrokeRect(rect);
					offscreen->SetPenSize(oldSize);
				} else
					offscreen->FillRect(rect);

				offscreen->SetHighColor(oldColor);
				invalidRegion.Include(rect);
				break;
			}

			case RP_DRAW_STRING:
			{
				BPoint point;
				size_t length;
				char *string;
				bool hasDelta;

				message.Read(point);
				message.ReadString(&string, length);
				if (message.Read(hasDelta) != B_OK) {
					free(string);
					continue;
				}

				if (hasDelta) {
					escapement_delta delta[length];
					message.ReadList(delta, length);
					offscreen->DrawString(string, point, delta);
				} else
					offscreen->DrawString(string, point);

				free(string);
				reply.Start(RP_DRAW_STRING_RESULT);
				reply.Add(token);
				reply.Add(offscreen->PenLocation());
				reply.Flush();

				font_height height;
				offscreen->GetFontHeight(&height);

				BRect bounds(point, offscreen->PenLocation());
				bounds.top -= height.ascent;
				bounds.bottom += height.descent;
				invalidRegion.Include(bounds);
				break;
			}

			case RP_DRAW_STRING_WITH_OFFSETS:
			{
				size_t length;
				char *string;
				message.ReadString(&string, length);
				int32 count = UTF8CountChars(string, length);

				BPoint offsets[count];
				if (message.ReadList(offsets, count) != B_OK) {
					free(string);
					continue;
				}

				offscreen->DrawString(string, offsets, count);

				free(string);
				reply.Start(RP_DRAW_STRING_RESULT);
				reply.Add(token);
				reply.Add(offscreen->PenLocation());
				reply.Flush();

				BFont font;
				offscreen->GetFont(&font);

				BRect boxes[count];
				font.GetBoundingBoxesAsGlyphs(string, count, B_SCREEN_METRIC,
					boxes);

				font_height height;
				offscreen->GetFontHeight(&height);

				for (int32 i = 0; i < count; i++) {
					// TODO: validate
					boxes[i].OffsetBy(offsets[i] + BPoint(0, -height.ascent));
					invalidRegion.Include(boxes[i]);
				}

				break;
			}

			case RP_READ_BITMAP:
			{
				BRect bounds;
				bool drawCursor;

				message.Read(bounds);
				if (message.Read(drawCursor) != B_OK)
					continue;

				// TODO: support the drawCursor flag
				BBitmap bitmap(bounds, B_BITMAP_NO_SERVER_LINK, B_RGB32);
				bitmap.ImportBits(fOffscreenBitmap, bounds.LeftTop(),
					BPoint(0, 0), bounds.IntegerWidth() + 1,
					bounds.IntegerHeight() + 1);

				reply.Start(RP_READ_BITMAP_RESULT);
				reply.Add(token);
				reply.AddBitmap(&bitmap);
				reply.Flush();
				break;
			}

			default:
				TRACE_ERROR("unknown protocol code: %u\n", code);
				break;
		}

		if (syncDrawing) {
			offscreen->Sync();
			Invalidate(&invalidRegion);
		}
	}
}
Example #30
0
AttribRect::AttribRect ()
    : AttribView (BRect (0, 0, 148, 90), lstring (31, "Rectangles"))
{
    SetViewColor (LightGrey);
    lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc'));
    AddChild (lSlid);
    fType = RECT_OUTFILL;
    fPenSize = 1;
    BBox *type = new BBox (BRect (18, 32, 130, 82), "type");
    type->SetLabel (lstring (311, "Type"));
    AddChild (type);
    BRect shape = BRect (3, 5, 27, 25);

    BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL));
    BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL));
    picWindow->AddChild (bg);

    BPicture *p10;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (LightGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetLowColor (White);
    bg->FillRect (shape, B_SOLID_LOW);
    bg->StrokeRect (shape);
    p10 = bg->EndPicture();

    BPicture *p20;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (LightGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->FillRect (shape, B_SOLID_LOW);
    p20 = bg->EndPicture();

    BPicture *p30;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (LightGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->StrokeRect (shape);
    p30 = bg->EndPicture();

    BPicture *p11;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (DarkGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->FillRect (shape, B_SOLID_LOW);
    bg->StrokeRect (shape);
    p11 = bg->EndPicture();

    BPicture *p21;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (DarkGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->FillRect (shape, B_SOLID_LOW);
    p21 = bg->EndPicture();

    BPicture *p31;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (DarkGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->StrokeRect (shape);
    p31 = bg->EndPicture();

    SetViewColor (LightGrey);
    delete picWindow;

    pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON);
    pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON);
    pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON);
    type->AddChild (pT1);
    type->AddChild (pT2);
    type->AddChild (pT3);
    pT1->SetValue (B_CONTROL_ON);
    fCurrentProperty = 0;
}