コード例 #1
0
ファイル: CalcView.cpp プロジェクト: RTOSkit/haiku
void
CalcView::MessageReceived(BMessage* message)
{
	if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
		// if we are embedded in desktop we need to receive these
		// message here since we don't have a parent BWindow
		switch (message->what) {
			case MSG_OPTIONS_AUTO_NUM_LOCK:
				ToggleAutoNumlock();
				return;

			case MSG_OPTIONS_AUDIO_FEEDBACK:
				ToggleAudioFeedback();
				return;

			case MSG_OPTIONS_ANGLE_MODE_RADIAN:
				SetDegreeMode(false);
				return;

			case MSG_OPTIONS_ANGLE_MODE_DEGREE:
				SetDegreeMode(true);
				return;
		}
	}

	// check if message was dropped
	if (message->WasDropped()) {
		// pass message on to paste
		if (message->IsSourceRemote())
			Paste(message);
	} else {
		// act on posted message type
		switch (message->what) {

			// handle "cut"
			case B_CUT:
				Cut();
				break;

			// handle copy
			case B_COPY:
				Copy();
				break;

			// handle paste
			case B_PASTE:
				// access system clipboard
				if (be_clipboard->Lock()) {
					BMessage* clipper = be_clipboard->Data();
					//clipper->PrintToStream();
					Paste(clipper);
					be_clipboard->Unlock();
				}
				break;

			// (replicant) about box requested
			case B_ABOUT_REQUESTED:
				AboutRequested();
				break;

			case MSG_UNFLASH_KEY:
			{
				int32 key;
				if (message->FindInt32("key", &key) == B_OK)
					_FlashKey(key, 0);
				break;
			}

			default:
				BView::MessageReceived(message);
				break;
		}
	}
}
コード例 #2
0
ファイル: CalcView.cpp プロジェクト: ysei/haiku
void
CalcView::MessageReceived(BMessage* message)
{
	if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
		// if we are embedded in desktop we need to receive these
		// message here since we don't have a parent BWindow
		switch (message->what) {
			case MSG_OPTIONS_AUTO_NUM_LOCK:
				ToggleAutoNumlock();
				return;

			case MSG_OPTIONS_AUDIO_FEEDBACK:
				ToggleAudioFeedback();
				return;

			case MSG_OPTIONS_ANGLE_MODE_RADIAN:
				SetDegreeMode(false);
				return;

			case MSG_OPTIONS_ANGLE_MODE_DEGREE:
				SetDegreeMode(true);
				return;
		}
	}

	// check if message was dropped
	if (message->WasDropped()) {
		// pass message on to paste
		if (message->IsSourceRemote())
			Paste(message);
	} else {
		// act on posted message type
		switch (message->what) {

			// handle "cut"
			case B_CUT:
				Cut();
				break;

			// handle copy
			case B_COPY:
				Copy();
				break;

			// handle paste
			case B_PASTE:
				// access system clipboard
				if (be_clipboard->Lock()) {
					BMessage* clipper = be_clipboard->Data();
					//clipper->PrintToStream();
					Paste(clipper);
					be_clipboard->Unlock();
				}
				break;

			// (replicant) about box requested
			case B_ABOUT_REQUESTED:
				if (fAboutWindow == NULL) {
					// create the about window
					const char* extraCopyrights[] = {
						"1997, 1998 R3 Software Ltd.",
						NULL
					};

					const char* authors[] = {
						"Stephan Aßmus",
						"John Scipione",
						"Timothy Wayper",
						"Ingo Weinhold",
						NULL
					};

					fAboutWindow = new BAboutWindow(kAppName, kSignature);
					fAboutWindow->AddCopyright(2006, "Haiku, Inc.",
						extraCopyrights);
					fAboutWindow->AddAuthors(authors);
					fAboutWindow->Show();
				} else if (fAboutWindow->IsHidden())
					fAboutWindow->Show();
				else
					fAboutWindow->Activate();

				break;

			case MSG_UNFLASH_KEY:
			{
				int32 key;
				if (message->FindInt32("key", &key) == B_OK)
					_FlashKey(key, 0);

				break;
			}

			default:
				BView::MessageReceived(message);
				break;
		}
	}
}
コード例 #3
0
ファイル: CalcView.cpp プロジェクト: looncraz/haiku
void
CalcView::MessageReceived(BMessage* message)
{
	if (message->what == B_COLORS_UPDATED && !fHasCustomBaseColor) {
		const char* panelBgColorName = ui_color_name(B_PANEL_BACKGROUND_COLOR);
		if (message->HasColor(panelBgColorName)) {
			fBaseColor = message->GetColor(panelBgColorName, fBaseColor);
			_Colorize();
		}

		return;
	}

	if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
		// if we are embedded in desktop we need to receive these
		// message here since we don't have a parent BWindow
		switch (message->what) {
			case MSG_OPTIONS_AUTO_NUM_LOCK:
				ToggleAutoNumlock();
				return;

			case MSG_OPTIONS_AUDIO_FEEDBACK:
				ToggleAudioFeedback();
				return;

			case MSG_OPTIONS_ANGLE_MODE_RADIAN:
				SetDegreeMode(false);
				return;

			case MSG_OPTIONS_ANGLE_MODE_DEGREE:
				SetDegreeMode(true);
				return;
		}
	}

	// check if message was dropped
	if (message->WasDropped()) {
		// pass message on to paste
		if (message->IsSourceRemote())
			Paste(message);
	} else {
		// act on posted message type
		switch (message->what) {

			// handle "cut"
			case B_CUT:
				Cut();
				break;

			// handle copy
			case B_COPY:
				Copy();
				break;

			// handle paste
			case B_PASTE:
				// access system clipboard
				if (be_clipboard->Lock()) {
					BMessage* clipper = be_clipboard->Data();
					//clipper->PrintToStream();
					Paste(clipper);
					be_clipboard->Unlock();
				}
				break;

			// (replicant) about box requested
			case B_ABOUT_REQUESTED:
			{
				BAboutWindow* window = new BAboutWindow(kAppName, kSignature);

				// create the about window
				const char* extraCopyrights[] = {
					"1997, 1998 R3 Software Ltd.",
					NULL
				};

				const char* authors[] = {
					"Stephan Aßmus",
					"John Scipione",
					"Timothy Wayper",
					"Ingo Weinhold",
					NULL
				};

				window->AddCopyright(2006, "Haiku, Inc.", extraCopyrights);
				window->AddAuthors(authors);

				window->Show();

				break;
			}

			case MSG_UNFLASH_KEY:
			{
				int32 key;
				if (message->FindInt32("key", &key) == B_OK)
					_FlashKey(key, 0);

				break;
			}

			case kMsgAnimateDots:
			{
				int32 end = fExpressionTextView->TextLength();
				int32 start = end - 3;
				if (fEnabled || strcmp(fExpressionTextView->Text() + start,
						"...") != 0) {
					// stop the message runner
					delete fEvaluateMessageRunner;
					fEvaluateMessageRunner = NULL;
					break;
				}

				uint8 dot = 0;
				if (message->FindUInt8("dot", &dot) == B_OK) {
					rgb_color fontColor = fExpressionTextView->HighColor();
					rgb_color backColor = fExpressionTextView->LowColor();
					fExpressionTextView->SetStylable(true);
					fExpressionTextView->SetFontAndColor(start, end, NULL, 0,
						&backColor);
					fExpressionTextView->SetFontAndColor(start + dot - 1,
						start + dot, NULL, 0, &fontColor);
					fExpressionTextView->SetStylable(false);
				}

				dot++;
				if (dot == 4)
					dot = 1;

				delete fEvaluateMessageRunner;
				BMessage animate(kMsgAnimateDots);
				animate.AddUInt8("dot", dot);
				fEvaluateMessageRunner = new (std::nothrow) BMessageRunner(
					BMessenger(this), &animate, kAnimationInterval, 1);
				break;
			}

			case kMsgCalculating:
			{
				// calculation has taken more than 3 seconds
				if (fEnabled) {
					// stop the message runner
					delete fEvaluateMessageRunner;
					fEvaluateMessageRunner = NULL;
					break;
				}

				BString calculating;
				calculating << B_TRANSLATE("Calculating") << "...";
				fExpressionTextView->SetText(calculating.String());

				delete fEvaluateMessageRunner;
				BMessage animate(kMsgAnimateDots);
				animate.AddUInt8("dot", 1U);
				fEvaluateMessageRunner = new (std::nothrow) BMessageRunner(
					BMessenger(this), &animate, kAnimationInterval, 1);
				break;
			}

			case kMsgDoneEvaluating:
			{
				_SetEnabled(true);
				rgb_color fontColor = fExpressionTextView->HighColor();
				fExpressionTextView->SetFontAndColor(NULL, 0, &fontColor);

				const char* result;
				if (message->FindString("error", &result) == B_OK)
					fExpressionTextView->SetText(result);
				else if (message->FindString("value", &result) == B_OK)
					fExpressionTextView->SetValue(result);

				// stop the message runner
				delete fEvaluateMessageRunner;
				fEvaluateMessageRunner = NULL;
				break;
			}

			default:
				BView::MessageReceived(message);
				break;
		}
	}
}