Exemple #1
0
void
AddOnManager::MessageReceived(BMessage* message)
{
	CALLED();

	BMessage reply;
	status_t status;

	ERROR("%s what: %.4s\n", __PRETTY_FUNCTION__, (char*)&message->what);

	switch (message->what) {
		case IS_FIND_DEVICES:
			status = _HandleFindDevices(message, &reply);
			break;
		case IS_WATCH_DEVICES:
			status = _HandleWatchDevices(message, &reply);
			break;
		case IS_IS_DEVICE_RUNNING:
			status = _HandleIsDeviceRunning(message, &reply);
			break;
		case IS_START_DEVICE:
			status = _HandleStartStopDevices(message, &reply);
			break;
		case IS_STOP_DEVICE:
			status = _HandleStartStopDevices(message, &reply);
			break;
		case IS_CONTROL_DEVICES:
			status = _HandleControlDevices(message, &reply);
			break;
		case SYSTEM_SHUTTING_DOWN:
			status = _HandleSystemShuttingDown(message, &reply);
			break;
		case IS_METHOD_REGISTER:
			status = _HandleMethodReplicant(message, &reply);
			break;

		case B_PATH_MONITOR:
			_HandleDeviceMonitor(message);
			return;

		default:
			return;
	}

	reply.AddInt32("status", status);
	message->SendReply(&reply);
}
void
ScreenshotWindow::_WriteSettings()
{
	if (fDelayControl)
		fDelay = (atoi(fDelayControl->Text()) * 1000000) + 50000;

	BMessage settings;

	settings.AddInt32("type", fImageFileType);
	settings.AddBool("includeBorder", fIncludeBorder);
	settings.AddBool("includeCursor", fIncludeCursor);
	settings.AddBool("grabActiveWindow", fGrabActiveWindow);
	settings.AddInt64("delay", fDelay);
	settings.AddString("outputFilename", fOutputFilename);

	BString path;
	int32 count = fOutputPathMenu->CountItems();
	if (count > 5) {
		for (int32 i = count - 3; i > count - 8 && i > 2; --i) {
			BMenuItem* item = fOutputPathMenu->ItemAt(i);
			if (item) {
				BMessage* msg = item->Message();
				if (msg && msg->FindString("path", &path) == B_OK)
					settings.AddString("path", path.String());
			}
		}
	}

	if (fLastSelectedPath) {
		BMessage* msg = fLastSelectedPath->Message();
		if (msg && msg->FindString("path", &path) == B_OK)
			settings.AddString("lastSelectedPath", path.String());
	}

	BPath settingsPath;
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &settingsPath) != B_OK)
		return;
	settingsPath.Append("Screenshot_settings");

	BFile file(settingsPath.Path(), B_CREATE_FILE | B_ERASE_FILE
		| B_WRITE_ONLY);
	if (file.InitCheck() == B_OK) {
		ssize_t size;
		settings.Flatten(&file, &size);
	}
}
//------------------------------------------------------------------------------
void WindowEditor::InitLookMenu()
{
	BPopUpMenu *menu = new BPopUpMenu("Document Window");
	BMessage *msg;
	for (int i = 0; WindowLooks[i].label; ++i)
	{
		msg = new BMessage(MSG_WINDOW_SET_LOOK);
		msg->AddInt32("newlook", WindowLooks[i].message);
		menu->AddItem(new BMenuItem(WindowLooks[i].label, msg));
	}
#if 0
	msg = new BMessage(MSG_WINDOW_SET_LOOK);
	msg->AddInt32("newlook",B_TITLED_WINDOW_LOOK);
	menu->AddItem(new BMenuItem("Titled Window",msg));
	msg = new BMessage(MSG_WINDOW_SET_LOOK);
	msg->AddInt32("newlook",B_FLOATING_WINDOW_LOOK);
	menu->AddItem(new BMenuItem("Floating Window",msg));
	msg = new BMessage(MSG_WINDOW_SET_LOOK);
	msg->AddInt32("newlook",B_MODAL_WINDOW_LOOK);
	menu->AddItem(new BMenuItem("Modal Window",msg));
	msg = new BMessage(MSG_WINDOW_SET_LOOK);
	msg->AddInt32("newlook",B_BORDERED_WINDOW_LOOK);
	menu->AddItem(new BMenuItem("Bordered Window",msg));
	msg = new BMessage(MSG_WINDOW_SET_LOOK);
	msg->AddInt32("newlook",B_NO_BORDER_WINDOW_LOOK);
	menu->AddItem(new BMenuItem("Borderless Window",msg));
#endif
	switch (fWindowInfo.look)
	{
		case B_DOCUMENT_WINDOW_LOOK:
			menu->ItemAt(0)->SetMarked(true);
			break;
		case B_TITLED_WINDOW_LOOK:
			menu->ItemAt(1)->SetMarked(true);
			break;
		case B_FLOATING_WINDOW_LOOK:
			menu->ItemAt(2)->SetMarked(true);
			break;
		case B_MODAL_WINDOW_LOOK:
			menu->ItemAt(3)->SetMarked(true);
			break;
		case B_BORDERED_WINDOW_LOOK:
			menu->ItemAt(4)->SetMarked(true);
			break;
		case B_NO_BORDER_WINDOW_LOOK:
			menu->ItemAt(5)->SetMarked(true);
			break;
	}

	fLookField = new BMenuField(BRect(10,40,240,60),"look","Window Look: ",menu);
	fLookField->SetDivider(be_plain_font->StringWidth("Window Look: "));
	AddChild(fLookField);
}
/*!	
 *	\brief
 *	\param[in]	year	The current year
 *	\returns		The created BMenu.
 *	\remarks		It's up to the caller to delete this menu!
 */
