コード例 #1
0
ファイル: Looper.cpp プロジェクト: AdamRLukaitis/spoon
/** Any pulses received on the Looper's IPC port are
 * passed to this virtual method. 
 *
 * \warning Do not delete the Pulse parameter that you are given. It does 
 * 		    not belong to you either.
 *
 * \param pulse A pointer to the received Pulse. 
 */
void Looper::PulseReceived( Pulse* pulse )
{
	switch ((*pulse)[0])
	{
		case QUIT_REQUESTED:
			QuitRequested();
			Terminate();
			break;
	}
}
コード例 #2
0
void ObservableLooper::Quit() {
    ASSERT(IsLocked());

    if(QuitRequested()) {
        releaseComplete();
        _inherited::Quit();
    }
    else
        Unlock();
}
コード例 #3
0
ファイル: InfoWindow.cpp プロジェクト: HaikuArchives/BeAIM
void InfoWindow::MessageReceived( BMessage* msg ) {

	switch( msg->what ) {
	
		case BEAIM_UPDATE_INFO:
			iView->UpdateDisplay( msg );
			gotInfo = true;
			needsAway = needsAway || (msg->HasBool("away") && msg->FindBool("away"));
			if( needsAway && !askedAway )
				AskAway();
			if( needsAway && !gotAway )
				statView->SetMessage( (char*)LangWithSuffix("IW_WAITING_FOR_AWAY",B_UTF8_ELLIPSIS) );
			else {
				statView->SetMessage( (char*)Language.get("IM_GOT_INFO") );
				statView->SetSpinner(false);
			}
			iView->Invalidate();
			break;
			
		case BEAIM_UPDATE_AWAY_INFO:
			if( gotInfo ) {
				statView->SetMessage( (char*)Language.get("IM_GOT_INFO") );
				statView->SetSpinner(false);
			} else
				statView->SetMessage( (char*)LangWithSuffix("IM_WAITING_FOR_INFO",B_UTF8_ELLIPSIS) );
			EnableAwayMode();
			iView->UpdateAwayDisplay( msg );
			iView->Invalidate();
			gotAway = true;
			break;

		case B_CANCEL:
		case BEAIM_CLOSE_WINDOW:
			QuitRequested();
			Close();
			break;
			
		case BEAIM_UPDATE_NAME_FORMAT:
			userName = AIMUser(msg->FindString("userid"));
			break;
			
		case BEAIM_ADD_BUDDY:
			AddPerson();
			break;

		case BEAIM_REFRESH_LANG_STRINGS:
			RefreshLangStrings();
			break;

		default:
			BWindow::MessageReceived( msg );
			break;
	}
}
コード例 #4
0
void Window::MessageReceived(BMessage* msg)
{
	switch(msg->what)
	{
		case EXIT : {
				QuitRequested();
				break;
			}
		default: {
			BWindow::MessageReceived(msg);
			}
	}
}
コード例 #5
0
void BookmarkItemWindow::MessageReceived(BMessage* i_pMessage)
{
	switch (i_pMessage->what)
	{
		case MSG_ITEM_CANCEL:
			QuitRequested();
			break;
		case MSG_ITEM_OK:
			//OkRequested(i_pMessage);
			OkRequested();
			break;
		default:
			BWindow::MessageReceived(i_pMessage);
			break;
	}
}
コード例 #6
0
ファイル: AboutWindow.cpp プロジェクト: puckipedia/FilWip
AboutWindow::AboutWindow ()
	: BWindow (BRect (0, 0, 300, 200), "About", B_MODAL_WINDOW,
		B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE)
{
	PRINT (("AboutWindow::AboutWindow ()\n"));
	SetFeel (B_MODAL_APP_WINDOW_FEEL);
	SetLook (B_MODAL_WINDOW_LOOK);

	/* Create the BBitmap objects and set its data with error checking */
	BBitmap *appIcon = new BBitmap (BRect (0, 0, kLargeIconWidth - 1, kLargeIconHeight - 1), B_COLOR_8_BIT);
	appIcon->SetBits (iconBits, 32 * 32 * 8, 0, B_COLOR_8_BIT);
	BBitmap *bmp = BTranslationUtils::GetBitmap ('PNG ', "Image:AboutTitle");
	if (bmp == NULL)
	{
		BAlert *err = new BAlert ("Error", "An error was encountered while "
							"trying to load the resource element \"Image:AboutTitle\"\n", "Hmm..",
							NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_STOP_ALERT);
		err->Go();
		Hide();
		Quit();
		QuitRequested();
		return;
	}
	
	/* Yet another annoying control rendering section :( */
	BRect bounds (Bounds());
	backView = new BView (bounds.InsetBySelf (1, 1), "AboutWindow:BackView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
	AddChild (backView);

	iconView = new BView (BRect (1.5 * DialogMargin + 3, 1.5 * DialogMargin,
					1.5 * DialogMargin + kLargeIconWidth - 1 + 3, 1.5 * DialogMargin + kLargeIconWidth - 1),
					"AboutWindow:IconView", B_FOLLOW_LEFT, B_WILL_DRAW);
	backView->AddChild (iconView);
	iconView->SetViewBitmap (appIcon);
	
	float left = DialogMargin + kLargeIconWidth + 1.5 * ButtonSpacing - 3;
	float top = DialogMargin / 2.0;
	titleView = new BView (BRect (left, top, 214 + left, 58 + top), "AboutWindow:TitleView",
						B_FOLLOW_LEFT, B_WILL_DRAW);
	backView->AddChild (titleView);
	titleView->SetViewBitmap (bmp);
	
	lineView = new BView (BRect (0, titleView->Frame().bottom + 3, bounds.right, titleView->Frame().bottom + 3),
						"AboutWindow:LineView", B_FOLLOW_LEFT, B_WILL_DRAW);
	lineView->SetViewColor (128, 128, 128);
	backView->AddChild (lineView);
	
	textView = new MarqueeView (BRect (2, lineView->Frame().bottom + ButtonSpacing / 2 + 2,
									bounds.right - DialogMargin - 1, bounds.bottom - 2 - ButtonSpacing / 2),
									"AboutWindow:CreditsView", BRect (0, 0, bounds.right - DialogMargin, 0),
									B_FOLLOW_LEFT, B_WILL_DRAW);
	backView->AddChild (textView);
	textView->SetStylable (true);
	textView->MakeSelectable (false);
	textView->MakeEditable (false);
	textView->SetAlignment (B_ALIGN_CENTER);
	textView->SetViewColor (BePureWhite);
	backView->SetViewColor (BePureWhite);
	textView->SetFontAndColor (be_plain_font, B_FONT_ALL, &BeJetBlack);
	
	/* Calculate no of '\n's to leave to make the text go to the bottom, calculate the no. of lines */
	font_height fntHt;
	textView->GetFontHeight (&fntHt);
	int32 noOfLines = (int32)(textView->Frame().Height() / fntHt.ascent) - 1;
	for (int32 i = 1; i < (int32)noOfLines; i++)
		lineFeeds << "\n";

	creditsText =
		"Freeware, Version " AppVersion "\n"
		"Copyright " B_UTF8_COPYRIGHT " 2002 Ramshankar\n\n\n"
		CODING "\nRamshankar\n([email protected])\n\n* * *\n\n\n\n\n\n\n\n\n"

		THANKS_TO "\n\n"
		BUBBLEHELP "\nMarco Nelissen\n\n"
		BESHARE "\nJeremy Friesner\n\n"
		"Thank you all for your\n"
		"contributions with the code...\n\n* * *\n\n\n\n\n\n\n\n\n"
		"Also thanks to\n\n"
		"John Trujillo\nSebastian Benner\nM Floro\n\n"
		"for your support and contributions...\n\n* * *\n\n\n\n\n\n\n\n\n"
		"A special round of applause\n"
		"to BeShare members (in no\n"
		"particular order) :\n\n"
		"lillo\nshatty\nProcton\n"
		"Bryan\nPahtz\nmmu_man\nBeMikko\nNeil\nskiBUM\nand "
		"others\n\n"
		"for being so good... :)\n\n* * *\n\n\n\n\n\n\n\n\n"
		
		LEGAL_MUMBO_JUMBO "\n\n"
		"This program is distributed under\n"
		"its own license, and the gist of\n"
		"the license is attached to each\n"
		"source file of this program\n\n"
		
		"For third party code, the license's\n"
		"terms and conditions are explicitly\n"
		"stated and the author disclaimed of\n"
		"any and all liabilities\n\n"
		
		"For the full license read the\n"
		"file \"License.txt\" and for\n"
		"information on how to use this\n"
		"program read \"Readme.txt\"\n\n* * *\n\n\n\n\n\n\n\n\n"
		
		DISCLAIMER "\n\n"
		"Because the software is licensed\n"
		"free of charge, there is no warranty\n"
		"for the software. The copyright\n"
		"holders and/or other parties provide\n"
		"the software \"AS IS\" without warranty\n"
		"of any kind, either expressed or\n"
		"implied, including, but not limited to,\n"
		"the implied warranties of merchantability\n"
		"and fitness for a particular purpose.\n"
		"The entire risk as to the quality and\n"
		"performance of the software is with you.\n"
		"Should the software prove defective, you\n"
		"assume the cost of all necessary\n"
		"servicing, repair or correction.\n\n"
		
		"In no event will the copyright holder,\n"
		"or any other party who may modify and/or\n"
		"redistribute the software as permitted\n"
		"above, be liable to you for damages,\n"
		"including any general, special, incidental\n"
		"or consequential damages arising out of\n"
		"the use or inability to use the software\n"
		"(including but not limited to the loss of\n"
		"data or data being rendered inaccurate or\n"
		"losses sustained by you or third parties\n"
		"or a failure of the software to operate\n"
		"with any other programs), even if such\n"
		"holder or other party has been advised\n"
		"of the possibility of such damages.\n\n\n\n\n\n\n\n\n"
		
		FINAL_THANKS "\n\n"
		"Be, Inc., for making this OS\n"
		"in the first place\n\n"
		"OpenBeOS for their efforts to\n"
		"keep BeOS alive\n\n"
		"BeBits.com, BeGroovy.com, BeZip.de and\n"
		"other BeOS related sites for their\n"
		"continued enthusiasm and effort!\n\n"
		"BeOS programmers, designers, artists for\n"
		"their contributions to the OS' growth\n\n"
		"and a big applause goes to the Be\n"
		"community (it includes me too :)\n\n* * *\n\n\n\n\n\n\n\n\n"
		"OK... you can close this window now :)\n\n\n\n\n\n";
		
	textView->SetText (lineFeeds.String());
	textView->Insert (lineFeeds.Length(), creditsText, strlen(creditsText));
	
	int32 nSubHeadings = 4;
	BString subHeadings[] =
	{
		CODING,				// 0
		BUBBLEHELP,			// 2
		BESHARE,			// 3
		DISCLAIMER			// 4
	};

	int32 nMainHeadings = 3;
	BString mainHeadings[] =
	{
		THANKS_TO,			// 0
		LEGAL_MUMBO_JUMBO,	// 1
		FINAL_THANKS		// 2
	};
	
	/* Search and color sub headings */
	BString temp = textView->Text();
	int32 strt;
	for (int32 i = 0; i < nSubHeadings; i++)
	{
		if ((strt = temp.FindFirst (subHeadings[i].String())) != B_ERROR)
		{
			textView->SetFontAndColor (strt, strt + strlen(subHeadings[i].String()),
							be_plain_font, B_FONT_ALL, &TreeLabelColor);
		}
	}
	
	/* Search and color main headings */
	for (int32 i = 0; i < nMainHeadings; i++)
	{
		if ((strt = temp.FindFirst (mainHeadings[i].String())) != B_ERROR)
		{
			textView->SetFontAndColor (strt, strt + strlen(mainHeadings[i].String()),
							be_plain_font, B_FONT_ALL, &(rgb_color){0, 0, 200});
		}
	}
	
	/* Center window on-screen */
	BRect screen_rect (BScreen().Frame());
	MoveTo (screen_rect.Width() / 2 - Frame().Width() / 2, screen_rect.Height() / 2 - Frame().Height() / 2);

	/* Delete unwanted stuff */
	delete appIcon;
	delete bmp;

	/* Spawn & resume the scroller thread now */
	PRINT ((" >> spawning_thread: Magic_Scroll\n"));
	thread_id tid = spawn_thread (ScrollIt, "Magic_Scroll", B_NORMAL_PRIORITY, (void*)this);
	resume_thread (tid);
}
コード例 #7
0
ファイル: GraphWindow.cpp プロジェクト: HaikuArchives/Graph
void GraphWindow::MessageReceived(BMessage *message)
{
			
	switch (message->what)
	{
		case MENU_FILE_ABOUT:
		{
			//	DA@Y2K:
			//	This is a subtle memory leak.
			//	PostMessage will copy your message, and your pointer will not be deleted.
			//	Use a stack allocated object instead.
			
			BMessage msg(B_ABOUT_REQUESTED);
			be_app->PostMessage(&msg);
		}
		break;
		case MENU_FILE_QUIT:
			QuitRequested();
			break;
		case MENU_EDIT_COPY:
			the_graph->CopyGraph();
			break;
		case MENU_FILE_SAVE:
		{
			savePanel->Show();
			break;
		}
		case B_SAVE_REQUESTED:
		{
			entry_ref saveDir;
			BString fileName;
			message->FindRef("directory",&saveDir);
			message->FindString("name", &fileName);
			
			the_graph->SaveGraph(saveDir,fileName);
			break;
		}
		case MENU_WINDOW_SETTINGS:
		{
			settingsWindowItem->SetMarked(!settingsWindowItem->IsMarked());
			if (settingsWindowItem->IsMarked() && settingsWindow->IsHidden())
				settingsWindow->Show();
			else if ((!settingsWindowItem->IsMarked()) && !(settingsWindow->IsHidden())) 
				settingsWindow->Hide();
			break;
		}
		case MENU_WINDOW_FUNCTION:
		{
			functionWindowItem->SetMarked(!functionWindowItem->IsMarked());
			if (functionWindowItem->IsMarked() && functionWindow->IsHidden())
				functionWindow->Show();
			else if ((!functionWindowItem->IsMarked()) && !(functionWindow->IsHidden())) 
				functionWindow->Hide();
			break;
		}
		case INVAL_GRAPH:
		{
			the_graph->UpdateGraph();
		}
		break;
		default:
			BWindow::MessageReceived(message);
			break;
	}
	return;
}
コード例 #8
0
ファイル: BoardWindow.cpp プロジェクト: HaikuArchives/Puri
void BoardWindow::MessageReceived(BMessage* message)
{
    if (_MessageFilter(message) == true)
        return;

	switch (message->what) {
		case REPLYCODE_ENGINE:
		{
            if (fEngineCanWrite == false)
                break;

            PostMessage(message, fEngineOutput);
			break;
		}

        case MSG_ENGINEMOVE:
            fEngineIsRunning = false;
            PostMessage(message, fChessBoard);
            break;

        case REPLYCODE_ICS:
		{
			break;
		}


        case REPLYCODE_TIMEVIEW:
            int32  value;
            message->FindInt32("time", &value);
            break;

        case MSG_SKILLCHANGED:
        {
            BString str = "Engine Skill: ";
            str << fSkillSlider->Value();
            fSkillSlider->SetToolTip(str);

            BMessage msg(MSG_SKILLCHANGED);
            msg.AddInt32("val", fSkillSlider->Value());

            if (fEngine != NULL)
                fEngine->PostMessage(&msg);

            break;
        }

		//case 10:
		//	be_roster->Launch( "application/x-vnd.cipri.Puri" );
		//	break;

        case MENU_VIEW_3D:
            f3DMI->SetMarked(!f3DMI->IsMarked());
            fChessBoard->SetViewMode3D(f3DMI->IsMarked());
            break;

		case MSG_MOVEFIRST:
            fEngineCanWrite = false;
            _EngineStop();
            fEngineIsRunning = false;
            fEngineOutput->SetOn(false);
            fTimeView->Stop();
			fChessBoard->MoveFirst();
            fMovesView ->MoveFirst();
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
            fChessBoard->SetUserCanMove();
			break;

		case MSG_MOVEBACK:

			fEngineCanWrite = false;
            _EngineStop();
            fEngineIsRunning = false;
            fEngineOutput->SetOn(false);
            fTimeView->Stop();
			fChessBoard->MoveBack();
            fMovesView ->MoveBack();
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
            fChessBoard->SetUserCanMove();
			break;

		case MSG_MOVENEXT:
            fEngineCanWrite = false;
            _EngineStop();
            fEngineIsRunning = false;
            fEngineOutput->SetOn(false);
            fTimeView->Stop();
			fChessBoard->MoveNext();
            fMovesView ->MoveNext();
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
            fChessBoard->SetUserCanMove();
			break;

		case MSG_MOVELAST:
            fEngineCanWrite = false;
            _EngineStop();
            fEngineIsRunning = false;
            fEngineOutput->SetOn(false);
            fTimeView->Stop();
			fChessBoard->MoveLast();
            fMovesView ->MoveLast();
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
            fChessBoard->SetUserCanMove();
			break;

        case MSG_GOTO_MOVE:
        {
            fEngineCanWrite = false;
            _EngineStop();
            fEngineIsRunning = false;
            fEngineOutput->SetOn(false);
            uint32  idx = 0;
            message->FindUInt32("move_idx", &idx);
            fTimeView->Stop();
            fChessBoard->GotoMove(idx);
            fMovesView ->GotoMove(idx);
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
            break;
        }

		case MENU_APP_QUIT:
			be_app->PostMessage(B_QUIT_REQUESTED);
			break;

        case MSG_QUIT:
            fICSMainWindow = NULL;

            QuitRequested();
            break;

        case MENU_VIEW_SHOW_WINDOW:
        {
            Show();
            break;
        }

        case MENU_VIEW_FLIPBOARD:
        {
            if (fFlipBoardMI->IsMarked())
                fFlipBoardMI->SetMarked(false);
            else
                fFlipBoardMI->SetMarked(true);

            fChessBoard->FlipBoard();
            break;
        }

		case MENU_VIEW_MININTERFACE:
			if (fMinIfMenuItem->IsMarked()) {
				if (!fShowborderMenuItem->IsMarked())
					PostMessage( MENU_VIEW_SHOWBORDER);

				if (!fSidebarMenuItem->IsMarked())
					PostMessage(MENU_VIEW_SIDEBAR);

				if (!fShowMBarMenuItem->IsMarked())
					PostMessage(MENU_VIEW_SHOWMENU);

                if (fAlwaysOnTopMenuItem->IsMarked())
					PostMessage(MENU_VIEW_ALWAYSONTOP);

				fMinIfMenuItem->SetMarked(false);
			} else {
				if (fShowborderMenuItem->IsMarked())
					PostMessage (MENU_VIEW_SHOWBORDER);

				if (fSidebarMenuItem->IsMarked())
					PostMessage (MENU_VIEW_SIDEBAR);

				if (fShowMBarMenuItem->IsMarked())
					PostMessage(MENU_VIEW_SHOWMENU);

                if (!fAlwaysOnTopMenuItem->IsMarked())
					PostMessage(MENU_VIEW_ALWAYSONTOP);

				fMinIfMenuItem->SetMarked(true);
			}

			break;

        case MENU_VIEW_FULLSCREEN:
        {
            if (fFullScrMI->IsMarked()) {
                fFullScrMI->SetMarked(false);
                Hide();
                MoveTo(fSavedFrame.left, fSavedFrame.top);
                ResizeTo(fSavedFrame.Width(), fSavedFrame.Height());
                Show();
            } else {
                fFullScrMI->SetMarked(true);
                fSavedFrame = Frame();
                BScreen screen(this);
                BRect rect(screen.Frame());
                Hide();
                MoveTo(rect.left, rect.top);
                ResizeTo(rect.Width(), rect.Height());
                Show();
            }

            break;
        }

		case MENU_VIEW_SIDEBAR:
        	if (fSidebarMenuItem->IsMarked() == false) {
        		fSidebarMenuItem->SetMarked(true);
                fSidebarView->Show();
        	} else {
				fSidebarMenuItem->SetMarked(false);
                fSidebarView->Hide();
			}

			break;

		case MENU_VIEW_SHOWBORDER:
			if (fShowborderMenuItem->IsMarked()) {
				SetLook(B_BORDERED_WINDOW_LOOK);
				fShowborderMenuItem->SetMarked(false);
			} else {
				SetLook(B_DOCUMENT_WINDOW_LOOK);
				fShowborderMenuItem->SetMarked(true);
			}

			break;

		case MENU_VIEW_AUTOHIDING:
        	if (fAutohidingMenuItem->IsMarked()) {
        		fAutohidingMenuItem->SetMarked(false);
        		fSidebarView->SetAutohiding(false);
                fNavigationView->SetAutohiding(false);
        	} else {
				fAutohidingMenuItem->SetMarked(true);
                fSidebarView->SetAutohiding(true);
                fNavigationView->SetAutohiding(true);
			}

			break;

		case MENU_VIEW_SHOWCLOCK:
			if (fShowClockMenuItem->IsMarked() == false) {
				fTimeView->Show();
				fShowClockMenuItem->SetMarked(true);
			} else {
				fTimeView->Hide();
				fShowClockMenuItem->SetMarked(false);
			}

			break;

        case MENU_VIEW_SHOWMENU:
			if (fShowMBarMenuItem->IsMarked() == false) {
				fMenuBar->Show();
				fShowMBarMenuItem->SetMarked(true);
			} else {
				fMenuBar->Hide();
				fShowMBarMenuItem->SetMarked(false);
			}

			break;

        case MENU_VIEW_ALWAYSONTOP:
            fAlwaysOnTopMenuItem->SetMarked(!fAlwaysOnTopMenuItem->IsMarked());
            SetFeel(fAlwaysOnTopMenuItem->IsMarked() ?
                             B_FLOATING_ALL_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL);
            break;

        // TODO: after the game, ask for isready,
        // and wait till the engine is ready.
		case MENU_GAME_NEWGAME:
            fEngineCanWrite = false;
            fChessBoard->NewGame();
			fTimeView->Init(300);
            fMovesView->Clear();
            fMaterialView->Clear();
            fChessBoard->SetUserCanMove(true);

            if (fEngine != NULL) {
                fEngine->PostMessage(MSG_UNLOCK);
                fEngine->PostMessage(MSG_ENG_NEWGAME);
			}
            fEngineCanWrite = true;
            fEngineIsRunning = false;
			break;

        case MENU_GAME_MOVENOW:
            if (fEngineOffMenuItem->IsMarked())
                fEngineOffMenuItem->SetMarked(false);

            if (fTimeView->IsStarted() == false)
                fTimeView->Start();

            if (fEngineIsRunning)
                _EngineStop();
            else
                _EngineGo();

            break;

		case MENU_ENGINE_SOENGINE:
            if (fEngineOffMenuItem->IsMarked()) {
                fEngineOffMenuItem->SetMarked(false);
            } else {
                fEngineCanWrite = false;
                _EngineStop();
                fEngineOffMenuItem->SetMarked(true);
                fChessBoard->SetUserCanMove(true);
            }

			break;

        case ICS_DISCONNECTED:
          //  fICSConnectMI->SetMarked(false);
           // fChessBoard->SetUserCanMove(false);
            break;

        case MSG_SEND_ICS_CMD:
            if (fICSMainWindow != NULL) {
                fICSMainWindow->PostMessage(message);
            }
            break;

        case MENU_HELP_MOVEASSISTANT:
            fMoveAssistantMenuItem->SetMarked(
                                           !fMoveAssistantMenuItem->IsMarked());
            fChessBoard->ShowValidMoves(fMoveAssistantMenuItem->IsMarked());
            break;

		case MENU_HELP_HINT:
            break;

		case MENU_HELP_HELP:
        {
            BString str = "file://";
            str << Tools::AppPath() << "/data/Help/Help.html";
            char const* args[] = {str.String(), 0};
            be_roster->Launch("text/html", 1, const_cast<char **>(args));
			break;
        }

		case MENU_HELP_ABOUT:
        {
            BString str;
            str << "Puri is a Chess GUI\n\twritten by\n";
            str << "Ciprian Nedisan\n\n\n";
            str << "Version: " << (float)VERSION << "\n";
            str << "License: MIT\n\n";
            str << "Many thanks to:\n";
            str << "\talexd\n";
            str << "\tingo\n";
            str << "\tstippi\n";
            str << "\tZuMi\n\n";

            fChessBoard->CancelSelection();
			(new BAlert("About Puri", str, "Ok"))->Go();
			break;
        }

        case MSG_BOARDSTATE:
        {
            int32 state;
            message->FindInt32("val", &state);

            if (state > 1) {
                fTimeView->Stop();
                if (fEngineOutput != NULL)
                	fEngineOutput->SetOn(false);
            }

            break;
        }

        case ICS_GAME_INFO:
        {
            BString str;
            message->FindString("info", &str);
            // The ics protocol is wrongly  implemented. it= , i=
            vector<BString> timeW = Tools::Split(Tools::Find(str, "it="), ',');
            vector<BString> timeB = Tools::Split(Tools::Find(str, "i="), ',');
            fTimeView->SetTimeWhite(atoi(timeW[0]));
            fTimeView->SetTimeBlack(atoi(timeB[0]));
            fTimeView->Stop();

            vector<BString> elo = Tools::Split(Tools::Find(str, "rt=").RemoveSet("PE "), ',');
            BString title;
            title << fPlayerName[0] << " (" << elo[0] << ")  -  ";
            title << fPlayerName[1] << " (" << elo[1] << ")    [ ";
            title << atoi(timeW[0]) / 60 << " +" << atoi(timeW[1]);

            if (Tools::Find(str, "r=") == "1")
                title << "  rated ]";
            else
                title << "  unrated ]";

            SetTitle(title);

            break;
        }

        case ICS_MADE_MOVE:
        {
            BString move;
            message->FindString("info", &move);
            std::vector<BString> vec = Tools::Split(move);
            fTimeView->SetTimeMS(atoi(vec[5]), atoi(vec[1])%2 == 1);
            fChessBoard->DoICSMove(vec[3]);
            break;
        }

        case ICS_FORFEIT_ON_TIME:
        {
            fChessBoard->CancelSelection();
            fTimeView->Stop();
            fChessBoard->SetUserCanMove(true);
            BString str;
            message->FindString("info", &str);
            str << "\nforfeits on time";
            (new BAlert("Time", str, "OK"))->Go();

            break;
        }

        case ICS_FORFEIT_BY_DISCONNECTION:
        {
            fChessBoard->CancelSelection();
            fTimeView->Stop();
            fChessBoard->SetUserCanMove(true);
            BString str;
            message->FindString("info", &str);
            str << "\nforfeits by disconnection";

            (new BAlert("Disconnection", str, "OK"))->Go();

            break;
        }

        case ICS_RESIGN:
        {
            fChessBoard->CancelSelection();
            fTimeView->Stop();
            fChessBoard->SetUserCanMove(true);
            (new BAlert("Resign", "Game was resigned", "OK"))->Go();

            break;
        }

        case ICS_NOTPLAYING:
        {
            fTimeView->Stop();
            fChessBoard->SetUserCanMove(true);
         //   (new BAlert("Not Playing", "Game not active", "OK"))->Go();

            break;
        }

        case ICS_GAME_DRAWN:
        {
            fChessBoard->CancelSelection();
            fTimeView->Stop();
            fChessBoard->SetUserCanMove(true);
            (new BAlert("Draw", "Game was drawn", "OK"))->Go();

            break;
        }

        case ICS_OFFERED_INFO:
        case ICS_TELL:
        case ICS_SHOUT:
            PostMessage(message, fChatView);
            break;


        case ICS_GAME_ABORTED:
        {
            fChessBoard->CancelSelection();
            fTimeView->Stop();
            fChessBoard->SetUserCanMove(true);
            (new BAlert("Abort", "Game was aborted", "OK"))->Go();

            break;
        }

        case ICS_NEW_GAME:
        {
            fChessBoard->NewGame();
			fTimeView->Init(0);
            fMovesView->Clear();
            fMaterialView->Clear();

            BString wuser, buser;
            bool isWhite;
            message->FindString("wuser", &wuser);
            message->FindString("buser", &buser);
            message->FindBool("iswhite", & isWhite);

            fChessBoard->SetBoardTurned(!isWhite);

            if (isWhite)
                fChessBoard->SetUserCanMove(true);
            else
                fChessBoard->SetUserCanMove(false);

            Activate();
            break;
        }

        case MSG_ICS_MOVE_DONE:
        {
            BString move;
            message->FindString("move", &move);
            fMovesView->AddMove(move, !fChessBoard->IsWhiteTurn());
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
			fTimeView->Switch();
            fChessBoard->SetUserCanMove(true);
            break;
        }

		case USER_MADE_MOVE:
        {
            BString move;
            message->FindString("move", &move);
            fMovesView->AddMove(move, !fChessBoard->IsWhiteTurn());
			fTimeView->Switch();
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());

            if (fICSConnectMI->IsMarked()) {
                BMessage msg(USER_MADE_MOVE);
                BString str;
                str << BLK_GAME_MOVE << " " << fChessBoard->LastMoveICSF();
                SendICS(str, fICSMainWindow);
                fChessBoard->SetUserCanMove(false);
            } else if (fEngineOffMenuItem->IsMarked() == false)
            {
                _EngineGo();
            }

			break;
        }

        case ENGINE_MADE_MOVE:
        {
            BString move;
            message->FindString("move", &move);
            fMovesView->AddMove(move, !fChessBoard->IsWhiteTurn());
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
			fTimeView->Switch();
            fChessBoard->SetUserCanMove(true);
			break;
        }

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
コード例 #9
0
ファイル: bydpmainwindow.cpp プロジェクト: ytmytm/beos-bsap
void BYdpMainWindow::MessageReceived(BMessage *Message) {
	int item;
	this->DisableUpdates();
	switch (Message->what) {
		case MSG_MODIFIED_INPUT:
			HandleModifiedInput(false);
			break;
		case MSG_LIST_INVOKED:
			item = dictList->CurrentSelection(0);
			wordInput->SetText(((BStringItem*)dictList->ItemAt(item))->Text());
			break;
		case MSG_LIST_SELECTED:
			item = dictList->CurrentSelection(0);
			if (item>dictList->CountItems())
				item = dictList->CountItems();
			if (item>=0)
				myDict->GetDefinition(myDict->wordPairs[item+dictList->topIndex]);
			break;
		case MSG_LISTUP:
		case MSG_LISTDOWN:
//			printf("got listup\n");
			myDict->GetDefinition(myDict->wordPairs[dictList->topIndex+dictList->CurrentSelection(0)]);
			break;
//		case MSG_LISTDOWN:
//			printf("got listdown\n");
//			myDict->GetDefinition(myDict->wordPairs[dictList->topIndex+dictList->CurrentSelection(0)]);
//			break;
		case MSG_CLEAR_INPUT:
			wordInput->SetText("");
			wordInput->MakeFocus();
			break;
		case MENU_ENG2POL:
			UpdateLanguages(true);
			break;
		case MENU_POL2ENG:
			UpdateLanguages(false);
			break;
		case MENU_SWITCH:
			UpdateLanguages(!config->toPolish);
			break;
		case MENU_FUZZY:
			config->searchmode = SEARCH_FUZZY;
			config->save();
			HandleModifiedInput(true);
			UpdateMenus();
			break;
		case MENU_PLAIN:
			config->searchmode = SEARCH_BEGINS;
			config->save();
			HandleModifiedInput(true);
			UpdateMenus();
			break;
/*		case MENU_ENGINESQ2:
			SwitchEngine(DICTIONARY_SQ2);
			break; */
		case MENU_ENGINESAP:
			SwitchEngine(DICTIONARY_SAP);
			break;
		case MENU_ENGINEYDP:
			SwitchEngine(DICTIONARY_YDP);
			break;
		case MENU_PATH:
			ConfigPath();
			break;
		case MENU_COLOR0:
			ConfigColour(0);
			break;
		case MENU_COLOR1:
			ConfigColour(1);
			break;
		case MENU_COLOR2:
			ConfigColour(2);
			break;
		case MENU_COLOR3:
			ConfigColour(3);
			break;
		case MENU_CLIP:
			config->clipboardTracking = !config->clipboardTracking;
			config->save();
			UpdateMenus();
			break;
		case MENU_FOCUS:
			config->setFocusOnSelf = !config->setFocusOnSelf;
			config->save();
			UpdateMenus();
			break;
		case MENU_DISTANCE:
			ConfigDistance();
			break;
/*		case MENU_SQL:
			ConfigSQLTables();
			break; */
		case MENU_ABOUT: {
			BString about;
			about = "\n\n" APP_NAME " " APP_VERSION "\n";
			about += "English-Polish, Polish-English dictionary\n";
			about += "\n\nBeOS version:\n";
			about += "Maciej Witkowiak <*****@*****.**>";
			about += "\n\nSAP engine based on sap v0.2b\n";
			about += "(c) 1998 Bohdan R. Rau,\n(c) 2001 Daniel Mealha Cabrita";
			about += "\nYDP and SQL engines by Maciej Witkowiak\n";
			about += "\n\nSoftware released under GNU/GPL license";
			about += "\n\nvisit:\n";
			about += "http://home.elysium.pl/ytm/html/beos.html\n";
			about += "\nDevelopment has been encouraged by:\n";
			about += "http://www.haiku-os.pl";
			outputView->SetText(about.String()); }
			break;
		case FONT_SIZE:
		{
			float fontSize;
			Message->FindFloat("size",&fontSize);
			SetFontSize(fontSize);
		}
		break;
		case FONT_FAMILY:
		{
			const char * fontFamily = 0, * fontStyle = 0;
			void * ptr;
			if (Message->FindPointer("source",&ptr) == B_OK) {
				currentFontItem = static_cast<BMenuItem*>(ptr);
				fontFamily = currentFontItem->Label();
			}
			SetFontStyle(fontFamily, fontStyle);
		}
		case FONT_STYLE:
		{
			const char * fontFamily = 0, * fontStyle = 0;
			void * ptr;
			if (Message->FindPointer("source",&ptr) == B_OK) {
				BMenuItem * item = static_cast<BMenuItem*>(ptr);
				fontStyle = item->Label();
				BMenu * menu = item->Menu();
				if (menu != 0) {
					currentFontItem = menu->Superitem();
					if (currentFontItem != 0) {
						fontFamily = currentFontItem->Label();
					}
				}
			}
			SetFontStyle(fontFamily, fontStyle);
		}
		case MSG_SCROLL:
//			printf("scroll value changed\n");
			if (scrollBar->Value() != dictList->topIndex) {
				dictList->ListScrolled(scrollBar->Value());
				myDict->GetDefinition(myDict->wordPairs[dictList->topIndex+dictList->CurrentSelection(0)]);
			}
			break;
		case MSG_COLOURUPDATE:
//			printf("colour update\n");
			myDict->ReGetDefinition();
			break;
		case MSG_FUZZYUPDATE:
//			printf("fuzzy update\n");
			if (config->searchmode == SEARCH_FUZZY)
				HandleModifiedInput(true);
			break;
/*		case MSG_SQLTABLESUPDATE:
//			printf("sql tables updated\n");
			myDict->FlushCache();
			SwitchEngine(config->dictionarymode);
			break; */
		case B_CLIPBOARD_CHANGED:
			NewClipData();
			break;
		case B_REFS_RECEIVED:
			RefsReceived(Message);
			break;
		case B_CANCEL:
//			printf("canceled\n");
			if (firstStart) {
				config->dictionarymode = DICTIONARY_SAP;	// will be saved in QuitRequested below
				BAlert *alert = new BAlert(APP_NAME, "Couldn't open dictionary. Dictionary engine has been reset to SAP.", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
				alert->Go();
				QuitRequested();
			}
			else
				delete myPanel;
//			break;
		default:
			BWindow::MessageReceived(Message);
			break;
	}
	this->EnableUpdates();
}