Пример #1
0
void
ReceiveOSCThread::ProcessMessage(const osc::ReceivedMessage&m, const IpEndpointName& remoteEndPoint)
{
	std::ostringstream oss;

	if ((m.AddressPattern())[0] == '/') {
		m_minuitMethods->receiveNetworkMessage(m.AddressPattern());
	} else {
		std::string currentString(m.AddressPattern());

		if (currentString.find(":namespace") != currentString.npos) {
			osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin();

			if (arg->IsChar()) {
				oss << arg->AsChar();
			} else if (arg->IsInt32()) {
				oss << arg->AsInt32();
			} else if (arg->IsString()) {
				oss << arg->AsString();
			} 
			
			m_minuitMethods->minuitParseNamespaceRequest(oss.str(), m);
		} else if (currentString.find(":get") != currentString.npos) {
			osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin();

			if (arg->IsChar()) {
				oss << arg->AsChar();
			} else if (arg->IsInt32()) {
				oss << arg->AsInt32();
			} else if (arg->IsString()) {
				oss << arg->AsString();
			}

			m_minuitMethods->minuitParseGetRequest(oss.str(), m);
		} else if (currentString.find("?namespace") != currentString.npos ||
				   currentString.find("?get") != currentString.npos) {
			osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin();
	
			if (arg->IsChar()) {
				oss << arg->AsChar();
			} else if (arg->IsInt32()) {
				oss << arg->AsInt32();
			} else if (arg->IsString()) {
				oss << arg->AsString();
			}
			
			m_minuitMethods->receiveNetworkRequest(oss.str(), currentString);
		} 
	}
};
/*!	\function		ColorUpdateWindow::MessageReceived
 *	\brief			Main function
 */
void ColorUpdateWindow::MessageReceived( BMessage* in )
{
	BAlert* al = NULL;
	DebuggerPrintout* deb = NULL;
	BTextView* textView = NULL;
	BView* background = NULL;
	BMessenger* mesg = NULL;
	status_t errorCode = B_OK;
	BString currentString( this->originalString );
	rgb_color previousHighColor;
	BRect tempRect;
	switch ( in->what )
	{
		case kColorSelected:
			/* The user had make his choise. */
			/* Checking if the color has changed... */
			if ( colorControl )
			{
				currentColor = colorControl->ValueAsColor();
				if ( currentColor != originalColor )
				{
					this->dirty = true;
				}
			}
			
			/* Checking if the string has changed... */
			if ( enableEditingLabel )
			{
				if ( labelView )
				{
					// textView = ( BTextView* )labelView;	// For matter of simplicity only
					currentString.SetTo( ( ( BTextControl* )labelView )->Text() );
					
					if ( currentString != originalString )	// If there were changes
					{
						if ( ! utl_CheckStringValidity( currentString ) )
						{
							// User has changed the string to an invalid one -
							// he must correct it before proceeding
							al = new BAlert("Error detected!",
											"The string you've entered is invalid. Please correct.",
											"Ok",
											NULL,
											NULL,
											B_WIDTH_AS_USUAL,
											B_STOP_ALERT );
							if ( al ) { 
								al->Go();
								break; 		// Returning to main window
							} else {
								/* Panic! */
								exit(1);
							}						
						}	// <-- end of "if (string is not valid) "
						else
						{
							// String is valid - verify it's different
							if ( currentString != originalString )
							{
								this->dirty = true;
							}							
						}						
					}	// <-- end of "if (user changed the string)					
				}	// <-- end of "if ( BTextView exists )"
			}	// <-- end of "if (user has possibility to change the string)"
		
			// If anything has changed, send the update message. Else, send revert message.
			if ( ! messageToSend )
			{
				if ( this->dirty )
				{
					this->messageToSend = new BMessage( kColorSelected );
				} else {
					this->messageToSend = new BMessage( kColorReverted );
				}
				if ( ! this->messageToSend ) {
					/* Panic! */
					exit(1);
				}
			}
			
			// Stuff the message with needed data
			messageToSend->AddBool( "Dirty", this->dirty );
			messageToSend->AddString ( "Original string", this->originalString );
			if ( this->dirty ) {
				messageToSend->AddString("New string", currentString );
			}

			messageToSend->AddInt32( "Original color", RepresentColorAsUint32( this->originalColor ) );
			messageToSend->AddInt32( "New color", RepresentColorAsUint32( this->currentColor ) );
			
			// Send the message and close current window
			// mesg = new BMessenger( (BHandler* )target, NULL,  &errorCode );
			mesg = new BMessenger( "application/x-vnd.Hitech.Skeleton", -1, &errorCode );
			
			if ( errorCode == B_OK ) {
				
				mesg->SendMessage( messageToSend, ( BHandler* )NULL );
				
				deb = new DebuggerPrintout( "Message was sent" );
			} else {
				deb = new DebuggerPrintout( "Message wasn't sent" );
			}
			
			this->Quit();
			
			break;

		case kColorReverted:
			/* Returning to original settings */
			if ( colorControl )
			{
				colorControl->SetValue( originalColor );
				colorControl->Invoke();
			}

			if ( enableEditingLabel && this->labelView )
			{
				( (BTextControl*)this->labelView )->SetText( this->originalString.String() );
				( (BTextControl*)this->labelView )->MakeFocus( false );	// Prevent accidental change of text
			}
			
			break;
			
		case kColorChanged:
		
			// We need to reflect the change in color.
			// We'll do it using the current view's high color. For this, we need to
			// back up current high color in order to restore it later.
			background = this->FindView( "Background" );
			if ( ! background )
			{
				deb = new DebuggerPrintout( "Didn't find background!" );
				return;
			}
			previousHighColor = background->HighColor();

			background->SetHighColor( 0, 0, 1 );	// almost black
			
			tempRect = BRect( ( revertButton->Frame() ).right + 10,
							  ( revertButton->Frame() ).top,
							  ( okButton->Frame() ).left - 10,
							  ( revertButton->Frame() ).bottom );

			// Actual drawing
			if ( this->Lock() ) {
				background->SetPenSize( 1 );
				
				// Create border
				background->StrokeRoundRect( tempRect.InsetBySelf( 1, 1 ), 4, 4 );
				
				// Fill the rectangle
				background->SetHighColor( colorControl->ValueAsColor() );
				background->FillRoundRect( tempRect.InsetBySelf( 1, 1 ), 4, 4 );
				background->Flush();
				this->Flush();
				this->Unlock();	
			}		

			background->SetHighColor( previousHighColor );
			break;

		default:
			BWindow::MessageReceived( in );
	};
	
}	// <-- end of function "ColorUpdateWindow::MessageReceived"
Пример #3
0
	void ComboBoxDelegate::onCurrentChanged (QString const & s)
	{
		emit currentString(s);
	}