Exemplo n.º 1
0
status_t
PControl::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	if (!fView)
		return B_NO_INIT;
	
	BControl *viewAsControl = (BControl*)fView;
	
	if (str.ICompare("Enabled") == 0)
		((BoolProperty*)prop)->SetValue(viewAsControl->IsEnabled());
	else if (str.ICompare("Label") == 0)
		((StringProperty*)prop)->SetValue(viewAsControl->Label());
	else if (str.ICompare("Value") == 0)
		((IntProperty*)prop)->SetValue(viewAsControl->Value());
	else
		return PView::GetProperty(name,value,index);
	
	return prop->GetValue(value);
}
Exemplo n.º 2
0
void
AppWindowPrefsView::MessageReceived (BMessage *msg)
{
	switch (msg->what)
	{
		case M_APPWINDOWPREFS_ENCODING_CHANGED:
			{
				BMenuItem *source (NULL);
				msg->FindPointer ("source", reinterpret_cast<void **>(&source));
				source->SetMarked(true);
				int32 encoding (msg->FindInt32("encoding"));
				vision_app->SetInt32("encoding", encoding);
			}
			break;
			
		case M_APPWINDOWPREFS_SETTING_CHANGED:
			{
				BControl *source (NULL);
				msg->FindPointer ("source", reinterpret_cast<void **>(&source));
				BString setting;
				msg->FindString ("setting", &setting);
				int32 value (source->Value() == B_CONTROL_ON);
				if ((setting.ICompare ("versionParanoid") == 0))
					value = !value;
				vision_app->SetBool (setting.String(), value);
			}
			break;
		default:
			BView::MessageReceived(msg);
			break;
	}
}
Exemplo n.º 3
0
filter_result 
DiscreteMessageFilter::Filter(BMessage *message, BHandler **target)
{
	BControl *control;

	if (message->what != kMsgParameterChanged
		|| (control = dynamic_cast<BControl *>(*target)) == NULL)
		return B_DISPATCH_MESSAGE;

	// update view

	int32 value = 0;

	if (BCheckBox *checkBox = dynamic_cast<BCheckBox *>(control)) {
		value = checkBox->Value();
	} else if (BOptionPopUp *popUp = dynamic_cast<BOptionPopUp *>(control)) {
		popUp->SelectedOption(NULL, &value);
	}

	TRACE("DiscreteMessageFilter::Filter: update view %s, value = %ld\n", control->Name(), value);

	if (fParameter.SetValue((void *)&value, sizeof(value), system_time()) < B_OK) {
		ERROR("DiscreteMessageFilter::Filter: Could not set parameter value for %p\n", &fParameter);
		return B_DISPATCH_MESSAGE;
	}

	return B_SKIP_MESSAGE;
}
Exemplo n.º 4
0
void HDialog::SetEnabled(const char *name, bool enabled)
{
	BControl *ctl;
	ctl = dynamic_cast<BControl*>(FindView(name));
	if (ctl)
		ctl->SetEnabled(enabled);
} /* HDialog::SetEnabled */
Exemplo n.º 5
0
void HDialog::SetOn(const char *name, bool on)
{
	BControl *ctrl;
	ctrl = dynamic_cast<BControl *>(FindView(name));
	if (ctrl)
		ctrl->SetValue(on ? B_CONTROL_ON : B_CONTROL_OFF);
} /* HDialog::SetOn */
Exemplo n.º 6
0
void HDialog::SetLabel(const char *id, const char *label)
{
	BControl *control = dynamic_cast<BControl*>(FindView(id));
	if (control)
		control->SetLabel(label);
	else
		THROW(("Control '%s' not found", id));
} // HDialog::SetLabel
Exemplo n.º 7
0
bool HDialog::IsOn(const char *name) const
{
	BControl *ctrl;
	ctrl = dynamic_cast<BControl *>(FindView(name));
	if (ctrl)
		return ctrl->Value() == B_CONTROL_ON;
	else
		return false;
} /* HDialog::IsOn */
Exemplo n.º 8
0
void 
GroupView::AttachedToWindow()
{
	for (int32 i = CountChildren(); i-- > 0;) {
		BControl *control = dynamic_cast<BControl *>(ChildAt(i));
		if (control == NULL)
			continue;

		control->SetTarget(control);
	}
}
void
ChangeGadgetLabel(struct MyGadget *gad,char *txt)
{
	BControl *xt;
	BAutolock win(gad->pt->Window());
	
	if (xt = (BControl *)gad->pt->ChildAt(0))
	{
		if (is_kind_of(xt,BControl))
		{
			xt->SetLabel(txt);		
		}	
	}
}
Exemplo n.º 10
0
void DetailsBuilder::AddView(BView* view)
{
	if (view != NULL) {
		fDetails->AddChild(view);
		view->ResizeToPreferred();
		
		fBounds.OffsetBy(0, view->Bounds().Height()+1);
		
		BControl* control = dynamic_cast<BControl*>(view);
		if (control != NULL) {
			control->SetTarget(fParent);
		}
	}
}
void
ThemeInterfaceView::PopulateThemeList()
{
	int i;
	BControl *c;
	for (i = 0; ChildAt(i); i++) {
		c = dynamic_cast<BControl *>(ChildAt(i));
		if (c)
			c->SetEnabled(false);
	}
	thread_id tid = spawn_thread(_ThemeListPopulatorTh, "ThemeListPopulator", 
		B_LOW_PRIORITY, this);
	resume_thread(tid);
}
Exemplo n.º 12
0
void PatternNrButton::MessageReceived( BMessage *message ) {

	if (!IsEnabled()) return;

	switch( message->what ) {
		case B_TRASH_TARGET: {
			if (message->IsReply()) {
				BControl *trash = (BControl *)Window()->FindView("patterntrashbutton");
				if (trash) trash->Invoke();
			}
		} break;
	
		case 'drpt': {

			BPoint	where;
			uint32	buttons;
		
			GetMouse( &where, &buttons );
			int32	wo = FindButtonNr( where );
			if (wo==Value()) return;

			gSong->Lock();
			bool containsdata = gSong->fPattern->PartContainsData( wo-1 );
			gSong->Unlock();

			if (!containsdata || !(new BAlert("", "This part already contains data!", "What shalls?", "Don't overwrite!"))->Go()) {
				message->AddInt32("destination", wo );
				Window()->PostMessage( message );
			}
			Draw( Bounds() );
		}
	
		default:
		
			BControl::MessageReceived(message);

	}

}
Exemplo n.º 13
0
void
CAssemblyWindow::AddFrameView(
	BRect frame,
	CTrack *track)
{
	// Create the frame for the strips, and the scroll bar
	stripFrame = new CStripFrameView(BRect(frame), (char *)NULL,
									 track, B_FOLLOW_ALL);

	stripScroll = new CScroller(BRect(frame.left - 1, frame.bottom + 1,
									  frame.right - 41, frame.bottom + 15),
								NULL, stripFrame, 0.0, 0.0, B_HORIZONTAL);

	BControl *magButton;
	magButton = new CBorderButton(BRect(frame.right - 27, frame.bottom + 1,
										frame.right - 13, frame.bottom + 15),
								  NULL, ResourceUtils::LoadImage("SmallPlus"),
								  new BMessage(ZoomIn_ID), true,
								  B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT,
								  B_WILL_DRAW);
	magButton->SetTarget((CDocWindow *)this);
	AddChild(magButton);

	magButton = new CBorderButton(BRect(frame.right - 41, frame.bottom + 1,
										frame.right - 27, frame.bottom + 15),
								  NULL, ResourceUtils::LoadImage("SmallMinus"),
								  new BMessage(ZoomOut_ID), true,
								  B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT,
								  B_WILL_DRAW);
	magButton->SetTarget((CDocWindow *)this);
	AddChild(magButton);

	// add views to window
	AddChild(stripScroll);
	AddChild(stripFrame);

	CTrackWindow::AddFrameView(frame, track);
}
Exemplo n.º 14
0
status_t
PControl::SetProperty(const char *name, PValue *value, const int32 &index)
{
	// Modal, Front, and Floating properties are missing because they are read-only
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	status_t status = prop->SetValue(value);
	if (status != B_OK)
		return status;
	
	if (!fView)
		return B_NO_INIT;
	
	BControl *viewAsControl = (BControl*)fView;
	
	BoolValue bv;
	IntValue iv;
	StringValue sv;
	
	if (viewAsControl->Window())
		viewAsControl->Window()->Lock();
	
	if (str.ICompare("Enabled") == 0)
	{
		prop->GetValue(&bv);
		viewAsControl->SetEnabled(bv.value);
	}
	else if (str.ICompare("Label") == 0)
	{
		prop->GetValue(&sv);
		viewAsControl->SetLabel(sv.value->String());
		viewAsControl->Invalidate();
	}
	else if (str.ICompare("Value") == 0)
	{
		prop->GetValue(&iv);
		viewAsControl->SetValue(*iv.value);
	}
	else
	{
		if (viewAsControl->Window())
			viewAsControl->Window()->Unlock();
		return PView::SetProperty(name,value,index);
	}

	if (viewAsControl->Window())
		viewAsControl->Window()->Unlock();
	
	return prop->GetValue(value);
}
void
ThemeInterfaceView::_ThemeListPopulator()
{
	status_t err;
	int32 i, count;
	int32 importer;
	BString name;
	ThemeItem *ti;
	bool isro;
	BStringItem *si;

	LockLooper();
	fThemeList->MakeEmpty();
	UnlockLooper();

	ThemeManager* tman = GetThemeManager();
	tman->LoadThemes();

	count = tman->CountThemes();
	

	LockLooper();

	si = new BStringItem("(System themes)");
	si->SetEnabled(false);
	fThemeList->AddItem(si);
	si = NULL; // first non-readonly item will set it again

	// native themes
	for (i = 0; i < count; i++) {
		err = tman->ThemeName(i, name);
		isro = tman->ThemeIsReadOnly(i);
		if (err)
			continue;

		if (!isro && si == NULL) {
			si = new BStringItem("(User themes)");
			si->SetEnabled(false);
			fThemeList->AddItem(si);
		}

		ti = new ThemeItem(i, name.String(), isro);
		fThemeList->AddItem(ti);
	}

	UnlockLooper();

	// for each importer
	for (importer = 0; importer < tman->CountThemeImporters(); importer++) {
		err = tman->ImportThemesFor(importer);
		if (err < 0)
			continue;
		PRINT(("Imports for %s: %d\n", tman->ThemeImporterAt(importer), (tman->CountThemes() - count)));
		if (tman->CountThemes() == count)
			continue; // nothing found

		// separator item
		name = "Imported (";
		name << tman->ThemeImporterAt(importer) << ")";
		si = new BStringItem(name.String());
		si->SetEnabled(false);
		LockLooper();
		fThemeList->AddItem(si);
		UnlockLooper();

		// add new themes
		count = tman->CountThemes();
		// we reuse i from where it was left
		for (; i < count; i++) {
			err = tman->ThemeName(i, name);
			isro = true;// importers can't save themes back
			if (err)
				continue;
			ti = new ThemeItem(i, name.String(), isro);
			LockLooper();
			fThemeList->AddItem(ti);
			UnlockLooper();
			// rest a bit
			snooze(1000);
		}
	}

	// enable controls again
	BControl *c;
	LockLooper();
	for (i = 0; ChildAt(i); i++) {
		c = dynamic_cast<BControl *>(ChildAt(i));
		if (c)
			c->SetEnabled(true);
	}
	UnlockLooper();
}
Exemplo n.º 16
0
status_t
BMailProtocolConfigView::Archive(BMessage *into, bool deep) const
{
	const char *host = TextControl((BView *)this,"host");
	int32 port = -1;
	BString host_name = host;
	if (host_name.FindFirst(':') > -1) {
		port = atol(host_name.String() + host_name.FindFirst(':') + 1);
		host_name.Truncate(host_name.FindFirst(':'));
	}

	if (into->ReplaceString("server",host_name.String()) != B_OK)
		into->AddString("server",host_name.String());

	// since there is no need for the port option, remove it here
	into->RemoveName("port");
	if (port != -1)
		into->AddInt32("port",port);

	if (into->ReplaceString("username",TextControl((BView *)this,"user")) != B_OK)
		into->AddString("username",TextControl((BView *)this,"user"));

	// remove old unencrypted passwords
	into->RemoveName("password");

	set_passwd(into,"cpasswd",TextControl((BView *)this,"pass"));

	BMenuField *field;
	int32 index = -1;

	if ((field = (BMenuField *)(FindView("flavor"))) != NULL) {
		BMenuItem *item = field->Menu()->FindMarked();
		if (item != NULL)
			index = field->Menu()->IndexOf(item);
	}

	if (into->ReplaceInt32("flavor",index) != B_OK)
		into->AddInt32("flavor",index);

	index = -1;

	if ((field = (BMenuField *)(FindView("auth_method"))) != NULL) {
		BMenuItem *item = field->Menu()->FindMarked();
		if (item != NULL)
			index = field->Menu()->IndexOf(item);
	}

	if (into->ReplaceInt32("auth_method",index) != B_OK)
		into->AddInt32("auth_method",index);

	if (FindView("leave_mail_on_server") != NULL) {
		BControl* control = (BControl*)FindView("leave_mail_on_server");
		bool on = (control->Value() == B_CONTROL_ON);
		if (into->ReplaceBool("leave_mail_on_server", on) != B_OK)
			into->AddBool("leave_mail_on_server", on);

		control = (BControl*)FindView("delete_remote_when_local");
		on = (control->Value() == B_CONTROL_ON);
		if (into->ReplaceBool("delete_remote_when_local", on)) {
			into->AddBool("delete_remote_when_local", on);
		}
	} else {
		if (into->ReplaceBool("leave_mail_on_server", false) != B_OK)
			into->AddBool("leave_mail_on_server", false);

		if (into->ReplaceBool("delete_remote_when_local", false) != B_OK)
			into->AddBool("delete_remote_when_local", false);
	}

	if (fBodyDownloadConfig)
		fBodyDownloadConfig->Archive(into, deep);
	return B_OK;
}