Exemplo n.º 1
0
/***********************************************************
 * SetFrom
 ***********************************************************/
void
HAddressView::SetFrom(const char* in_address)
{
	if( ::strlen(in_address) == 0)
		return;
	BString address(in_address);
	
	// Compare existing accounts	
	char name[B_FILE_NAME_LENGTH];
	BPath path;
	::find_directory(B_USER_SETTINGS_DIRECTORY,&path);
	path.Append(APP_NAME);
	path.Append("Accounts");
	BDirectory dir(path.Path());
	status_t err = B_OK;
	BEntry entry;
	bool changed = false;
	
	while(err == B_OK)
	{
		if( (err = dir.GetNextEntry(&entry)) != B_OK  )
			break;
		BFile file(&entry,B_READ_ONLY);
		if(file.InitCheck() == B_OK && entry.IsFile())
		{
			BMessage msg;
			msg.Unflatten(&file);
			BString myAddress;
			PRINT(("%s\n",in_address));
			if(msg.FindString("address",&myAddress) != B_OK)
				myAddress = "";
			// Change account
			if(address.FindFirst(myAddress) != B_ERROR)
			{
				entry.GetName(name);	
				ChangeAccount(name);
				// Set From menu
				BMenuField *field = cast_as(FindView("FromMenu"),BMenuField);
				BMenu *menu = field->Menu();
				BMenuItem *item = menu->FindItem(name);
				if(item)
					item->SetMarked(true);
				changed=true;
				break;
			}
		}
	}
	
	if(!changed && cast_as(Window()->FindView("HMailView"),BTextView))
	{
		BMenuField *field = cast_as(FindView("FromMenu"),BMenuField);
		BMenuItem *item(NULL);
		item = field->Menu()->FindMarked();
		if(item)
		{
			ChangeAccount(item->Label());
			item->SetMarked(true);	
		}
	}
}
Exemplo n.º 2
0
int CharismaWindow::saveprefs()
{
	FILE *f;
	BMenu *m;
	char fname[B_PATH_NAME_LENGTH];
	int r;
	BRect rect;
	
	r=find_directory(B_COMMON_SETTINGS_DIRECTORY,0,true,fname,sizeof fname);
	if(r) return r;
	strcat(fname,"/");
	strcat(fname,"Charisma_settings");
	
	f=fopen(fname,"w");
	if(!f)return -1;

	fprintf(f,"Charisma_settings\n");
	fprintf(f,"version=1\n");
	fprintf(f,"directory=%s\n",g_webdir);
	m=modemenu->Menu();
	fprintf(f,"mode=%d\n",m->IndexOf(m->FindMarked()));
	m=smartrefresh->Menu();
	fprintf(f,"smart_refresh=%d\n",m->IndexOf(m->FindMarked()));
	fprintf(f,"external_control=%s\n",extcontrol_item->IsMarked()?"yes":"no");
	fprintf(f,"netpositive_autoset=%s\n",netposautoset_item->IsMarked()?"yes":"no");
	rect=Frame();
	fprintf(f,"position=%f,%f\n",rect.left,rect.top);
	fprintf(f,"minimized=%s\n",isminim?"yes":"no");

	fclose(f);
	
	return 0;
}
Exemplo n.º 3
0
void PecoApp::ChangeRenamer() {
	BMenuField	*myField = (BMenuField *)fWindow->FindView("selectMode");
	BMenu		*myMenu = myField->Menu();
	if (fRenameMode != myMenu->IndexOf(myField->Menu()->FindMarked())) {
		BView	*bottomView = fWindow->FindView("bottomView");
		fWindow->Lock();
		if (fRenameMode != -1) 
			bottomView->RemoveChild((BView *)((PecoApp *)be_app)->fRenamers[fRenameMode]);
		else {
			float deltaHeight = be_plain_font->Size()*2 + 40;
			fWindow->FindView("topView")->SetResizingMode(0);
			fWindow->FindView("bottomView")->SetResizingMode(B_FOLLOW_TOP_BOTTOM);	
			fWindow->ResizeBy(0, deltaHeight);
			fWindow->FindView("topView")->SetResizingMode(B_FOLLOW_TOP_BOTTOM);
			fWindow->FindView("bottomView")->SetResizingMode(B_FOLLOW_BOTTOM);	
			float min_h, max_h, min_v, max_v;
			fWindow->GetSizeLimits( &min_h, &max_h, &min_v, &max_v );
			fWindow->SetSizeLimits( min_h, max_h, min_v + deltaHeight, max_v );
		}
		fRenameMode = myMenu->IndexOf(myField->Menu()->FindMarked());
		bottomView->AddChild(((PecoApp *)be_app)->fRenamers[fRenameMode]);
		if (((PecoApp *)be_app)->fRenamers[fRenameMode]->ChildAt(0) != NULL) 
			((PecoApp *)be_app)->fRenamers[fRenameMode]->ChildAt(0)->MakeFocus();
		else
			fWindow->FindView("DoIt")->MakeFocus();
		fWindow->Unlock();
		MakeList();
	}
}
Exemplo n.º 4
0
int CharismaWindow::getprefs()
{
	FILE *f;
	char s[200],param[200];
	int d;
	char fname[B_PATH_NAME_LENGTH];
	int r;
	float x,y;

	r=find_directory(B_COMMON_SETTINGS_DIRECTORY,0,true,fname,sizeof fname);
	if(r) return r;
	strcat(fname,"/");
	strcat(fname,"Charisma_settings");
	
	f=fopen(fname,"r");
	if(!f)return -1;

	if(!fgets(s,sizeof s,f)) goto error;
	if(strcmp(s,"Charisma_settings\n")) goto error;
	
	if(!fgets(s,sizeof s,f)) goto error;
	if(!sscanf(s,"version=%d",&d)) goto error;

	if(!fgets(s,sizeof s,f)) goto error;
	if(!sscanf(s,"directory=%[^\n]",g_webdir)) goto error;

	if(!fgets(s,sizeof s,f)) goto error;
	if(!sscanf(s,"mode=%d",&d)) goto error;
	modemenu->Menu()->ItemAt(d)->SetMarked(true);

	if(!fgets(s,sizeof s,f)) goto error;
	if(!sscanf(s,"smart_refresh=%d",&d)) goto error;
	smartrefresh->Menu()->ItemAt(d)->SetMarked(true);

	if(!fgets(s,sizeof s,f)) goto error;
	if(!sscanf(s,"external_control=%s",param)) goto error;
	extcontrol_item->SetMarked(!strcmp(param,"yes"));

	if(!fgets(s,sizeof s,f)) goto error;
	if(!sscanf(s,"netpositive_autoset=%s",param)) goto error;
	netposautoset_item->SetMarked(!strcmp(param,"yes"));

	if(!fgets(s,sizeof s,f)) goto error;
	if(2!=sscanf(s,"position=%f,%f\n",&x,&y)) goto error;
	MoveTo(x,y);

	if(!fgets(s,sizeof s,f)) goto error;
	if(!sscanf(s,"minimized=%s",&param)) goto error;
	if(!strcmp(param,"yes")) Minimize(true);

	fclose(f);
	update_proxy_settings();
	return 0;
	
error:
	fclose(f);
	update_proxy_settings();
	return -1;
}
Exemplo n.º 5
0
void
BMailProtocolConfigView::SetTo(MailAddonSettings& settings)
{
 	const BMessage* archive = &settings.Settings();

	BString host = archive->FindString("server");
	if (archive->HasInt32("port"))
		host << ':' << archive->FindInt32("port");

	SetTextControl(this,"host", host.String());
	SetTextControl(this,"user", archive->FindString("username"));

	char *password = get_passwd(archive, "cpasswd");
	if (password) {
		SetTextControl(this,"pass", password);
		delete[] password;
	} else
		SetTextControl(this,"pass", archive->FindString("password"));

	if (archive->HasInt32("flavor")) {
		BMenuField *menu = (BMenuField *)(FindView("flavor"));
		if (menu != NULL) {
			if (BMenuItem *item = menu->Menu()->ItemAt(archive->FindInt32("flavor")))
				item->SetMarked(true);
		}
	}

	if (archive->HasInt32("auth_method")) {
		BMenuField *menu = (BMenuField *)(FindView("auth_method"));
		if (menu != NULL) {
			if (BMenuItem *item = menu->Menu()->ItemAt(archive->FindInt32("auth_method"))) {
				item->SetMarked(true);
				if (item->Command() != 'none') {
					enable_control("user");
					enable_control("pass");
				}
			}
		}
	}


	BCheckBox *box = (BCheckBox *)(FindView("leave_mail_on_server"));
	if (box != NULL)
		box->SetValue(archive->FindBool("leave_mail_on_server") ? B_CONTROL_ON : B_CONTROL_OFF);

	box = (BCheckBox *)(FindView("delete_remote_when_local"));
	if (box != NULL) {
		box->SetValue(archive->FindBool("delete_remote_when_local") ? B_CONTROL_ON : B_CONTROL_OFF);

		if (archive->FindBool("leave_mail_on_server"))
			box->SetEnabled(true);
		else
			box->SetEnabled(false);
	}

	if (fBodyDownloadConfig)
		fBodyDownloadConfig->SetTo(settings);
}
Exemplo n.º 6
0
void CharismaWindow::setdefaults()
{
	extcontrol_item->SetMarked(1);
	netposautoset_item->SetMarked(0);
		
	modemenu->Menu()->ItemAt(k_offline)->SetMarked(true);
	smartrefresh->Menu()->ItemAt(3)->SetMarked(true);

	update_proxy_settings();
}
Exemplo n.º 7
0
void
BMailProtocolConfigView::AddFlavor(const char *label)
{
	BMenuField *menu = (BMenuField *)(FindView("flavor"));
	if (menu != NULL) {
		menu->Menu()->AddItem(new BMenuItem(label,NULL));
		if (menu->Menu()->FindMarked() == NULL)
			menu->Menu()->ItemAt(0)->SetMarked(true);
	}
}
Exemplo n.º 8
0
void
BMailProtocolConfigView::AddAuthMethod(const char *label,bool needUserPassword)
{
	BMenuField *menu = (BMenuField *)(FindView("auth_method"));
	if (menu != NULL) {
		BMenuItem *item = new BMenuItem(label,new BMessage(needUserPassword ? 'some' : 'none'));

		menu->Menu()->AddItem(item);

		if (menu->Menu()->FindMarked() == NULL) {
			menu->Menu()->ItemAt(0)->SetMarked(true);
			MessageReceived(menu->Menu()->ItemAt(0)->Message());
		}
	}
}
Exemplo n.º 9
0
void PecoApp::NoRenamer() {
	if (fRenameMode == MODE_NONE) return;

	fWindow->Lock();
	BMenuField	*myField = (BMenuField *)fWindow->FindView("selectMode");
	BMenu		*myMenu = myField->Menu();
	
	myMenu->FindMarked()->SetMarked(false);

	myField->MenuItem()->SetLabel(STR_PLEASE_SELECT);
	
	BView	*bottomView = fWindow->FindView("bottomView");
	bottomView->RemoveChild((BView *)((PecoApp *)be_app)->fRenamers[fRenameMode]);

	fRenameMode = MODE_NONE;

	float deltaHeight = - be_plain_font->Size()*2 - 40;

	float min_h, max_h, min_v, max_v;
	fWindow->GetSizeLimits( &min_h, &max_h, &min_v, &max_v );
	fWindow->SetSizeLimits( min_h, max_h, min_v + deltaHeight, max_v );

	fWindow->FindView("topView")->SetResizingMode(0);
	fWindow->FindView("bottomView")->SetResizingMode(B_FOLLOW_TOP_BOTTOM);	
	fWindow->ResizeBy(0, deltaHeight);
	fWindow->FindView("topView")->SetResizingMode(B_FOLLOW_TOP_BOTTOM);
	fWindow->FindView("bottomView")->SetResizingMode(B_FOLLOW_BOTTOM);	

	fWindow->Unlock();

}
Exemplo n.º 10
0
void CPasteFunctionDialog::PostInit()
{
	fCellView = fOwner->GetCellView();
	
	BAutolock lock(this);
	if (!lock.IsLocked())
		THROW((errLockWindow));

	fList = (BListView *)FindView("list");
	fList->SetInvocationMessage(new BMessage(msg_OK));
	fList->SetSelectionMessage(new BMessage(msg_FuncChanged));
//	fList->SetFont(be_plain_font);

	fFuncDescription = (BTextView *)FindView("desc");

	BMenuField *mf = dynamic_cast<BMenuField *>(FindView("group"));
	fMenu = mf->Menu();
	fMenu->AddItem(new BMenuItem("All", new BMessage(msg_MenuChanged)));
	fMenu->AddSeparatorItem();
	fMenu->AddItem(new BMenuItem("Cell", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Date-Time", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Financial", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Math", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Statistical", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Text", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Logical", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Engineering", new BMessage(msg_MenuChanged)));
	fMenu->AddItem(new BMenuItem("Plugins", new BMessage(msg_MenuChanged)));

	fMenu->FindItem("All")->SetMarked(true);

	FillList();
	
	Show();
} /* CPasteFunctionDialog::CPasteFunctionDialog */
Exemplo n.º 11
0
status_t
NotifierConfigView::SaveInto(BMailAddOnSettings& settings) const
{
	int32 method = 0;

	BMenuField *field;
	if ((field = dynamic_cast<BMenuField *>(FindView("notify"))) != NULL) {
		for (int32 i = field->Menu()->CountItems(); i-- > 0;) {
			BMenuItem *item = field->Menu()->ItemAt(i);
			if (item->IsMarked())
				method |= 1L << i;
		}
	}

	return settings.SetInt32("notification_method", method);
}
Exemplo n.º 12
0
void HDialog::SetValue(const char *id, int value)
{
	BView *v = FindView(id);
	if (v == NULL) THROW(("View '%s' not found", id));

	if (typeid(*v) == typeid(BMenuField))
	{
		BMenuField *mf = static_cast<BMenuField*>(v);
		BMenuItem *item = mf->Menu()->ItemAt(value - 1);
		if (item)
			item->SetMarked(true);
		return;
	}
	else if (typeid(*v) == typeid(BTextControl))
	{
		char b[32];
		sprintf(b, "%d", value);
		SetText(id, b);
		return;
	}
	else if (typeid(*v) == typeid(BSlider))
	{
		static_cast<BSlider*>(v)->SetValue(value);
		return;
	}

	THROW(("view '%s' not found", id));
} // HDialog::SetValue
Exemplo n.º 13
0
void
TestWindow::AddTest(Test* test)
{
	if (test == NULL || fTests.HasItem(test))
		return;

	if (!fTests.AddItem(test)) {
		delete test;
		return;
	}

	BMessage* message = new BMessage(MSG_SELECT_TEST);
	message->AddInt32("index", fTests.CountItems() - 1);

	BMenuItem* item = new BMenuItem(test->Name(), message);
	if (!fTestSelectionField->Menu()->AddItem(item)) {
		fTests.RemoveItem(fTests.CountItems() - 1);
		delete test;
		delete item;
		return;
	}

	if (fTests.CountItems() == 1)
		SetToTest(0);
}
Exemplo n.º 14
0
void ConfigView::SetTo(const BMessage *archive)
{
	int32 method = archive->FindInt32("notification_method");
	if (method < 0)
		method = 1;

	BMenuField *field;
	if ((field = dynamic_cast<BMenuField *>(FindView("notify"))) == NULL)
		return;

	for (int32 i = field->Menu()->CountItems();i-- > 0;)
	{
		BMenuItem *item = field->Menu()->ItemAt(i);
		item->SetMarked((method & (1L << i)) != 0);
	}
	UpdateNotifyText();
}
Exemplo n.º 15
0
/***********************************************************
 * AccountName
 ***********************************************************/
const char*
HAddressView::AccountName()
{
	BMenuField *field = cast_as(FindView("FromMenu"),BMenuField);
	BMenu *menu = field->Menu();
	BMenuItem *item = menu->FindMarked();
	if(!item)
		return NULL;
	return item->Label();
}
Exemplo n.º 16
0
void
BMailProtocolConfigView::AttachedToWindow()
{
	BMenuField *menu = (BMenuField *)(FindView("auth_method"));
	if (menu != NULL)
		menu->Menu()->SetTargetForItems(this);

	BCheckBox *box = (BCheckBox *)(FindView("leave_mail_on_server"));
	if (box != NULL)
		box->SetTarget(this);
}
Exemplo n.º 17
0
status_t ConfigView::Archive(BMessage *into, bool) const
{
	int32 method = 0;

	BMenuField *field;
	if ((field = dynamic_cast<BMenuField *>(FindView("notify"))) != NULL)
	{
		for (int32 i = field->Menu()->CountItems();i-- > 0;)
		{
			BMenuItem *item = field->Menu()->ItemAt(i);
			if (item->IsMarked())
				method |= 1L << i;
		}
	}

	if (into->ReplaceInt32("notification_method",method) != B_OK)
		into->AddInt32("notification_method",method);

	return B_OK;
}
Exemplo n.º 18
0
void TeamListView::UpdatePopUpPriorityMenu()
{
	BMenuField *Priority = (BMenuField *)slayer->mainWindow->FindView("MainPriorityField");
	BMenu *menu = Priority->Menu();
	BMenuItem *item;
	int32 i;
	for (i = 2; (item = menu->ItemAt(i)); i++) {
		priorityMenu->ItemAt(i-2)->SetMarked(item->IsMarked());
		priorityMenu->ItemAt(i-2)->SetEnabled(item->IsEnabled());
	}
}
Exemplo n.º 19
0
void ConfigView::UpdateNotifyText()
{
	BMenuField *field;
	if ((field = dynamic_cast<BMenuField *>(FindView("notify"))) == NULL)
		return;

	BString label;
	for (int32 i = field->Menu()->CountItems();i-- > 0;)
	{
		BMenuItem *item = field->Menu()->ItemAt(i);
		if (!item->IsMarked())
			continue;

		if (label != "")
			label.Prepend(" + ");
		label.Prepend(item->Label());
	}
	if (label == "")
		label = "none";
	field->MenuItem()->SetLabel(label.String());
}
Exemplo n.º 20
0
void
TestWindow::SetToTest(int32 index)
{
	Test* test = (Test*)fTests.ItemAt(index);
	if (test == NULL)
		return;

	fTestSelectionField->Menu()->ItemAt(index)->SetMarked(true);

	fClippingTestView->SetTestRenderer(test->ClippingTest());
	fValidateTestView->SetTestRenderer(test->ValidateTest());
}
Exemplo n.º 21
0
button_width
Window::_ButtonWidth()
{
	switch (fSizeField->Menu()->FindMarkedIndex()) {
		case 0:
		default:
			return B_WIDTH_AS_USUAL;
		case 1:
			return B_WIDTH_FROM_WIDEST;
		case 2:
			return B_WIDTH_FROM_LABEL;
	}
}
Exemplo n.º 22
0
void
AccountView::AttachedToWindow()
{
	// Once we are attached to window, the GUI is already created
	// so we can set our window as target for messages
	for (int32 i = 0; i < CountChildren(); i++) {
		BView* child = ChildAt(i);

		BMenu* menu = dynamic_cast<BMenu*>(child);
		BMenuField* menuField
			= dynamic_cast<BMenuField*>(child);
		BTextControl* textControl
			= dynamic_cast<BTextControl*>(child);
		NotifyingTextView* textView
			= dynamic_cast<NotifyingTextView*>(child);
		BCheckBox* checkBox = dynamic_cast<BCheckBox*>(child);

		if (menuField)
			menu = menuField->Menu();

		if (menu) {
			for (int32 j = 0; j < menu->CountItems(); j++) {
				BMenuItem* item = menu->ItemAt(j);
				item->SetMessage(new BMessage(kChanged));
				item->SetTarget(Window());
			}

			menu->SetTargetForItems(Window());
		}

		if (textControl) {
			textControl->SetMessage(new BMessage(kChanged));
			textControl->SetTarget(Window());
		}

		if (checkBox) {
			checkBox->SetMessage(new BMessage(kChanged));
			checkBox->SetTarget(Window());
		}

		if (textView) {
			textView->SetMessage(new BMessage(kChanged));
			textView->SetTarget(Window());
		}
	}
}
Exemplo n.º 23
0
void TeamListView::ItemsToPopUpPriorityMenu()
{
	BMenuField *Priority = (BMenuField *)slayer->mainWindow->FindView("MainPriorityField");
	BMenu *menu = Priority->Menu();
	BMenuItem *add;
	int32 i;
	for (i = 2; (add = menu->ItemAt(i)); i++) {
		BMenuItem *newItem;
		if (add->Label() && add->Label()[0])
			newItem = new BMenuItem(add->Label(), new BMessage(
				add->Command()));
		else
			newItem = new BSeparatorItem();
			
		newItem->SetTarget(slayer->mainWindow);
		priorityMenu->AddItem(newItem);
	}
		// priorityMenu->AddItem(add);
}
Exemplo n.º 24
0
/***********************************************************
 * Destructor
 ***********************************************************/
HAddressView::~HAddressView()
{
	// Save send account
	int32 smtp_account;
	BMenuField *field = cast_as(FindView("FromMenu"),BMenuField);
	BMenu *menu = field->Menu();
	smtp_account = menu->IndexOf(menu->FindMarked());
	((HApp*)be_app)->Prefs()->SetData("smtp_account",smtp_account);
	
	// free memories
	int32 count = fAddrList.CountItems();
	while(count>0)
	{
		char *p = (char*)fAddrList.RemoveItem(--count);
		if(p)
			free(p);
	}
	fTo->SetModificationMessage(NULL);
	fCc->SetModificationMessage(NULL);
	fBcc->SetModificationMessage(NULL);
	fSubject->SetModificationMessage(NULL);
}
Exemplo n.º 25
0
void iupdrvListAppendItem(Ihandle* ih, const char* value)
{
  BView* view = (BView*)ih->handle;

  BMenuField* menu = dynamic_cast<BMenuField*>(view);
  if(menu)
  {
    menu->Menu()->AddItem(new BMenuItem(value, NULL));
	return;
  }

  BListView* listview = iuphaikuGetListView(view);

  if(listview)
  {
    BListItem* item = new BStringItem(value);
	listview->LockLooper();
    listview->AddItem(item);
	listview->UnlockLooper();
  } else {
    fprintf(stderr, "View hierarchy problem\n");
  }

}
Exemplo n.º 26
0
CInfoDialog::CInfoDialog(BRect frame, const char *name, window_type type, int flags,
			BWindow *owner, BPositionIO* data)
	: HDialog(frame, name, type, flags, owner, data)
{
	fDoc = dynamic_cast<PDoc*>(owner);
	FailNil(fDoc);

	SetText("name", owner->Title());

	char s[32];
	sprintf(s, "%d", fDoc->TextView()->Size());
	SetText("docsize", s);

	sprintf(s, "%d", fDoc->TextView()->LineCount());
	SetText("lines", s);

	BMenuField *mf = dynamic_cast<BMenuField*>(FindView("mime"));
	FailNil(mf);
	fTypes = mf->Menu();

	const char *p;
	int i = 0;
	while ((p = gPrefs->GetIxPrefString(prf_X_Mimetype, i++)) != NULL)
		fTypes->AddItem(new BMenuItem(p, new BMessage(msg_FieldChanged)));

	if (i == 1)
		fTypes->AddItem(new BMenuItem("text/plain", new BMessage(msg_FieldChanged)));

	const char *mime = fDoc->MimeType();

	if (mime && mime[0])
	{
		for (i = 0; i < fTypes->CountItems(); i++)
		{
			BMenuItem *item = fTypes->ItemAt(i);
			if (strcmp(item->Label(), mime) == 0)
			{
				item->SetMarked(true);
				break;
			}
		}

		if (i == fTypes->CountItems())
		{
			fTypes->AddSeparatorItem();
			fTypes->AddItem(new BMenuItem(mime, new BMessage(msg_FieldChanged)));
			fTypes->ItemAt(fTypes->CountItems() - 1)->SetMarked(true);
		}
	}
	else
	{
		BMenuItem *item;
		fTypes->AddSeparatorItem();
		fTypes->AddItem(item = new BMenuItem("<undefined>", new BMessage(msg_FieldChanged)));
		item->SetMarked(true);
	}

	if (fDoc->EntryRef())
	{
		BNode node;
		FailOSErr(node.SetTo(fDoc->EntryRef()));

		time_t t;
		node.GetModificationTime(&t);

		char time[256];
		strcpy(time, ctime(&t));
		time[strlen(time) - 1] = 0;

		SetText("time", time);
	}
	else
	{
		//SetEnabled("mime", false);
		SetText("time", "Not Saved");
	}

	mf = dynamic_cast<BMenuField*>(FindView("font"));
	FailNil(mf);

	fMenu = mf->Menu();
	FailNil(fMenu);

	font_family ff;
	font_style fs;

	for (int i = 0; i < count_font_families(); i++)
	{
		get_font_family(i, &ff);
		BMenu *fontItem = new BMenu(ff);
		FailNil(fontItem);
		fMenu->AddItem(new BMenuItem(fontItem, new BMessage(msg_FieldChanged)));
		fontItem->SetFont(be_plain_font);

		for (int j = 0; j < count_font_styles(ff); j++)
		{
			get_font_style(ff, j, &fs);

			BMessage *msg = new BMessage(msg_FieldChanged);
			msg->AddString("family", ff);
			msg->AddString("style", fs);
			fontItem->AddItem(new BMenuItem(fs, msg));
		}
	}

	fMenu->SetRadioMode(true);

	mf = dynamic_cast<BMenuField*>(FindView("encoding"));
	FailNil(mf);
	fEncoding = mf->Menu();
	FailNil(fEncoding);
	fEncoding->SetRadioMode(true);

	mf = dynamic_cast<BMenuField*>(FindView("source encoding"));
	FailNil(mf);
	fSourceEncoding = mf->Menu();
	FailNil(fSourceEncoding);
	fSourceEncoding->SetRadioMode(true);

	mf = dynamic_cast<BMenuField*>(FindView("linebreaks"));
	FailNil(mf);
	fLineBreaks = mf->Menu();
	FailNil(fLineBreaks);
	fLineBreaks->SetRadioMode(true);

	BTextControl *tc = dynamic_cast<BTextControl*>(FindView("tabs"));
	if (tc) tc->SetDivider(be_plain_font->StringWidth(tc->Label()) + 4);

	BMenu *lang;
	mf = dynamic_cast<BMenuField*>(FindView("language"));
	FailNil(mf);
	lang = mf->Menu();

	CLanguageInterface *intf;
	int cookie = 0;
	while ((intf = CLanguageInterface::NextIntf(cookie)) != NULL)
		lang->AddItem(new BMenuItem(intf->Name(), new BMessage(msg_FieldChanged)));

	lang->SetRadioMode(true);
	int curLang = fDoc->TextView()->Language();
	SetValue("language", curLang >= 0 ? curLang + 3 : 1);

	CancelClicked();
} /* CInfoDialog::CInfoDialog */
Exemplo n.º 27
0
void
PBox::GetData(BMessage* data){
			
			
			
			BView * panel = fPrefView;
			BMessage cur;
			
			for (int i = 0; fTemplate.FindMessage("setting", i, &cur) == B_OK; i++) {
				const char *name = cur.FindString("name");
				int32 type = -1;
				
				cur.FindInt32("type", &type);
				
				if ( dynamic_cast<BTextControl*>(panel->FindView(name))) { 
//					Free text
					BTextControl * ctrl = (BTextControl*)panel->FindView(name);
				
					switch (type) {
						case B_STRING_TYPE: {
							data->AddString(name, ctrl->Text() );
						} break;
						case B_INT32_TYPE: {
							data->AddInt32(name, atoi(ctrl->Text()) );
						} break;
						default: {
							return;
						};
					};
				} else if (dynamic_cast<BMenuField*>(panel->FindView(name))) {
//					Provided option
					BMenuField * ctrl = (BMenuField*)panel->FindView(name);
					BMenuItem * item = ctrl->Menu()->FindMarked();
					
									
					if (!item) return;
					
					switch (type) {
						case B_STRING_TYPE: {
							data->AddString(name, item->Label() );
							BString index(name);
							index << "_index";
							data->AddInt32(index.String(), ctrl->Menu()->IndexOf(item)); //index 
						} break;
						case  B_INT32_TYPE: {
							data->AddInt32(name, atoi(item->Label()) );
							BString index(name);
							index << "_index";
							data->AddInt32(index.String(), ctrl->Menu()->IndexOf(item)); //index
						} break;
						default: {
							return;
						};
					}
				} else
				if (dynamic_cast<BCheckBox*>(panel->FindView(name))) {
// 					Boolean setting
					BCheckBox * box = (BCheckBox*)panel->FindView(name);
					
					if ( box->Value() == B_CONTROL_ON ) {
						data->AddBool(name,true);
					} else {
						data->AddBool(name,false);
					}
				} else if (dynamic_cast<BTextView *>(panel->FindView(name))) {
					BTextView *view = (BTextView *)panel->FindView(name);
					data->AddString(name, view->Text());
				};
				
				
			};

		
}
Exemplo n.º 28
0
alert_type
Window::_AlertType()
{
	return (alert_type)fTypeField->Menu()->FindMarkedIndex();
}
Exemplo n.º 29
0
void
HWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case M_OTHER_MESSAGE:
		{
			BMenuField* menufield
				= dynamic_cast<BMenuField*>(FindView("filemenu"));
			if (menufield == NULL)
				return;
			BMenu* menu = menufield->Menu();

			HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
			if (row != NULL) {
				BPath path(row->Path());
				if (path.InitCheck() != B_OK) {
					BMenuItem* item = menu->FindItem(B_TRANSLATE("<none>"));
					if (item != NULL)
						item->SetMarked(true);
				} else {
					BMenuItem* item = menu->FindItem(path.Leaf());
					if (item != NULL)
						item->SetMarked(true);
				}
			}
			fFilePanel->Show();
			break;
		}

		case B_SIMPLE_DATA:
		case B_REFS_RECEIVED:
		{
			entry_ref ref;
			HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
			if (message->FindRef("refs", &ref) == B_OK && row != NULL) {
				BMenuField* menufield
					= dynamic_cast<BMenuField*>(FindView("filemenu"));
				if (menufield == NULL)
					return;
				BMenu* menu = menufield->Menu();

				// check audio file
				BNode node(&ref);
				BNodeInfo ninfo(&node);
				char type[B_MIME_TYPE_LENGTH + 1];
				ninfo.GetType(type);
				BMimeType mtype(type);
				BMimeType superType;
				mtype.GetSupertype(&superType);
				if (superType.Type() == NULL
					|| strcmp(superType.Type(), "audio") != 0) {
					beep();
					BAlert* alert = new BAlert("",
						B_TRANSLATE("This is not an audio file."),
						B_TRANSLATE("OK"), NULL, NULL,
						B_WIDTH_AS_USUAL, B_STOP_ALERT);
					alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
					alert->Go();
					break;
				}

				// add file item
				BMessage* msg = new BMessage(M_ITEM_MESSAGE);
				BPath path(&ref);
				msg->AddRef("refs", &ref);
				BMenuItem* menuitem = menu->FindItem(path.Leaf());
				if (menuitem == NULL)
					menu->AddItem(menuitem = new BMenuItem(path.Leaf(), msg), 0);
				// refresh item
				fEventList->SetPath(BPath(&ref).Path());
				// check file menu
				if (menuitem != NULL)
					menuitem->SetMarked(true);
			}
			break;
		}

		case M_PLAY_MESSAGE:
		{
			HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
			if (row != NULL) {
				const char* path = row->Path();
				if (path != NULL) {
					entry_ref ref;
					::get_ref_for_path(path, &ref);
					delete fPlayer;
					fPlayer = new BFileGameSound(&ref, false);
					fPlayer->StartPlaying();
				}
			}
			break;
		}

		case M_STOP_MESSAGE:
		{
			if (fPlayer == NULL)
				break;
			if (fPlayer->IsPlaying()) {
				fPlayer->StopPlaying();
				delete fPlayer;
				fPlayer = NULL;
			}
			break;
		}

		case M_EVENT_CHANGED:
		{
			const char* path;
			BMenuField* menufield
				= dynamic_cast<BMenuField*>(FindView("filemenu"));
			if (menufield == NULL)
				return;
			BMenu* menu = menufield->Menu();

			if (message->FindString("path", &path) == B_OK) {
				BPath path(path);
				if (path.InitCheck() != B_OK) {
					BMenuItem* item = menu->FindItem(B_TRANSLATE("<none>"));
					if (item != NULL)
						item->SetMarked(true);
				} else {
					BMenuItem* item = menu->FindItem(path.Leaf());
					if (item != NULL)
						item->SetMarked(true);
				}
			}
			break;
		}

		case M_ITEM_MESSAGE:
		{
			entry_ref ref;
			if (message->FindRef("refs", &ref) == B_OK)
				fEventList->SetPath(BPath(&ref).Path());
			break;
		}

		case M_NONE_MESSAGE:
		{
			fEventList->SetPath(NULL);
			break;
		}

		default:
			BWindow::MessageReceived(message);
	}
}
Exemplo n.º 30
0
void
HWindow::SetupMenuField()
{
	BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu"));
	if (menufield == NULL)
		return;
	BMenu* menu = menufield->Menu();
	int32 count = fEventList->CountRows();
	for (int32 i = 0; i < count; i++) {
		HEventRow* row = (HEventRow*)fEventList->RowAt(i);
		if (row == NULL)
			continue;

		BPath path(row->Path());
		if (path.InitCheck() != B_OK)
			continue;
		if (menu->FindItem(path.Leaf()))
			continue;

		BMessage* msg = new BMessage(M_ITEM_MESSAGE);
		entry_ref ref;
		::get_ref_for_path(path.Path(), &ref);
		msg->AddRef("refs", &ref);
		menu->AddItem(new BMenuItem(path.Leaf(), msg), 0);
	}

	BPath path;
	BDirectory dir;
	BEntry entry;
	BPath item_path;

	status_t err = find_directory(B_BEOS_SOUNDS_DIRECTORY, &path);
	if (err == B_OK)
		err = dir.SetTo(path.Path());
	while (err == B_OK) {
		err = dir.GetNextEntry(&entry, true);
		if (entry.InitCheck() != B_NO_ERROR)
			break;

		entry.GetPath(&item_path);

		if (menu->FindItem(item_path.Leaf()))
			continue;

		BMessage* msg = new BMessage(M_ITEM_MESSAGE);
		entry_ref ref;
		::get_ref_for_path(item_path.Path(), &ref);
		msg->AddRef("refs", &ref);
		menu->AddItem(new BMenuItem(item_path.Leaf(), msg), 0);
	}

	err = find_directory(B_USER_SOUNDS_DIRECTORY, &path);
	if (err == B_OK)
		err = dir.SetTo(path.Path());
	while (err == B_OK) {
		err = dir.GetNextEntry(&entry, true);
		if (entry.InitCheck() != B_NO_ERROR)
			break;

		entry.GetPath(&item_path);

		if (menu->FindItem(item_path.Leaf()))
			continue;

		BMessage* msg = new BMessage(M_ITEM_MESSAGE);
		entry_ref ref;

		::get_ref_for_path(item_path.Path(), &ref);
		msg->AddRef("refs", &ref);
		menu->AddItem(new BMenuItem(item_path.Leaf(), msg), 0);
	}

	err = find_directory(B_COMMON_SOUNDS_DIRECTORY, &path);
	if (err == B_OK)
		err = dir.SetTo(path.Path());
	while (err == B_OK) {
		err = dir.GetNextEntry(&entry, true);
		if (entry.InitCheck() != B_NO_ERROR)
			break;

		entry.GetPath(&item_path);

		if (menu->FindItem(item_path.Leaf()))
			continue;

		BMessage* msg = new BMessage(M_ITEM_MESSAGE);
		entry_ref ref;

		::get_ref_for_path(item_path.Path(), &ref);
		msg->AddRef("refs", &ref);
		menu->AddItem(new BMenuItem(item_path.Leaf(), msg), 0);
	}

}