Пример #1
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;
}
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;
}
Пример #3
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
Пример #4
0
/*
 * Make inside state picture.
 */
BPicture*
HToolbarButton::MakeInsidePicture(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->SetDrawingMode(B_OP_ALPHA); 
	view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
	view->BeginPicture(new BPicture); 
	
	DrawBitmap(view,in);
	DrawString(view,fName.String());
	
	//view->SetHighColor(White);
	//view->FillRect(BRect(0,0,0,22));
	//view->FillRect(BRect(0,0,22,0));
	//view->SetHighColor(BeShadow);
	//view->FillRect(BRect(21,0,21,21));
	//view->FillRect(BRect(0,21,21,21));
	BRect rect(Bounds());
	view->SetDrawingMode(B_OP_OVER); 
	rect.InsetBy(1,1);
	view->BeginLineArray(5);
	view->AddLine(rect.LeftTop(), rect.LeftBottom(),
			tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT));
	view->AddLine(rect.LeftTop(), rect.RightTop(),
			tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT));
	view->AddLine(rect.LeftBottom(), rect.RightBottom(),
			tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT));
	rect.bottom--;
	view->AddLine(rect.LeftBottom(), rect.RightBottom(),
			tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
	view->AddLine(rect.RightTop(), rect.RightBottom(),
			tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT));
	view->EndLineArray();
	
	view->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT));
	view->StrokeRect(Bounds());
	pict = view->EndPicture();
	bitmap->Unlock();
	delete bitmap;
	return pict;
}
Пример #5
0
bool
ClipView::InitiateDrag(BPoint point, int32 index, bool wasSelected)
{
	ClipItem* sItem = dynamic_cast<ClipItem *> (ItemAt(index));
	if (sItem == NULL)
		return false;

	BString string(sItem->GetClip());
	BMessage message(FAV_ADD);
	message.AddData("text/plain", B_MIME_TYPE, string, string.Length());
	message.AddPointer("clip", sItem);

	BRect dragRect(0.0f, 0.0f, Bounds().Width(), sItem->Height());
	BBitmap* dragBitmap = new BBitmap(dragRect, B_RGB32, true);
	if (dragBitmap->IsValid()) {
		BView* view = new BView(dragBitmap->Bounds(), "helper", B_FOLLOW_NONE,
			B_WILL_DRAW);
		dragBitmap->AddChild(view);
		dragBitmap->Lock();

		sItem->DrawItem(view, dragRect);
		view->SetHighColor(0, 0, 0, 255);
		view->StrokeRect(view->Bounds());
		view->Sync();

		dragBitmap->Unlock();
	} else {
		delete dragBitmap;
		dragBitmap = NULL;
	}

	if (dragBitmap != NULL)
		DragMessage(&message, dragBitmap, B_OP_ALPHA, BPoint(0.0, 0.0));
	else
		DragMessage(&message, dragRect.OffsetToCopy(point), this);

	return true;
}
/*!	\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"
Пример #7
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;
}
Пример #8
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();
}
Пример #9
0
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);
		}
	}
}
Пример #10
0
void MonthWindowView::KeyDown(const char *bytes, int32 numBytes)
{
 switch(bytes[0])
 {
  case B_TAB:
  {
   Bmp->Lock();
   switch(which_focused)
   {
    case 0: // months
    {
     BmpView->SetHighColor(VIEW_COLOR);
     BmpView->StrokeLine(BPoint(monthMStringView[0]->Frame().left,
                                monthMStringView[0]->Frame().bottom+1),
                         BPoint(monthMStringView[1]->Frame().right,
                                monthMStringView[1]->Frame().bottom+1));
     BmpView->SetHighColor(0,0,0);
     break;
    }
    case 1: // years
    {
     BmpView->SetHighColor(VIEW_COLOR);
     BmpView->StrokeLine(BPoint(yearMStringView[0]->Frame().left,
                                yearMStringView[0]->Frame().bottom+1),
                         BPoint(yearMStringView[1]->Frame().right,
                                yearMStringView[1]->Frame().bottom+1));
     BmpView->SetHighColor(0,0,0);
     break;
    }
    case 2: // days of month
    {
     BmpView->SetHighColor(NOACTIVE_COLOR);
     BmpView->StrokeRect(cursor);
     BmpView->SetHighColor(0,0,0);
     break;
    }
    case 3: // today
    {
     BmpView->SetHighColor(VIEW_COLOR);
     BmpView->StrokeLine(BPoint(todayStringView->Frame().left,
                                todayStringView->Frame().bottom+1),
                         BPoint(todayStringView->Frame().right,
                                todayStringView->Frame().bottom+1));
     BmpView->SetHighColor(0,0,0);
     break;
    }
   }
   
   // changing which_focused
   if(modifiers() & B_SHIFT_KEY)
   {
    if(which_focused==0)
      which_focused=3;
    else which_focused--;
   }
   else // simply Tab
   {
    if(which_focused==3)
     which_focused=0;
    else which_focused++;
   }
   
   // drawing with new which_focused
   switch(which_focused)
   {
    case 0: // months
    {
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeLine(BPoint(monthMStringView[0]->Frame().left,
                                monthMStringView[0]->Frame().bottom+1),
                         BPoint(monthMStringView[1]->Frame().right,
                                monthMStringView[1]->Frame().bottom+1));
     BmpView->SetHighColor(0,0,0);
     break;
    }
    case 1: // years
    {
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeLine(BPoint(yearMStringView[0]->Frame().left,
                                yearMStringView[0]->Frame().bottom+1),
                         BPoint(yearMStringView[1]->Frame().right,
                                yearMStringView[1]->Frame().bottom+1));
     BmpView->SetHighColor(0,0,0);
     break;
    }
    case 2: // days of month
    {
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeRect(cursor);
     BmpView->SetHighColor(0,0,0);
     break;
    }
    case 3: // today
    {
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeLine(BPoint(todayStringView->Frame().left,
                                todayStringView->Frame().bottom+1),
                         BPoint(todayStringView->Frame().right,
                                todayStringView->Frame().bottom+1));
     BmpView->SetHighColor(0,0,0);
     break;
    }
   }
   BmpView->Sync();
   Bmp->Unlock();
   Draw(Bounds());
   break;
  } // B_TAB
  
  case B_DOWN_ARROW:
  {
   if(which_focused==0) // month
   { 
    BMessage msg('MON0');
    MessageReceived(&msg);
   }
   else if(which_focused==1) // year
   {
    BMessage msg('YEA0');
    MessageReceived(&msg);
   }
   else if(which_focused==2) // days of month
   {
    int qu_days=monthDays[cmonth-1];
    if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
    if((cday+7)<=qu_days)
    {
     Bmp->Lock();
     BmpView->SetHighColor(VIEW_COLOR);
     BmpView->StrokeRect(cursor);
     cursor.OffsetBySelf(0, h_cell);
     cday+=7;
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeRect(cursor);
     BmpView->SetHighColor(0,0,0);
     BmpView->Sync();
     Bmp->Unlock();
     Draw(Bounds());
    }
   }
   break;
  }
  
  case B_UP_ARROW:
  {
   // Test whether Ctrl+UpArrow is pressed
   if(modifiers() & B_CONTROL_KEY)
    Window()->PostMessage(B_QUIT_REQUESTED);
   else
   {
    if(which_focused==0) // month
    {
     BMessage msg('MON1');
     MessageReceived(&msg);
    }
    else if(which_focused==1) // year
    {
     BMessage msg('YEA1');
     MessageReceived(&msg);
    }
    else if(which_focused==2) // days of month
    {
     if((cday-7)>=1)
     {
      Bmp->Lock();
      BmpView->SetHighColor(VIEW_COLOR);
      BmpView->StrokeRect(cursor);
      cursor.OffsetBySelf(0, -h_cell);
      cday-=7;
      BmpView->SetHighColor(ACTIVE_COLOR);
      BmpView->StrokeRect(cursor);
      BmpView->SetHighColor(0,0,0);
      BmpView->Sync();
      Bmp->Unlock();
      Draw(Bounds());
     }
    }
   }
   break;
  }
  
  case B_LEFT_ARROW:
  {
   if(which_focused==0) // month
   {
    BMessage msg('MON0');
    MessageReceived(&msg);
   }
   else if(which_focused==1) // year
   {
    BMessage msg('YEA0');
    MessageReceived(&msg);
   }
   else if(which_focused==2) // days of month
   {
    if(cday>1)
    {
     Bmp->Lock();
     BmpView->SetHighColor(VIEW_COLOR);
     BmpView->StrokeRect(cursor);
     if(cwday>0) // by dates no matter of day of week
     {
      cursor.OffsetBySelf(-w_cell,0);
      cwday--;
     }
     else // cwday==0
     {
      cursor.OffsetBySelf(w_cell*6,-h_cell);
      cwday=6;
     }
     cday--;
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeRect(cursor);
     BmpView->SetHighColor(0,0,0);
     BmpView->Sync();
     Bmp->Unlock();
     Draw(Bounds());
    }
    else // 1st of month, go month before
    {
     if(cyear>first_year || cmonth>1) // one can go
     {
      int cm=(cmonth==1) ? 12 : cmonth-1;
      int qu_days=monthDays[cm-1];
      if(cm==2) if(cyear%4==0) 
       if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
       // it is correct not to pay attention to year changing
       // because if we moved to february then year was not changed
       // but if month is other then february 
       // then it has the same number of days every year.
      cday=qu_days;
      
      BMessage msg('MON0');
      MessageReceived(&msg); // here month, cwday and year (if needed) will be changed
     }
    }
   }
   break;
  }
  
  case B_RIGHT_ARROW:
  {
   if(which_focused==0) // month
   {
    BMessage msg('MON1');
    MessageReceived(&msg);
   }
   else if(which_focused==1) // year
   {
    BMessage msg('YEA1');
    MessageReceived(&msg);
   }
   else if(which_focused==2) // days of month
   {
    int qu_days=monthDays[cmonth-1];
    if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
    if(cday<qu_days)
    {
     Bmp->Lock();
     BmpView->SetHighColor(VIEW_COLOR);
     BmpView->StrokeRect(cursor);
     if(cwday<6) // by dates no matter of day of week
     {
      cursor.OffsetBySelf(w_cell,0);
      cwday++;
     }
     else // cwday==6
     {
      cursor.OffsetBySelf(-w_cell*6,h_cell);
      cwday=0;
     }
     cday++;
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeRect(cursor);
     BmpView->SetHighColor(0,0,0);
     BmpView->Sync();
     Bmp->Unlock();
     Draw(Bounds());
    }
    else // last of month, go next month
    {
     if(cyear<last_year || cmonth<12) // one can go
     {
      cday=1;
      BMessage msg('MON1');
      MessageReceived(&msg); // here month, cwday and year (if needed) will be changed
     }
    }
   }
   break;
  }
  
  case B_ESCAPE:
  {
   Window()->PostMessage(B_QUIT_REQUESTED);
   break;
  }
  
  case B_ENTER:
  {
   if(which_focused==2)
   {
    // here it is needed to send dayPressed (==cwday), cyear, cmonth
    // to window and leave
    BMessage *msg=new BMessage('MVME');
    msg->AddInt32("day",cday);
    msg->AddInt32("month",cmonth);
    msg->AddInt32("year",cyear);
    Window()->PostMessage(msg);
   }
   else if(which_focused==3)
   {
    BMessage msg('TODA');
    MessageReceived(&msg);
   }
   break;
  }
  
  case B_SPACE: // the same as B_ENTER
  {
   if(which_focused==2)
   {
    // here it is needed to send dayPressed (==cwday), cyear, cmonth
    // to window and leave
    BMessage *msg=new BMessage('MVME');
    msg->AddInt32("day",cday);
    msg->AddInt32("month",cmonth);
    msg->AddInt32("year",cyear);
    Window()->PostMessage(msg);
   }
   else if(which_focused==3)
   {
    BMessage msg('TODA');
    MessageReceived(&msg);
   }
   break;
  }
  
  default: 
   BView::KeyDown(bytes, numBytes);
 }
}
Пример #11
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());
}
Пример #12
0
bool
AudioListView::InitiateDrag(BPoint point, int32 dragIndex, bool)
{
	BListItem* item = ItemAt(CurrentSelection(0));
	if (item == NULL) {
		// workaround for a timing problem (see Locale prefs)
		Select(dragIndex);
		item = ItemAt(dragIndex);
	}
	if (item == NULL)
		return false;

	// create drag message
	BMessage message(kDraggedItem);
	for (int32 i = 0;; i++) {
		int32 index = CurrentSelection(i);
		if (index < 0)
			break;
		message.AddPointer("trackitem", ItemAt(CurrentSelection(i)));
	}

	// figure out drag rect
	BRect dragRect(0.0, 0.0, Bounds().Width(), -1.0);

	// figure out, how many items fit into our bitmap
	bool fade = false;

	for (int32 i = 0; message.FindPointer("trackitem", i,
		reinterpret_cast<void**>(&item)) == B_OK; i++) {

		dragRect.bottom += ceilf(item->Height()) + 1.0;

		if (dragRect.Height() > MAX_DRAG_HEIGHT) {
			dragRect.bottom = MAX_DRAG_HEIGHT;
			fade = true;
			break;
		}
	}

	BBitmap* dragBitmap = new BBitmap(dragRect, B_RGB32, true);
	if (dragBitmap->IsValid()) {
		BView* view = new BView(dragBitmap->Bounds(), "helper", B_FOLLOW_NONE,
			B_WILL_DRAW);
		dragBitmap->AddChild(view);
		dragBitmap->Lock();
		BRect itemBounds(dragRect) ;
		itemBounds.bottom = 0.0;
		// let all selected items, that fit into our drag_bitmap, draw
		for (int32 i = 0; message.FindPointer("trackitem", i,
				reinterpret_cast<void**>(&item)) == B_OK; i++) {
			AudioListItem* item;
			message.FindPointer("trackitem", i,
				reinterpret_cast<void**>(&item));
			itemBounds.bottom = itemBounds.top + ceilf(item->Height());
			if (itemBounds.bottom > dragRect.bottom)
				itemBounds.bottom = dragRect.bottom;
			item->DrawItem(view, itemBounds);
			itemBounds.top = itemBounds.bottom + 1.0;
		}
		// make a black frame around the edge
		view->SetHighColor(0, 0, 0, 255);
		view->StrokeRect(view->Bounds());
		view->Sync();

		uint8* bits = (uint8*)dragBitmap->Bits();
		int32 height = (int32)dragBitmap->Bounds().Height() + 1;
		int32 width = (int32)dragBitmap->Bounds().Width() + 1;
		int32 bpr = dragBitmap->BytesPerRow();

		if (fade) {
			for (int32 y = 0; y < height - ALPHA / 2; y++, bits += bpr) {
				uint8* line = bits + 3;
				for (uint8* end = line + 4 * width; line < end; line += 4)
					*line = ALPHA;
			}
			for (int32 y = height - ALPHA / 2; y < height;
				y++, bits += bpr) {
				uint8* line = bits + 3;
				for (uint8* end = line + 4 * width; line < end; line += 4)
					*line = (height - y) << 1;
			}
		} else {
			for (int32 y = 0; y < height; y++, bits += bpr) {
				uint8* line = bits + 3;
				for (uint8* end = line + 4 * width; line < end; line += 4)
					*line = ALPHA;
			}
		}
		dragBitmap->Unlock();
	} else {
		delete dragBitmap;
		dragBitmap = NULL;
	}

	if (dragBitmap != NULL)
		DragMessage(&message, dragBitmap, B_OP_ALPHA, BPoint(0.0, 0.0));
	else
		DragMessage(&message, dragRect.OffsetToCopy(point), this);

	return true;
}
Пример #13
0
//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
Пример #14
0
void ColorMenu::MouseMoved (BPoint point, uint32 transit, const BMessage *msg)
{
	msg = msg;
	uint32 buttons;
	if (!Parent())
		return;
//	printf ("("); fflush (stdout);
	GetMouse (&point, &buttons);
//	printf (")"); fflush (stdout);
	if (transit == B_EXITED_VIEW && buttons)	// Do the tear off thing!
	{
#if defined (EASTER_EGG_SFX)
		extern bool EasterEgg;
		if (modifiers() & B_SHIFT_KEY && EasterEgg)
		{
			extern EffectsPlayer *easterEgg;
			easterEgg->StartEffect();
		}
#endif
		BMessage *tearmsg = new BMessage ('tear');
		BBitmap *dragmap = new BBitmap (Bounds(), B_RGBA32, true);
		dragmap->Lock();
		BView *dragview = new BView (Bounds(), "temp dragmap view", B_FOLLOW_ALL, B_WILL_DRAW);
		dragmap->AddChild (dragview);
		//dragview->SetLowColor (LightGrey);
		//dragview->FillRect (Bounds(), B_SOLID_LOW);
		for (int i = 0; i < MAX_COLORS; i++)
		{
			dragview->SetHighColor (items[i]->getColor());
			dragview->FillRect (items[i]->Frame());
			dragview->Sync();
		}
		dragview->SetHighColor (DarkGrey);
		dragview->StrokeRect (Bounds());
		dragmap->RemoveChild (dragview);
		bgra_pixel *bits = (bgra_pixel *) dragmap->Bits();
		for (bgra_pixel p = 0; p < dragmap->BitsLength()/4; p++)
		{
			bgra_pixel pixel = *bits;
			*bits++ = (pixel & COLOR_MASK) | (127 << ALPHA_BPOS);
		}
		dragmap->Unlock();
		delete dragview;
		DragMessage (tearmsg, dragmap, B_OP_ALPHA, B_ORIGIN);
		delete tearmsg;
		BRect place = Bounds();
		
		// Send a fake Esc keydown to the popup
		char kbuf[2];
		BMessage kmsg (B_KEY_DOWN);
		kmsg.AddInt64 ("when", system_time());
		kmsg.AddInt32 ("modifiers", 0);
		kmsg.AddInt32 ("key", B_ESCAPE);
		kmsg.AddInt8 ("byte", B_ESCAPE);
		kbuf[0] = B_ESCAPE;
		kbuf[1] = '\0';
		kmsg.AddString ("bytes", kbuf);
		Window()->PostMessage (&kmsg, this);
		// This makes the original popup go away.
		// We can't use Hide() since that crashes.
		
		colorTearInfo *tearInfo = new colorTearInfo (place, this, parent);
		resume_thread (spawn_thread (color_tear_drag, "Menu Tear Thread", B_NORMAL_PRIORITY, tearInfo));
	}
}
bool
LanguageListView::InitiateDrag(BPoint point, int32 dragIndex,
	bool /*wasSelected*/)
{
	if (fDragMessage == NULL)
		return false;

	BListItem* item = ItemAt(CurrentSelection(0));
	if (item == NULL) {
		// workaround for a timing problem
		// TODO: this should support extending the selection
		item = ItemAt(dragIndex);
		Select(dragIndex);
	}
	if (item == NULL)
		return false;

	// create drag message
	BMessage message = *fDragMessage;
	message.AddPointer("listview", this);

	for (int32 i = 0;; i++) {
		int32 index = CurrentSelection(i);
		if (index < 0)
			break;

		message.AddInt32("index", index);
	}

	// figure out drag rect

	BRect dragRect(0.0, 0.0, Bounds().Width(), -1.0);
	int32 numItems = 0;
	bool fade = false;

	// figure out, how many items fit into our bitmap
	for (int32 i = 0, index; message.FindInt32("index", i, &index) == B_OK;
			i++) {
		BListItem* item = ItemAt(index);
		if (item == NULL)
			break;

		dragRect.bottom += ceilf(item->Height()) + 1.0;
		numItems++;

		if (dragRect.Height() > MAX_DRAG_HEIGHT) {
			dragRect.bottom = MAX_DRAG_HEIGHT;
			fade = true;
			break;
		}
	}

	BBitmap* dragBitmap = new BBitmap(dragRect, B_RGB32, true);
	if (dragBitmap->IsValid()) {
		BView* view = new BView(dragBitmap->Bounds(), "helper", B_FOLLOW_NONE,
			B_WILL_DRAW);
		dragBitmap->AddChild(view);
		dragBitmap->Lock();
		BRect itemBounds(dragRect) ;
		itemBounds.bottom = 0.0;
		// let all selected items, that fit into our drag_bitmap, draw
		for (int32 i = 0; i < numItems; i++) {
			int32 index = message.FindInt32("index", i);
			LanguageListItem* item
				= static_cast<LanguageListItem*>(ItemAt(index));
			itemBounds.bottom = itemBounds.top + ceilf(item->Height());
			if (itemBounds.bottom > dragRect.bottom)
				itemBounds.bottom = dragRect.bottom;
			item->DrawItem(view, itemBounds);
			itemBounds.top = itemBounds.bottom + 1.0;
		}
		// make a black frame arround the edge
		view->SetHighColor(0, 0, 0, 255);
		view->StrokeRect(view->Bounds());
		view->Sync();

		uint8* bits = (uint8*)dragBitmap->Bits();
		int32 height = (int32)dragBitmap->Bounds().Height() + 1;
		int32 width = (int32)dragBitmap->Bounds().Width() + 1;
		int32 bpr = dragBitmap->BytesPerRow();

		if (fade) {
			for (int32 y = 0; y < height - ALPHA / 2; y++, bits += bpr) {
				uint8* line = bits + 3;
				for (uint8* end = line + 4 * width; line < end; line += 4)
					*line = ALPHA;
			}
			for (int32 y = height - ALPHA / 2; y < height;
				y++, bits += bpr) {
				uint8* line = bits + 3;
				for (uint8* end = line + 4 * width; line < end; line += 4)
					*line = (height - y) << 1;
			}
		} else {
			for (int32 y = 0; y < height; y++, bits += bpr) {
				uint8* line = bits + 3;
				for (uint8* end = line + 4 * width; line < end; line += 4)
					*line = ALPHA;
			}
		}
		dragBitmap->Unlock();
	} else {
		delete dragBitmap;
		dragBitmap = NULL;
	}

	if (dragBitmap != NULL)
		DragMessage(&message, dragBitmap, B_OP_ALPHA, BPoint(0.0, 0.0));
	else
		DragMessage(&message, dragRect.OffsetToCopy(point), this);

	return true;
}