コード例 #1
0
/*!	\brief Returns the time interval between two messages and the number of
		   times the message has still to be sent.

	Both parameters (\a interval and \a count) may be \c NULL.

	\param interval Pointer to a pre-allocated bigtime_t variable to be set
		   to the time interval. May be \c NULL.
	\param count Pointer to a pre-allocated int32 variable to be set
		   to the number of times the message has still to be sent.
		   May be \c NULL.
	\return
	- \c B_OK: Everything went fine.
	- \c B_BAD_VALUE: The message runner is not longer valid. All the
	  messages that had to be sent have already been sent.
*/
status_t
BMessageRunner::GetInfo(bigtime_t *interval, int32 *count) const
{
	status_t error =  (fToken >= 0 ? B_OK : B_BAD_VALUE);
	// compose the request message
	BMessage request(B_REG_GET_MESSAGE_RUNNER_INFO);
	if (error == B_OK)
		error = request.AddInt32("token", fToken);
	// send the request
	BMessage reply;
	if (error == B_OK)
		error = BRoster::Private().SendTo(&request, &reply, false);
	// evaluate the reply
	if (error == B_OK) {
		if (reply.what == B_REG_SUCCESS) {
			// count
			int32 _count;
			if (reply.FindInt32("count", &_count) == B_OK) {
				if (count)
					*count = _count;
			} else
				error = B_ERROR;
			// interval
			bigtime_t _interval;
			if (reply.FindInt64("interval", &_interval) == B_OK) {
				if (interval)
					*interval = _interval;
			} else
				error = B_ERROR;
		} else
			reply.FindInt32("error", &error);
	}
	return error;
}
コード例 #2
0
ファイル: Keymap.cpp プロジェクト: ysei/Faber
void
KeyControl::KeyDown(const char *bytes, int32 numBytes)
{
	int32 key, mod, raw_key;
	if (numBytes == 1) {
		BMessage *msg = Window()->CurrentMessage();
		msg->FindInt32("key", &raw_key);
		msg->FindInt32("modifiers", &mod);
		msg->FindInt32("raw_char", &key);

		// now do some conversions for combinations
		if (key == B_FUNCTION_KEY) {
			key = 12+raw_key;
		} else if (key>='a' && key<='z')
			key -= ('a'-'A');
		
		mod = mod & (B_SHIFT_KEY | B_CONTROL_KEY | B_COMMAND_KEY | B_OPTION_KEY);		// mask left / right stuff
		if (m_menu)	mod = mod | B_COMMAND_KEY;
		
		if (!m_menu || (m_menu && key>=' ' && key<'z')) {
			m_mod = mod ;
			m_key = key;
			Invalidate();
		}
	}
}
コード例 #3
0
ファイル: BreakpointSetting.cpp プロジェクト: mariuz/haiku
status_t
BreakpointSetting::SetTo(const BMessage& archive)
{
	_Unset();

	fFunctionID = ArchivingUtils::UnarchiveChild<FunctionID>(archive,
		"function");
	if (fFunctionID == NULL)
		return B_BAD_VALUE;

	archive.FindString("sourceFile", &fSourceFile);

	int32 line;
	if (archive.FindInt32("line", &line) != B_OK)
		line = -1;

	int32 column;
	if (archive.FindInt32("column", &column) != B_OK)
		column = -1;

	fSourceLocation = SourceLocation(line, column);

	if (archive.FindUInt64("relativeAddress", &fRelativeAddress) != B_OK)
		fRelativeAddress = 0;

	if (archive.FindBool("enabled", &fEnabled) != B_OK)
		fEnabled = false;

	return B_OK;
}
コード例 #4
0
ファイル: Enclosure.cpp プロジェクト: HaikuArchives/FeedKit
status_t Enclosure::Unflatten(type_code /*code*/, const void *buffer, ssize_t /*numBytes*/) {
	BMessage flat;
	status_t ret = flat.Unflatten((char *)buffer);
	fProgress = NULL;
	
	if (ret == B_OK) {
		// Compulsory
		if (flat.FindString("url", &fURL) != B_OK) ret = B_ERROR;

		// Optional
		if (flat.FindString("mime", &fMIME) != B_OK) fMIME = "";
		if (flat.FindString("description", &fDescription) != B_OK) fDescription = "";
		if (flat.FindInt32("size", &fSize) != B_OK) fSize = -1;
		
		if (flat.FindInt32("state", reinterpret_cast<int32 *>(&fState)) != B_OK) fState = Error;
		flat.FindRef("localRef", &fLocalRef);

		DownloadProgress progress;
		if (flat.FindFlat("progress", &progress) == B_OK) {
			fProgress = new DownloadProgress(progress);
		};
	};
	
	return ret;
};
コード例 #5
0
ファイル: InfoStrView.cpp プロジェクト: puckipedia/FilWip
void InfoStrView::MouseDown (BPoint where)
{
	/* Detect double-click */
	BMessage* msg = Window()->CurrentMessage();
	int32 clicks = msg->FindInt32 ("clicks");
	int32 button = msg->FindInt32 ("buttons");
	static BPoint previousPoint = where;

	if ((button == lastButton) && (clicks > 1))
		clickCount++;
	else
		clickCount = 1;

	lastButton = button;
	
	/* Make sure the two clicks are clicked close to eachother (5 pixel tolerance) */
	if (clickCount >= 2 && button == B_PRIMARY_MOUSE_BUTTON && itemPath != NULL
		&& ((where.y >= previousPoint.y - 5 && where.y <= previousPoint.y + 5)
			&& where.x >= previousPoint.x - 5 && where.x <= previousPoint.x + 5))
	{
		DrawOpenAnimation (CalcAnimationRect (where));
		OpenFolder (itemPath);
	}

	previousPoint = where;
	
	BStringView::MouseDown (where);
}
コード例 #6
0
status_t GlMidiEvent::ReadFrom(const BMessage& msg, bool portName)
{
	status_t				err;
	if (portName) {
		BString16			name;
		if ((err = msg.FindString(P_STR, &name)) != B_OK) return err;
		int32				id = 0;
		BMidiProducer*		prod;
		bool				found = false;
		while ((prod = BMidiRoster::NextProducer(&id)) != NULL) {
			if (prod->IsValid() && prod->Name() && name == prod->Name()) {
				portId = prod->ID();
				found = true;
				break;
			}
		}
		if (!found) return B_ERROR;
	} else {
		if ((err = msg.FindInt32(P_STR, &portId)) != B_OK) return err;
	}
	if ((err = msg.FindInt32(T_STR, &type)) != B_OK) return err;
	if ((err = msg.FindInt32(C_STR, &channel)) != B_OK) return err;
	if ((err = msg.FindInt32(V1_STR, &value1)) != B_OK) return err;
	if ((err = msg.FindInt32(V2_STR, &value2)) != B_OK) return err;
	return B_OK;
}
コード例 #7
0
ファイル: StateView.cpp プロジェクト: mmadia/haiku-1
// MouseDown
void
StateView::MouseDown(BPoint where)
{
    if (fLocker && !fLocker->WriteLock())
        return;

    // query more info from the windows current message if available
    uint32 buttons;
    uint32 clicks;
    BMessage* message = Window() ? Window()->CurrentMessage() : NULL;
    if (!message || message->FindInt32("buttons", (int32*)&buttons) != B_OK)
        buttons = B_PRIMARY_MOUSE_BUTTON;
    if (!message || message->FindInt32("clicks", (int32*)&clicks) != B_OK)
        clicks = 1;

    if (fCurrentState)
        fCurrentState->MouseDown(where, buttons, clicks);

    // update mouse info *after* having called the ViewState hook
    fMouseInfo.buttons = buttons;
    fMouseInfo.position = where;

    if (fLocker)
        fLocker->WriteUnlock();
}
コード例 #8
0
ファイル: NotificationWindow.cpp プロジェクト: looncraz/haiku
void
NotificationWindow::_LoadDisplaySettings(BMessage& settings)
{
	int32 setting;
	float originalWidth = fWidth;

	if (settings.FindFloat(kWidthName, &fWidth) != B_OK)
		fWidth = kDefaultWidth;
	if (originalWidth != fWidth)
		GetLayout()->SetExplicitSize(BSize(fWidth, B_SIZE_UNSET));

	if (settings.FindInt32(kIconSizeName, &setting) != B_OK)
		fIconSize = kDefaultIconSize;
	else
		fIconSize = (icon_size)setting;

	int32 position;
	if (settings.FindInt32(kNotificationPositionName, &position) != B_OK)
		fPosition = kDefaultNotificationPosition;
	else
		fPosition = position;

	// Notify the views about the change
	appview_t::iterator aIt;
	for (aIt = fAppViews.begin(); aIt != fAppViews.end(); ++aIt) {
		AppGroupView* view = aIt->second;
		view->Invalidate();
	}
}
コード例 #9
0
ファイル: main.cpp プロジェクト: BackupTheBerlios/nirvana-svn
	virtual void KeyDown(const char* pzRawString, int32 numBytes )
	{
		BMessage *curMsg = Window()->CurrentMessage();
		int32 key(0), modifiers(0);
		
		curMsg->FindInt32( "key", &key );
		curMsg->FindInt32( "modifiers", &modifiers );
		
	#warning These shortcuts should change to be more BeOS like.
		if ( modifiers & B_CONTROL_KEY ) {
			switch( pzRawString[0] )
			{
			case B_TAB:
				Window()->PostMessage( ID_ACTIVATE_URLEDIT, Window() );
				break;
			case 'r':
				Window()->PostMessage( ID_RELOAD, Window() );
				break;			
			case 'f':
				Window()->PostMessage( ID_FIND, Window() );
				break;
			case B_INSERT:
			case 'c':
				Window()->PostMessage( ID_COPY, Window() );
				break;
			case 'n':
				Window()->PostMessage( ID_NEW_WINDOW, Window() );
				break;
			default:
				QWidget::KeyDown( pzRawString, numBytes );
				break;
			}
		} else {
			switch( pzRawString[0] )
			{
			case B_BACKSPACE:
				Window()->PostMessage( ID_PREV_URL, Window() );
				break;			
			case B_FUNCTION_KEY:
				switch( key )
				{
//				case 4:	// F3
				case B_F3_KEY:	// F3
					Window()->PostMessage( ID_REPEAT_FIND, Window() );
					break;
				default:
					QWidget::KeyDown( pzRawString, numBytes );
					break;
				}
				break;
			default:
				QWidget::KeyDown( pzRawString, numBytes );
				break;
			
			}
		}
	}
