Exemple #1
0
status_t
ActivityView::SaveState(BMessage& state) const
{
	status_t status = state.AddBool("show legend", fShowLegend);
	if (status != B_OK)
		return status;

	status = state.AddInt64("refresh interval", fRefreshInterval);
	if (status != B_OK)
		return status;

	status = state.AddData("history background color", B_RGB_COLOR_TYPE,
		&fHistoryBackgroundColor, sizeof(rgb_color));
	if (status != B_OK)
		return status;

	for (int32 i = 0; i < fSources.CountItems(); i++) {
		DataSource* source = fSources.ItemAt(i);

		if (!source->PerCPU() || source->CPU() == 0)
			status = state.AddString("source", source->InternalName());
		if (status != B_OK)
			return status;

		BString name = source->Name();
		name << " color";
		rgb_color color = source->Color();
		state.AddData(name.String(), B_RGB_COLOR_TYPE, &color,
			sizeof(rgb_color));
	}
	return B_OK;
}
Exemple #2
0
void MediaJack::showContextMenu(
	BPoint point)
{
	D_METHOD(("MediaJack::showContextMenu()\n"));

	BPopUpMenu *menu = new BPopUpMenu("MediaJack PopUp", false, false, B_ITEMS_IN_COLUMN);
	menu->SetFont(be_plain_font);
	BMenuItem *item;

	// add the "Get Info" item
	if (isInput())
	{
		media_input input;
		getInput(&input);
		BMessage *message = new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED);
		message->AddData("input", B_RAW_TYPE,
						 reinterpret_cast<const void *>(&input), sizeof(input));
		menu->AddItem(item = new BMenuItem("Get info", message));
	}
	else if (isOutput())
	{
		media_output output;
		getOutput(&output);
		BMessage *message = new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED);
		message->AddData("output", B_RAW_TYPE,
						 reinterpret_cast<const void *>(&output), sizeof(output));
		menu->AddItem(item = new BMenuItem("Get info", message));
	}

	menu->SetTargetForItems(view());
	view()->ConvertToScreen(&point);
	point -= BPoint(1.0, 1.0);
	menu->Go(point, true, true, true);
}
Exemple #3
0
bool gui_commit_clipboard(void)
{
	BMessage *clip;

	if (current_selection.Length() == 0)
		return true;

	if (be_clipboard->Lock()) {
		be_clipboard->Clear();
		clip = be_clipboard->Data();
		if (clip) {
			clip->AddData("text/plain", B_MIME_TYPE, 
				current_selection.String(), 
				current_selection.Length());
			int arraySize = sizeof(text_run_array) + 
				current_selection_textruns.CountItems() * sizeof(text_run);
			text_run_array *array = (text_run_array *)malloc(arraySize);
			array->count = current_selection_textruns.CountItems();
			for (int i = 0; i < array->count; i++)
				memcpy(&array->runs[i], current_selection_textruns.ItemAt(i), 
					sizeof(text_run));
			clip->AddData("application/x-vnd.Be-text_run_array", B_MIME_TYPE, 
				array, arraySize);
			free(array);
			
			gui_empty_clipboard();
			be_clipboard->Commit();
		}
		be_clipboard->Unlock();
	}
	return true;
}
Exemple #4
0
void
FindTextView::Copy(BClipboard* clipboard)
{
	if (fMode != kHexMode) {
		BTextView::Copy(clipboard);
		return;
	}

	int32 start, end;
	GetSelection(&start, &end);

	if (clipboard == NULL || start == end)
		return;

	AutoLocker<BClipboard> _(clipboard);

	BMessage* clip = clipboard->Data();
	if (clip == NULL)
		return;

	// convert hex-text to real data
	uint8* data;
	size_t dataSize;
	if (_GetDataFromHex(Text() + start, end - start, &data, &dataSize)
			!= B_OK)
		return;

	clip->AddData(B_FILE_MIME_TYPE, B_MIME_TYPE, data, dataSize);

	if (is_valid_utf8(data, dataSize))
		clip->AddData("text/plain", B_MIME_TYPE, data, dataSize);

	free(data);
}
void
FileTypesWindow::_MoveUpAttributeIndex(int32 index)
{
	BMessage attributes;
	if (fCurrentType.GetAttrInfo(&attributes) != B_OK)
		return;

	// Iterate over all known attribute fields, and for each field,
	// iterate over all fields of the same name and build a copy
	// of the attributes message with the field at the given index swapped
	// with the previous field.
	BMessage resortedAttributes;
	for (uint32 i = 0; i <
			sizeof(kAttributeNames) / sizeof(kAttributeNames[0]);
			i++) {

		type_code type;
		int32 count;
		bool isFixedSize;
		if (attributes.GetInfo(kAttributeNames[i], &type, &count,
				&isFixedSize) != B_OK) {
			// Apparently the message does not contain this name,
			// so just ignore this attribute name.
			// NOTE: This shows that the attribute description is
			// too fragile. It would have been better to pack each
			// attribute description into a separate BMessage. 
			continue;
		}

		for (int32 j = 0; j < count; j++) {
			const void* data;
			ssize_t size;
			int32 originalIndex;
			if (j == index - 1)
				originalIndex = j + 1;
			else if (j == index)
				originalIndex = j - 1;
			else
				originalIndex = j; 
			attributes.FindData(kAttributeNames[i], type,
				originalIndex, &data, &size);
			if (j == 0) {
				resortedAttributes.AddData(kAttributeNames[i], type,
					data, size, isFixedSize);
			} else {
				resortedAttributes.AddData(kAttributeNames[i], type,
					data, size);
			}
		}
	}

	// Setting it directly on the type will trigger an update of the GUI as
	// well. TODO: FileTypes is heavily descructive, it should use an
	// Undo/Redo stack.
	fCurrentType.SetAttrInfo(&resortedAttributes);
}
Exemple #6
0
void
FindTextView::GetData(BMessage& message)
{
	if (fMode == kHexMode) {
		// convert hex-text to real data
		uint8* data;
		size_t dataSize;
		if (_GetDataFromHex(Text(), TextLength(), &data, &dataSize) != B_OK)
			return;

		message.AddData("data", B_RAW_TYPE, data, dataSize);
		free(data);
	} else
		message.AddData("data", B_RAW_TYPE, Text(), TextLength());
}
  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;
    }
  };
