Пример #1
0
void
QuaSymbolBridge::MouseDown(BPoint where)
{
	long		channel, quant;
	BRect		area = Bounds();

	ulong		mods = modifiers(); // Key mods???
	ulong		buts;
	BMessage	*msg;
	BPoint		pt;
	drawing_mode	cur_mode = DrawingMode();
	long		clicks;
	
	GetMouse(&pt, &buts);
	msg = Window()->CurrentMessage();
	
	if ((clicks=msg->FindInt32("clicks")) == 1) {
		if (buts & B_SECONDARY_MOUSE_BUTTON) {
			BPopUpMenu	*qMenu = new BPopUpMenu("env sel", true, FALSE);
			
			BPoint			orig = where;
			ConvertToScreen(&where);
			
			BMessage	*msg = new BMessage(SET_DISPLAY_MODE);
			msg->AddInt32("display mode", OBJECT_DISPLAY_SMALL);
			BMenuItem	*item = new BMenuItem("Small", msg);
			qMenu->AddItem(item);
			item->SetTarget(this);
		
			msg = new BMessage(SET_DISPLAY_MODE);
			msg->AddInt32("display mode", OBJECT_DISPLAY_BIG);
			item = new BMenuItem("Large", msg);
			qMenu->AddItem(item);
			item->SetTarget(this);
		
			qMenu->SetAsyncAutoDestruct(true);
			qMenu->Go(where, true, false, true);
		} else {
			msg = new BMessage(MOVE_OBJECT);
		 	msg->AddPointer("sym_object", this);
		 	
			if (mods & B_SHIFT_KEY) {
				((ObjectViewContainer *)Parent())->AddSelection(this);
			} else {
				((ObjectViewContainer *)Parent())->Select(this);
			}
		
			DragMessage(msg, area);
		}
	} else if (clicks > 1) {	// edit object
		Edit();
	} else {
	}
}
Пример #2
0
void
Panel::MouseDown(BPoint where)
{
	long		channel, quant;
	BRect		area = Bounds();

	ulong		mods = modifiers(); // Key mods???
	ulong		buts;
	BMessage	*msg;
	BPoint		pt;
	drawing_mode	cur_mode = DrawingMode();
	long		clicks;
	
	GetMouse(&pt, &buts);
	msg = Window()->CurrentMessage();
	
	fprintf(stderr, "%x %d\n", buts, buts & B_SECONDARY_MOUSE_BUTTON);
	if ((clicks=msg->FindInt32("clicks")) == 1) {
		if (buts & B_SECONDARY_MOUSE_BUTTON) {
			RunControlMenu(where);
		} else {
//			msg = new BMessage(MOVE_OBJECT);
//		 	msg->AddPointer("object_view", this);
		 	
			if (mods & B_SHIFT_KEY) {
//				((ObjectViewContainer *)Parent())->AddSelection(this);
			} else {
//				((ObjectViewContainer *)Parent())->Select(this);
			}
		
//			DragMessage(msg, area);
		}
	} else if (clicks > 1) {	// rescale
		if (displayMode==PANEL_DISPLAY_SMALL)
			SetDisplayMode(PANEL_DISPLAY_BIG);
		else
			SetDisplayMode(PANEL_DISPLAY_SMALL);
	} else {
	}
}
Пример #3
0
void ArpTwoStateButton::Draw(BRect clip)
{
	inherited::Draw(clip);
	drawing_mode	mode = DrawingMode();
	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);

	bool	state = (mDrawFromSwitched) ? mSwitched : mPressed;
	if( state && mBmPressed ) {
		BRect	r( clip );
		BRect	b( mBmPressed->Bounds() );
		if( r.right > b.right ) r.right = b.right;
		if( r.bottom > b.bottom ) r.bottom = b.bottom;
		DrawBitmapAsync( mBmPressed, r, r );
	} else if( !state && mBmNormal ) {
		BRect	r( clip );
		BRect	b( mBmNormal->Bounds() );
		if( r.right > b.right ) r.right = b.right;
		if( r.bottom > b.bottom ) r.bottom = b.bottom;
		DrawBitmapAsync( mBmNormal, r, r );
	}
	if (Window()) Sync();
	SetDrawingMode(mode);
}
Пример #4
0
void ToolbarView::Draw(BRect clip) {
	BRect 	r;
	int 	i;
	
	drawing_mode oldmode = DrawingMode();	
	SetDrawingMode(B_OP_ALPHA);
	for (i=0; i<item_count; i++) {
		r = items[i].rect;
		if (items[i].bitmap && r.Intersects(clip)) 
		{
			// We're dawing with alpha, so we need to overdraw the old bitmap
			// with the toolbar's colour, or they 'overlay' each other.
			SetHighColor(216,216,216);
			FillRect(r);
			
			if ((items[i].state & ENABLED_MASK)) {
				DrawBitmapAsync(items[i].bitmap, BPoint(r.left, r.top));
			} else {
				// Disabled icons should be greyed out.
				// We build a heavily alpha blended grey version of the icon.
				BBitmap greyedBitmap(items[i].bitmap->Bounds(), B_RGBA32);
				rgb_color *bitsFrom = static_cast<rgb_color *>(items[i].bitmap->Bits());
				rgb_color *bitsTo = static_cast<rgb_color *>(greyedBitmap.Bits());
				
				int pixels = items[i].bitmap->BitsLength()/4;
				int count;
				for(count=0; count<pixels; count++)
				{
					unsigned char shade = (bitsFrom[count].red/3) +
										  (bitsFrom[count].green/3) +
										  (bitsFrom[count].blue/3); 
					bitsTo[count].red = shade;
					bitsTo[count].green = shade;
					bitsTo[count].blue = shade;
					bitsTo[count].alpha = bitsFrom[count].alpha/4;
				}
				
				// We can't use DrawBitmapAsync, bacause the greyed bitmap is deallocated before it's
				// drawn.  We should really store they greyed versions somewhere permanent.
				DrawBitmap(&greyedBitmap, BPoint(r.left, r.top));
			}

			// Pressed icons should look like they are pressed (ie down)
			if (items[i].state & PRESSED_MASK) {
				HighLightItem(i, 2);
			}
		}
		else if (items[i].type == SEPERATOR) {
			HighLightItem(i, 1);
		}
	}
	
	// Draw a nice BeOSey border around the toolbar.
	r = Bounds();
	
	rgb_color dark={154,154,154};
	rgb_color light_dark={186,186,186};
	rgb_color light={241,241,241};

	SetDrawingMode(B_OP_COPY);

	BeginLineArray(4);
	AddLine(BPoint(r.left, r.top), BPoint(r.right, r.top), light);
	AddLine(BPoint(r.left, r.top), BPoint(r.left, r.bottom), light);
	AddLine(BPoint(r.left, r.bottom-1), BPoint(r.right, r.bottom-1), light_dark);
	AddLine(BPoint(r.left, r.bottom), BPoint(r.right, r.bottom), dark);
	
	EndLineArray();
	
	SetDrawingMode(oldmode);
}