本文整理汇总了C++中Message::AddRect方法的典型用法代码示例。如果您正苦于以下问题:C++ Message::AddRect方法的具体用法?C++ Message::AddRect怎么用?C++ Message::AddRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::AddRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Register
int Window::Register()
{
Message *msg = new Message(REGISTER);
msg->AddString( "_type", "window" );
msg->AddInt( "_port", Port() );
msg->AddString( "_title", m_title );
msg->AddRect( "_rect", Frame() );
msg->AddBool( "_visible", false );
msg->AddInt( "_flags", m_flags );
Message *reply = Messenger::SendReceiveMessage( "gui_server", 0, msg );
if ( reply == NULL )
{
delete msg;
return -1;
}
delete msg;
if ( reply->rc() != 0 )
{
delete reply;
return -1;
}
// Good reply.. let's get the information.
int bad = 0;
if ( reply->FindInt( "_id", &m_wid ) != 0 ) bad = -1;
if ( reply->FindInt( "_sid", &m_sid ) != 0 ) bad = -1;
if ( reply->FindInt( "_did", &m_did ) != 0 ) bad = -1;
if ( reply->FindRect( "_rect", &m_frame ) != 0 ) bad = -1;
delete reply;
// Accept the GUI memory and everything.
int tmp_pages;
unsigned int tmp_flags;
if ( smk_request_shmem( m_sid, (void**)&m_buffer, &tmp_pages, &tmp_flags ) != 0 )
bad = -1;
// We now have our GUI buffer, size and ID.
if ( bad != 0 ) return -1;
// Registered with desktop port = m_did
return 0;
}
示例2: ResizeTo
bool Window::ResizeTo( int width, int height )
{
// within reason.
if ( (width < 5) || (height < 5) ) return false;
Rect newFrame = Frame();
newFrame.right = newFrame.left + width - 1;
newFrame.bottom = newFrame.top + height - 1;
// Send resize request.
Message *msg = new Message(RESIZE);
msg->AddInt( "_id", m_wid );
msg->AddRect( "_rect", newFrame );
Message *reply = Messenger::SendReceiveMessage( "gui_server", m_did, msg );
if ( reply == NULL )
{
delete msg;
return false;
}
delete msg;
if ( reply->rc() != 0 )
{
delete reply;
return false;
}
// Good reply.. let's get the information.
int bad = 0;
int new_sid;
if ( reply->FindInt( "_sid", &new_sid ) != 0 ) bad = -1;
if ( reply->FindRect( "_rect", &newFrame ) != 0 ) bad = -1;
delete reply;
if ( bad != 0 ) return -1;
// --------- Release what used to be.
if ( m_sid >= 0 ) smk_release_shmem( m_sid );
m_buffer = NULL;
m_sid = new_sid;
m_frame = newFrame;
// Accept the GUI memory and everything.
int tmp_pages;
unsigned int tmp_flags;
if ( smk_request_shmem( m_sid, (void**)&m_buffer, &tmp_pages, &tmp_flags) != 0 )
{
// Freak out...
exit(-1);
}
// ....................
Draw(Bounds());
Sync();
// We now have our GUI buffer, size and ID.
return true;
}
示例3: ConvertFromAMessage
status_t ConvertFromAMessage(const os::Message & from, Message & to)
{
to.Clear();
to.what = from.GetCode();
int numNames = from.GetNumNames();
for (int32 i=0; i<numNames; i++)
{
int type;
int count;
std::string name = from.GetName(i);
if (from.GetNameInfo(name.c_str(), &type, &count) == B_NO_ERROR)
{
for (int j=0; j<count; j++)
{
const void * nextItem;
size_t itemSize;
if (from.FindData(name.c_str(), type, &nextItem, &itemSize, j) != B_NO_ERROR) return B_ERROR;
// do any necessary translation from the AtheOS data types to Muscle data types
switch(type)
{
case os::T_POINT:
{
const os::Point * p = static_cast<const os::Point *>(nextItem);
Point pPoint(p->x, p->y);
if (to.AddPoint(name.c_str(), pPoint) != B_NO_ERROR) return B_ERROR;
}
break;
case os::T_RECT:
{
const os::Rect * r = static_cast<const os::Rect *>(nextItem);
Rect pRect(r->left, r->top, r->right, r->bottom);
if (to.AddRect(name.c_str(), pRect) != B_NO_ERROR) return B_ERROR;
}
break;
case os::T_MESSAGE:
{
os::Message amsg;
if (amsg.Unflatten(static_cast<const uint8 *>(nextItem)) != B_NO_ERROR) return B_ERROR;
Message * newMsg = newnothrow Message;
if (newMsg)
{
MessageRef msgRef(newMsg);
if (ConvertFromAMessage(amsg, *newMsg) != B_NO_ERROR) return B_ERROR;
if (to.AddMessage(name.c_str(), msgRef) != B_NO_ERROR) return B_ERROR;
}
else {WARN_OUT_OF_MEMORY; return B_ERROR;}
}
break;
default:
if (to.AddData(name.c_str(), type, nextItem, itemSize) != B_NO_ERROR) return B_ERROR;
break;
}
}
}
}
return B_NO_ERROR;
}