本文整理汇总了C++中BListView类的典型用法代码示例。如果您正苦于以下问题:C++ BListView类的具体用法?C++ BListView怎么用?C++ BListView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BListView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MessageReceived
void MessageReceived(BMessage *msg)
{
BListView *list;
int32 curItem;
switch (msg->what)
{
case MSG_SHARE_SELECT:
break;
case MSG_SHARE_INVOKE:
msg->FindPointer("source", (void **) &list);
curItem = list->CurrentSelection();
if (curItem != -1)
{
CLVEasyItem *item = (CLVEasyItem *) MyColumnListView->ItemAt(curItem);
if (item)
{
const char *share = item->GetColumnContentText(1);
const char *type = item->GetColumnContentText(2);
if (strcmp(type, "Shared Files") == 0)
mountToLocalFolder(host, (char *) share);
else
createSharedPrinter(host, (char *) share, 0);
}
}
break;
default:
BWindow::MessageReceived(msg);
break;
}
}
示例2: DWindow
AsciiWindow::AsciiWindow(void)
:
DWindow(BRect(0.0f, 0.0f, kWindowWidth, kWindowHeight),
B_TRANSLATE("ASCII table"), B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS),
fIsZoomed(false),
fLastFrame(Frame())
{
BListView* listView = new BListView("listView", B_MULTIPLE_SELECTION_LIST,
B_WILL_DRAW);
BScrollView* listScrollView = new BScrollView("scrollView", listView, 0,
false, true, B_NO_BORDER);
listView->SetFont(be_fixed_font);
listView->AddItem(new BStringItem(B_TRANSLATE(" Dec Hex Oct Code Description")));
listView->AddItem(new BStringItem(""));
for (int i = 0; i < 128; i++) {
char* row;
asprintf(&row, " %3d %2x %3o %3s %s", i, i, i,
sAsciiTable[i].code, sAsciiTable[i].description.String());
listView->AddItem(new BStringItem(row));
free(row);
}
BLayoutBuilder::Group<>(this, B_VERTICAL)
.Add(listScrollView)
.SetInsets(-1)
.End();
CenterOnScreen();
}
示例3: str
status_t
PListView::SetProperty(const char *name, PValue *value, const int32 &index)
{
if (!name || !value)
return B_ERROR;
BString str(name);
PProperty *prop = FindProperty(name,index);
if (!prop)
return B_NAME_NOT_FOUND;
if (FlagsForProperty(prop) & PROPERTY_READ_ONLY)
return B_READ_ONLY;
BListView *backend = (BListView*)fView;
BoolValue boolval;
CharValue charval;
ColorValue colorval;
FloatValue floatval;
IntValue intval;
PointValue pointval;
RectValue rectval;
StringValue stringval;
status_t status = prop->SetValue(value);
if (status != B_OK)
return status;
if (backend->Window())
backend->Window()->Lock();
else if (str.ICompare("SelectionMessage") == 0)
{
BMessage selMsg(*intval.value);
backend->SetSelectionMessage(&selMsg);
}
else if (str.ICompare("InvocationMessage") == 0)
{
BMessage invMsg(*intval.value);
backend->SetInvocationMessage(&invMsg);
}
else if (str.ICompare("SelectionType") == 0)
{
prop->GetValue(&intval);
backend->SetListType((list_view_type)*intval.value);
}
else
{
if (backend->Window())
backend->Window()->Unlock();
return PView::SetProperty(name, value, index);
}
if (backend->Window())
backend->Window()->Unlock();
return prop->GetValue(value);
}
示例4: Init
void TQueueDialog::Init()
{
//
// Locate all child views
//
// Find buttons
m_StopButton = (BButton *)FindView("StopButton");
m_StartButton = (BButton *)FindView("StartButton");
m_AddButton = (BButton *)FindView("AddButton");
m_RemoveButton = (BButton *)FindView("RemoveButton");
// Find and setup list view
m_TracksListScrollView = (BScrollView *)FindView("TracksListScrollView");
BListView *tracksListView = (BListView *)FindView("TracksListView");
BRect frame = tracksListView->Frame();
frame.InsetBy(2, 2);
m_TracksListView = new TQueueListView(this, frame);
tracksListView->Parent()->AddChild(m_TracksListView);
tracksListView->RemoveSelf();
delete tracksListView;
// Set list view messages
BMessage *selectMessage = new BMessage(QUEUE_LIST_SELECT_MSG);
m_TracksListView->SetSelectionMessage(selectMessage);
BMessage *invokeMessage = new BMessage(QUEUE_LIST_INVOKE_MSG);
m_TracksListView->SetInvocationMessage(invokeMessage);
// Find status bar
m_EncodeStatusBar = (BStatusBar *)FindView("EncodeStatusBar");
m_EncodeStatusBar->Reset("Waiting...", "");
UpdateControls();
}
示例5: getListView
/**
* @brief Stops or restarts selection changed notification.
* @param[in] doStop true to stop, false to restart.
*/
void BeListViewAdapter::StopSelectionChangedNotification(bool doStop)
{
BListView* listView = getListView();
if (doStop)
{
if (0 == stoppedSelectionChangedNotificationCount)
{
BMessage* message = listView->SelectionMessage();
if (NULL != message)
{
stoppedSelectionChangedCommand = message->what;
message->what = ID_NULL;
}
}
stoppedSelectionChangedNotificationCount++;
}
else
{
stoppedSelectionChangedNotificationCount--;
if (0 == stoppedSelectionChangedNotificationCount)
{
BMessage* message = listView->SelectionMessage();
if (NULL != message)
{
message->what = stoppedSelectionChangedCommand;
stoppedSelectionChangedCommand = ID_NULL;
}
}
}
}
示例6: TRACE
void NavigatorEditor::InsertNewList(BListView *source)
{
TRACE();
int32 selection = -1;
BaseListItem *item = NULL;
selection = source->CurrentSelection(0);
if (selection>=0)
{
item =(BaseListItem *) source->ItemAt(selection);
//vorher alle überfüssigen Views löschen
BView *sibling=source->Parent()->NextSibling();
while (sibling != NULL)
{
RemoveChild(sibling);
sibling=source->Parent()->NextSibling();
}
if (item->GetSupportedType() == P_C_CLASS_TYPE)
{
BRect listrect = Bounds();
listrect.left = source->Parent()->Frame().right+5;
listrect.right = listrect.left +400;
if (listrect.right > Bounds().right)
{
ResizeTo(listrect.right+B_V_SCROLL_BAR_WIDTH+5,Bounds().bottom);
}
BListView *list = new MessageListView(doc,listrect,((NodeItem *)item)->GetNode());
BMessage *invoked = new BMessage(N_A_INVOKATION);
invoked->AddPointer("ListView",list);
list->SetInvocationMessage(invoked);
list->SetTarget(this);
AddChild(new BScrollView("root",list,B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM,0,false,true));
}
Invalidate();
}
}
示例7: modifyGuide
void GuideWindow::deleteGuide(BMessage *msg)
{
BStringItem *item = modifyGuide(msg);
BListView *view = getCurrentListView();
view->RemoveItem(item);
view->Select(0);
view->ScrollToSelection();
}
示例8: BeGenericDataStringItem
/**
* @brief Adds one item to the control.
* @param[in] text item text.
* @param[in] data associated data of adding item.
* @return the index of added item.
*/
SInt32 BeListViewAdapter::AddItem(ConstAStr text, void* data)
{
BeGenericDataStringItem* listItem = new BeGenericDataStringItem(text);
listItem->SetItemData(data);
BListView* listView = getListView();
listView->AddItem(listItem);
return listView->CountItems() - 1;
}
示例9: BView
HostInfoView::HostInfoView(BRect rect, const char *name, uint32 ipAddr)
: BView(rect, "HostInfoView", B_FOLLOW_ALL, B_WILL_DRAW)
{
address = ipAddr;
hostInfo.cpus = 0;
thread_id infoThread = spawn_thread(getHostInfo, "Get Host Info", B_NORMAL_PRIORITY, this);
resume_thread(infoThread);
rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(gray);
BRect bmpRect(0.0, 0.0, 31.0, 31.0);
icon = new BBitmap(bmpRect, B_CMAP8);
BMimeType mime("application/x-vnd.BeServed-fileserver");
mime.GetIcon(icon, B_LARGE_ICON);
BRect r(40, 55, 230, 120);
BListView *aliasList = new BListView(r, "Aliases", B_SINGLE_SELECTION_LIST);
AddChild(new BScrollView("ScrollAliases", aliasList, B_FOLLOW_LEFT | B_FOLLOW_TOP,
0, false, true));
r.top = 145;
r.bottom = 210;
BListView *addressList = new BListView(r, "Addresses", B_SINGLE_SELECTION_LIST);
AddChild(new BScrollView("ScrollAddresses", addressList, B_FOLLOW_LEFT | B_FOLLOW_TOP,
0, false, true));
r.top = 275;
r.bottom = 305;
r.left = 38;
r.right = 245;
status = new BStatusBar(r, "Connections");
status->SetBarHeight(13.0);
AddChild(status);
ent = gethostbyaddr((char *) &ipAddr, sizeof(ipAddr), AF_INET);
if (ent)
{
char buf[50];
int i;
for (i = 0; ent->h_aliases[i] != 0; i++)
aliasList->AddItem(new BStringItem(ent->h_aliases[i]));
for (i = 0; ent->h_addr_list[i] != 0; i++)
{
sprintf(buf, "%d.%d.%d.%d", (uint8) ent->h_addr_list[i][0], (uint8) ent->h_addr_list[i][1],
(uint8) ent->h_addr_list[i][2], (uint8) ent->h_addr_list[i][3]);
addressList->AddItem(new BStringItem(buf));
}
}
}
示例10: getCurrentListView
BStringItem * GuideWindow::getFocusSelectedItem()
{
BListView *view;
view = getCurrentListView();
int32 sel = view->CurrentSelection();
if(sel >= 0) {
return (BStringItem *)view->ItemAt(sel);
}
return NULL;
}
示例11: 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) ;
}
示例12: PListViewInvoke
int32_t
PListViewInvoke(void *pobject, void *in, void *out, void *extraData)
{
if (!pobject || !in || !out)
return B_ERROR;
PView *parent = static_cast<PView*>(pobject);
if (!parent)
return B_BAD_TYPE;
BListView *backend = (BListView*)parent->GetView();
PArgs *args = static_cast<PArgs*>(in);
int32 what;
if (args->FindInt32("message", &what) != B_OK)
what = -1;
if (backend->Window())
backend->Window()->Lock();
if (what >= 0)
{
BMessage invMsg(what);
backend->Invoke(&invMsg);
}
else
backend->Invoke();
if (backend->Window())
backend->Window()->Unlock();
return B_OK;
}
示例13: iupdrvListRemoveItem
void iupdrvListRemoveItem(Ihandle* ih, int pos)
{
BView* view = (BView*)ih->handle;
BMenuField* menu = dynamic_cast<BMenuField*>(view);
if(menu)
{
UNIMPLEMENTED
return;
}
BListView* listview = iuphaikuGetListView(view);
if(listview) {
BListItem* item = listview->RemoveItem(pos - 1);
delete item;
} else {
fprintf(stderr, "View hierarchy problem\n");
}
}
示例14: FixupScrollbars
void MainView::FixupScrollbars()
{
return;
BRect bounds=(Bounds()).InsetBySelf(5, 5);
bounds.right -= B_V_SCROLL_BAR_WIDTH;
bounds.bottom -= B_H_SCROLL_BAR_HEIGHT;
BScrollBar *sb;
BListView* listView = (BListView*)this->FindView("list");
float ratio=1, realRectWidth=1, realRectHeight=1;
if (!listView || !scrollView) { return; }
listView->GetPreferredSize(&realRectWidth, &realRectHeight);
realRectHeight = listView->CountItems() * 18;
realRectWidth += 15 + B_V_SCROLL_BAR_WIDTH;
sb = scrollView->ScrollBar(B_HORIZONTAL);
if (sb) {
ratio = bounds.Width() / (float)realRectWidth;
sb->SetRange(0, realRectWidth-bounds.Width());
if (ratio >= 1) {
sb->SetProportion(1);
} else {
sb->SetProportion(ratio);
}
}
sb = scrollView->ScrollBar(B_VERTICAL);
if (sb) {
ratio = bounds.Height() / (float)realRectHeight;
sb->SetRange(0, realRectHeight+2);
if (ratio >= 1) {
sb->SetProportion(1);
} else {
sb->SetProportion(ratio);
}
}
}
示例15: PListViewRemoveItem
int32_t
PListViewRemoveItem(void *pobject, void *in, void *out, void *extraData)
{
if (!pobject || !in || !out)
return B_ERROR;
PView *parent = static_cast<PView*>(pobject);
if (!parent)
return B_BAD_TYPE;
BListView *backend = (BListView*)parent->GetView();
PArgs *args = static_cast<PArgs*>(in), *outArgs = static_cast<PArgs*>(out);
int32 index;
if (args->FindInt32("index", &index) != B_OK)
return B_ERROR;
if (backend->Window())
backend->Window()->Lock();
bool outValue = backend->RemoveItems(index, 1);
if (backend->Window())
backend->Window()->Unlock();
outArgs->MakeEmpty();
outArgs->AddBool("value", outValue);
return B_OK;
}