本文整理汇总了C++中BStringItem::Text方法的典型用法代码示例。如果您正苦于以下问题:C++ BStringItem::Text方法的具体用法?C++ BStringItem::Text怎么用?C++ BStringItem::Text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BStringItem
的用法示例。
在下文中一共展示了BStringItem::Text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenTable
//Opens the table that is currently selected using the given view. Or, if the table
//is already open, brings it to the front.
void BeAccessibleWindow::OpenTable(int view)
{
DBTabView* tab = (DBTabView*)fTabView->GetCurrentTab();
BStringItem* selectedTable;
//Find the currently selected table
if (tab->fListView->CurrentSelection() >= 0)
{
selectedTable = (BStringItem*)tab->fListView->ItemAt(
tab->fListView->CurrentSelection() );
}
else
{
//No table is selected
return;
}
if (!WindowExists(selectedTable->Text()))
{
//Open a new table window if it isn't already
fNewGrid = new TableWindow(view, selectedTable->Text());
}
else
{
//If the table is already open, bring it to the front
BringWindowToFront(selectedTable->Text());
}
}
示例2: parentDomain
BStringItem*
CookieWindow::_AddDomain(BString domain, bool fake)
{
BStringItem* parent = NULL;
int firstDot = domain.FindFirst('.');
if (firstDot >= 0) {
BString parentDomain(domain);
parentDomain.Remove(0, firstDot + 1);
parent = _AddDomain(parentDomain, true);
} else {
parent = (BStringItem*)fDomains->FullListItemAt(0);
}
BListItem* existing;
int i = 0;
// check that we aren't already there
while ((existing = fDomains->ItemUnderAt(parent, true, i++)) != NULL) {
DomainItem* stringItem = (DomainItem*)existing;
if (stringItem->Text() == domain) {
if (fake == false)
stringItem->fEmpty = false;
return stringItem;
}
}
#if 0
puts("==============================");
for (i = 0; i < fDomains->FullListCountItems(); i++) {
BStringItem* t = (BStringItem*)fDomains->FullListItemAt(i);
for (unsigned j = 0; j < t->OutlineLevel(); j++)
printf(" ");
printf("%s\n", t->Text());
}
#endif
// Insert the new item, keeping the list alphabetically sorted
BStringItem* domainItem = new DomainItem(domain, fake);
domainItem->SetOutlineLevel(parent->OutlineLevel() + 1);
BStringItem* sibling = NULL;
int siblingCount = fDomains->CountItemsUnder(parent, true);
for (i = 0; i < siblingCount; i++) {
sibling = (BStringItem*)fDomains->ItemUnderAt(parent, true, i);
if (strcmp(sibling->Text(), domainItem->Text()) > 0) {
fDomains->AddItem(domainItem, fDomains->FullListIndexOf(sibling));
return domainItem;
}
}
if (sibling) {
// There were siblings, but all smaller than what we try to insert.
// Insert after the last one (and its subitems)
fDomains->AddItem(domainItem, fDomains->FullListIndexOf(sibling)
+ fDomains->CountItemsUnder(sibling, false) + 1);
} else {
// There were no siblings, insert right after the parent
fDomains->AddItem(domainItem, fDomains->FullListIndexOf(parent) + 1);
}
return domainItem;
}
示例3: NaturalCompare
static int
StringItemComp(const BListItem* first, const BListItem* second)
{
BStringItem* firstItem = (BStringItem*)first;
BStringItem* secondItem = (BStringItem*)second;
return BPrivate::NaturalCompare(firstItem->Text(), secondItem->Text());
}
示例4: OKClicked
bool CPasteFunctionDialog::OKClicked()
{
bool result = true;
BStringItem *item = (BStringItem *)fList->ItemAt(fList->CurrentSelection());
char *cp;
if (item)
{
BMessage msg(msg_FunctionChosen);
const char *s = item->Text();
msg.AddString("string", item->Text());
if (strstr(s, "()") != NULL)
;
else if ((cp = strchr(s, '(')) != NULL)
{
int start;
start = cp - s + 1;
int end = 0;
char *sp;
if ((sp = strchr(cp, gListSeparator)) != NULL)
{
end = sp - cp - 1;
}
if (!end && (sp = strchr(cp, ')')) != NULL)
{
end = sp - cp - 1;
}
if (!end)
end = strlen(s) - start - 1;
msg.AddInt32("start", start);
msg.AddInt32("stop", end);
}
fOwner->PostMessage(&msg, fOwner->GetEditBox());
}
else
result = false;
return result;
} /* CPasteFunctionDialog::OKClicked */
示例5:
void
CookieWindow::MessageReceived(BMessage* message)
{
switch(message->what) {
case DOMAIN_SELECTED:
{
int32 index = message->FindInt32("index");
BStringItem* item = (BStringItem*)fDomains->ItemAt(index);
if (item != NULL) {
BString domain = item->Text();
_ShowCookiesForDomain(domain);
}
return;
}
case COOKIE_REFRESH:
_BuildDomainList();
return;
case COOKIE_DELETE:
_DeleteCookies();
return;
}
BWindow::MessageReceived(message);
}
示例6: Save
// Gets the user's selection, and parses it up to get the server,
// then formats a BMessage and sends it to whomever opened the window.
void InexactMatchWindow::Save()
{
const char *selectedText;
int selection = cdList->CurrentSelection();
if (selection < 0)
{
beep();
return;
}
// Copy the selected string.
BStringItem *item;
item = (BStringItem *) cdList->ItemAt(selection);
selectedText = item->Text();
char *parseStr= new char[strlen(selectedText)+1];
strcpy(parseStr,selectedText);
char *disc_id;
char *category;
// Send the response to the CDDB looper
category = strtok(parseStr," ");
disc_id = strtok(NULL," ");
printf("Category is %s.\n",category);
printf("New ID is %s.\n",disc_id);
BMessage *msg = new BMessage(CDDB_READ);
msg->AddString("category",category);
msg->AddString("disc_id",disc_id);
replyTo.SendMessage(msg);
delete parseStr;
PostMessage(B_QUIT_REQUESTED);
}
示例7: file
void
MidiSettingsView::_LoadSettings()
{
// TODO: Duplicated code between here
// and BSoftSynth::SetDefaultInstrumentsFile
char buffer[512];
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
path.Append(SETTINGS_FILE);
BFile file(path.Path(), B_READ_ONLY);
if (file.InitCheck() == B_OK) {
file.Read(buffer, sizeof(buffer));
char soundFont[512];
sscanf(buffer, "# Midi Settings\n soundfont = %s\n",
soundFont);
for (int32 i = 0; i < fListView->CountItems(); i++) {
BStringItem* item = (BStringItem*)fListView->ItemAt(i);
if (!strcmp(item->Text(), soundFont)) {
fListView->Select(i);
break;
}
}
}
}
}
示例8: FindInIndex
void BrowseView::FindInIndex(bool select, const char *s)
{
if (s==NULL)
s = searchTextView->Text();
BString str(s);
if(!containsSearch)
{
unsigned int nL = linksList->CountItems();
for (unsigned int i=0; i<nL; i++)
{
BStringItem *it = (BStringItem*)linksList->ItemAt(i);
if (str.ICompare(it->Text()) <= 0)
{
BRect r = linksList->ItemFrame(i);
linksList->ScrollTo(r.LeftTop());
if (select)
linksList->Select(i);
break;
}
}
}
else
{
tasks->GiveUp();
linksList->MakeEmpty();
if (str == "")
return;
tasks->DoFindInIndex(str,this,select);
}
}
示例9: BAlert
void
GrepWindow::_OnTrimSelection()
{
if (fSearchResults->CurrentSelection() < 0) {
BString text;
text << B_TRANSLATE("Please select the files you wish to keep searching.");
text << "\n";
text << B_TRANSLATE("The unselected files will be removed from the list.");
text << "\n";
BAlert* alert = new BAlert(NULL, text.String(), B_TRANSLATE("OK"), NULL, NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go(NULL);
return;
}
BMessage message;
BString path;
for (int32 index = 0; ; index++) {
BStringItem* item = dynamic_cast<BStringItem*>(
fSearchResults->ItemAt(index));
if (item == NULL)
break;
if (!item->IsSelected() || item->OutlineLevel() != 0)
continue;
if (path == item->Text())
continue;
path = item->Text();
entry_ref ref;
if (get_ref_for_path(path.String(), &ref) == B_OK)
message.AddRef("refs", &ref);
}
fModel->fDirectory = entry_ref();
// invalidated on purpose
fModel->fSelectedFiles.MakeEmpty();
fModel->fSelectedFiles = message;
PostMessage(MSG_START_CANCEL);
_SetWindowTitle();
}
示例10:
void
GrepWindow::_OnCopyText()
{
bool onlyCopySelection = true;
if (fSearchResults->CurrentSelection() < 0)
onlyCopySelection = false;
BString buffer;
for (int32 index = 0; ; index++) {
BStringItem* item = dynamic_cast<BStringItem*>(
fSearchResults->ItemAt(index));
if (item == NULL)
break;
if (onlyCopySelection) {
if (item->IsSelected())
buffer << item->Text() << "\n";
} else
buffer << item->Text() << "\n";
}
status_t status = B_OK;
BMessage* clip = NULL;
if (be_clipboard->Lock()) {
be_clipboard->Clear();
clip = be_clipboard->Data();
clip->AddData("text/plain", B_MIME_TYPE, buffer.String(),
buffer.Length());
status = be_clipboard->Commit();
if (status != B_OK) {
be_clipboard->Unlock();
return;
}
be_clipboard->Unlock();
}
}
示例11: SetList
void FreqWindow::SetList(){
BStringItem *it = NULL;
for (int32 i=0; i<list->CountItems(); i++){
it = (BStringItem*)list->ItemAt(i);
it->Deselect();
float frequency = atof( it->Text() );
if (Pool.frequency == frequency){ it->Select(); text->SetValue(Pool.frequency); }
}
}
示例12: GetItemText
/**
* @brief Gets a string at specified index from the control.
* @param[in] index index
* @param[out] text a string value is returned.
*/
void BeListViewAdapter::GetItemText(SInt32 index, MBCString& text)
{
BListView* listView = getListView();
BStringItem* listItem = dynamic_cast<BStringItem*>(listView->ItemAt(index));
if (NULL != listItem)
{
text = listItem->Text();
}
else
{
text.Empty();
}
}
示例13:
void
KeymapWindow::_SetListViewSize(BListView* listView)
{
float minWidth = 0;
for (int32 i = 0; i < listView->CountItems(); i++) {
BStringItem* item = (BStringItem*)listView->ItemAt(i);
float width = listView->StringWidth(item->Text());
if (width > minWidth)
minWidth = width;
}
listView->SetExplicitMinSize(BSize(minWidth + 8, 32));
}
示例14: entry
void
SearchApp::LaunchFile(BMessage *message)
{
BListView *searchResults ;
int32 index ;
message->FindPointer("source", (void**)&searchResults) ;
message->FindInt32("index", &index) ;
BStringItem *result = (BStringItem*)searchResults->ItemAt(index) ;
entry_ref ref ;
BEntry entry(result->Text()) ;
entry.GetRef(&ref) ;
be_roster->Launch(&ref) ;
}
示例15: atol
void
GrepWindow::_OnInvokeItem()
{
for (int32 selectionIndex = 0; ; selectionIndex++) {
int32 itemIndex = fSearchResults->CurrentSelection(selectionIndex);
BListItem* item = fSearchResults->ItemAt(itemIndex);
if (item == NULL)
break;
int32 level = item->OutlineLevel();
int32 lineNum = -1;
// Get the line number.
// only this level has line numbers
if (level == 1) {
BStringItem* str = dynamic_cast<BStringItem*>(item);
if (str != NULL) {
lineNum = atol(str->Text());
// fortunately, atol knows when to stop the conversion
}
}
// Get the top-most item and launch its entry_ref.
while (level != 0) {
item = fSearchResults->Superitem(item);
if (item == NULL)
break;
level = item->OutlineLevel();
}
ResultItem* entry = dynamic_cast<ResultItem*>(item);
if (entry != NULL) {
bool done = false;
if (fModel->fInvokePe)
done = _OpenInPe(entry->ref, lineNum);
if (!done)
be_roster->Launch(&entry->ref);
}
}
}