예제 #1
0
		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;
			}
		}
// Stuff we can only do when the main view is attached to a window
void
OutputFormatView::AttachedToWindow()
{
	// Get the window and lock it
	the_window = Window();
	the_window->Lock();

	// Set some size limits on the window
	the_window->SetSizeLimits(
		200.0,
		32767.0,
		Bounds().Height() - scroll_view->Bounds().Height() + 50.0,
		32767.0);
	// Set the target for messages sent to this view
	list_view->SetTarget(this);
	the_button->SetTarget(this);

	// Make the list view the keyboard focus
	list_view->MakeFocus();

	// Select the first item in the list,
	// and make its config view show up
	if (list_view->CountItems() > 0)
		list_view->Select(0);
	else
		the_button->SetEnabled(false);

	// Unlock the window
	the_window->Unlock();

	// Call the base class
	BView::AttachedToWindow();
}
예제 #3
0
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();
}
예제 #4
0
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);
}
예제 #5
0
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();	
}
/**
 *	@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;
			}
		}
	}
}
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();
	}
}
예제 #8
0
void
ModulesView::EmptyScreenSaverList()
{
	fScreenSaversListView->DeselectAll();
	while (BListItem* item = fScreenSaversListView->RemoveItem((int32)0))
		delete item;
}
예제 #9
0
void GuideWindow::deleteGuide(BMessage *msg)
{
	BStringItem *item = modifyGuide(msg);
	BListView *view = getCurrentListView();
	view->RemoveItem(item);
	view->Select(0);
	view->ScrollToSelection();
}
/**
 *	@brief	Sets a string at specified index from the control.
 *	@param[in]	index	index
 *	@param[out]	text	a string value to set.
 */
void BeListViewAdapter::SetItemText(SInt32 index, ConstAStr text)
{
	BListView* listView = getListView();
	BeGenericDataStringItem* listItem = dynamic_cast<BeGenericDataStringItem*>(listView->ItemAt(index));
	if (NULL != listItem)
	{
		listItem->SetText(text);
	}
}
/**
 *	@brief	Sets associated data of specified index.
 *	@param[in]	index	item index.
 *	@param[in]	data	associated data.
 */
void BeListViewAdapter::SetItemData(SInt32 index, void* data)
{
	BListView* listView = getListView();
	BeGenericDataStringItem* listItem = dynamic_cast<BeGenericDataStringItem*>(listView->ItemAt(index));
	if (NULL != listItem)
	{
		listItem->SetItemData(data);
	}
}
/**
 *	@brief	Removes one item from the control.
 *	@param[in]	index	item index.
 */
void BeListViewAdapter::RemoveItem(SInt32 index)
{
	BListView* listView = getListView();
	BListItem* listItem = listView->RemoveItem(index);
	if (NULL != listItem)
	{
		delete listItem;
	}
}
/**
 *	@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;
}
/**
 *	@brief	Makes specified item selected.
 *	@param[in]	index	item index. if this is -1, no item is selected.
 */
void BeListViewAdapter::SetSelectedItem(SInt32 index)
{
	BListView* listView = getListView();
	int32 current = listView->CurrentSelection(0);
	if (current != index)
	{
		listView->DeselectAll();
		listView->Select(index);
	}
}
예제 #15
0
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));
		}
	}
}
/**
 *	@brief	Returns an index of selected item.
 *	@return	item index of selected item. or -1 if no item is selected.
 */
SInt32 BeListViewAdapter::GetSelectedItem()
{
	BListView* listView = getListView();
	int32 ret = listView->CurrentSelection(0);
	if (ret < 0)
	{
		return -1;
	}
	else
	{
		return ret;
	}
}
예제 #17
0
BStringItem * GuideWindow::getFocusSelectedItem()
{
	BListView *view;
	
	view = getCurrentListView();
	
	int32 sel = view->CurrentSelection();
	if(sel >= 0) {
		return (BStringItem *)view->ItemAt(sel);		
	}
	
	return NULL;
}
/**
 *	@brief	Returns associated data of specified index.
 *	@param[in]	index	item index.
 *	@return	associated data.
 */