BPopUpMenu* CalendarControl::CreateYearsMenu( int yearIn )
{
	BPopUpMenu* toReturn = new BPopUpMenu("Years list");
	BMessage* message = NULL;
	BMenuItem* item = NULL;
	BString yearName;
	if (!toReturn) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return NULL;
	}
	toReturn->SetLabelFromMarked(true);
	toReturn->SetRadioMode(true);
	for ( int i = yearIn - YEARS_UP_AND_DOWN; 
			i <= yearIn + YEARS_UP_AND_DOWN; 
			++i )
	{
		message = new BMessage( kYearChanged );
		if ( !message )
		{
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return NULL;
		}
		if ( B_OK != message->AddInt32( "Year", i ) )
		{
			exit(5);	
		}
		yearName.Truncate( 0 );
		yearName << i;
		item = new BMenuItem( yearName.String(), message );
		if ( !item ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return NULL;
		}
		item->SetTarget( this );
		if ( i == yearIn ) {
			item->SetMarked( true );
		}
		toReturn->AddItem( item );
	}
	UpdateTargets( toReturn );
	return toReturn;
}	// <-- end of function CalendarControl::CreateYearsMenu
void TCueSheetWindow::WindowActivated( bool activate)
{
	// Move indicator tick offscreen to hide it
	if ( activate == false ) {
		BPoint where;
		where.x = 0;
		BMessage* message = new BMessage(UPDATE_TIMELINE_MSG);
		message->AddPoint("Where", where);
		message->AddInt32("TheTime", GetCurrentTime());
		fTimeline->MessageReceived(message);
		delete message;
	} else {
		// Tell stage to end edit mode
		BMessage* theMessage = new BMessage(END_STAGE_EDIT_MSG);
		fStageWindow->PostMessage(theMessage, fStageWindow->GetStageView());
		delete theMessage;
	}

	/*
	   if (activate)
	   {
	        // Show stage
	        fStageWindow->Lock();
	        if (fStageWindow->IsHidden())
	                fStageWindow->Show();
	        fStageWindow->Unlock();

	        // We are now the main Cue Sheet
	        if ( static_cast<MuseumApp *>(be_app)->GetCueSheet() != this )
	                static_cast<MuseumApp *>(be_app)->SetCueSheet(this);
	   }
	   else
	   {
	        fStageWindow->Lock();
	        if (fStageWindow->IsHidden() == false)
	        {
	                if ( IsHidden() )
	                        fStageWindow->Hide();
	        }
	        fStageWindow->Unlock();
	   }
	 */

	BWindow::WindowActivated(activate);
}
Exemple #6
0
InfoWindow::InfoWindow( BRect frame, AIMUser uName )
				: BWindow(frame, "", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE )
{
	char windowTitle[DISPLAY_NAME_MAX+50];
	userName = uName;

	// Make the message to request the info
	BMessage* infMessage = new BMessage( BEAIM_GET_USER_INFO );
	infMessage->AddString( "userid", uName.UserString() );

	// do some name stuff
	sprintf( windowTitle, "%s: %s", Language.get("IW_USER_INFO"), uName.UserString() );
	SetTitle( windowTitle );

	// invoke the instantiation routine to create a new view 
	BRect rect = Bounds();
	rect.bottom -= 15;
	iView = new InfoView( users->IsABuddy(uName), rect, "InfoView", infMessage, users->GetBuddyEncoding(uName) ); 

	// add the view to the window 
	AddChild(iView);

	// make the stats view
	BRect statFrame = Bounds();
	statFrame.bottom = Bounds().bottom;
	statFrame.top = statFrame.bottom - 14;
	statView = new GStatusView( (char*)LangWithSuffix("IM_WAITING_FOR_INFO", B_UTF8_ELLIPSIS), statFrame );
	statView->SetSpinner(true);
	AddChild( statView );
	
	// Tell the main app that the window has been opened
	BMessage* sendMessage = new BMessage( BEAIM_IM_WINDOW_OPENED );
	sendMessage->AddInt32( "wtype", (int32)USER_INFO_TYPE );
	sendMessage->AddString( "userid", uName.UserString() );
	sendMessage->AddPointer( "new_window", this );
	PostAppMessage( sendMessage );
	
	gotInfo = false;
	gotAway = false;
	needsAway = false;
	askedAway = false;
	
	// get all the language stuff taken care of
	RefreshLangStrings();
}
Exemple #7
0
void
BViewState::ArchiveToMessage(BMessage &message) const
{
	message.AddInt32(kViewStateVersionName, kViewStateArchiveVersion);

	message.AddInt32(kViewStateViewModeName, static_cast<int32>(fViewMode));
	message.AddInt32(kViewStateLastIconModeName,
		static_cast<int32>(fLastIconMode));
	message.AddPoint(kViewStateListOriginName, fListOrigin);
	message.AddPoint(kViewStateIconOriginName, fIconOrigin);
	message.AddInt32(kViewStatePrimarySortAttrName,
		static_cast<int32>(fPrimarySortAttr));
	message.AddInt32(kViewStatePrimarySortTypeName,
		static_cast<int32>(fPrimarySortType));
	message.AddInt32(kViewStateSecondarySortAttrName,
		static_cast<int32>(fSecondarySortAttr));
	message.AddInt32(kViewStateSecondarySortTypeName,
		static_cast<int32>(fSecondarySortType));
	message.AddBool(kViewStateReverseSortName, fReverseSort);
	message.AddInt32(kViewStateIconSizeName, static_cast<int32>(fIconSize));
	message.AddInt32(kViewStateLastIconSizeName,
		static_cast<int32>(fLastIconSize));
}
void
FSClipboardRemove(Model *model)
{
	BMessenger messenger(kTrackerSignature);
	if (messenger.IsValid()) {
		BMessage *report = new BMessage(kFSClipboardChanges);
		TClipboardNodeRef tcnode;
		tcnode.node = *model->NodeRef();
		tcnode.moveMode = kDelete;
		const entry_ref *ref = model->EntryRef();
		report->AddInt32("device", ref->device);
		report->AddInt64("directory", ref->directory);
		report->AddBool("clearClipboard", false);
		report->AddData("tcnode", T_CLIPBOARD_NODE, &tcnode, sizeof(tcnode), true);
		messenger.SendMessage(report);
		delete report;
	}
}
void PDocument::PushToStream(BPositionIO *pushTo)
{
	Indexer		*indexer			= new Indexer((PDocument *)this);
	BMessage	*tmpNode			= NULL;
	BMessage	*commandManage		= new BMessage();
	BMessage	*selectedMessage	= new BMessage();
	int			i					= 0;
	//**security check if the passed BPositionIO ok is
	documentSetting->Flatten(pushTo);
	for (i=0; i<allNodes->CountItems();i++)
	{
		tmpNode=(BMessage *)allNodes->ItemAt(i);
		BMessage *indexed = indexer->IndexNode(tmpNode);
		indexed->Flatten(pushTo);
	}
	for (i=0; i<allConnections->CountItems();i++)
	{
		tmpNode=(BMessage *)allConnections->ItemAt(i);
		BMessage *indexed = indexer->IndexConnection(tmpNode);
		indexed->Flatten(pushTo);
	}
	for (i=0; i<selected->CountItems();i++)
	{
		selectedMessage->AddPointer("node",selected->ItemAt(i));
	}
	selectedMessage->Flatten(pushTo);
	for (i=0;i<(commandManager->GetMacroList())->CountItems();i++)
	{
			BMessage *macro =(BMessage *)(commandManager->GetMacroList()->ItemAt(i));
			macro->Flatten(pushTo);
	}
	for (i=0;i<(commandManager->GetUndoList())->CountItems();i++)
	{
		BMessage *indexed = indexer->IndexMacroCommand((BMessage *)(commandManager->GetUndoList()->ItemAt(i)));
		indexed->Flatten(pushTo);
	}
	//**add the UndoIndex
	commandManage->AddInt32("undoStatus",commandManager->GetUndoIndex());
	//add the commandManage
	commandManage->Flatten(pushTo);
	delete	indexer;
	delete	commandManage;
	delete	selectedMessage;
}
Exemple #10
0
void DCCConnect::MessageReceived(BMessage* msg)
{
	switch (msg->what) {
	case M_DCC_STOP_BUTTON: {
		Stopped();
	} break;

	case M_DCC_UPDATE_STATUS: {
		fLabel->SetText(msg->FindString("text"));
	} break;

	case M_DCC_GET_CONNECT_DATA: {
		BMessage reply;
		reply.AddString("port", fPort.String());
		reply.AddString("ip", fIp.String());
		reply.AddString("name", fFileName.String());
		reply.AddString("nick", fNick.String());
		reply.AddString("size", fSize.String());
		DCCReceive* recview(dynamic_cast<DCCReceive*>(this));
		if (recview != NULL) reply.AddBool("resume", recview->fResume);
		DCCSend* sendview(dynamic_cast<DCCSend*>(this));
		if (sendview != NULL) reply.AddMessenger("caller", sendview->fCaller);
		msg->SendReply(&reply);
	} break;

	case M_DCC_GET_RESUME_POS: {
		BMessage reply;
		DCCSend* sendview(dynamic_cast<DCCSend*>(this));
		if (sendview != NULL) reply.AddInt32("pos", sendview->fPos);
		msg->SendReply(&reply);
	} break;

	case M_DCC_UPDATE_TRANSFERRED: {
		fTotalTransferred = msg->FindInt32("transferred");
	} break;

	case M_DCC_UPDATE_AVERAGE: {
		fFinalRateAverage = msg->FindInt32("average");
	} break;

	default:
		BView::MessageReceived(msg);
	}
}
Exemple #11
0
status_t
BNetworkInterface::AutoConfigure(int family)
{
	BMessage message(kMsgConfigureInterface);
	message.AddString("device", Name());

	BMessage address;
	address.AddInt32("family", family);
	address.AddBool("auto_config", true);
	message.AddMessage("address", &address);

	BMessenger networkServer(kNetServerSignature);
	BMessage reply;
	status_t status = networkServer.SendMessage(&message, &reply);
	if (status == B_OK)
		reply.FindInt32("status", &status);

	return status;
}
Exemple #12
0
void
AppServer::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case AS_GET_DESKTOP:
		{
			Desktop* desktop = NULL;

			int32 userID = message->GetInt32("user", 0);
			int32 version = message->GetInt32("version", 0);
			const char* targetScreen = message->GetString("target");

			if (version != AS_PROTOCOL_VERSION) {
				syslog(LOG_ERR, "Application for user %" B_PRId32 " does not "
					"support the current server protocol.\n", userID);
			} else {
				desktop = _FindDesktop(userID, targetScreen);
				if (desktop == NULL) {
					// we need to create a new desktop object for this user
					// TODO: test if the user exists on the system
					// TODO: maybe have a separate AS_START_DESKTOP_SESSION for
					// authorizing the user
					desktop = _CreateDesktop(userID, targetScreen);
				}
			}

			BMessage reply;
			if (desktop != NULL)
				reply.AddInt32("port", desktop->MessagePort());
			else
				reply.what = (uint32)B_ERROR;

			message->SendReply(&reply);
			break;
		}

		default:
			// We don't allow application scripting
			STRACE(("AppServer received unexpected code %" B_PRId32 "\n",
				message->what));
			break;
	}
}
void
BNavigator::SendNavigationMessage(NavigationAction action, BEntry *entry, bool option)
{
	entry_ref ref;

	if (entry->GetRef(&ref) == B_OK) {
		BMessage message;
		message.AddRef("refs", &ref);
		message.AddInt32("action", action);
		
		// get the node of this folder for selecting it in the new location
		const node_ref *nodeRef;
		if (Window() && Window()->TargetModel())
			nodeRef = Window()->TargetModel()->NodeRef();
		else
			nodeRef = NULL;
		
		// if the option key was held down, open in new window (send message to be_app)
		// otherwise send message to this window. TTracker (be_app) understands nodeRefToSlection,
		// BContainerWindow doesn't, so we have to select the item manually
		if (option) {
			message.what = B_REFS_RECEIVED;
			if (nodeRef)
				message.AddData("nodeRefToSelect", B_RAW_TYPE, nodeRef, sizeof(node_ref));
			be_app->PostMessage(&message);
		} else {
			message.what = kSwitchDirectory;
			Window()->PostMessage(&message);
			UnlockLooper();
				// This is to prevent a dead-lock situation. SelectChildInParentSoon()
				// eventually locks the TaskLoop::fLock. Later, when StandAloneTaskLoop::Run()
				// runs, it also locks TaskLoop::fLock and subsequently locks this window's looper.
				// Therefore we can't call SelectChildInParentSoon with our Looper locked,
				// because we would get different orders of locking (thus the risk of dead-locking).
				//
				// Todo: Change the locking behaviour of StandAloneTaskLoop::Run() and sub-
				// sequently called functions.
			if (nodeRef)
				dynamic_cast<TTracker *>(be_app)->SelectChildInParentSoon(&ref, nodeRef);
			LockLooper();
		}
	}
}
Exemple #14
0
/*****************************************************************************
 * LanguageMenu::AttachedToWindow
 *****************************************************************************/
