Example #1
0
status_t
BMenuField::Archive(BMessage* data, bool deep) const
{
	BArchiver archiver(data);
	status_t ret = BView::Archive(data, deep);

	if (ret == B_OK && Label())
		ret = data->AddString("_label", Label());

	if (ret == B_OK && !IsEnabled())
		ret = data->AddBool("_disable", true);

	if (ret == B_OK)
		ret = data->AddInt32("_align", Alignment());
	if (ret == B_OK)
		ret = data->AddFloat("_divide", Divider());

	if (ret == B_OK && fFixedSizeMB)
		ret = data->AddBool("be:fixeds", true);

	bool dmark = false;
	if (_BMCMenuBar_* menuBar = dynamic_cast<_BMCMenuBar_*>(fMenuBar))
		dmark = menuBar->IsPopUpMarkerShown();

	data->AddBool("be:dmark", dmark);

	return archiver.Finish(ret);
}
Example #2
0
//------------------------------------------------------------------------------
status_t BMenuField::Archive(BMessage *data, bool deep) const
{
	BView::Archive(data, deep);

	if (Label())
		data->AddString("_label", Label());

	if (!IsEnabled())
		data->AddBool("_disable", true);

	data->AddInt32("_align", Alignment());

	data->AddFloat("_divide", Divider());

	if (fFixedSizeMB)
		data->AddBool("be:fixeds", true);

	BMenuItem *item = fMenuBar->ItemAt(0);

	if (!item)
		return B_OK;

	_BMCItem_ *bmcitem = dynamic_cast<_BMCItem_*>(item);

	if (bmcitem && !bmcitem->fShowPopUpMarker)
		data->AddBool("be:dmark", false);

	return B_OK;
}
Example #3
0
/*------------------------------------------------------------------------------*\
	( )
		-	
\*------------------------------------------------------------------------------*/
void BmTextControl::InitSize( const char* label, int32 fixedTextLen, 
										int32 minTextLen, BmMenuControllerBase* popup) {
	ResizeToPreferred();
	BRect b = Bounds();
	float divPos = 0;
	if (label)
		divPos = StringWidth(label) + (mLabelIsMenu ? 27 : 3);
	inherited::SetDivider( divPos);
	BFont font;
	mTextView->GetFont( &font);
	if (fixedTextLen) {
		mTextView->SetMaxBytes( fixedTextLen);
		float width = divPos + font.StringWidth("W")*float(fixedTextLen);
		ct_mpm = minimax( int(width), int(b.Height()+4), int(width), 
								int(b.Height()+4));
	} else {
		if (minTextLen)
			ct_mpm = minimax( int(divPos + font.StringWidth("W")*float(minTextLen)), 
									int(b.Height()+4), 100000, int(b.Height()+4));
		else
			ct_mpm = minimax( int(divPos + font.StringWidth("W")*10), 
									int(b.Height()+4), 100000, int(b.Height()+4));
	}
	if (mLabelIsMenu) {
		float width, height;
		GetPreferredSize( &width, &height);
//		if (!popup)
//			popup = new BmMenuControllerBase( label, true, false);
		if (BeamOnDano)
			mMenuField 
				= new BMenuField( BRect( 2,2,Divider(),height), NULL, label,
										popup, true, B_FOLLOW_NONE, B_WILL_DRAW);
		else
			mMenuField 
				= new BMenuField( BRect( 2,0,Divider(),height), NULL, label,
										popup, true, B_FOLLOW_NONE, B_WILL_DRAW);
		mMenuField->SetDivider( 0);
		AddChild( mMenuField);
	}
	SetModificationMessage( new BMessage(BM_TEXTFIELD_MODIFIED));
}
Example #4
0
/*------------------------------------------------------------------------------*\
	( )
		-	
\*------------------------------------------------------------------------------*/
BRect BmTextControl::layout(BRect frame) {
	if (frame == Frame())
		return frame;
	MoveTo(frame.LeftTop());
	ResizeTo(frame.Width(),frame.Height());
#ifdef __HAIKU__
	float occupiedSpace = 3 + Divider();
	float top = mTextView->Frame().top;
	float height = mTextView->Frame().Height();
	if (mLabelIsMenu) {
		top = mMenuField->MenuBar()->Frame().top;
		height = mMenuField->MenuBar()->Frame().Height();
	}
	mTextView->MoveTo( occupiedSpace, top);
	mTextView->ResizeTo( frame.Width()-occupiedSpace-4, height);
#else
	float occupiedSpace = 3 + Divider();
	mTextView->MoveTo( occupiedSpace, 5);
	mTextView->ResizeTo( frame.Width()-occupiedSpace-4, 
								mTextView->Frame().Height());
#endif // __HAIKU__
	return frame;
}
Example #5
0
status_t
BTextControl::Archive(BMessage *data, bool deep) const
{
	BView::Archive(data, deep);

	alignment labelAlignment, textAlignment;

	GetAlignment(&labelAlignment, &textAlignment);

	data->AddInt32("_a_label", labelAlignment);
	data->AddInt32("_a_text", textAlignment);
	data->AddFloat("_divide", Divider());

	if (ModificationMessage())
		data->AddMessage("_mod_msg", ModificationMessage());

	return B_OK;
}
Example #6
0
status_t
BTextControl::Archive(BMessage *data, bool deep) const
{
	BArchiver archiver(data);
	status_t ret = BControl::Archive(data, deep);
	alignment labelAlignment, textAlignment;

	GetAlignment(&labelAlignment, &textAlignment);

	if (ret == B_OK)
		ret = data->AddInt32("_a_label", labelAlignment);
	if (ret == B_OK)
		ret = data->AddInt32("_a_text", textAlignment);
	if (ret == B_OK)
		ret = data->AddFloat("_divide", Divider());

	if (ModificationMessage() && (ret == B_OK))
		ret = data->AddMessage("_mod_msg", ModificationMessage());

	return archiver.Finish(ret);
}
Example #7
0
void
KeyControl::Draw(BRect r)
{
	BFont font;
	GetFont(&font);
	font_height fh;
	font.GetHeight(&fh);
	float y = Bounds().bottom - (float)ceil(fh.descent);

	const char* key;

	SetHighColor(0,0,0);
	DrawString( Label(), BPoint(2.0, y));

	r = Bounds();
	r.left = Divider();

	if (IsFocus())
		SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
	else
		SetHighColor(0,0,0);

	StrokeRect(r);
	r.InsetBy(1,1);
	SetHighColor( 255,255,255 );
	FillRect(r);
	SetHighColor(0,0,0);
	r.InsetBy(1,1);

	float x = DrawMods(
		BRect(r.left, r.top+1, r.left+font.Size()+6, r.bottom-1), fMod);

	if (fKey >' ' && fKey < 'a')
		DrawChar( fKey, BPoint( x, r.bottom - (float)ceil(fh.descent)));
	else if (fKey) {
		key = _KeyLabel(fKey);
		DrawKey(BRect(x-2, r.top+1, x+font.StringWidth(key)+2, r.bottom-1), key);
	}
}
Example #8
0
void KeyControl::Draw(BRect r)
{
	BFont font;
	GetFont(&font);
	font_height fh;
	font.GetHeight(&fh);
	float y = Bounds().bottom - ceil(fh.descent);

	const char *key;

	SetHighColor(0,0,0);
	DrawString( Label(), BPoint(2.0, y));

	r = Bounds();
	r.left = Divider();
	if (IsFocus())
		SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
	else
		SetHighColor(0,0,0);

	StrokeRect(r);
	r.InsetBy(1,1);
	SetHighColor( 255,255,255 );
	FillRect(r);
	SetHighColor(0,0,0);
	r.InsetBy(1,1);

	float x = DrawMods(BRect( r.left, r.top+1, r.left +font.Size()+6, r.bottom-1), m_mod);
	if (m_key >' ' && m_key < 'a'){
		DrawChar( m_key, BPoint( x, r.bottom - ceil(fh.descent)));
	}else if (m_key){
		switch(m_key){
		case ' ':	key = "   ";	break;
		case 1:		key = "Home";	break;
		case 4:		key = "End";	break;
		case 5:		key = "Ins";	break;
		case 8:		key = "BS ";	break;
		case 9:		key = "Tab";	break;
		case 10:	key = "Return";	break;
		case 11:	key = "PgUp";	break;
		case 12:	key = "PgDown";	break;
		case 14:	key = "F1";		break;
		case 15:	key = "F2";		break;
		case 16:	key = "F3";		break;
		case 17:	key = "F4";		break;
		case 18:	key = "F5";		break;
		case 19:	key = "F6";		break;
		case 20:	key = "F7";		break;
		case 21:	key = "F8";		break;
		case 22:	key = "F9";		break;
		case 23:	key = "F10";	break;
		case 24:	key = "F11";	break;
		case 25:	key = "F12";	break;
		case 27:	key = "Esc";	break;
		case 28:	key = "Left";	break;
		case 29:	key = "Right";	break;
		case 30:	key = "Up";		break;
		case 31:	key = "Down";	break;
		case 127:	key = "Del";	break;
		default:	key = "???";	break;
		}

		DrawKey(BRect(x-2, r.top+1, x+font.StringWidth(key)+2, r.bottom-1), key);
	}
}
Example #9
0
/*------------------------------------------------------------------------------*\
	( )
		-	
\*------------------------------------------------------------------------------*/
void BmTextControl::FrameResized( float new_width, float new_height) {
	BRect curr = Bounds();
	Invalidate( BRect( Divider(), 0, new_width-1, curr.Height()));
	inherited::FrameResized( new_width, new_height);
	TextView()->ScrollToSelection();
}
Example #10
0
/*------------------------------------------------------------------------------*\
	( )
		-	
\*------------------------------------------------------------------------------*/
void BmTextControl::SetDivider( float divider) {
	float diff = divider-Divider();
	ct_mpm.maxi.x += diff;
	inherited::SetDivider( divider);
}