void* BeListViewAdapter::GetItemData(SInt32 index)
{
	BListView* listView = getListView();
	BeGenericDataStringItem* listItem = dynamic_cast<BeGenericDataStringItem*>(listView->ItemAt(index));
	if (NULL != listItem)
	{
		return listItem->GetItemData();
	}
	else
	{
		return NULL;
	}
}
/**
 *	@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();
	}
}
/**
 *	@brief	Removes all item from the control.
 */
void BeListViewAdapter::RemoveAllItem()
{
	BListView* listView = getListView();
	int32 count = listView->CountItems();
	int32 index;
	for (index = count - 1; index >= 0; index--)
	{
		BListItem* listItem = listView->RemoveItem(index);
		if (NULL != listItem)
		{
			delete listItem;
		}
	}
}
예제 #21
0
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) ;
}
예제 #22
0
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;
}
예제 #23
0
void
ModulesView::AttachedToWindow()
{
	_OpenSaver();

	fScreenSaversListView->SetTarget(this);
	fTestButton->SetTarget(this);
	fAddButton->SetTarget(this);
}
예제 #24
0
void
ModulesView::PopulateScreenSaverList()
{
 	fScreenSaversListView->DeselectAll();
	while (ScreenSaverItem* item
			= (ScreenSaverItem*)fScreenSaversListView->RemoveItem((int32)0)) {
		delete item;
	}

	// Blackness is a built-in screen saver
	fScreenSaversListView->AddItem(
		new ScreenSaverItem(B_TRANSLATE("Blackness"), ""));

	// Iterate over add-on directories, and add their files to the list view

	directory_which which[] = {
		B_USER_ADDONS_DIRECTORY,
		B_COMMON_ADDONS_DIRECTORY,
		B_SYSTEM_ADDONS_DIRECTORY,
	};
	ScreenSaverItem* selectItem = NULL;

	for (uint32 i = 0; i < sizeof(which) / sizeof(which[0]); i++) {
		BPath basePath;
		find_directory(which[i], &basePath);
		basePath.Append("Screen Savers", true);

		BDirectory dir(basePath.Path());
		BEntry entry;
		while (dir.GetNextEntry(&entry, true) == B_OK) {
			char name[B_FILE_NAME_LENGTH];
			if (entry.GetName(name) != B_OK)
				continue;

			BPath path = basePath;
			path.Append(name);

			ScreenSaverItem* item = new ScreenSaverItem(name, path.Path());
			fScreenSaversListView->AddItem(item);

			if (strcmp(fSettings.ModuleName(), item->Text()) != 0
				|| (strcmp(fSettings.ModuleName(), "") != 0
					&& strcmp(item->Text(), B_TRANSLATE("Blackness")) != 0)) {
				selectItem = item;
			}
		}
	}

	fScreenSaversListView->SortItems(_CompareScreenSaverItems);

	fScreenSaversListView->Select(fScreenSaversListView->IndexOf(selectItem));
	fScreenSaversListView->ScrollToSelection();
}
예제 #25
0
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");
  }
}
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);
		}
	}
}
예제 #27
0
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;
}
예제 #28
0
int32_t
PListViewScrollTo(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 *inArgs = static_cast<PArgs*>(in);

	float x;
	if (inArgs->FindFloat("x", &x) != B_OK)
		return B_ERROR;

	float y;
	if (inArgs->FindFloat("y", &y) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();


	backend->ScrollTo(x, y);

	if (backend->Window())
		backend->Window()->Unlock();

	return B_OK;
}
예제 #29
0
int32_t
PListViewScrollToPoint(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 *inArgs = static_cast<PArgs*>(in);

	BPoint pt;
	if (inArgs->FindPoint("pt", &pt) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();


	backend->ScrollTo(pt);

	if (backend->Window())
		backend->Window()->Unlock();

	return B_OK;
}
예제 #30
0
int32_t
PListViewSelect(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 *inArgs = static_cast<PArgs*>(in);

	int32 index;
	if (inArgs->FindInt32("index", &index) != B_OK)
		return B_ERROR;

	bool extend;
	if (inArgs->FindBool("extend", &extend) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();


	backend->Select(index, extend);

	if (backend->Window())
		backend->Window()->Unlock();

	return B_OK;
}