void LanguageMenu::AttachedToWindow()
{
    BMenuItem * item;

    // remove all items
    while( ( item = RemoveItem( 0L ) ) )
    {
        delete item;
    }

    SetRadioMode( true );

    input_thread_t * p_input = (input_thread_t *)
            vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
    if( !p_input )
    {
        return;
    }

    vlc_value_t val_list, text_list;
    BMessage * message;
    int i_current;

    i_current = var_GetInteger( p_input, psz_variable );
    var_Change( p_input, psz_variable, VLC_VAR_GETLIST, &val_list, &text_list );
    for( int i = 0; i < val_list.p_list->i_count; i++ )
    {
        message = new BMessage( SELECT_CHANNEL );
        message->AddInt32( psz_variable, val_list.p_list->p_values[i].i_int );
        item = new BMenuItem( text_list.p_list->p_values[i].psz_string, message );
        if( val_list.p_list->p_values[i].i_int == i_current )
        {
            item->SetMarked( true );
        }
        AddItem( item );
    }
    var_FreeList( &val_list, &text_list );

    vlc_object_release( p_input );

    BMenu::AttachedToWindow();
}
Exemple #15
0
/*****************************************************************************
 * ChapterMenu::AttachedToWindow
 *****************************************************************************/
void ChapterMenu::AttachedToWindow()
{
    BMenuItem * item;
    while( ( item = RemoveItem( 0L ) ) )
    {
        delete item;
    }

    input_thread_t * p_input;
    p_input = (input_thread_t *)
        vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
    if( !p_input )
    {
        return;
    }

    vlc_value_t val;
    BMessage * message;
    if( !var_Get( p_input, "chapter", &val ) )
    {
        vlc_value_t val_list, text_list;
        var_Change( p_input, "chapter", VLC_VAR_GETCHOICES,
                    &val_list, &text_list );

        for( int i = 0; i < val_list.p_list->i_count; i++ )
        {
            message = new BMessage( TOGGLE_CHAPTER );
            message->AddInt32( "index", val_list.p_list->p_values[i].i_int );
            item = new BMenuItem( text_list.p_list->p_values[i].psz_string,
                                  message );
            if( val_list.p_list->p_values[i].i_int == val.i_int )
            {
                item->SetMarked( true );
            }
            AddItem( item );
        }

        var_FreeList( &val_list, &text_list );
    }
    vlc_object_release( p_input );
    BMenu::AttachedToWindow();
}
status_t BoolItem::Invoke(BMessage *message)
{
	BMessage	*sendMessage	= NULL;
	BMessage	*valueContainer	= new BMessage();
	if (message==NULL)
		sendMessage = new BMessage(*Message());
	else
		sendMessage = new BMessage(*message);
	if (sendMessage != NULL)
	{
		sendMessage->FindMessage("valueContainer",valueContainer);
		valueContainer->AddInt32("type",B_BOOL_TYPE);
		valueContainer->AddString("name",label);
		valueContainer->AddBool("newValue", GetValue());
		sendMessage->ReplaceMessage("valueContainer",valueContainer);
		BInvoker::Invoke(sendMessage);
	}
	else
		return B_ERROR;
}
Exemple #17
0
    void show(const IntRect& rect, FrameView* view, int index)
    {
        // Clean out the menu first
        for (int32 i = CountItems() - 1; i >= 0; i--)
            delete RemoveItem(i);

        // Popuplate the menu from the client
        int itemCount = m_popupClient->listSize();
        for (int i = 0; i < itemCount; i++) {
            if (m_popupClient->itemIsSeparator(i))
                AddSeparatorItem();
            else {
                // NOTE: WebCore distinguishes between "Group" and "Label"
                // here, but both types of item (radio or check mark) currently
                // look the same on Haiku.
                BString label(m_popupClient->itemText(i));
                BMessage* message = new BMessage(kPopupResult);
                message->AddInt32("index", i);
                BMenuItem* item = new BMenuItem(label.String(), message);
                AddItem(item);
                item->SetTarget(BMessenger(&m_Handler));
                item->SetEnabled(m_popupClient->itemIsEnabled(i));
                item->SetMarked(i == index);
            }
        }

        // We need to force a layout now, or the item frames will not be
        // computed yet, so we cannot move the current item under the mouse.
        DoLayout();

        // Account for frame of menu field
        BRect screenRect(view->contentsToScreen(rect));
        screenRect.OffsetBy(2, 2);
        // Move currently selected item under the mouse.
        if (BMenuItem* item = ItemAt(index))
            screenRect.OffsetBy(0, -item->Frame().top);

        BRect openRect = Bounds().OffsetToSelf(screenRect.LeftTop());

        Go(screenRect.LeftTop(), true, true, openRect, true);
    }
