Exemple #1
0
/*!
	\brief Retrieves a cursor from the set.
	\param which System cursor specifier defined in CursorSet.h
	\param cursor ServerCursor** to receive a newly-allocated ServerCursor containing the appropriate data
	\return
	- \c B_OK: Success
	- \c B_BAD_VALUE: a NULL parameter was passed
	- \c B_NAME_NOT_FOUND: The specified cursor does not exist in this set
	- \c B_ERROR: An internal error occurred
	
	BBitmaps created by this function are the responsibility of the caller.
*/
status_t
CursorSet::FindCursor(BCursorID which, ServerCursor **_cursor) const
{
	BMessage msg;
	if (FindMessage(_CursorWhichToString(which), &msg) != B_OK)
		return B_NAME_NOT_FOUND;

	const char *className;
	BPoint hotspot;

	if (msg.FindString("class", &className) != B_OK)
		return B_ERROR;

	if (msg.FindPoint("hotspot", &hotspot) != B_OK)
		return B_ERROR;

	if (strcmp(className, "cursor") == 0) {
		ServerCursor *cursor = new ServerCursor(msg.FindRect("_frame"),
			(color_space)msg.FindInt32("_cspace"), 0, hotspot);

		const void *buffer;
		int32 bufferLength;
		msg.FindData("_data",B_RAW_TYPE, (const void **)&buffer,
			(ssize_t *)&bufferLength);
		memcpy(cursor->Bits(), buffer, bufferLength);

		*_cursor = cursor;
		return B_OK;
	}
	return B_ERROR;
}
Exemple #2
0
/*!
	\brief Retrieves a cursor from the set.
	\param which System cursor specifier defined in CursorSet.h
	\param cursor Bitmap** to receive a newly-allocated BBitmap containing the appropriate data
	\param hotspot The recipient of the hotspot for the cursor
	\return
	- \c B_OK: Success
	- \c B_BAD_VALUE: a NULL parameter was passed
	- \c B_NAME_NOT_FOUND: The specified cursor does not exist in this set
	- \c B_ERROR: An internal error occurred
	
	BBitmaps created by this function are the responsibility of the caller.
*/
status_t
CursorSet::FindCursor(BCursorID which, BBitmap **cursor, BPoint *hotspot)
{
	if (!cursor || !hotspot)
		return B_BAD_VALUE;

	BMessage msg;
	if (FindMessage(_CursorWhichToString(which), &msg) != B_OK)
		return B_NAME_NOT_FOUND;

	const void *buffer;
	const char *tempstr;
	int32 bufferLength;
	BBitmap *bmp;
	BPoint hotpt;

	if (msg.FindString("class", &tempstr) != B_OK)
		return B_ERROR;

	if (msg.FindPoint("hotspot", &hotpt) != B_OK)
		return B_ERROR;

	if (strcmp(tempstr, "cursor") == 0) {
		bmp = new BBitmap(msg.FindRect("_frame"),
			(color_space)msg.FindInt32("_cspace"), true);
		msg.FindData("_data", B_RAW_TYPE, (const void **)&buffer,
			(ssize_t *)&bufferLength);
		memcpy(bmp->Bits(), buffer, bufferLength);

		*cursor = bmp;
		*hotspot = hotpt;
		return B_OK;
	}
	return B_ERROR;
}
// GetAttribute
Font
AttributeMessage::GetAttribute(const char* name,
	const Font& defaultValue) const
{
	Font value(defaultValue);
	BString valueString;
	BMessage archivedFont;
	if (FindMessage(name, &archivedFont) == B_OK) {
		// find family part
		const char* family;
		const char* style;
		float size;
		if (archivedFont.FindString("family", &family) == B_OK
			&& archivedFont.FindString("style", &style) == B_OK
			&& archivedFont.FindFloat("size", &size) == B_OK) {
			font_family fontFamily;
			font_style fontStyle;
			snprintf(fontFamily, sizeof(fontFamily), "%s", family);
			snprintf(fontStyle, sizeof(fontStyle), "%s", style);

			if (strlen(family) == 0 || strlen(style) == 0)
				return value;

			value.SetFamilyAndStyle(fontFamily, fontStyle);
			if (size > 0.0f)
				value.SetSize(size);
		}
	}
	return value;
}
Exemple #4
0
myinline const BMessage ArpMessage::GetMessage(const char *name, const BMessage& def, int32 index) const
{
	if( this ) {
		BMessage res;
		if( FindMessage(name, index, &res) != B_NO_ERROR ) return def;
		return res;
	}
	return def;
}
BMessage
AttributeMessage::GetAttribute(const char* name,
	const BMessage& defaultValue) const
{
	BMessage value;
	if (FindMessage(name, &value) != B_OK)
		return defaultValue;
	return value;
}
void elg_readcb_MPI_RECV(elg_ui4 lid, elg_d8 time, elg_ui4 slid, elg_ui4 cid,
       elg_ui4 tag, void* userdata) {

  double tcoords[2];
  int ycoords[2];
  int32_t vals[4];
    
  Message *tmp = FindMessage(slid, lid, tag, cid);

#ifdef DEBUG
 printf("Message recieved at %d from %d with tag %d at time %f \n",lid, slid, tag, time);
#endif
    
  if(primitives == NULL) {
    primitives = (PRIMITIVES_List*) malloc(sizeof(struct _primitives_list));
    last_primitive = primitives;
    primitives->size = 0;
  } else {
    last_primitive->next = (PRIMITIVES_List*) malloc(sizeof(struct _primitives_list));
    last_primitive = last_primitive->next;
  }

  /* New Event */
  primitives->size++;

  last_primitive->next = NULL;
  last_primitive->prim = (DRAW_Primitive *) malloc(sizeof(DRAW_Primitive));
  last_primitive->prim->starttime = tmp->stime;
  last_primitive->prim->endtime = time;
  last_primitive->prim->type_idx = ST_MESSAGE;
  last_primitive->prim->num_tcoords = 2;
  last_primitive->prim->tcoords = (double*) malloc(2*sizeof(double));
  last_primitive->prim->tcoords[0] = tmp->stime;
  last_primitive->prim->tcoords[1] = time;
  last_primitive->prim->num_ycoords = 2;
  last_primitive->prim->ycoords = (int*) malloc(2*sizeof(int));
  last_primitive->prim->ycoords[0] = slid;
  last_primitive->prim->ycoords[1] = lid;
  last_primitive->prim->num_info = 4*sizeof(int32_t);
  last_primitive->prim->info = (char*) malloc(last_primitive->prim->num_info*sizeof(char));

  vals[0] = slid;
  vals[1] = lid;
  vals[2] = tag;
  vals[3] = tmp->len;
  if(ELG_BYTE_ORDER == ELG_LITTLE_ENDIAN) {
    elg_swap(&vals[0], sizeof(int32_t));
    elg_swap(&vals[1], sizeof(int32_t));
    elg_swap(&vals[2], sizeof(int32_t));
    elg_swap(&vals[3], sizeof(int32_t));
  }
  memcpy(last_primitive->prim->info, vals, last_primitive->prim->num_info);

}
Exemple #7
0
//------------------------------------------------------------------------------
status_t	TTextData::Unarchive(const BMessage& oArc)
{
	status_t	aResult = B_OK;

	aResult |= SUPER::Unarchive(oArc);
	// bool
	aResult |= FindBool(oArc, ARC_NAME_EXPAND, &mExpand);
	aResult |= FindBool(oArc, ARC_NAME_GROUP, &mGroup);
	aResult |= FindBool(oArc, ARC_NAME_PATTERN_MATCH, &mPatternMatch);
	// int32
	aResult |= FindInt32(oArc, ARC_NAME_ID, &mID);
	// uint32
	aResult |= FindInt32(oArc, ARC_NAME_OUTLINE_LEVEL, reinterpret_cast<int32*>(&mOutlineLevel));
	// string
	aResult |= FindString(oArc, ARC_NAME_TITLE, &mTitle);
	// Message
	aResult |= FindMessage(oArc, ARC_NAME_DATA, &mData);
	return aResult;
}
Exemple #8
0
int32 Message::FindMessage(const char *name, Message *message) const
{
	return FindMessage( name, 0, message );
}