void
TextDocumentView::Copy(BClipboard* clipboard)
{
	if (!HasSelection() || fTextDocument.Get() == NULL) {
		// Nothing to copy, don't clear clipboard contents for now reason.
		return;
	}

	if (clipboard == NULL || !clipboard->Lock())
		return;

	clipboard->Clear();

	BMessage* clip = clipboard->Data();
	if (clip != NULL) {
		int32 start;
		int32 end;
		GetSelection(start, end);

		BString text = fTextDocument->Text(start, end - start);
		clip->AddData("text/plain", B_MIME_TYPE, text.String(),
			text.Length());

		// TODO: Support for "application/x-vnd.Be-text_run_array"

		clipboard->Commit();
	}

	clipboard->Unlock();
}
Exemple #9
0
void
TermView::KeyDown(const char* bytes, int32 numBytes)
{
	// Translate some keys to more usual VT100 escape codes
	switch (bytes[0]) {
		case B_UP_ARROW:
			numBytes = 3;
			bytes = "\x1B[A";
			break;
		case B_DOWN_ARROW:
			numBytes = 3;
			bytes = "\x1B[B";
			break;
		case B_RIGHT_ARROW:
			numBytes = 3;
			bytes = "\x1B[C";
			break;
		case B_LEFT_ARROW:
			numBytes = 3;
			bytes = "\x1B[D";
			break;
		case B_BACKSPACE:
			numBytes = 1;
			bytes = "\x7F";
			break;
	}

	// Send the bytes to the serial port
	BMessage* keyEvent = new BMessage(kMsgDataWrite);
	keyEvent->AddData("data", B_RAW_TYPE, bytes, numBytes);
	be_app_messenger.SendMessage(keyEvent);
}
Exemple #10
0
/* static */
status_t SerialApp::PollSerial(void*)
{
	SerialApp* application = (SerialApp*)be_app;
	char buffer[256];

	for(;;)
	{
		ssize_t bytesRead;

		bytesRead = application->fSerialPort.Read(buffer, sizeof(buffer));
		if (bytesRead == B_FILE_ERROR)
		{
			// Port is not open - wait for it and start over
			acquire_sem(application->fSerialLock);
		} else if (bytesRead > 0) {
			// We read something, forward it to the app for handling
			BMessage* serialData = new BMessage(kMsgDataRead);
			serialData->AddData("data", B_RAW_TYPE, buffer, bytesRead);
			be_app_messenger.SendMessage(serialData);
		}
	}
	
	// Should not reach this line anyway...
	return B_OK;
}
Exemple #11
0
void
MixerSettings::Save()
{
	fLocker->Lock();
	// if we don't have a settings file, don't continue
	if (!fSettingsFile) {
		fLocker->Unlock();
		return;
	}
	TRACE("MixerSettings: SAVE!\n");

	BMessage msg;
	msg.AddInt32("version", SETTINGS_VERSION);
	msg.AddData("settings", B_RAW_TYPE, (void *)&fSettings, sizeof(fSettings));
	msg.AddMessage("output", &fOutputSetting);
	for (int i = 0; i < MAX_INPUT_SETTINGS; i++)
		msg.AddMessage("input", &fInputSetting[i]);

	char *buffer;
    size_t length;

    length = msg.FlattenedSize();
    buffer = new char [length];
    msg.Flatten(buffer, length);

	BFile file(fSettingsFile->Path(), B_READ_WRITE | B_CREATE_FILE);
	file.Write(buffer, length);

   	delete [] buffer;

	fSettingsDirty = false;
	fLocker->Unlock();
}
Exemple #12
0
void QHaikuClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode)
{
    if (mode != QClipboard::Clipboard)
        return;

    if (!be_clipboard->Lock())
        return;

    be_clipboard->Clear();
    if (mimeData) {
        BMessage *clipboard = be_clipboard->Data();
        if (clipboard) {
            const QStringList formats = mimeData->formats();
            Q_FOREACH (const QString &format, formats) {
                const QByteArray data = mimeData->data(format).data();
                clipboard->AddData(format.toUtf8(), B_MIME_TYPE, data, data.count());
            }
        }
    }

    if (be_clipboard->Commit() != B_OK)
        qWarning("Unable to store mime data on clipboard");

    be_clipboard->Unlock();
}
Exemple #13
0
/*! This method is called when BMediaFormats asks for any updates
 	made to our format list.
	If there were any changes since the last time, the whole
	list will be sent back.
*/
void 
FormatManager::GetFormats(BMessage& message)
{
	BAutolock locker(fLock);

	bigtime_t lastUpdate;
	if (message.FindInt64("last_timestamp", &lastUpdate) == B_OK
		&& lastUpdate >= fLastUpdate) {
		// There weren't any changes since last time.
		BMessage reply;
		reply.AddBool("need_update", false);

		message.SendReply(&reply, (BHandler*)NULL, TIMEOUT);
		return;
	}

	// Add all meta formats to the list
	BMessage reply;
	reply.AddBool("need_update", true);
	reply.AddInt64("timestamp", system_time());

	int32 count = fList.CountItems();
	printf("FormatManager::GetFormats(): put %" B_PRId32 " formats into "
		"message\n", count);
	for (int32 i = 0; i < count; i++) {
		meta_format* format = fList.ItemAt(i);
		reply.AddData("formats", MEDIA_META_FORMAT_TYPE, format,
			sizeof(meta_format));
	}

	message.SendReply(&reply, (BHandler*)NULL, TIMEOUT);
}
/*!	Stores all configurations as separate BMessages into the provided
	\a settings container.
*/
status_t
ScreenConfigurations::Store(BMessage& settings) const
{
	// Store the configuration of all current screens

	for (int32 i = 0; i < fConfigurations.CountItems(); i++) {
		screen_configuration* configuration = fConfigurations.ItemAt(i);

		BMessage screenSettings;
		screenSettings.AddInt32("id", configuration->id);

		if (configuration->has_info) {
			screenSettings.AddString("vendor", configuration->info.vendor);
			screenSettings.AddString("name", configuration->info.name);
			screenSettings.AddInt32("product id",
				configuration->info.product_id);
			screenSettings.AddString("serial",
				configuration->info.serial_number);
			screenSettings.AddInt32("produced week",
				configuration->info.produced.week);
			screenSettings.AddInt32("produced year",
				configuration->info.produced.year);
		}

		screenSettings.AddRect("frame", configuration->frame);
		screenSettings.AddData("mode", B_RAW_TYPE, &configuration->mode,
			sizeof(display_mode));

		settings.AddMessage("screen", &screenSettings);
	}

	return B_OK;
}
BMessage* Copy::Do(PDocument *doc, BMessage *settings)
{
	BMessage 	*clip				= NULL;
	BMessage	*node				= NULL;
	BMessage	*from				= NULL;
	BMessage	*to					= NULL;
	bool		fselect				= false;
	bool		tselect				= false;
	BMessage	*copyMessage		= new BMessage();
	BList		*selected			= doc->GetSelected();
	BList		*allConnections		= doc->GetAllConnections();

	int32		i					= 0;
	Indexer		*indexer			= new Indexer(doc);
	if (doc->Lock())
	{
		for (i=0;i<selected->CountItems();i++)
		{
			if (node=(BMessage *)selected->ItemAt(i))
			{
				if (node->what != P_C_CONNECTION_TYPE)
					copyMessage->AddMessage("node",indexer->IndexNode(node));
			}

		}
		for (i=0;i<allConnections->CountItems();i++ )
		{

			node = (BMessage *)allConnections->ItemAt(i);
			if ( (node->FindPointer("From",(void **)&from) == B_OK) &&
				 (node->FindPointer("To",(void **)&to) == B_OK) )
			{
				if ((from->FindBool("selected",&fselect)==B_OK) && (to->FindBool("selected",&tselect) == B_OK) )
				{
					if (fselect && tselect)
						copyMessage->AddMessage("node",indexer->IndexConnection(node,true));
					else if (fselect || tselect)
						copyMessage->AddMessage("node",indexer->IndexConnection(node));
				}
			}

		}	
		doc->Unlock();
	}
	if (be_clipboard->Lock()) 
	{
		be_clipboard->Clear();
		if (clip = be_clipboard->Data()) 
		{
			clip->AddData("application/x-vnd.projectconceptor-document", B_MIME_TYPE, copyMessage, sizeof(copyMessage));
			clip->AddMessage("test",copyMessage);
			PRINT_OBJECT(*clip);
			be_clipboard->Commit();
		}
		be_clipboard->Unlock();
	} 
	settings = PCommand::Do(doc,settings);
	return settings;
}
void PasteOMaticPaster::MessageReceived(BMessage *message)
{
    void *data;
    char *returnString;
    int32 size;
    entry_ref ref;
    BMessage reply;
    BMessage *clip;

    switch (message->what)
    {
    case MESSAGE_PASTE_POINTER:
        cout << "Paster: got pointer\n";
        message->PrintToStream();
        message->FindPointer("data", &data);
        message->FindInt32("size", &size);
        returnString = _Paste(data, (size_t)size);
        break;
    case MESSAGE_PASTE_REF:
        cout << "Paster: got ref\n";
        message->PrintToStream();
        message->FindRef("ref", &ref);
        returnString = _Paste(&ref);
    }
    if (success)
    {
        cerr << "Paster sending SUCCESS message: ";
        reply.what = MESSAGE_PASTE_SUCCESS;
        reply.AddString("link", returnString);

        be_clipboard->Lock();
        be_clipboard->Clear();
        if ((clip = be_clipboard->Data()))
        {
            clip->AddData("text/plain", B_MIME_TYPE, returnString, strlen(returnString));
            be_clipboard->Commit();
        }
        be_clipboard->Unlock();


        reply.PrintToStream();
        fHandler->Looper()->Lock();
        fHandler->MessageReceived(&reply);
        fHandler->Looper()->Unlock();
    }
    else
    {
        cerr << "Paster sending FAIL message: ";
        reply.what = MESSAGE_PASTE_FAIL;
        reply.AddString("error", returnString);
        reply.PrintToStream();
        fHandler->Looper()->Lock();
        fHandler->MessageReceived(&reply);
        fHandler->Looper()->Unlock();
    }

    Quit();
}
Exemple #17
0
status_t
AddRGBColor(BMessage &message, const char *name, rgb_color a_color, type_code type)
{
#ifdef B_BEOS_VERSION_DANO
	return message.AddRGBColor(name, a_color, type);
#else
	return message.AddData(name, type, &a_color, sizeof(a_color));
#endif
}
Exemple #18
0
status_t
AddFont(BMessage &message, const char *name, BFont *f, int32 count)
{
#ifdef B_BEOS_VERSION_DANO
	return message.AddFlat(name, f, count);
#else
	return message.AddData(name, 'FONt', (void *)&f, sizeof(f), true, count);
#endif
}
Exemple #19
0
void PutScrap(uint32 type, void *scrap, int32 length)
{
	D(bug("PutScrap type %08lx, data %p, length %ld\n", type, scrap, length));
	if (we_put_this_data) {
		we_put_this_data = false;
		return;
	}
	if (length <= 0)
		return;

	switch (type) {
		case 'TEXT':
			D(bug(" clipping TEXT\n"));
			cm_scrap = scrap;
			cm_length = length;
			while (send_data(cm_thread, MSG_PUT_TEXT, NULL, 0) == B_INTERRUPTED) ;
			while (acquire_sem(cm_done_sem) == B_INTERRUPTED) ;
			break;

		case 'PICT':
			D(bug(" clipping PICT\n"));
			//!! this has to be converted to use the Clipboard Manager
#if 0
			if (be_clipboard->Lock()) {
				be_clipboard->Clear();
				BMessage *clipper = be_clipboard->Data();				
	// Waaaah! This crashes!
				if (input_cap > 0) {		// if there is an converter for PICT datatype convert data to bitmap.
					BMemoryIO *in_buffer = new BMemoryIO(scrap, length);
					BMallocIO *out_buffer = new BMallocIO();
					status_t result=roster->Translate(in_buffer,&input_info,NULL,out_buffer,B_TRANSLATOR_BITMAP);
					clipper->AddData("image/x-be-bitmap", B_MIME_TYPE, out_buffer->Buffer(), out_buffer->BufferLength());
					D(bug("conversion result:%08x buffer_size:%d\n",result,out_buffer->BufferLength()));
					delete in_buffer;
					delete out_buffer;
				}
				clipper->AddData("image/pict", B_MIME_TYPE, scrap, length);
				be_clipboard->Commit();
				be_clipboard->Unlock();
			}
#endif
			break;
	}
}
/* static */
BMenuItem *
OutputView::CreateCodecMenuItem(const media_codec_info &codec)
{
	BMessage *message = new BMessage(kCodecChanged);
	if (message == NULL)
		return NULL;
	message->AddData(kCodecData, B_SIMPLE_DATA, &codec, sizeof(media_codec_info));
	BMenuItem *item = new BMenuItem(codec.pretty_name, message);
	return item;
}
Exemple #21
0
void 
BTextView::CutUndoBuffer::RedoSelf(BClipboard* clipboard)
{
	BMessage* clip = NULL;
	
	fTextView->Select(fStart, fStart);
	fTextView->Delete(fStart, fEnd);
	if (clipboard->Lock()) {
		clipboard->Clear();
		if ((clip = clipboard->Data())) {
			clip->AddData("text/plain", B_MIME_TYPE, fTextData, fTextLength);
			if (fRunArray)
				clip->AddData("application/x-vnd.Be-text_run_array",
					B_MIME_TYPE, fRunArray, fRunArrayLength);
			clipboard->Commit();
		}
		clipboard->Unlock();
	}
}
Exemple #22
0
void
BDirMenu::AddItemToDirMenu(const BEntry* entry, BWindow* originatingWindow,
	bool atEnd, bool addShortcuts, bool navMenuEntries)
{
	Model model(entry);
	if (model.InitCheck() != B_OK)
		return;

	BMessage* message = new BMessage(fCommand);
	message->AddRef(fEntryName.String(), model.EntryRef());

	// add reference to the container windows model so that we can
	// close the window if
	BContainerWindow* window = originatingWindow ?
		dynamic_cast<BContainerWindow*>(originatingWindow) : 0;
	if (window)
		message->AddData("nodeRefsToClose", B_RAW_TYPE,
			window->TargetModel()->NodeRef(), sizeof (node_ref));
	ModelMenuItem* item;
	if (navMenuEntries) {
		BNavMenu* subMenu = new BNavMenu(model.Name(), B_REFS_RECEIVED,
			fTarget, window);
		entry_ref ref;
		entry->GetRef(&ref);
		subMenu->SetNavDir(&ref);
		item = new ModelMenuItem(&model, subMenu);
		item->SetLabel(model.Name());
		item->SetMessage(message);
	} else {
		item = new ModelMenuItem(&model, model.Name(), message);
	}

	if (addShortcuts) {
		if (model.IsDesktop())
			item->SetShortcut('D', B_COMMAND_KEY);
		else if (FSIsHomeDir(entry))
			item->SetShortcut('H', B_COMMAND_KEY);
	}

	if (atEnd)
		AddItem(item);
	else
		AddItem(item, 0);

	item->SetTarget(fTarget);

	if (fMenuBar) {
		ModelMenuItem* menu
			= dynamic_cast<ModelMenuItem*>(fMenuBar->ItemAt(0));
		if (menu) {
			ThrowOnError(menu->SetEntry(entry));
			item->SetMarked(true);
		}
	}
}
Exemple #23
0
void
DataView::InitiateDrag(view_focus focus)
{
	BMessage *drag = new BMessage(B_MIME_DATA);

	// Add originator and action
	drag->AddPointer("be:originator", this);
	//drag->AddString("be:clip_name", "Byte Clipping");
	//drag->AddInt32("be_actions", B_TRASH_TARGET);

	// Add data (just like in Copy())
	uint8 *data = fData + fStart;
	size_t length = fEnd + 1 - fStart;

	drag->AddData(B_FILE_MIME_TYPE, B_MIME_TYPE, data, length);
	if (is_valid_utf8(data, length))
		drag->AddData("text/plain", B_MIME_TYPE, data, length);

	// get a frame that contains the whole selection - SelectionFrame()
	// only spans a rectangle between the start and the end point, so
	// we have to pass it the correct input values

	BRect frame;
	const int32 width = kBlockSize - 1;
	int32 first = fStart & ~width;
	int32 last = ((fEnd + width) & ~width) - 1;
	if (first == (last & ~width))
		frame = SelectionFrame(focus, fStart, fEnd);
	else
		frame = SelectionFrame(focus, first, last);

	BRect bounds = Bounds();
	if (!bounds.Contains(frame))
		frame = bounds & frame;

	DragMessage(drag, frame, NULL);

	fStoredStart = fStart;
	fStoredEnd = fEnd;
	fDragMessageSize = length;
}
void
DeviceWatcher::_SetIcons(BMidiEndpoint* endpoint)
{
	BMessage msg;

	if (fVectorIconData && fVectorIconDataSize > 0) {
		msg.AddData("icon", B_VECTOR_ICON_TYPE, fVectorIconData,
			fVectorIconDataSize);
	}

	if (fLargeIcon) {
		msg.AddData("be:large_icon", B_LARGE_ICON_TYPE, fLargeIcon->Bits(),
			fLargeIcon->BitsLength());
	}

	if (fMiniIcon) {
		msg.AddData("be:mini_icon", B_MINI_ICON_TYPE, fMiniIcon->Bits(),
			fMiniIcon->BitsLength());
	}

	endpoint->SetProperties(&msg);
}
Exemple #25
0
void DeskbarView::MouseUp(BPoint point)
{
   uint32 buttons = lastButtons;
   
   BMessage *mes = new BMessage('TRAY');
   mes->AddInt32("event",TRAY_MOUSEUP);
   mes->AddPoint("point",ConvertToScreen(point));
   mes->AddInt32("buttons",buttons);
   mes->AddInt32("clicks",1);
   mes->AddData("qtrayobject",B_ANY_TYPE,&traysysobject,sizeof(void*));
   ReplyMessenger.SendMessage(mes);
   
}
void RemoveAttribute::AddAttribute(PDocument *doc, BMessage *node, BMessage *valueContainer,BMessage *undoMessage)
{
	node->PrintToStream();
	valueContainer->PrintToStream();
	undoMessage->PrintToStream();
	int32 		i				= 0;
	status_t	err				= B_OK;
	BList		*subGroupList	= new BList();
	BMessage	*subGroup		= NULL;
	BMessage	*tmpSubGroup	= new BMessage();
	BList		*changed		= doc->GetChangedNodes();
	//do 
	char		*name			= NULL;
	char		*subGroupName	= NULL;
	type_code	type			= B_ANY_TYPE;
	ssize_t		size			= 0;
	
	//undo
	char		*compareName	= NULL;
	void*		newValue		= NULL;
	int32		lastIndex		= -1;
	int32		count			= 0;
	int32		index			= 0;
	type_code	typeFound		= B_ANY_TYPE;

	err = undoMessage->FindString("deletedName",(const char**)&name);
	err = err | undoMessage->FindInt32("deletedType",(int32 *)&type);
	err = undoMessage->FindData("deletedAttribut", type,(const void **)&newValue, &size);
	
	subGroup = node;
	subGroupList->AddItem(subGroup);
	while (valueContainer->FindString("subgroup",i,(const char**)&subGroupName) == B_OK)
	{	
		subGroup->FindMessage(subGroupName,tmpSubGroup);
		subGroupList->AddItem(tmpSubGroup);
		subGroup	= tmpSubGroup;
		tmpSubGroup	= new BMessage();
		i++;
	}
	delete tmpSubGroup;
	subGroup->AddData(name,type,newValue,size);
	for (i=subGroupList->CountItems()-1;i>0;i--)
	{
		tmpSubGroup = (BMessage *)subGroupList->ItemAt(i-1);
		valueContainer->FindString("subgroup",i-1,(const char**)&subGroupName);
		if (tmpSubGroup)
			tmpSubGroup->ReplaceMessage(subGroupName,(BMessage *)subGroupList->ItemAt(i));
		delete subGroupList->RemoveItem(i);
	}
	changed->AddItem(node);
}
Exemple #27
0
void copy_to_clipboard(const std::string& text, const bool)
{
	BMessage *clip;
	if (be_clipboard->Lock())
	{
		be_clipboard->Clear();
		if ((clip = be_clipboard->Data()))
		{
			clip->AddData("text/plain", B_MIME_TYPE, text.c_str(), text.size()+1);
			be_clipboard->Commit();
		}
		be_clipboard->Unlock();
	}
}
Exemple #28
0
void
DataView::Copy()
{
	if (!be_clipboard->Lock())
		return;

	be_clipboard->Clear();

	BMessage *clip;
	if ((clip = be_clipboard->Data()) != NULL) {
		uint8 *data = fData + fStart;
		size_t length = fEnd + 1 - fStart;

		clip->AddData(B_FILE_MIME_TYPE, B_MIME_TYPE, data, length);

		if (is_valid_utf8(data, length))
			clip->AddData("text/plain", B_MIME_TYPE, data, length);

		be_clipboard->Commit();
	}

	be_clipboard->Unlock();
}
Exemple #29
0
void Pasteboard::writePlainText(const String& text)
{
    AutoClipboardLocker locker(be_clipboard);
    if (!locker.isLocked())
        return;

    be_clipboard->Clear();
    BMessage* data = be_clipboard->Data();
    if (!data)
        return;

    BString string(text);
    data->AddData("text/plain", B_MIME_TYPE, string.String(), string.Length());
    be_clipboard->Commit();
}
Exemple #30
0
void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
{
    AutoClipboardLocker locker(be_clipboard);
    if (!locker.isLocked())
        return;

    be_clipboard->Clear();
    BMessage* data = be_clipboard->Data();
    if (!data)
        return;

    BString string(frame->editor()->selectedText());

    // Replace unwanted representation of blank lines
    const char* utf8BlankLine = "\302\240\n";
    string.ReplaceAll(utf8BlankLine, "\n");

    data->AddData("text/plain", B_MIME_TYPE, string.String(), string.Length());

    BString markupString(createMarkup(selectedRange, 0, AnnotateForInterchange, false, ResolveNonLocalURLs));
    data->AddData("text/html", B_MIME_TYPE, markupString.String(), markupString.Length());

    be_clipboard->Commit();
}