status_t
PropEnumFlagEditor::SetProperty(PObject *obj, PProperty *prop)
{
	if (!prop || !HandlesType(prop->GetType()))
		return B_BAD_VALUE;
	
	// Calling the inherited version before doing anything else is required
	PropEnumEditor::SetProperty(obj,prop);
	EnumFlagProperty *eprop = dynamic_cast<EnumFlagProperty*>(prop);
	if (!eprop)
		return B_ERROR;
	*fPropName = eprop->GetName();
	
	while (fMenu->CountItems())
		delete fMenu->RemoveItem(0L);
	
	for (int32 i = 0; i < eprop->CountValuePairs(); i++)
	{
		BMessage *msg = new BMessage(M_EDIT);
		msg->AddInt32("value",eprop->PairValueAt(i));
		fMenu->AddItem(new BMenuItem(eprop->PairNameAt(i).String(),msg));
	}
	
	IntValue iv;
	prop->GetValue(&iv);
	int32 value = *iv.value;
	for (int32 i = 0; i < fMenu->CountItems(); i++)
	{
		BMenuItem *item = fMenu->ItemAt(i);
		int32 temp;
		if (!item || item->Message()->FindInt32("value",&temp) != B_OK)
			continue;
		
		if (value & temp)
			item->SetMarked(true);
		else
			item->SetMarked(false);
	}
	
	return B_OK;
}
status_t
DisplayView::Save()
{
	BPath path;

	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
		return B_ERROR;

	path.Append(kSettingsDirectory);
	path.Append(kDisplaySettings);

	BMessage settings;

	float width = atof(fWindowWidth->Text());
	settings.AddFloat(kWidthName, width);

	icon_size iconSize = kDefaultIconSize;
	switch (fIconSize->IndexOf(fIconSize->FindMarked())) {
		case 0:
			iconSize = B_MINI_ICON;
			break;
		default:
			iconSize = B_LARGE_ICON;
	}
	settings.AddInt32(kIconSizeName, (int32)iconSize);

	// Save settings file
	BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
	status_t ret = settings.Flatten(&file);
	if (ret != B_OK) {
		BAlert* alert = new BAlert("",
			B_TRANSLATE("Can't save preferenes, you probably don't have "
				"write access to the settings directory or the disk is full."),
				B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		(void)alert->Go();
		return ret;
	}

	return B_OK;
}
Exemple #20
0
BPopUpMenu *TPrefsWindow::BuildWrapMenu(bool wrap)
{
	BMenuItem	*item;
	BMessage	*msg;
	BPopUpMenu	*menu;

	menu = new BPopUpMenu("");
	msg = new BMessage(P_WRAP);
	msg->AddBool("wrap", true);
	menu->AddItem(item = new BMenuItem("On", msg));
	if (wrap)
		item->SetMarked(true);

	msg = new BMessage(P_WRAP);
	msg->AddInt32("wrap", false);
	menu->AddItem(item = new BMenuItem("Off", msg));
	if (!wrap)
		item->SetMarked(true);

	return menu;
}
Exemple #21
0
// ------------------------------------------------------------------------ RHTML_Preferences_Win - FTHSetFT -
void RHTMLPreferencesWin::FTHSetFT(uint FileType)
{
 fFTHFTBox->RemoveChild(fFTHFC);

 BMenu *fFCMenu = new BMenu(fOptions->GetLocaleString("FileTypes_FontColorName",fOptions->FileTypes[FileType]->FCName[0]->String()));
 fFCMenu->SetLabelFromMarked(true);
 fFCMenu->SetRadioMode(true);
 for (int32 i=0;i<(int32)fOptions->FileTypes[FileType]->FontColorDb;i++)
 {
  BMessage* msg = new BMessage('FTHT');
  msg->AddInt32("FontColor",i);
  BMenuItem *item;
  fFCMenu->AddItem(item=new BMenuItem(fOptions->GetLocaleString("FileTypes_FontColorName",fOptions->FileTypes[FileType]->FCName[i]->String()),msg));
  item->SetTarget(this);
 }
 
 fFTHFC= new BMenuField(BRect(10,40,210,65),"FileTypesMenu",fOptions->GetLocaleString("Preferences_Window_FileTypes","Element"),fFCMenu);
 fFTHFC->SetDivider(100);
 fFTHFTBox->AddChild(fFTHFC);
 FTHSetFSize(0);
}
  virtual void Pulse (void)
  {
    return; // Not force testing message injection at this time.

    BMessage EventMessage;
    char     KeyAsString [16];
    int      i;
    m_EventTriggerCounter++;
printf ("Event %d\n", m_EventTriggerCounter);
    switch (m_EventTriggerCounter)
    {
      case 4:
//        EventMessage.what = B_MOUSE_MOVED;
//        EventMessage.AddFloat ("x", 0.2);
//        EventMessage.AddFloat ("y", 0.1);
//        EventMessage.AddInt64 ("when", system_time ());
//        EventMessage.AddInt32 ("buttons", 2);
//        EventMessage.what = B_MOUSE_WHEEL_CHANGED;
//        EventMessage.AddFloat ("be:wheel_delta_x", 0.0F);
//        EventMessage.AddFloat ("be:wheel_delta_y", -1.0F);
//        m_InputDeviceMousePntr->Control ('ViNC', &EventMessage);
        EventMessage.what = B_KEY_DOWN;
        EventMessage.AddInt64 ("when", system_time ());
        EventMessage.AddInt32 ("key", 61);
        EventMessage.AddInt32 ("modifiers", 0);
        strcpy (KeyAsString, "é");
        for (i = 0; KeyAsString[i] != 0; i++)
          EventMessage.AddInt8 ("byte", KeyAsString [i]);
        EventMessage.AddString ("bytes", KeyAsString);
        EventMessage.AddData ("states", B_UINT8_TYPE, KeyAsString, 16);
        EventMessage.AddInt32 ("raw_char", 62);
        m_InputDeviceKeyboardPntr->Control ('ViNC', &EventMessage);
        EventMessage.MakeEmpty ();
        EventMessage.what = B_KEY_UP;
        EventMessage.AddInt64 ("when", system_time ());
        EventMessage.AddInt32 ("key", 61);
        EventMessage.AddInt32 ("modifiers", 0);
        for (i = 0; KeyAsString[i] != 0; i++)
          EventMessage.AddInt8 ("byte", KeyAsString [i]);
        EventMessage.AddString ("bytes", KeyAsString);
        EventMessage.AddData ("states", B_UINT8_TYPE, KeyAsString, 16);
        EventMessage.AddInt32 ("raw_char", 62);
        m_InputDeviceKeyboardPntr->Control ('ViNC', &EventMessage);
        break;
      default:
        break;
    }
  };
Exemple #23
0
// --------------------------------------------------
status_t Fonts::Archive(BMessage *archive, bool deep) const
{
	archive->AddString("class", "Fonts");
	const int n = Length();
	for (int i = 0; i < n; i++) {
		FontFile* f = At(i);
		BMessage m;
		if (f->Archive(&m) == B_OK) {
			archive->AddMessage("fontfile", &m);
		}
	}
	BMessage m;
	font_encoding enc;
	bool active;
	for (int i = 0; GetCJKOrder(i, enc, active); i++) {
		m.AddInt32("encoding", enc);
		m.AddBool("active", active);
	}
	archive->AddMessage("cjk_order", &m);
	return B_OK;
}
//------------------------------------------------------------------------------
void WindowEditor::MessageReceived(BMessage *msg)
{
	BMessage fwd;
	switch (msg->what)
	{
		case MSG_WINDOW_SET_TITLE:
			fwd.what = msg->what;
			fwd.AddString("title", fTitleText->Text());
			fEditWindow.SendMessage(&fwd);
			break;

		case MSG_WINDOW_SET_LOOK:
			fEditWindow.SendMessage(msg);
			break;

		case MSG_WINDOW_SET_FLAG:
			fwd.what = msg->what;
			fwd.AddInt32("flags", MakeBitmask());
			fEditWindow.SendMessage(&fwd);
			break;

		case MSG_WINDOW_ADD_MENU:
		{
			BCheckBox* cbox;
			msg->FindPointer("source",(void **)(&cbox));
			fwd.what = msg->what;
			fwd.AddBool("addmenu", cbox->Value() == B_CONTROL_ON);
			fEditWindow.SendMessage(&fwd);
			break;
		}

		case MSG_WINDOW_SET_FEEL:
			fEditWindow.SendMessage(msg);
			break;

		default:
			BView::MessageReceived(msg);
			break;
	}
}
PropEnumEditor::PropEnumEditor(PObject *obj, PProperty *prop)
	:	PropertyEditor(obj,prop),
		fEditor(NULL),
		fMsgr(NULL)
{
	fPropName = new BString();
	BString label("EnumEditor");
	if (GetProperty())
	{
		*fPropName = GetProperty()->GetName();
		label = *fPropName;
	}
	
	EnumProperty *eprop = dynamic_cast<EnumProperty*>(prop);
	
	fMenu = new BMenu("Enum");
	fMenu->SetLabelFromMarked(true);
	fMenu->SetRadioMode(true);
	
	if (eprop)
	{
		for (int32 i = 0; i < eprop->CountValuePairs(); i++)
		{
			BMessage *msg = new BMessage(M_EDIT);
			msg->AddInt32("value",eprop->PairValueAt(i));
			fMenu->AddItem(new BMenuItem(eprop->PairNameAt(i).String(),msg));
		}
	}
	
	fEditor = new BMenuField(Bounds(),"editor",label.String(), fMenu,
							B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	

	if (eprop)
	{
		BMenuItem *item = fMenu->FindItem(eprop->GetValueAsString().String());
		if (item)
			item->SetMarked(true);
	}
}
Exemple #26
0
BPopUpMenu *TPrefsWindow::BuildSizeMenu(BFont *font)
{
	char		label[16];
	int32		loop;
	int32		sizes[] = {9, 10, 12, 14, 18, 24};
	float		size;
	BMenuItem	*item;
	BMessage	*msg;
	BPopUpMenu	*menu;

	menu = new BPopUpMenu("");
	size = font->Size();
	for (loop = 0; loop < sizeof(sizes) / sizeof(int32); loop++) {
		msg = new BMessage(P_SIZE);
		msg->AddInt32("size", sizes[loop]);
		sprintf(label, "%d", sizes[loop]);
		menu->AddItem(item = new BMenuItem(label, msg));
		if (sizes[loop] == (int32)size)
			item->SetMarked(true);
	}
	return menu;
}
Exemple #27
0
// Fills the passed BMessage with B_ARGV_RECEIVED infos.
static void
fill_argv_message(BMessage &message)
{
	message.what = B_ARGV_RECEIVED;

	int32 argc = __libc_argc;
	const char* const *argv = __libc_argv;

	// add argc
	message.AddInt32("argc", argc);

	// add argv
	for (int32 i = 0; i < argc; i++) {
		if (argv[i] != NULL)
			message.AddString("argv", argv[i]);
	}

	// add current working directory
	char cwd[B_PATH_NAME_LENGTH];
	if (getcwd(cwd, B_PATH_NAME_LENGTH))
		message.AddString("cwd", cwd);
}
Exemple #28
0
status_t
ThemeManager::LoadSettings()
{
	FENTRY;
	BMessage addonSettings;
	int32 i;
	ThemesAddon *ta;
	uint32 addonFlags;
	BPath path;
	BFile sFile;
	status_t err;
	
	/* load prefs */
	err = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
	if (!err) {
		path.Append(Z_THEME_MANAGER_SETTINGS_FILE);
		err = sFile.SetTo(path.Path(), B_READ_ONLY);
		if (!err) {
			err = fSettings.Unflatten(&sFile);
		}
	}
	
	/* tell addons */
	for (i = 0; i < fAddonCount; i++) {
		ta = AddonAt(i);
		if (!ta || !ta->Name())
			continue;
		if (fSettings.FindMessage(ta->Name(), &addonSettings) < B_OK) {
			addonSettings.MakeEmpty();
		}
		fSettings.RemoveName(ta->Name());
		if (addonSettings.FindInt32("ta:flags", (int32 *)&addonFlags) < B_OK) {
			addonFlags = Z_THEME_ADDON_DO_SET_ALL | Z_THEME_ADDON_DO_RETRIEVE;
			addonSettings.AddInt32("ta:flags", addonFlags);
		}
		ta->LoadSettings(addonSettings);
	}
	return B_OK;
}
status_t
TerminalThemesAddon::ApplyDefaultTheme(uint32 flags)
{
	BMessage theme;
	BMessage termpref;
	int32 i;

	// XXX: add font and stuff...

	for (i = 0; i < NENTS(sHaikuPrefsMapInt32); i++) {
		termpref.AddInt32(sHaikuPrefsMapInt32[i].name,
			sHaikuPrefsMapInt32[i].def);
	}

	for (i = 0; i < NENTS(sHaikuPrefsMapColors); i++) {
		AddRGBColor(termpref, sHaikuPrefsMapColors[i].name,
			sHaikuPrefsMapColors[i].def);
	}

	theme.AddMessage(Z_THEME_TERMINAL_SETTINGS, &termpref);
	return ApplyTheme(theme, flags);
}
Exemple #30
0
BPopUpMenu*
TPrefsWindow::_BuildBoolMenu(uint32 what, const char* boolItem, bool isTrue)
{
	BMenuItem* item;
	BMessage* msg;
	BPopUpMenu* menu;

	menu = new BPopUpMenu("");
	msg = new BMessage(what);
	msg->AddBool(boolItem, true);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("On"), msg));
	if (isTrue)
		item->SetMarked(true);

	msg = new BMessage(what);
	msg->AddInt32(boolItem, false);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Off"), msg));
	if (!isTrue)
		item->SetMarked(true);

	return menu;
}