コード例 #10
0
status_t
ScreenConfigurations::Restore(const BMessage& settings)
{
	fConfigurations.MakeEmpty();

	BMessage stored;
	for (int32 i = 0; settings.FindMessage("screen", i, &stored) == B_OK; i++) {
		const display_mode* mode;
		ssize_t size;
		int32 id;
		if (stored.FindInt32("id", &id) != B_OK
			|| stored.FindData("mode", B_RAW_TYPE, (const void**)&mode,
					&size) != B_OK
			|| size != sizeof(display_mode))
			continue;

		screen_configuration* configuration
			= new(std::nothrow) screen_configuration;
		if (configuration == NULL)
			return B_NO_MEMORY;

		configuration->id = id;
		configuration->is_current = false;

		const char* vendor;
		const char* name;
		uint32 productID;
		const char* serial;
		int32 week, year;
		if (stored.FindString("vendor", &vendor) == B_OK
			&& stored.FindString("name", &name) == B_OK
			&& stored.FindInt32("product id", (int32*)&productID) == B_OK
			&& stored.FindString("serial", &serial) == B_OK
			&& stored.FindInt32("produced week", &week) == B_OK
			&& stored.FindInt32("produced year", &year) == B_OK) {
			// create monitor info
			strlcpy(configuration->info.vendor, vendor,
				sizeof(configuration->info.vendor));
			strlcpy(configuration->info.name, name, sizeof(configuration->info.name));
			strlcpy(configuration->info.serial_number, serial,
				sizeof(configuration->info.serial_number));
			configuration->info.product_id = productID;
			configuration->info.produced.week = week;
			configuration->info.produced.year = year;
			configuration->has_info = true;
		} else
			configuration->has_info = false;

		stored.FindRect("frame", &configuration->frame);
		memcpy(&configuration->mode, mode, sizeof(display_mode));

		fConfigurations.AddItem(configuration);
	}

	return B_OK;
}
コード例 #11
0
ファイル: MouseView.cpp プロジェクト: simonsouth/haiku
void
MouseView::MouseDown(BPoint where)
{
	BMessage *mouseMsg = Window()->CurrentMessage();
	fButtons = mouseMsg->FindInt32("buttons");
	int32 modifiers = mouseMsg->FindInt32("modifiers");
	if (modifiers & B_CONTROL_KEY) {
		if (modifiers & B_COMMAND_KEY)
			fButtons = B_TERTIARY_MOUSE_BUTTON;
		else
			fButtons = B_SECONDARY_MOUSE_BUTTON;
	}

	// Get the current clipping region before requesting any updates.
	// Otherwise those parts would be excluded from the region.
	BRegion clipping;
	GetClippingRegion(&clipping);

	if (fOldButtons != fButtons) {
		Invalidate(_ButtonsRect());
		fOldButtons = fButtons;
	}

	const int32* offset = getButtonOffsets(fType);
	int32 button = -1;
	for (int32 i = 0; i <= fType; i++) {
		if (_ButtonRect(offset, i).Contains(where)) {
			button = i;
			break;
		}
	}
	if (button < 0)
		return;

	// We are setup to receive all mouse events, even if our window
	// is not active, so make sure that we don't display the menu when
	// the user clicked inside our view, but another window is on top.
	if (clipping.Contains(where)) {
		button = _ConvertFromVisualOrder(button);

		BPopUpMenu menu("Mouse Map Menu");
		BMessage message(kMsgMouseMap);
		message.AddInt32("button", button);

		menu.AddItem(new BMenuItem("1", new BMessage(message)));
		menu.AddItem(new BMenuItem("2", new BMessage(message)));
		menu.AddItem(new BMenuItem("3", new BMessage(message)));

		menu.ItemAt(getMappingNumber(fSettings.Mapping(button)))
			->SetMarked(true);
		menu.SetTargetForItems(Window());

		ConvertToScreen(&where);
		menu.Go(where, true);
	}
}
コード例 #12
0
static status_t lowest_position(const BMessage& msg, int32* lowest)
{
    status_t	err;
    int32		position;
    if ( (err = msg.FindInt32("position", 0, lowest)) != B_OK) return err;
    for (int32 k = 1; msg.FindInt32("position", k, &position) == B_OK; k++) {
        if (position < *lowest) *lowest = position;
    }
    return B_OK;
}
コード例 #13
0
ファイル: DaemonClient.cpp プロジェクト: naveedasmat/haiku
status_t
BDaemonClient::GetInstallationLocationInfo(
	BPackageInstallationLocation location, BInstallationLocationInfo& _info)
{
	status_t error = _InitMessenger();
	if (error != B_OK)
		return error;

	// send the request
	BMessage request(B_MESSAGE_GET_INSTALLATION_LOCATION_INFO);
	error = request.AddInt32("location", location);
	if (error != B_OK)
		return error;

	BMessage reply;
	fDaemonMessenger.SendMessage(&request, &reply);
	if (reply.what != B_MESSAGE_GET_INSTALLATION_LOCATION_INFO_REPLY)
		return B_ERROR;

	// extract the location info
	int32 baseDirectoryDevice;
	int64 baseDirectoryNode;
	int32 packagesDirectoryDevice;
	int64 packagesDirectoryNode;
	int64 changeCount;
	BPackageInfoSet activePackages;
	BPackageInfoSet inactivePackages;
	if ((error = reply.FindInt32("base directory device", &baseDirectoryDevice))
			!= B_OK
		|| (error = reply.FindInt64("base directory node", &baseDirectoryNode))
			!= B_OK
		|| (error = reply.FindInt32("packages directory device",
			&packagesDirectoryDevice)) != B_OK
		|| (error = reply.FindInt64("packages directory node",
			&packagesDirectoryNode)) != B_OK
		|| (error = _ExtractPackageInfoSet(reply, "active packages",
			activePackages)) != B_OK
		|| (error = _ExtractPackageInfoSet(reply, "inactive packages",
			inactivePackages)) != B_OK
		|| (error = reply.FindInt64("change count", &changeCount)) != B_OK) {
		return error;
	}

	_info.Unset();
	_info.SetLocation(location);
	_info.SetBaseDirectoryRef(node_ref(baseDirectoryDevice, baseDirectoryNode));
	_info.SetPackagesDirectoryRef(
		node_ref(packagesDirectoryDevice, packagesDirectoryNode));
	_info.SetActivePackageInfos(activePackages);
	_info.SetInactivePackageInfos(inactivePackages);
	_info.SetChangeCount(changeCount);

	return B_OK;
}
コード例 #14
0
ファイル: AlbumView.cpp プロジェクト: HaikuArchives/Album
/**
	Mouse click scenarios.
*/
void AlbumView::MouseDown(BPoint where)
{
    // This is an event hook so there must be a Looper.
	BMessage *message = Window()->CurrentMessage();

    int32 mods = 0, clicks = 0, buttons=0;
    message->FindInt32("modifiers", &mods);
    message->FindInt32("clicks", &clicks);
    message->FindInt32("buttons", &buttons);
		
    // Scale back.
	where.x /= fZoom;
	where.y /= fZoom;
	
	int32 i = IndexOf(&where);
	int32 changes = 0;
	if (i >= 0) {
		AlbumItem *item = ItemAt(i);
		
		// double-clicks are handled later in MouseUp()
		fDoubleClick = (fLastSelected == i && clicks == 2 && (buttons & B_PRIMARY_MOUSE_BUTTON));
        fMayDrag = !fDoubleClick && (buttons & B_PRIMARY_MOUSE_BUTTON);			
        if (mods & B_SHIFT_KEY) 
        	// Block selection
			changes += SelectBlock(fLastSelected, i, !item->IsSelected());
        else if (mods & B_COMMAND_KEY)
        	// Modify selection
        	changes += Select(i, 1, !item->IsSelected());
		else {
			// Normal selection
			if (!item->IsSelected())
				changes += DeselectAll();
        	changes += Select(i);
		}
        fLastWhere = where;
        fLastSelected = i;
    }
    else
	   	changes += DeselectAll();

	if (changes > 0) {
		//PRINT(("selection changed\n"));
    	SelectionChanged();
    	if (!fDoubleClick && Message()) {
			BMessage msg = *Message();
			msg.AddInt32("buttons", buttons);
    		msg.AddPoint("where", where);        
        	msg.AddInt32("index", fLastSelected);
			Invoke(&msg);
    	}
	}
    
    
}
コード例 #15
0
status_t GlMidiEvent::ReadFakeFrom(const BMessage& msg, BString16* portName)
{
	status_t		err;
	if (portName) {
		if ((err = msg.FindString(P_STR, portName)) != B_OK) return err;
	}
	if ((err = msg.FindInt32(T_STR, &type)) != B_OK) return err;
	if ((err = msg.FindInt32(C_STR, &channel)) != B_OK) return err;
	if ((err = msg.FindInt32(V1_STR, &value1)) != B_OK) return err;
	if ((err = msg.FindInt32(V2_STR, &value2)) != B_OK) return err;
	return B_OK;
}
コード例 #16
0
void
AppearancePrefView::_SetWindowSize(int rows, int cols)
{
	for (int32 i = 0; i < fWindowSizeField->Menu()->CountItems(); i++) {
		BMenuItem* item = fWindowSizeField->Menu()->ItemAt(i);
		BMessage* msg = item->Message();
		if (msg->FindInt32("rows") == rows && msg->FindInt32("columns") == cols) {
			item->SetMarked(true);
			break;
		}
	}
}
コード例 #17
0
ファイル: ViewState.cpp プロジェクト: Ithamar/cosmoe
BColumn::BColumn(const BMessage &message, int32 index)
{
	message.FindString(kColumnTitleName, index, &fTitle);
	message.FindFloat(kColumnOffsetName, index, &fOffset);
	message.FindFloat(kColumnWidthName, index, &fWidth);
	message.FindInt32(kColumnAlignmentName, index, (int32 *)&fAlignment);
	message.FindString(kColumnAttrName, index, &fAttrName);
	message.FindInt32(kColumnAttrHashName, index, (int32 *)&fAttrHash);
	message.FindInt32(kColumnAttrTypeName, index, (int32 *)&fAttrType);
	message.FindBool(kColumnStatFieldName, index, &fStatField);
	message.FindBool(kColumnEditableName, index, &fEditable);
}
コード例 #18
0
ファイル: BackgroundImage.cpp プロジェクト: mariuz/haiku
BackgroundImage *
BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop)
{
	attr_info info;
	if (node->GetAttrInfo(kBackgroundImageInfo, &info) != B_OK)
		return NULL;
	
	BMessage container;
	char *buffer = new char [info.size];

	status_t error = node->ReadAttr(kBackgroundImageInfo, info.type, 0, buffer, (size_t)info.size);
	if (error == info.size)
		error = container.Unflatten(buffer);

	delete [] buffer;

	if (error != B_OK)
		return NULL;

	BackgroundImage *result = NULL;
	for (int32 index = 0; ; index++) {
		const char *path;
		uint32 workspaces = B_ALL_WORKSPACES;
		Mode mode = kTiled;
		bool textWidgetLabelOutline = false;
		BPoint offset;
		BBitmap *bitmap = NULL;

		if (container.FindString(kBackgroundImageInfoPath, index, &path) == B_OK) {	
			bitmap = BTranslationUtils::GetBitmap(path);
			if (!bitmap) {
				PRINT(("failed to load background bitmap from path\n"));
			}
		} else
			break;

		container.FindInt32(kBackgroundImageInfoWorkspaces, index, (int32 *)&workspaces);
		container.FindInt32(kBackgroundImageInfoMode, index, (int32 *)&mode);
		container.FindBool(kBackgroundImageInfoTextOutline, index, &textWidgetLabelOutline);
		container.FindPoint(kBackgroundImageInfoOffset, index, &offset);

		BackgroundImage::BackgroundImageInfo *imageInfo = new
			BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode, offset,
				textWidgetLabelOutline);

		if (!result)
			result = new BackgroundImage(node, isDesktop);

		result->Add(imageInfo);
	}
	return result;
}
コード例 #19
0
void _ControllerRangeSettings::RefreshControls(const BMessage& settings)
{
	if (mTable) {
		BMessage		msg;
		for (int32 k = 0; settings.FindMessage(_RANGE_MSG, k, &msg) == B_OK; k++) {
			int32		cc, low, high;
			if (msg.FindInt32(_CC_STR, &cc) == B_OK && msg.FindInt32(_LOW_VALUE, &low) == B_OK
					&& msg.FindInt32(_HIGH_VALUE, &high) == B_OK)
				mTable->UpdateCc(cc, low, high);
			msg.MakeEmpty();
		}
	}
}
コード例 #20
0
ファイル: StateView.cpp プロジェクト: mmadia/haiku-1
// KeyUp
void
StateView::KeyUp(const char* bytes, int32 numBytes)
{
    uint32 key;
    uint32 modifiers;
    BMessage* message = Window() ? Window()->CurrentMessage() : NULL;
    if (message
            && message->FindInt32("raw_char", (int32*)&key) >= B_OK
            && message->FindInt32("modifiers", (int32*)&modifiers) >= B_OK) {
        if (HandleKeyUp(key, modifiers))
            return;
    }
    BView::KeyUp(bytes, numBytes);
}
コード例 #21
0
ファイル: ViewState.cpp プロジェクト: Ithamar/cosmoe
BViewState::BViewState(const BMessage &message)
{
	message.FindInt32(kViewStateViewModeName, (int32 *)&fViewMode);
	message.FindInt32(kViewStateLastIconModeName, (int32 *)&fLastIconMode);
	message.FindPoint(kViewStateListOriginName, &fListOrigin);
	message.FindPoint(kViewStateIconOriginName, &fIconOrigin);
	message.FindInt32(kViewStatePrimarySortAttrName, (int32 *)&fPrimarySortAttr);
	message.FindInt32(kViewStatePrimarySortTypeName, (int32 *)&fPrimarySortType);
	message.FindInt32(kViewStateSecondarySortAttrName, (int32 *)&fSecondarySortAttr);
	message.FindInt32(kViewStateSecondarySortTypeName, (int32 *)&fSecondarySortType);
	message.FindBool(kViewStateReverseSortName, &fReverseSort);
	
	fStateNeedsSaving = false;
}
コード例 #22
0
ファイル: MimeType.cpp プロジェクト: AmirAbrams/haiku
// Sets the list of filename extensions associated with the MIME type
status_t
BMimeType::SetFileExtensions(const BMessage* extensions)
{
	status_t err = InitCheck();

	BMessage message(extensions ? B_REG_MIME_SET_PARAM : B_REG_MIME_DELETE_PARAM);
	BMessage reply;
	status_t result;

	// Build and send the message, read the reply
	if (err == B_OK)
		err = message.AddString("type", Type());

	if (err == B_OK)
		err = message.AddInt32("which", B_REG_MIME_FILE_EXTENSIONS);

	if (err == B_OK && extensions != NULL)
		err = message.AddMessage("extensions", extensions);

	if (err == B_OK)
		err = BRoster::Private().SendTo(&message, &reply, true);

	if (err == B_OK)
		err = (status_t)(reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY);

	if (err == B_OK)
		err = reply.FindInt32("result", &result);

	if (err == B_OK)
		err = result;

	return err;
}
コード例 #23
0
ファイル: Deskbar.cpp プロジェクト: looncraz/haiku
deskbar_location
BDeskbar::Location(bool* _isExpanded) const
{
	deskbar_location location = B_DESKBAR_RIGHT_TOP;
	BMessage request(kMsgLocation);
	BMessage reply;

	if (_isExpanded)
		*_isExpanded = true;

	if (fMessenger->IsTargetLocal()) {
		// ToDo: do something about this!
		// (if we just ask the Deskbar in this case, we would deadlock)
		return location;
	}

	if (fMessenger->SendMessage(&request, &reply) == B_OK) {
		int32 value;
		if (reply.FindInt32("location", &value) == B_OK)
			location = static_cast<deskbar_location>(value);

		if (_isExpanded && reply.FindBool("expanded", _isExpanded) != B_OK)
			*_isExpanded = true;
	}

	return location;
}
コード例 #24
0
ファイル: MimeType.cpp プロジェクト: AmirAbrams/haiku
// Sets the app hint field for the MIME type
status_t
BMimeType::SetAppHint(const entry_ref* ref)
{
	status_t err = InitCheck();

	BMessage message(ref ? B_REG_MIME_SET_PARAM : B_REG_MIME_DELETE_PARAM);
	BMessage reply;
	status_t result;

	// Build and send the message, read the reply
	if (err == B_OK)
		err = message.AddString("type", Type());

	if (err == B_OK)
		err = message.AddInt32("which", B_REG_MIME_APP_HINT);

	if (err == B_OK && ref != NULL)
		err = message.AddRef("app hint", ref);

	if (err == B_OK)
		err = BRoster::Private().SendTo(&message, &reply, true);

	if (err == B_OK)
		err = (status_t)(reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY);

	if (err == B_OK)
		err = reply.FindInt32("result", &result);

	if (err == B_OK)
		err = result;

	return err;
}
コード例 #25
0
void
ImageView::MouseDown(BPoint point)
{
	if (!HasImage())
		return;

	// Only accept left button clicks
	BMessage *pmsg = Window()->CurrentMessage();
	int32 button = pmsg->FindInt32("buttons");
	if (button != B_PRIMARY_MOUSE_BUTTON)
		return;

	// Tell BeOS to setup a Drag/Drop operation
	//
	// (When the image is dropped, BeOS sends
	// the following message to ImageWindow,
	// which causes it to call ImageView::SetImage())
	BMessage msg(B_SIMPLE_DATA);
	msg.AddInt32("be:actions", B_COPY_TARGET);
	msg.AddString("be:filetypes", "application/octet-stream");
	msg.AddString("be:types", "application/octet-stream");
	msg.AddString("be:clip_name", "Bitmap");

	DragMessage(&msg, Bounds());
}
コード例 #26
0
status_t GlPlaneNode::ReadFrom(const BMessage& config)
{
	status_t		err = inherited::ReadFrom(config);
	int32			i32;
	if (config.FindInt32(PIXEL_TARGETS_IO, &i32) == B_OK) mPixelTargets = i32;
	return err;
}
コード例 #27
0
ファイル: MainView.cpp プロジェクト: brennanos/XFile-Haiku
void MainView::MouseDown(BPoint point)
{
	int32 mask;
	
	if(!track_mouse) return;
	
	BMessage *msg = Window()->CurrentMessage();
	msg->FindInt32("buttons", &mask);
	if(mask == B_SECONDARY_MOUSE_BUTTON) {
		showPopUp(ConvertToScreen(point));
		drag_start = point;
		return;
	}
	
	Invalidate();
	Field *child = getFieldByPoint(point);
	if(child && child->IsSelected()) {
		drag_move = true;
		drag_start = point;
		//this->BeginRectTracking(sel_bounds.OffsetByCopy(-2,-2));
		h_ruler->SetSelRect(sel_bounds);
		v_ruler->SetSelRect(sel_bounds);
		h_ruler->UpdateSlider(point);
		v_ruler->UpdateSlider(point);
	}
	else {
		this->BeginRectTracking(BRect(point.x, point.y,point.x,point.y), B_TRACK_RECT_CORNER);
		drag_select = true;
		sel_rect.SetLeftTop(point);
	}
}
コード例 #28
0
ファイル: GMenu.cpp プロジェクト: FEI17N/Lgi
int GSubMenu::Float(GView *Parent, int x, int y, bool Left)
{
	if (Info)
	{
		BPopUpMenu *Popup = new BPopUpMenu("PopUpMenu");
		if (Popup)
		{
			_CopyMenu(Popup, this);
		
			BPoint Pt(x, y);
			BMenuItem *Item = Popup->Go(Pt);
			if (Item)
			{
				#undef Message
				BMessage *Msg = Item->Message();
				int32 i;
				if (Msg && Msg->FindInt32("Cmd", &i) == B_OK)
				{
					return i;
				}
			}
		}
	}
	
	return 0;
}
コード例 #29
0
ファイル: ObjectView.cpp プロジェクト: DonCN/haiku
void
ObjectView::MouseDown(BPoint point)
{
	GLObject* object = NULL;

	BMessage *msg = Window()->CurrentMessage();
	uint32 buttons = msg->FindInt32("buttons");
	object = reinterpret_cast<GLObject*>(fObjects.ItemAt(ObjectAtPoint(point)));

	if (object != NULL){
		if (buttons == B_PRIMARY_MOUSE_BUTTON || buttons == B_SECONDARY_MOUSE_BUTTON) {
			fTrackingInfo.pickedObject = object;
			fTrackingInfo.buttons = buttons;
			fTrackingInfo.isTracking = true;
			fTrackingInfo.lastX = point.x;
			fTrackingInfo.lastY = point.y;
			fTrackingInfo.lastDx = 0.0f;
			fTrackingInfo.lastDy = 0.0f;
			fTrackingInfo.pickedObject->Spin(0.0f, 0.0f);


			SetMouseEventMask(B_POINTER_EVENTS,
						B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY);

			BCursor grabbingCursor(B_CURSOR_ID_GRABBING);
			SetViewCursor(&grabbingCursor);
		} else {
			ConvertToScreen(&point);
			object->MenuInvoked(point);
		}
	}
}
コード例 #30
0
ファイル: ScreenshotWindow.cpp プロジェクト: AmirAbrams/haiku
void
ScreenshotWindow::_ReadSettings()
{
	BMessage settings;

	BPath settingsPath;
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &settingsPath) != B_OK)
		return;

	settingsPath.Append("Screenshot_settings");

	BFile file(settingsPath.Path(), B_READ_ONLY);
	if (file.InitCheck() == B_OK)
		settings.Unflatten(&file);

	if (settings.FindInt32("type", &fImageFileType) != B_OK)
		fImageFileType = B_PNG_FORMAT;
	settings.FindBool("includeBorder", &fIncludeBorder);
	settings.FindBool("includeCursor", &fIncludeCursor);
	settings.FindBool("grabActiveWindow", &fGrabActiveWindow);
	settings.FindInt64("delay", &fDelay);
	settings.FindString("outputFilename", &fOutputFilename);

	_SetupOutputPathMenu(settings);
}