当前位置: 首页>>代码示例>>C++>>正文


C++ BString类代码示例

本文整理汇总了C++中BString的典型用法代码示例。如果您正苦于以下问题:C++ BString类的具体用法?C++ BString怎么用?C++ BString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

void
TeamWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_TEAM_RESTART_REQUESTED:
		{
			fListener->TeamRestartRequested();
			break;
		}
		case MSG_CHOOSE_DEBUG_REPORT_LOCATION:
		{
			try {
				char filename[B_FILE_NAME_LENGTH];
				UiUtils::ReportNameForTeam(fTeam, filename, sizeof(filename));
				BMessenger msgr(this);
				fFilePanel = new BFilePanel(B_SAVE_PANEL, &msgr,
					NULL, 0, false, new BMessage(MSG_GENERATE_DEBUG_REPORT));
				fFilePanel->SetSaveText(filename);
				fFilePanel->Show();
			} catch (...) {
				delete fFilePanel;
				fFilePanel = NULL;
			}
			break;
		}
		case MSG_GENERATE_DEBUG_REPORT:
		{
			delete fFilePanel;
			fFilePanel = NULL;

			BPath path;
			entry_ref ref;
			if (message->FindRef("directory", &ref) == B_OK
				&& message->HasString("name")) {
				path.SetTo(&ref);
				path.Append(message->FindString("name"));
				if (get_ref_for_path(path.Path(), &ref) == B_OK)
					fListener->DebugReportRequested(&ref);
			}
			break;
		}
		case MSG_DEBUG_REPORT_SAVED:
		{
			BString data;
			data.SetToFormat("Debug report successfully saved to '%s'",
				message->FindString("path"));
			BAlert *alert = new(std::nothrow) BAlert("Report saved",
				data.String(), "Close");
			if (alert == NULL)
				break;

			alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
			alert->Go();
			break;
		}
		case MSG_SHOW_INSPECTOR_WINDOW:
		{
			if (fInspectorWindow) {
				fInspectorWindow->Activate(true);
			} else {
				try {
					fInspectorWindow = InspectorWindow::Create(fTeam,
						fListener, this);
					if (fInspectorWindow != NULL) {
						BMessage settings;
						fInspectorWindow->LoadSettings(fUiSettings);
						fInspectorWindow->Show();
					}
	           	} catch (...) {
	           		// TODO: notify user
	           	}
			}

			target_addr_t address;
			if (message->FindUInt64("address", &address) == B_OK) {
				BMessage addressMessage(MSG_INSPECT_ADDRESS);
				addressMessage.AddUInt64("address", address);
				fInspectorWindow->PostMessage(&addressMessage);
			}
           	break;
		}
		case MSG_INSPECTOR_WINDOW_CLOSED:
		{
			_SaveInspectorSettings(CurrentMessage());
			fInspectorWindow = NULL;
			break;

		}
		case MSG_SHOW_BREAK_CONDITION_CONFIG_WINDOW:
		{
			if (fBreakConditionConfigWindow) {
				fBreakConditionConfigWindow->Activate(true);
			} else {
				try {
					fBreakConditionConfigWindow
						= BreakConditionConfigWindow::Create(
						fTeam, fListener, this);
					if (fBreakConditionConfigWindow != NULL)
						fBreakConditionConfigWindow->Show();
	           	} catch (...) {
//.........这里部分代码省略.........
开发者ID:MaddTheSane,项目名称:haiku,代码行数:101,代码来源:TeamWindow.cpp

示例2: CountItems

void
QPopupMenu::EntryCreated(const entry_ref &ref, ino_t node)
{
	BNode file;
	if (file.SetTo(&ref) < B_OK)
		return;

	// Make sure the pop-up menu is ready for additions.  Need a bunch of
	// groups at the top, a divider line, and miscellaneous people added below
	// the line.

	int32 items = CountItems();
	if (!items)
		AddSeparatorItem();

	// Does the file have a group attribute?  OK to have none.
	BString groups;
	const char *kNoGroup = "NoGroup!";
	ReadAttrString(&file, "META:group", &groups);
	if (groups.Length() <= 0)
		groups = kNoGroup;

	// Add the e-mail address to the all people group.  Then add it to all the
	// group menus that it exists in (based on the comma separated list of
	// groups from the People file), optionally making the group menu if it
	// doesn't exist.  If it's in the special NoGroup!  list, then add it below
	// the groups.

	bool allPeopleGroupDone = false;
	BMenu *groupMenu;
	do {
		BString group;

		if (!allPeopleGroupDone) {
			// Create the default group for all people, if it doesn't exist yet.
			group = "All People";
			allPeopleGroupDone = true;
		} else {
			// Break out the next group from the comma separated string.
			int32 comma;
			if ((comma = groups.FindFirst(',')) > 0) {
				groups.MoveInto(group, 0, comma);
				groups.Remove(0, 1);
			} else
				group.Adopt(groups);
		}

		// trim white spaces
		int32 i = 0;
		for (i = 0; isspace(group.ByteAt(i)); i++) {}
		if (i)
			group.Remove(0, i);
		for (i = group.Length() - 1; isspace(group.ByteAt(i)); i--) {}
		group.Truncate(i + 1);

		groupMenu = NULL;
		BMenuItem *superItem = NULL; // Corresponding item for group menu.

		if (group.Length() > 0 && group != kNoGroup) {
			BMenu *sub;

			// Look for submenu with label == group name
			for (int32 i = 0; i < items; i++) {
				if ((sub = SubmenuAt(i)) != NULL) {
					superItem = sub->Superitem();
					if (!strcmp(superItem->Label(), group.String())) {
						groupMenu = sub;
						i++;
						break;
					}
				}
			}

			// If no submenu, create one
			if (!groupMenu) {
				// Find where it should go (alphabetical)
				int32 mindex = 0;
				for (; mindex < fGroups; mindex++) {
					if (strcmp(ItemAt(mindex)->Label(), group.String()) > 0)
						break;
				}

				groupMenu = new BMenu(group.String());
				groupMenu->SetFont(be_plain_font);
				AddItem(groupMenu, mindex);

				superItem = groupMenu->Superitem();
				superItem->SetMessage(new BMessage(B_SIMPLE_DATA));
				if (fTargetHandler)
					superItem->SetTarget(fTargetHandler);

				fGroups++;
			}
		}

		BString	name;
		ReadAttrString(&file, "META:name", &name);

		BString email;
		ReadAttrString(&file, "META:email", &email);
//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:Header.cpp

示例3: BVolumeRoster

void
THeaderView::InitEmailCompletion()
{
	// get boot volume
	BVolume volume;
	BVolumeRoster().GetBootVolume(&volume);

	BQuery query;
	query.SetVolume(&volume);
	query.SetPredicate("META:email=**");
		// Due to R5 BFS bugs, you need two stars, META:email=** for the query.
		// META:email="*" will just return one entry and stop, same with
		// META:email=* and a few other variations.  Grumble.
	query.Fetch();
	entry_ref ref;

	while (query.GetNextRef (&ref) == B_OK) {
		BNode file;
		if (file.SetTo(&ref) == B_OK) {
			// Add the e-mail address as an auto-complete string.
			BString email;
			if (file.ReadAttrString("META:email", &email) >= B_OK)
				fEmailList.AddChoice(email.String());

			// Also add the quoted full name as an auto-complete string.  Can't
			// do unquoted since auto-complete isn't that smart, so the user
			// will have to type a quote mark if he wants to select someone by
			// name.
			BString fullName;
			if (file.ReadAttrString("META:name", &fullName) >= B_OK) {
				if (email.FindFirst('<') < 0) {
					email.ReplaceAll('>', '_');
					email.Prepend("<");
					email.Append(">");
				}
				fullName.ReplaceAll('\"', '_');
				fullName.Prepend("\"");
				fullName << "\" " << email;
				fEmailList.AddChoice(fullName.String());
			}

			// support for 3rd-party People apps.  Looks like a job for
			// multiple keyword (so you can have several e-mail addresses in
			// one attribute, perhaps comma separated) indices!  Which aren't
			// yet in BFS.
			for (int16 i = 2; i < 6; i++) {
				char attr[16];
				sprintf(attr, "META:email%d", i);
				if (file.ReadAttrString(attr, &email) >= B_OK)
					fEmailList.AddChoice(email.String());
			}
		}
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:54,代码来源:Header.cpp

示例4: Popup

		BOOTIL_EXPORT bool Popup( const BString & strName, const BString & strText )
		{
			MessageBoxA( NULL, strText.c_str(), strName.c_str(), MB_OK | MB_ICONASTERISK );
			return true;
		}
开发者ID:aleksijuvani,项目名称:bootil,代码行数:5,代码来源:Platform_WINDOWS.cpp

示例5: OpenWebpage

		BOOTIL_EXPORT void OpenWebpage( const BString & strURL )
		{
			ShellExecute( NULL, "open", strURL.c_str(),	NULL, NULL, SW_SHOWNORMAL );
		}
开发者ID:aleksijuvani,项目名称:bootil,代码行数:4,代码来源:Platform_WINDOWS.cpp

示例6: ReportProgress

status_t
POP3Protocol::Open(const char* server, int port, int)
{
	ReportProgress(0, 0, B_TRANSLATE("Connecting to POP3 server"
		B_UTF8_ELLIPSIS));

	if (port <= 0)
		port = fUseSSL ? 995 : 110;

	fLog = "";

	// Prime the error message
	BString error_msg, servString;
	error_msg << B_TRANSLATE("Error while connecting to server %serv");

	servString << server;
	error_msg.ReplaceFirst("%serv", servString);

	if (port != 110)
		error_msg << ":" << port;

	uint32 hostIP = inet_addr(server);
		// first see if we can parse it as a numeric address
	if (hostIP == 0 || hostIP == ~0UL) {
		struct hostent * he = gethostbyname(server);
		hostIP = he ? *((uint32*)he->h_addr) : 0;
	}

	if (hostIP == 0) {
		error_msg << B_TRANSLATE(": Connection refused or host not found");
		ShowError(error_msg.String());

		return B_NAME_NOT_FOUND;
	}

	delete fServerConnection;
	fServerConnection = NULL;
	if (fUseSSL) {
		fServerConnection = new(std::nothrow) BSecureSocket(
			BNetworkAddress(server, port));
	} else {
		fServerConnection = new(std::nothrow) BSocket(BNetworkAddress(
			server,	port));
	}

	if (fServerConnection == NULL)
		return B_NO_MEMORY;
	if (fServerConnection->InitCheck() != B_OK)
		return fServerConnection->InitCheck();

	BString line;
	status_t err = ReceiveLine(line);

	if (err < 0) {
		fServerConnection->Disconnect();
		error_msg << ": " << strerror(err);
		ShowError(error_msg.String());
		return B_ERROR;
	}

	if (strncmp(line.String(), "+OK", 3) != 0) {
		if (line.Length() > 0) {
			error_msg << B_TRANSLATE(". The server said:\n")
				<< line.String();
		} else
			error_msg << B_TRANSLATE(": No reply.\n");

		ShowError(error_msg.String());
		fServerConnection->Disconnect();
		return B_ERROR;
	}

	fLog = line;
	return B_OK;
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:75,代码来源:pop3.cpp

示例7: MessageSize

status_t
POP3Protocol::RetrieveInternal(const char *command, int32 message,
	BPositionIO *write_to, bool post_progress)
{
	const int bufSize = 1024 * 30;

	// To avoid waiting for the non-arrival of the next data packet, try to
	// receive only the message size, plus the 3 extra bytes for the ".\r\n"
	// after the message.  Of course, if we get it wrong (or it is a huge
	// message or has lines starting with escaped periods), it will then switch
	// back to receiving full buffers until the message is done.
	int amountToReceive = MessageSize (message) + 3;
	if (amountToReceive >= bufSize || amountToReceive <= 0)
		amountToReceive = bufSize - 1;

	BString bufBString; // Used for auto-dealloc on return feature.
	char *buf = bufBString.LockBuffer (bufSize);
	int amountInBuffer = 0;
	int amountReceived;
	int testIndex;
	char *testStr;
	bool cont = true;
	bool flushWholeBuffer = false;
	write_to->Seek(0,SEEK_SET);

	if (SendCommand(command) != B_OK)
		return B_ERROR;

	while (cont) {
		status_t result = fServerConnection->WaitForReadable(
			POP3_RETRIEVAL_TIMEOUT);
		if (result == B_TIMED_OUT) {
			// No data available, even after waiting a minute.
			fLog = "POP3 timeout - no data received after a long wait.";
			return B_ERROR;
		}
		if (amountToReceive > bufSize - 1 - amountInBuffer)
			amountToReceive = bufSize - 1 - amountInBuffer;

		amountReceived = fServerConnection->Read(buf + amountInBuffer,
			amountToReceive);

		if (amountReceived < 0) {
			fLog = strerror(errno);
			return errno;
		}
		if (amountReceived == 0) {
			fLog = "POP3 data supposedly ready to receive but not received!";
			return B_ERROR;
		}

		amountToReceive = bufSize - 1; // For next time, read a full buffer.
		amountInBuffer += amountReceived;
		buf[amountInBuffer] = 0; // NUL stops tests past the end of buffer.

		// Look for lines starting with a period.  A single period by itself on
		// a line "\r\n.\r\n" marks the end of the message (thus the need for
		// at least five characters in the buffer for testing).  A period
		// "\r\n.Stuff" at the start of a line get deleted "\r\nStuff", since
		// POP adds one as an escape code to let you have message text with
		// lines starting with a period.  For convenience, assume that no
		// messages start with a period on the very first line, so we can
		// search for the previous line's "\r\n".

		for (testIndex = 0; testIndex <= amountInBuffer - 5; testIndex++) {
			testStr = buf + testIndex;
			if (testStr[0] == '\r' && testStr[1] == '\n' && testStr[2] == '.') {
				if (testStr[3] == '\r' && testStr[4] == '\n') {
					// Found the end of the message marker.  Ignore remaining data.
					if (amountInBuffer > testIndex + 5)
						printf ("POP3Protocol::RetrieveInternal Ignoring %d bytes "
							"of extra data past message end.\n",
							amountInBuffer - (testIndex + 5));
					amountInBuffer = testIndex + 2; // Don't include ".\r\n".
					buf[amountInBuffer] = 0;
					cont = false;
				} else {
					// Remove an extra period at the start of a line.
					// Inefficient, but it doesn't happen often that you have a
					// dot starting a line of text.  Of course, a file with a
					// lot of double period lines will get processed very
					// slowly.
					memmove (buf + testIndex + 2, buf + testIndex + 3,
						amountInBuffer - (testIndex + 3) + 1 /* for NUL at end */);
					amountInBuffer--;
					// Watch out for the end of buffer case, when the POP text
					// is "\r\n..X".  Don't want to leave the resulting
					// "\r\n.X" in the buffer (flush out the whole buffer),
					// since that will get mistakenly evaluated again in the
					// next loop and delete a character by mistake.
					if (testIndex >= amountInBuffer - 4 && testStr[2] == '.') {
						printf ("POP3Protocol::RetrieveInternal: Jackpot!  "
							"You have hit the rare situation with an escaped "
							"period at the end of the buffer.  Aren't you happy"
							"it decodes it correctly?\n");
						flushWholeBuffer = true;
					}
				}
			}
		}
//.........这里部分代码省略.........
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:101,代码来源:pop3.cpp

示例8: screen

TMailWindow*
TMailApp::NewWindow(const entry_ref* ref, const char* to, bool resend,
	BMessenger* trackerMessenger)
{
	BScreen screen(B_MAIN_SCREEN_ID);
	BRect screenFrame = screen.Frame();

	BRect r;
	if (fMailWindowFrame.Width() < 64 || fMailWindowFrame.Height() < 20) {
		// default size
		r.Set(6, TITLE_BAR_HEIGHT, 6 + WIND_WIDTH,
			TITLE_BAR_HEIGHT + WIND_HEIGHT);
	} else
		r = fMailWindowFrame;

	// make sure the window is not larger than the screen space
	if (r.Height() > screenFrame.Height())
		r.bottom = r.top + screenFrame.Height();
	if (r.Width() > screenFrame.Width())
		r.bottom = r.top + screenFrame.Width();

	// cascading windows
	r.OffsetBy(((fWindowCount + 5) % 10) * 15 - 75,
		((fWindowCount + 5) % 10) * 15 - 75);

	// make sure the window is still on screen
	if (r.left - 6 < screenFrame.left)
		r.OffsetTo(screenFrame.left + 8, r.top);

	if (r.left + 20 > screenFrame.right)
		r.OffsetTo(6, r.top);

	if (r.top - 26 < screenFrame.top)
		r.OffsetTo(r.left, screenFrame.top + 26);

	if (r.top + 20 > screenFrame.bottom)
		r.OffsetTo(r.left, TITLE_BAR_HEIGHT);

	if (r.Width() < WIND_WIDTH)
		r.right = r.left + WIND_WIDTH;

	fWindowCount++;

	BString title;
	BFile file;
	if (!resend && ref && file.SetTo(ref, O_RDONLY) == B_OK) {
		BString name;
		if (file.ReadAttrString(B_MAIL_ATTR_NAME, &name) == B_OK) {
			title << name;
			BString subject;
			if (file.ReadAttrString(B_MAIL_ATTR_SUBJECT, &subject) == B_OK)
				title << " -> " << subject;
		}
	}
	if (title == "")
		title = B_TRANSLATE_SYSTEM_NAME("Mail");

	TMailWindow* window = new TMailWindow(r, title.String(), this, ref, to,
		&fContentFont, resend, trackerMessenger);
	fWindowList.AddItem(window);

	return window;
}
开发者ID:kodybrown,项目名称:haiku,代码行数:63,代码来源:MailApp.cpp

示例9: enclosure

void
TMailApp::ArgvReceived(int32 argc, char **argv)
{
	BEntry entry;
	BString names;
	BString ccNames;
	BString bccNames;
	BString subject;
	BString body;
	BMessage enclosure(B_REFS_RECEIVED);
	// a "mailto:" with no name should open an empty window
	// so remember if we got a "mailto:" even if there isn't a name
	// that goes along with it (this allows deskbar replicant to open
	// an empty message even when Mail is already running)
	bool gotmailto = false;

	for (int32 loop = 1; loop < argc; loop++)
	{
		if (strcmp(argv[loop], "-h") == 0
			|| strcmp(argv[loop], "--help") == 0)
		{
			printf(" usage: %s [ mailto:<address> ] [ -subject \"<text>\" ] [ ccto:<address> ] [ bccto:<address> ] "
				"[ -body \"<body text>\" ] [ enclosure:<path> ] [ <message to read> ...] \n",
				argv[0]);
			fPrintHelpAndExit = true;
			be_app->PostMessage(B_QUIT_REQUESTED);
			return;
		}
		else if (strncmp(argv[loop], "mailto:", 7) == 0)
		{
			if (names.Length())
				names += ", ";
			char *options;
			if ((options = strchr(argv[loop],'?')) != NULL)
			{
				names.Append(argv[loop] + 7, options - argv[loop] - 7);
				if (!strncmp(++options,"subject=",8))
					subject = options + 8;
			}
			else
				names += argv[loop] + 7;
			gotmailto = true;
		}
		else if (strncmp(argv[loop], "ccto:", 5) == 0)
		{
			if (ccNames.Length())
				ccNames += ", ";
			ccNames += argv[loop] + 5;
		}
		else if (strncmp(argv[loop], "bccto:", 6) == 0)
		{
			if (bccNames.Length())
				bccNames += ", ";
			bccNames += argv[loop] + 6;
		}
		else if (strcmp(argv[loop], "-subject") == 0)
			subject = argv[++loop];
		else if (strcmp(argv[loop], "-body") == 0 && argv[loop + 1])
			body = argv[++loop];
		else if (strncmp(argv[loop], "enclosure:", 10) == 0)
		{
			BEntry tmp(argv[loop] + 10, true);
			if (tmp.InitCheck() == B_OK && tmp.Exists())
			{
				entry_ref ref;
				tmp.GetRef(&ref);
				enclosure.AddRef("refs", &ref);
			}
		}
		else if (entry.SetTo(argv[loop]) == B_NO_ERROR)
		{
			BMessage msg(B_REFS_RECEIVED);
			entry_ref ref;
			entry.GetRef(&ref);
			msg.AddRef("refs", &ref);
			RefsReceived(&msg);
		}
	}

	if (gotmailto || names.Length() || ccNames.Length() || bccNames.Length() || subject.Length()
		|| body.Length() || enclosure.HasRef("refs"))
	{
		TMailWindow	*window = NewWindow(NULL, names.String());
		window->SetTo(names.String(), subject.String(), ccNames.String(), bccNames.String(),
			&body, &enclosure);
		window->Show();
	}
}
开发者ID:kodybrown,项目名称:haiku,代码行数:88,代码来源:MailApp.cpp

示例10: ArgvReceived

		void ArgvReceived(int32 argc, char **argv) {
			int i, j;
			BMessage msg(InfoPopper::AddMessage);
			InfoPopper::info_type type = InfoPopper::Information;
			const char *app = "Command Line";
			const char *title = "Something Happened";
			BString content;
			float progress = 0.0;
			const char *messageID = NULL;
			int32 timeout = 0;
			const char *iconFile = NULL;
			const char *onClickApp;
			entry_ref onClickFile;
			const char *onClickArgv;
			entry_ref onClickRef;
			for (i = 1; i < argc; i++) {
				//printf("argv[%d] = %s\n", i, argv[i]);
				if (!strcmp(argv[i], "--help")) {
					return Usage();
				} else if (!strcmp(argv[i], "--type")) {
					if (++i >= argc) return Usage();
					type = (InfoPopper::info_type)atoi(argv[i]);
					
					for (j=0; kTypeNames[j]; j++) {
						if (!strncmp(kTypeNames[j], argv[i], strlen(argv[i]))) {
							type = (InfoPopper::info_type)j;
						};
					};
				} else if (!strcmp(argv[i], "--app")) {
					if (++i >= argc)
						return Usage();
					app = argv[i];
				} else if (!strcmp(argv[i], "--title")) {
					if (++i >= argc) return Usage();
					title = argv[i];
				} else if (!strcmp(argv[i], "--messageID")) {
					if (++i >= argc) return Usage();
					messageID = argv[i];
					msg.AddString("messageID", messageID);
				} else if (!strcmp(argv[i], "--progress")) {
					if (++i >= argc) return Usage();
					progress = atof(argv[i]);
					msg.AddFloat("progress", progress);
				} else if (!strcmp(argv[i], "--timeout")) {
					if (++i >= argc) return Usage();
					timeout = atol(argv[i]);
					msg.AddInt32("timeout", timeout);
#if 0
				} else if (!strcmp(argv[i], "--empty")) { /* like alert's --empty */
					iconFile = NULL;
				} else if (!strcmp(argv[i], "--info")) {
					iconFile = "info";
				} else if (!strcmp(argv[i], "--idea")) {
				} else if (!strcmp(argv[i], "--warning")) {
				} else if (!strcmp(argv[i], "--stop")) {
#endif
				} else if (!strcmp(argv[i], "--icon")) {
					bool isOverlay = false;
					if (++i >= argc) return Usage();
					iconFile = argv[i];

					if (!strncmp(iconFile, "overlay:", 8)) {
						iconFile += 8;
						isOverlay = true;
					};
					if (!strncmp(iconFile, "attr:", 5)) {
						iconFile += 5;
						msg.AddInt32(isOverlay?"overlayIconType":"iconType", InfoPopper::Attribute);
					} else {
						msg.AddInt32(isOverlay?"overlayIconType":"iconType", InfoPopper::Contents);
					};
					
					entry_ref ref;
					if (get_ref_for_path(iconFile, &ref) < B_OK) {
						fprintf(stderr, "bad icon path\n");
						return Usage();
					};
					msg.AddRef(isOverlay?"overlayIconRef":"iconRef", &ref);
				} else if (!strcmp(argv[i], "--onClickApp")) {
					if (++i >= argc) return Usage();
					onClickApp = argv[i];
					msg.AddString("onClickApp", onClickApp);
				} else if (!strcmp(argv[i], "--onClickFile")) {
					if (++i >= argc) return Usage();
					if (get_ref_for_path(argv[i], &onClickFile) < B_OK) {
						fprintf(stderr, "bad path\n");
						return Usage();
					};
					msg.AddRef("onClickFile", &onClickFile);
				} else if (!strcmp(argv[i], "--onClickArgv")) {
					if (++i >= argc) return Usage();
					onClickArgv = argv[i];
					msg.AddString("onClickArgv", onClickArgv);
				} else if (!strcmp(argv[i], "--onClickRef")) {
					if (++i >= argc) return Usage();
					if (get_ref_for_path(argv[i], &onClickRef) < B_OK) {
						fprintf(stderr, "bad path\n");
						return Usage();
					}
					msg.AddRef("onClickRef", &onClickRef);
//.........这里部分代码省略.........
开发者ID:louisdem,项目名称:IMKit,代码行数:101,代码来源:main.cpp

示例11:

EventListItem::EventListItem(BString UID,BString Summary,time_t StartTime):BStringItem(Summary.String()){
	mSummary = Summary;
	mUID = UID;
	mStartTime = StartTime;
	
}
开发者ID:HaikuArchives,项目名称:Borg,代码行数:6,代码来源:monthcell.cpp

示例12: BWindow

KeymapWindow::KeymapWindow()
	:
	BWindow(BRect(80, 50, 880, 380), B_TRANSLATE_SYSTEM_NAME("Keymap"),
		B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{
	SetLayout(new BGroupLayout(B_VERTICAL));

	fKeyboardLayoutView = new KeyboardLayoutView("layout");
	fKeyboardLayoutView->SetKeymap(&fCurrentMap);

	fTextControl = new BTextControl(B_TRANSLATE("Sample and clipboard:"),
		"", NULL);

	fSwitchShortcutsButton = new BButton("switch", "",
		new BMessage(kMsgSwitchShortcuts));

	fRevertButton = new BButton("revertButton", B_TRANSLATE("Revert"),
		new BMessage(kMsgRevertKeymap));

	// controls pane
	AddChild(BGroupLayoutBuilder(B_VERTICAL)
		.Add(_CreateMenu())
		.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
			.Add(_CreateMapLists(), 0.25)
			.Add(BGroupLayoutBuilder(B_VERTICAL, 10)
				.Add(fKeyboardLayoutView)
				//.Add(new BStringView("text label", "Sample and clipboard:"))
				.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
					.Add(_CreateDeadKeyMenuField(), 0.0)
					.AddGlue()
					.Add(fSwitchShortcutsButton))
				.Add(fTextControl)
				.AddGlue(0.0)
				.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
					.AddGlue(0.0)
					.Add(fRevertButton)))
			.SetInsets(10, 10, 10, 10)));

	fKeyboardLayoutView->SetTarget(fTextControl->TextView());
	fTextControl->MakeFocus();

	// Make sure the user keymap directory exists
	BPath path;
	find_directory(B_USER_SETTINGS_DIRECTORY, &path);
	path.Append("Keymap");

	entry_ref ref;
	get_ref_for_path(path.Path(), &ref);

	BDirectory userKeymapsDir(&ref);
	if (userKeymapsDir.InitCheck() != B_OK)
		create_directory(path.Path(), S_IRWXU | S_IRWXG | S_IRWXO);

	BMessenger messenger(this);
	fOpenPanel = new BFilePanel(B_OPEN_PANEL, &messenger, &ref,
		B_FILE_NODE, false, NULL);
	fSavePanel = new BFilePanel(B_SAVE_PANEL, &messenger, &ref,
		B_FILE_NODE, false, NULL);

	BRect windowFrame;
	BString keyboardLayout;
	_LoadSettings(windowFrame, keyboardLayout);
	_SetKeyboardLayout(keyboardLayout.String());

	ResizeTo(windowFrame.Width(), windowFrame.Height());
	MoveTo(windowFrame.LeftTop());

	// TODO: this might be a bug in the interface kit, but scrolling to
	// selection does not correctly work unless the window is shown.
	Show();
	Lock();

	// Try and find the current map name in the two list views (if the name
	// was read at all)
	_SelectCurrentMap();

	KeymapListItem* current
		= static_cast<KeymapListItem*>(fUserListView->FirstItem());

	fCurrentMap.Load(current->EntryRef());
	fPreviousMap = fCurrentMap;
	fAppliedMap = fCurrentMap;
	fCurrentMap.SetTarget(this, new BMessage(kMsgKeymapUpdated));

	_UpdateButtons();

	_UpdateDeadKeyMenu();
	_UpdateSwitchShortcutButton();

	Unlock();
}
开发者ID:,项目名称:,代码行数:91,代码来源:

示例13:

/*!	Marks the menu items corresponding to the dead key state of the current
	key map.
*/
void
KeymapWindow::_UpdateDeadKeyMenu()
{
	BString trigger;
	fCurrentMap.GetDeadKeyTrigger(kDeadKeyAcute, trigger);
	if (!trigger.Length())
		trigger = kDeadKeyTriggerNone;
	BMenuItem* menuItem = fAcuteMenu->FindItem(trigger.String());
	if (menuItem)
		menuItem->SetMarked(true);

	fCurrentMap.GetDeadKeyTrigger(kDeadKeyCircumflex, trigger);
	if (!trigger.Length())
		trigger = kDeadKeyTriggerNone;
	menuItem = fCircumflexMenu->FindItem(trigger.String());
	if (menuItem)
		menuItem->SetMarked(true);

	fCurrentMap.GetDeadKeyTrigger(kDeadKeyDiaeresis, trigger);
	if (!trigger.Length())
		trigger = kDeadKeyTriggerNone;
	menuItem = fDiaeresisMenu->FindItem(trigger.String());
	if (menuItem)
		menuItem->SetMarked(true);

	fCurrentMap.GetDeadKeyTrigger(kDeadKeyGrave, trigger);
	if (!trigger.Length())
		trigger = kDeadKeyTriggerNone;
	menuItem = fGraveMenu->FindItem(trigger.String());
	if (menuItem)
		menuItem->SetMarked(true);

	fCurrentMap.GetDeadKeyTrigger(kDeadKeyTilde, trigger);
	if (!trigger.Length())
		trigger = kDeadKeyTriggerNone;
	menuItem = fTildeMenu->FindItem(trigger.String());
	if (menuItem)
		menuItem->SetMarked(true);
}
开发者ID:,项目名称:,代码行数:42,代码来源:

示例14: TypeLookupConstraints

status_t
CLanguageFamily::ParseTypeExpression(const BString& expression,
	TeamTypeInformation* info, Type*& _resultType) const
{
	status_t result = B_OK;
	Type* baseType = NULL;

	BString parsedName = expression;
	BString baseTypeName;
	BString arraySpecifier;
	parsedName.RemoveAll(" ");

	int32 modifierIndex = -1;
	modifierIndex = parsedName.FindFirst('*');
	if (modifierIndex == -1)
		modifierIndex = parsedName.FindFirst('&');
	if (modifierIndex == -1)
		modifierIndex = parsedName.FindFirst('[');
	if (modifierIndex == -1)
		modifierIndex = parsedName.Length();

	parsedName.MoveInto(baseTypeName, 0, modifierIndex);

	modifierIndex = parsedName.FindFirst('[');
	if (modifierIndex >= 0) {
		parsedName.MoveInto(arraySpecifier, modifierIndex,
			parsedName.Length() - modifierIndex);
	}

	result = info->LookupTypeByName(baseTypeName, TypeLookupConstraints(),
		baseType);
	if (result != B_OK)
		return result;

	BReference<Type> typeRef;
	typeRef.SetTo(baseType, true);

	if (!parsedName.IsEmpty()) {
		AddressType* derivedType = NULL;
		// walk the list of modifiers trying to add each.
		for (int32 i = 0; i < parsedName.Length(); i++) {
			if (!IsModifierValid(parsedName[i]))
				return B_BAD_VALUE;

			address_type_kind typeKind;
			switch (parsedName[i]) {
				case '*':
				{
					typeKind = DERIVED_TYPE_POINTER;
					break;
				}
				case '&':
				{
					typeKind = DERIVED_TYPE_REFERENCE;
					break;
				}
				default:
				{
					return B_BAD_VALUE;
				}

			}

			if (derivedType == NULL) {
				result = baseType->CreateDerivedAddressType(typeKind,
					derivedType);
			} else {
				result = derivedType->CreateDerivedAddressType(typeKind,
					derivedType);
			}

			if (result != B_OK)
				return result;
			typeRef.SetTo(derivedType, true);
		}

		_resultType = derivedType;
	} else
		_resultType = baseType;


	if (!arraySpecifier.IsEmpty()) {
		ArrayType* arrayType = NULL;

		int32 startIndex = 1;
		do {
			int32 size = strtoul(arraySpecifier.String() + startIndex,
				NULL, 10);
			if (size < 0)
				return B_ERROR;

			if (arrayType == NULL) {
				result = _resultType->CreateDerivedArrayType(0, size, true,
					arrayType);
			} else {
				result = arrayType->CreateDerivedArrayType(0, size, true,
					arrayType);
			}

			if (result != B_OK)
//.........这里部分代码省略.........
开发者ID:DonCN,项目名称:haiku,代码行数:101,代码来源:CLanguageFamily.cpp

示例15: autolock

void
TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)
{
	BAutolock autolock(sSubscriberLock);
	if (!autolock.IsLocked())
		return;

	// have we already seen this team, is this another instance of
	// a known app?
	BarTeamInfo* multiLaunchTeam = NULL;
	int32 teamCount = sBarTeamInfoList.CountItems();
	for (int32 i = 0; i < teamCount; i++) {
		BarTeamInfo* barInfo = (BarTeamInfo*)sBarTeamInfoList.ItemAt(i);
		if (barInfo->teams->HasItem((void*)team))
			return;
		if (strcasecmp(barInfo->sig, sig) == 0)
			multiLaunchTeam = barInfo;
	}

	if (multiLaunchTeam != NULL) {
		multiLaunchTeam->teams->AddItem((void*)team);

		int32 subsCount = sSubscribers.CountItems();
		if (subsCount > 0) {
			BMessage message(kAddTeam);
			message.AddInt32("team", team);
			message.AddString("sig", multiLaunchTeam->sig);

			for (int32 i = 0; i < subsCount; i++)
				((BMessenger*)sSubscribers.ItemAt(i))->SendMessage(&message);
		}
		return;
	}

	BFile file(ref, B_READ_ONLY);
	BAppFileInfo appMime(&file);

	BString name;
	if (!gLocalizedNamePreferred
		|| BLocaleRoster::Default()->GetLocalizedFileName(name, *ref) != B_OK)
		name = ref->name;

	BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
		new BBitmap(kIconRect, kIconFormat), strdup(name.String()));

	barInfo->teams->AddItem((void*)team);
	if (appMime.GetIcon(barInfo->icon, B_MINI_ICON) != B_OK)
		appMime.GetTrackerIcon(barInfo->icon, B_MINI_ICON);

	sBarTeamInfoList.AddItem(barInfo);

	if (fSettings.expandNewTeams)
		BarView()->AddExpandedItem(sig);

	int32 subsCount = sSubscribers.CountItems();
	if (subsCount > 0) {
		for (int32 i = 0; i < subsCount; i++) {
			BMessenger* messenger = (BMessenger*)sSubscribers.ItemAt(i);
			BMessage message(B_SOME_APP_LAUNCHED);

			BList* tList = new BList(*(barInfo->teams));
			message.AddPointer("teams", tList);

			BBitmap* icon = new BBitmap(barInfo->icon);
			ASSERT(icon);

			message.AddPointer("icon", icon);

			message.AddInt32("flags", static_cast<int32>(barInfo->flags));
			message.AddString("name", barInfo->name);
			message.AddString("sig", barInfo->sig);

			messenger->SendMessage(&message);
		}
	}
}
开发者ID:,项目名称:,代码行数:76,代码来源:


注:本文中的BString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。