Пример #1
0
void CharismaWindow::Minimize(bool minimize)
{
	const float margin=4.0f;
	BRect r;
	
	// en réalité, minimize est ignoré
	
	if(!isminim){
		menubar->Hide();
		setupview->MoveTo(B_ORIGIN);
		modemenu->MoveTo(margin,margin);
	
		r=modemenu->Frame();
		ResizeTo(r.right+margin,r.bottom+margin);
		
		SetLook(B_MODAL_WINDOW_LOOK);

		isminim=1;
	}else{
		menubar->Show();
		setupview->MoveTo(0,menubar->Frame().bottom);
		modemenu->MoveTo(10.0f,10.0f);

		r=setupview->Frame();
		ResizeTo(r.right,r.bottom);

		SetLook(B_TITLED_WINDOW_LOOK);

		isminim=0;
	}
}
Пример #2
0
/*****************************************************************************
 * VideoWindow::SetFullScreen
 *****************************************************************************/
void
VideoWindow::SetFullScreen(bool doIt)
{
    if (doIt)
    {
        SetLook( B_NO_BORDER_WINDOW_LOOK );
        BScreen screen( this );
        BRect rect = screen.Frame();
        Activate();
        MoveTo(0.0, 0.0);
        ResizeTo(rect.IntegerWidth(), rect.IntegerHeight());
        be_app->ObscureCursor();
        fInterfaceShowing = false;
        fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN);
    }
    else
    {
        SetLook( B_TITLED_WINDOW_LOOK );
        MoveTo(winSize.left, winSize.top);
        ResizeTo(winSize.IntegerWidth(), winSize.IntegerHeight());
        be_app->ShowCursor();
        fInterfaceShowing = true;
        fSettings->ClearFlags(VideoSettings::FLAG_FULL_SCREEN);
    }
}
Пример #3
0
void Pacman::SetDestination(float x, float y, float z)
{
	GameObject::SetDestination(x, y, z);
	D3DXVECTOR2 direction = D3DXVECTOR2(x - GetPosition().x, z - GetPosition().z);
	SetLook(direction);
	//gNextMove = NextMove::Forward;
}
NewControlsPropSheet::NewControlsPropSheet(CWnd* pParentWnd)
  : CMFCPropertySheet(IDS_CAPTION, pParentWnd) {
  //BOOL b32BitIcons = globalData.bIsOSAlphaBlendingSupport;
  BOOL b32BitIcons = TRUE;

  if (globalData.m_nBitsPerPixel == 16) {
    // 32-bit icons in 16 bpp display mode
    // are correctly displayed in WinXP only

    OSVERSIONINFO osvi;
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    ::GetVersionEx(&osvi);

    b32BitIcons = (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && (osvi.dwMajorVersion > 5 || (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion >= 1)));
  }

  SetLook(CMFCPropertySheet::PropSheetLook_OutlookBar);
  SetIconsList(b32BitIcons ? IDB_ICONS32 : IDB_ICONS, 32);

  AddPage(&m_Page1);
  AddPage(&m_Page2);
  AddPage(&m_Page3);
  AddPage(&m_Page4);
  AddPage(&m_Page5);
  AddPage(&m_Page6);

  m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
Пример #5
0
COptionsDlg::COptionsDlg(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CMFCPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
	SetLook(CMFCPropertySheet::PropSheetLook_Tree, 150 /* Tree control width */);
	SetIconsList(IDB_OPTIONSIMAGES, 16 /* Image width */);

	// <snippet23>
	// The second parameter is the zero based index of an icon that is displayed when 
	// the control property page is not selected.
	// The third parameter is the zero based index of an icon that is displayed when
	// the control property page is selected.
	CMFCPropertySheetCategoryInfo* pCat1 = AddTreeCategory(_T("Environment"), 0, 1);
	// </snippet23>

	AddPageToTree(pCat1, &m_Page11, -1, 2);
	AddPageToTree(pCat1, &m_Page12, -1, 2);

	CMFCPropertySheetCategoryInfo* pCat2 = AddTreeCategory(_T("Source Control"), 0, 1);

	AddPageToTree(pCat2, &m_Page21, -1, 2);
	AddPageToTree(pCat2, &m_Page22, -1, 2);

	CMFCPropertySheetCategoryInfo* pCat3 = AddTreeCategory(_T("Text Editor"), 0, 1);

	AddPageToTree(pCat3, &m_Page31, -1, 2);
	AddPageToTree(pCat3, &m_Page32, -1, 2);
}
Пример #6
0
PulseWindow::PulseWindow(BRect rect)
	:
	BWindow(rect, B_TRANSLATE_SYSTEM_NAME("Pulse"), B_TITLED_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{
	SetPulseRate(200000);
	
	PulseApp *pulseapp = (PulseApp *)be_app;
	BRect bounds = Bounds();
	fNormalPulseView = new NormalPulseView(bounds);
	AddChild(fNormalPulseView);

	fMiniPulseView = new MiniPulseView(bounds, "MiniPulseView", 
		pulseapp->prefs);
	AddChild(fMiniPulseView);

	fMode = pulseapp->prefs->window_mode;
	if (fMode == MINI_WINDOW_MODE) {
		SetLook(B_MODAL_WINDOW_LOOK);
		SetFeel(B_NORMAL_WINDOW_FEEL);
		SetFlags(B_NOT_ZOOMABLE);
		fNormalPulseView->Hide();
		SetSizeLimits(GetMinimumViewWidth() - 1, 4096, 2, 4096);
		ResizeTo(rect.Width(), rect.Height());
	} else
		fMiniPulseView->Hide();

	fPrefsWindow = NULL;
}
	CModelDlg::CModelDlg(CWnd* pParentWnd, UINT iSelectPage) :
		CMFCPropertySheet(_T("Model Editor"), pParentWnd, iSelectPage),
		m_generalPage(m_model),
		m_WGInputPage(m_model),
		m_SSIPage(m_model),
		m_inputPage(m_model),
		m_outputPage(m_model),
		m_creditPage(m_model)
	{
		m_psh.dwFlags |= PSH_NOAPPLYNOW;
		m_psh.dwFlags &= ~(PSH_HASHELP);

		//Load the icon what we will set later for the program
		m_hIcon = AfxGetApp()->LoadIcon(IDI_DBEDIT_MODEL);

		//Set look and icon
		SetLook(CMFCPropertySheet::PropSheetLook_OutlookBar);
		SetIconsList(IDB_UI_MODEL_ICONS, 48); 


		AddPage(&m_generalPage);
		AddPage(&m_WGInputPage);
		AddPage(&m_SSIPage);
		AddPage(&m_inputPage);
		AddPage(&m_outputPage);
		AddPage(&m_creditPage);

	}
Пример #8
0
BOOL CAppLookDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	SetLook ();

	m_wndStyle2007.EnableWindow (m_nAppLook == 3);

	if (m_bStartup)
	{
		if (!m_bShowAtStartup)
		{
			EndDialog (IDCANCEL);
			return TRUE;
		}

		CRect rectBtn;

		// Hide "Cancel" button:
		m_wndCancel.GetWindowRect (rectBtn);
		ScreenToClient (rectBtn);

		m_wndOK.MoveWindow (rectBtn);

		m_wndCancel.EnableWindow (FALSE);
		m_wndCancel.ShowWindow (SW_HIDE);
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Пример #9
0
void
MainWin::ToggleNoBorder()
{
	printf("ToggleNoBorder enter\n");
	fNoBorder = !fNoBorder;
//	SetLook(fNoBorder ? B_NO_BORDER_WINDOW_LOOK : B_TITLED_WINDOW_LOOK);
	SetLook(fNoBorder ? B_BORDERED_WINDOW_LOOK : B_TITLED_WINDOW_LOOK);
	printf("ToggleNoBorder leave\n");
}
Пример #10
0
void CAppLookDlg::OnApply() 
{
	SetLook ();

	if (!m_bStartup)
	{
		m_wndCancel.SetWindowText (_T("Close"));
	}
}
Пример #11
0
WorkspacesWindow::WorkspacesWindow(WorkspacesSettings *settings)
	: BWindow(settings->WindowFrame(), "Workspaces", B_TITLED_WINDOW_LOOK,
 			B_NORMAL_WINDOW_FEEL, B_AVOID_FRONT | B_WILL_ACCEPT_FIRST_CLICK,
 			B_ALL_WORKSPACES),
 	fSettings(settings),
 	fAutoRaising(false)
{
	AddChild(new WorkspacesView(Bounds()));

	if (!fSettings->HasBorder())
		SetLook(B_NO_BORDER_WINDOW_LOOK);
	else if (!fSettings->HasTitle())
		SetLook(B_MODAL_WINDOW_LOOK);

	if (fSettings->AlwaysOnTop())
		SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
	else
		SetAutoRaise(fSettings->AutoRaising());
}
Пример #12
0
CSetupSheet::CSetupSheet(CWnd* lpParentWnd)
	: CMFCPropertySheet(_T("参数设置"), lpParentWnd)
{
	SetLook(CMFCPropertySheet::PropSheetLook_OutlookBar);
	SetIconsList(IDB_SETUP_SHEET, 32);

	AddPage(&m_pageNetworkTest);
	AddPage(&m_pageEchoTest);
	AddPage(&m_pageDeviceTest);
	AddPage(&m_pageSetup);
}
Пример #13
0
void
PulseWindow::SetMode(int newmode)
{
	PulseApp *pulseapp = (PulseApp *)be_app;

	switch (newmode) {
		case PV_NORMAL_MODE:
			if (fMode == MINI_WINDOW_MODE) {
				pulseapp->prefs->mini_window_rect = Frame();
				pulseapp->prefs->window_mode = NORMAL_WINDOW_MODE;
				pulseapp->prefs->Save();
			}
			fMiniPulseView->Hide();
			fNormalPulseView->Show();
			fMode = NORMAL_WINDOW_MODE;
			SetType(B_TITLED_WINDOW);
			SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE);
			ResizeTo(pulseapp->prefs->normal_window_rect.IntegerWidth(),
				pulseapp->prefs->normal_window_rect.IntegerHeight());
			MoveTo(pulseapp->prefs->normal_window_rect.left,
				pulseapp->prefs->normal_window_rect.top);
			MoveOnScreen();
			break;

		case PV_MINI_MODE:
			if (fMode == NORMAL_WINDOW_MODE) {
				pulseapp->prefs->normal_window_rect = Frame();
				pulseapp->prefs->window_mode = MINI_WINDOW_MODE;
				pulseapp->prefs->Save();
			}
			fNormalPulseView->Hide();
			fMiniPulseView->Show();
			fMode = MINI_WINDOW_MODE;
			SetLook(B_MODAL_WINDOW_LOOK);
			SetFeel(B_NORMAL_WINDOW_FEEL);
			SetFlags(B_NOT_ZOOMABLE);
			SetSizeLimits(GetMinimumViewWidth() - 1, 4096, 2, 4096);
			ResizeTo(pulseapp->prefs->mini_window_rect.IntegerWidth(),
				pulseapp->prefs->mini_window_rect.IntegerHeight());
			MoveTo(pulseapp->prefs->mini_window_rect.left,
				pulseapp->prefs->mini_window_rect.top);
			MoveOnScreen();
			break;

		case PV_DESKBAR_MODE:
			// Do not set window's mode to DESKBAR_MODE because the
			// destructor needs to save the correct BRect. ~PulseApp()
			// will handle launching the replicant after our prefs are saved.
			pulseapp->prefs->window_mode = DESKBAR_MODE;
			PostMessage(B_QUIT_REQUESTED);
			break;
	}
}
Пример #14
0
CNetBarPropertySheet::CNetBarPropertySheet(CWnd* pParentWnd /*= NULL*/)
: CBCGPPropertySheet(IDS_NETBARCONFIG, pParentWnd)
{
	m_psh.dwFlags |= PSH_NOAPPLYNOW;

	SetLook(CBCGPPropertySheet::PropSheetLook_List);
	//SetLook(CBCGPPropertySheet::PropSheetLook_Tabs);

	//AddPage(&m_NetBarInfo);
	//AddPage(&m_NetBarConfig);
	
	EnableVisualManagerStyle();
}
CClientConfigPropertySheet::CClientConfigPropertySheet(CWnd* pParentWnd)
: CIBASheet(IDS_CLIENTSET, pParentWnd)
{
	m_psh.dwFlags |= PSH_NOAPPLYNOW;

	SetLook(CIBASheet::PropSheetLook_List);

	AddPage(&m_CommonConfig);
	AddPage(&m_BundleTimePage);
	AddPage(&m_UnlockPage);

	EnableVisualManagerStyle();
}
Пример #16
0
ProtocolWindow::ProtocolWindow(BRect frame, const char *title, window_type type, int stream)
			:BWindow(frame, title, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_PULSE_NEEDED|B_ASYNCHRONOUS_CONTROLS) {
	SetSizeLimits(300, 10000, 150, 10000);
	fStream=stream;
	mb=new BMenuBar(BRect(0,0,frame.Width(),1), _T("File")); // "TMI_FILE"
	mainM=new BMenu(_T("File")); // "TMI_FILE"
	clearMI=new BMenuItem(_T("Clear"), new BMessage(LOG_CLEAR), 'C'); // "TMI_CLEAR"
	closeMI=new BMenuItem(_T("Close"), new BMessage(B_QUIT_REQUESTED), 'W'); // ""TMI_CLOSE"
	
	logfileM=new BMenu(_T("Log file")); // "TMI_LOG_FILE"
	enablefileloggingMI=new BMenuItem(_T("Log to file"), // "TMI_ENABLE_LOG_FILE"
				new BMessage(ENABLE_LOG_FILE_MSG),'L');
				
	BString tmpstring;
	tmpstring << _T("Set file") << B_UTF8_ELLIPSIS; // "TMI_SETLOGFILENAME"
	setlognameMI=new BMenuItem( tmpstring.String(), new BMessage(SETLOGFILE_MSG));
	tmpstring = "";
	tmpstring << _T("Log settings") << B_UTF8_ELLIPSIS; // "TMI_SETLOGFILENAME"
	logsettingsMI=new BMenuItem( tmpstring.String(),
				new BMessage(LOGSETTINGS_MSG));
	
	contentView=new ProtocolView(BRect(0,0,frame.Width()-B_V_SCROLL_BAR_WIDTH, frame.Height()-(B_H_SCROLL_BAR_HEIGHT)), "contentView", BRect(1,1,2000,1000),B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW | B_PULSE_NEEDED, fStream);
	scrollView=new BScrollView("scrollView", contentView, B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP_BOTTOM, 0, true, true, B_NO_BORDER);
	AddChild(scrollView);
	AddChild(mb);
	mb->AddItem(mainM);
	mainM->AddItem(clearMI);
	mainM->AddItem(closeMI);
	
	mb->AddItem(logfileM);
	logfileM->AddItem(enablefileloggingMI);
	logfileM->AddItem(setlognameMI);
	////////////////////////////////////////////////
	//logfileM->AddItem(logsettingsMI);
	
	logfileF=new BFile();
	logfilenameS="";
	datewritten=false;

//	contentView=new BTextView(BRect(0,0,frame.Width()-B_V_SCROLL_BAR_WIDTH, frame.Height()-B_H_SCROLL_BAR_HEIGHT), "contentView", frame,B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
//	scrollView=new BScrollView("scrollView", contentView, B_FOLLOW_ALL_SIDES, 0, true, true);
	SetPulseRate(0);
//	reader_sem=create_sem(1, "ProtocolWindow(): reader_sem");
	SetLook(B_DOCUMENT_WINDOW_LOOK);
	contentView->MakeEditable(false);
	contentView->MakeResizable(false);
	contentView->SetStylable(true);
	
	MoveTo(40,40);
	contentView->MakeFocus(true);	
}
Пример #17
0
SLoadingModules::SLoadingModules(int32 modules_count)
	: BWindow(BRect(-100, -100, -10, -10), "BeCJK Loading Moudles", B_BORDERED_WINDOW, B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_AVOID_FOCUS, B_ALL_WORKSPACES)
{
	count = 0;
	nmodules = modules_count;
	SetPulseRate(500000);
	SetSizeLimits(0, 10000, 0, 10000);

	BString str;
	str << "BeCJK " << _("Loading Modules: ");

	bar = new BStatusBar(BRect(0, 0, 10, 10), NULL, str.String(), NULL);
	rgb_color bar_color = {255, 203, 0, 255};
	bar->SetBarColor(bar_color);
	bar->SetMaxValue(nmodules);
	bar->SetFont(be_plain_font);
	bar->SetFontSize(10);
	bar->SetBarHeight(10);
	float w = 0, h = 0;
	bar->GetPreferredSize(&w, &h);


	BScreen screen(this);
	BRect rect = screen.Frame();
	rect.OffsetTo(B_ORIGIN);
	rect.top = rect.bottom - SLoadingModulesView::GetHeightByChild(bar);
	ResizeTo(rect.Width(), rect.Height());
	MoveTo(rect.LeftTop());

	SLoadingModulesView *main_view = new SLoadingModulesView(Bounds());
	main_view->AddChild(bar);
	bar->ResizeTo(main_view->ContainerBounds().Width(), main_view->ContainerBounds().Height());
	bar->MoveTo(main_view->ContainerBounds().LeftTop());

	AddChild(main_view);

	RemoveShortcut((uint32)'W', (uint32)B_COMMAND_KEY);
	RemoveShortcut((uint32)'Q', (uint32)B_COMMAND_KEY);

	SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
	SetLook(B_NO_BORDER_WINDOW_LOOK);

	Run();
}
Пример #18
0
COptionsDlg::COptionsDlg(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
	:CBCGPPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
	SetLook (CBCGPPropertySheet::PropSheetLook_Tree, 150 /* Tree control width */);
	SetIconsList (IDB_OPTIONSIMAGES, 16 /* Image width */);

	CBCGPPropSheetCategory* pCat1 = AddTreeCategory (_T("Environment"), 0, 1);

	AddPageToTree (pCat1, &m_Page11, -1, 2);
	AddPageToTree (pCat1, &m_Page12, -1, 2);

	CBCGPPropSheetCategory* pCat2 = AddTreeCategory (_T("Source Control"), 0, 1);

	AddPageToTree (pCat2, &m_Page21, -1, 2);
	AddPageToTree (pCat2, &m_Page22, -1, 2);

	CBCGPPropSheetCategory* pCat3 = AddTreeCategory (_T("Text Editor"), 0, 1);

	AddPageToTree (pCat3, &m_Page31, -1, 2);
	AddPageToTree (pCat3, &m_Page32, -1, 2);
}
Пример #19
0
CSetOfIBAPropertySheet::CSetOfIBAPropertySheet(CWnd* pParentWnd)
: CIBASheet(IDS_IBASET, pParentWnd)
{
	m_psh.dwFlags |= PSH_NOAPPLYNOW;

	SetLook(CIBASheet::PropSheetLook_List);

	AddPage(&m_IBASetPage);
	AddPage(&m_MonitorSetPage);
	AddPage(&m_MonitorSetPage2);
	AddPage(&m_OnOffDutySetPage);
	AddPage(&m_BusinessSetPage);
	AddPage(&m_CreditSetPage);
	AddPage(&m_JXCSetPage);
	AddPage(&m_TTSSetPage);
	AddPage(&m_SeatSetPage);
	AddPage(&m_PrintSetPage);
	AddPage(&m_ClearDataSetPage);
	
	
	EnableVisualManagerStyle(); 
}
CBCGPRibbonCustomize::CBCGPRibbonCustomize (CWnd* pWndParent, CBCGPRibbonBar* pRibbon, BOOL bCustomizeQAT) :
	CBCGPPropertySheet (_T(""), pWndParent),
	m_bCustomizeQAT(bCustomizeQAT)
{
	m_psh.dwFlags |= PSH_NOAPPLYNOW;

	CBCGPLocalResource locaRes;

	m_strCaption = (AfxGetApp ()->m_pszAppName == NULL) ? _T("") : AfxGetApp ()->m_pszAppName;
	m_psh.pszCaption = m_strCaption;

	m_pQATPage = new CBCGPRibbonCustomizeQATPage (pRibbon);
	AddPage (m_pQATPage);

	if (pRibbon->IsCustomizationEnabled())
	{
		m_pPage = new CBCGPRibbonCustomizeRibbonPage (pRibbon);
		AddPage (m_pPage);

		SetActivePage(m_bCustomizeQAT ? 0 : 1);
	}
	else
	{
		m_pPage = NULL;
	}

	if (g_pUserToolsManager != NULL)
	{
		m_pToolsPage = new CBCGPRibbonToolsPage(pRibbon);
		AddPage (m_pToolsPage);
	}
	else
	{
		m_pToolsPage = NULL;
	}

	SetLook(CBCGPPropertySheet::PropSheetLook_List, 150 /* List width */);
}
Пример #21
0
void CAppLookDlg::OnOK() 
{
	CDialog::OnOK();
	SetLook ();
}
Пример #22
0
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);
}
Пример #23
0
WorkspacesWindow::WorkspacesWindow(WorkspacesSettings *settings)
	:
	BWindow(settings->WindowFrame(), B_TRANSLATE_SYSTEM_NAME("Workspaces"),
		B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
		B_AVOID_FRONT | B_WILL_ACCEPT_FIRST_CLICK | B_CLOSE_ON_ESCAPE,
		B_ALL_WORKSPACES),
	fSettings(settings),
	fSwitchOnWheel(false)
{
	// Turn window decor on to grab decor widths.
	BMessage windowSettings;
	float borderWidth = 0;

	SetLook(B_TITLED_WINDOW_LOOK);
	if (GetDecoratorSettings(&windowSettings) == B_OK) {
		BRect tabFrame = windowSettings.FindRect("tab frame");
		borderWidth = windowSettings.FindFloat("border width");
		fTabHeight = tabFrame.Height();
		fBorderWidth = borderWidth;
	}

	if (!fSettings->SettingsLoaded()) {
		// No settings, compute a reasonable default frame.
		// We aim for previews at 10% of actual screen size, and matching the
		// aspect ratio. We then scale that down, until it fits the screen.
		// Finally, we put the window on the bottom right of the screen so the
		// auto-raise mode can be used.

		BScreen screen;

		float screenWidth = screen.Frame().Width();
		float screenHeight = screen.Frame().Height();
		float aspectRatio = screenWidth / screenHeight;

		uint32 columns, rows;
		BPrivate::get_workspaces_layout(&columns, &rows);

		// default size of ~1/10 of screen width
		float workspaceWidth = screenWidth / 10;
		float workspaceHeight = workspaceWidth / aspectRatio;

		float width = floor(workspaceWidth * columns);
		float height = floor(workspaceHeight * rows);

		// If you have too many workspaces to fit on the screen, shrink until
		// they fit.
		while (width + 2 * borderWidth > screenWidth
				|| height + 2 * borderWidth + GetTabHeight() > screenHeight) {
			width = floor(0.95 * width);
			height = floor(0.95 * height);
		}

		BRect frame = fSettings->ScreenFrame();
		frame.OffsetBy(-2.0 * borderWidth, -2.0 * borderWidth);
		frame.left = frame.right - width;
		frame.top = frame.bottom - height;
		ResizeTo(frame.Width(), frame.Height());

		// Put it in bottom corner by default.
		MoveTo(screenWidth - frame.Width() - borderWidth,
			screenHeight - frame.Height() - borderWidth);

		fSettings->SetWindowFrame(frame);
	}

	if (!fSettings->HasBorder())
		SetLook(B_NO_BORDER_WINDOW_LOOK);
	else if (!fSettings->HasTitle())
		SetLook(B_MODAL_WINDOW_LOOK);

	AddChild(new WorkspacesView(Bounds()));

	if (fSettings->AlwaysOnTop())
		SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
	else
		SetAutoRaise(fSettings->AutoRaising());

	SetSwitchOnWheel(fSettings->SwitchOnWheel());
}
Пример #24
0
void
EBePrivateWin::DispatchMessage(BMessage *bMsg, BHandler *handler)
{
	bool handled = true;

	if(bMsg->what == 'etk_')
	{
		int32 what = 0;
		bMsg->FindInt32("etk:what", &what);

		switch(what)
		{
			case ETK_BEOS_QUIT:
				doQuit = true;
				PostMessage(B_QUIT_REQUESTED);
				break;

			case ETK_BEOS_CONTACT_TO:
				{
					fContactor = EMessenger();
					const char *buffer = NULL;
					ssize_t size = -1;
					if(bMsg->FindData("etk:messenger", B_ANY_TYPE, (const void**)&buffer, &size) != B_OK) break;
					if(buffer == NULL || size <= 0) break;
					fContactor.Unflatten(buffer, (size_t)size);
				}
				break;

			case ETK_BEOS_SET_BACKGROUND:
				{
					rgb_color bkColor;
					if(bMsg->FindInt32("background", (int32*)&bkColor) != B_OK) break;
					fTopView->SetViewColor(bkColor);
					fTopView->Invalidate();
				}
				break;

			case ETK_BEOS_SET_LOOK:
				{
					int8 look;
					if(bMsg->FindInt8("look", &look) != B_OK) break;
					switch((e_window_look)look)
					{
						case E_BORDERED_WINDOW_LOOK:
							SetLook(B_BORDERED_WINDOW_LOOK);
							break;

						case E_NO_BORDER_WINDOW_LOOK:
							SetLook(B_NO_BORDER_WINDOW_LOOK);
							break;

						case E_TITLED_WINDOW_LOOK:
							SetLook(B_TITLED_WINDOW_LOOK);
							break;

						case E_DOCUMENT_WINDOW_LOOK:
							SetLook(B_DOCUMENT_WINDOW_LOOK);
							break;

						case E_MODAL_WINDOW_LOOK:
							SetLook(B_MODAL_WINDOW_LOOK);
							break;

						case E_FLOATING_WINDOW_LOOK:
							SetLook(B_FLOATING_WINDOW_LOOK);
							break;

						default:
							break;
					}
				}
				break;

			case ETK_BEOS_SET_TITLE:
				{
					const char *title = NULL;
					if(bMsg->FindString("title", &title) != B_OK) break;
					SetTitle(title);
				}
				break;

			case ETK_BEOS_SET_WORKSPACES:
				{
					uint32 workspaces = 0;
					if(bMsg->FindInt32("workspaces", (int32*)&workspaces) != B_OK) break;
					if(workspaces == 0) workspaces = current_workspace() + 1;
					SetWorkspaces(workspaces);
				}
				break;

			case ETK_BEOS_GET_WORKSPACES:
				{
					uint32 workspaces = Workspaces();
					bMsg->AddInt32("workspaces", *((int32*)&workspaces));
				}
				break;

			case ETK_BEOS_ICONIFY:
				if(!IsMinimized()) Minimize(true);
				break;

			case ETK_BEOS_SHOW:
				if(IsHidden())
				{
					uint32 oldFlags = Flags();
					SetFlags(oldFlags | B_AVOID_FOCUS);
					Show();
					if(Look() != B_NO_BORDER_WINDOW_LOOK) SetFlags(oldFlags);
				}
				break;

			case ETK_BEOS_HIDE:
				if(!IsHidden()) Hide();
				break;

			case ETK_BEOS_RAISE:
				if(!IsFront())
				{
					uint32 oldFlags = Flags();
					SetFlags(oldFlags | B_AVOID_FOCUS);
					Activate(true);
					if(Look() != B_NO_BORDER_WINDOW_LOOK) SetFlags(oldFlags);
				}
				break;

			case ETK_BEOS_LOWER:
				{
					BHandler *_frontWin = NULL;
					if(bMsg->FindPointer("front", (void**)&_frontWin) != B_OK) break;
					BWindow *frontWin = e_cast_as(_frontWin, BWindow);
					if(frontWin == NULL) break;
					SendBehind(frontWin);
					bMsg->AddBool("done", true);
				}
				break;

			case ETK_BEOS_ACTIVATE:
				{
					bool state;
					if(bMsg->FindBool("state", &state) != B_OK || state == IsActive()) break;
					Activate(state);
				}
				break;

			case ETK_BEOS_GET_ACTIVATED_STATE:
				bMsg->AddBool("state", IsActive());
				break;

			case ETK_BEOS_MOVE_RESIZE:
				{
					if(bMsg->HasPoint("where"))
					{
						BPoint pt;
						if(bMsg->FindPoint("where", &pt) == B_OK) MoveTo(pt);
					}

					if(bMsg->HasFloat("width") && bMsg->HasFloat("height"))
					{
						float w = -1, h = -1;
						bMsg->FindFloat("width", &w);
						bMsg->FindFloat("height", &h);
						if(w < 0 || h < 0) break;
						ResizeTo(w, h);
					}
				}
				break;

			case ETK_BEOS_DRAW_BITMAP:
				{
					BBitmap *bitmap = NULL;
					BRect srcRect, destRect;
					const ERegion *clipping = NULL;

					if(bMsg->FindPointer("bitmap", (void**)&bitmap) != B_OK || bitmap == NULL) break;
					bMsg->FindRect("src", &srcRect);
					bMsg->FindRect("dest", &destRect);
					if(srcRect.IsValid() == false || destRect.IsValid() == false) break;
					bMsg->FindPointer("clipping", (void**)&clipping); 

					BRegion beRegion;
					__etk_convert_region(clipping, &beRegion, fTopView->Bounds());
					fTopView->ConstrainClippingRegion(&beRegion);
					fTopView->DrawBitmap(bitmap, srcRect, destRect);
				}
				break;

			case ETK_BEOS_GRAB_MOUSE:
			case ETK_BEOS_UNGRAB_MOUSE:
				{
					uint32 options = (what == ETK_BEOS_GRAB_MOUSE ? B_LOCK_WINDOW_FOCUS : 0);
					if(fTopView->SetEventMask(B_POINTER_EVENTS, options) != B_OK) break;
					bMsg->AddBool("state", what == ETK_BEOS_GRAB_MOUSE);
				}
				break;

			case ETK_BEOS_GRAB_KEYBOARD:
			case ETK_BEOS_UNGRAB_KEYBOARD:
				{
					uint32 options = (what == ETK_BEOS_GRAB_KEYBOARD ? B_LOCK_WINDOW_FOCUS : 0);
					if(fTopView->SetEventMask(B_KEYBOARD_EVENTS, options) != B_OK) break;
					bMsg->AddBool("state", what == ETK_BEOS_GRAB_KEYBOARD);
				}
				break;

			case ETK_BEOS_QUERY_MOUSE:
				{
					BPoint pt;
					uint32 btns = 0;
					fTopView->GetMouse(&pt, &btns, false);
					bMsg->AddInt32("x", (int32)pt.x);
					bMsg->AddInt32("y", (int32)pt.y);
					bMsg->AddInt32("buttons", (int32)btns);
				}
				break;

			case ETK_BEOS_SET_SIZE_LIMITS:
				{
					BRect r;
					if(bMsg->FindRect("limits", &r) != B_OK) break;
					SetSizeLimits(r.left, r.right, r.top, r.bottom);
					bMsg->AddBool("done", true);
				}
				break;

			case ETK_BEOS_GET_SIZE_LIMITS:
				{
					BRect r(-1, -1, -1, -1);
					GetSizeLimits(&(r.left), &(r.right), &(r.top), &(r.bottom));
					bMsg->AddRect("limits", r);
				}
				break;

			default:
				handled = false;
				break;
		}

		if(handled)
		{
			BMessage aMsg(*bMsg);
			bMsg->SendReply(&aMsg);
			return;
		}
	}

	switch(bMsg->what)
	{
		case B_WINDOW_ACTIVATED:
			{
				handled = false;

				if(fContactor.IsValid() == false) break;
				EMessage message(E_WINDOW_ACTIVATED);
				message.AddBool("etk:msg_from_gui", true);
				message.AddInt64("when", e_real_time_clock_usecs());
				fContactor.SendMessage(&message);
			}
			break;

		case B_MOUSE_DOWN:
		case B_MOUSE_UP:
		case B_MOUSE_MOVED:
			{
				if(fContactor.IsValid() == false) break;

				BPoint where;
				int32 buttons = 0;

				bMsg->FindPoint("where", &where);
				if(bMsg->what != B_MOUSE_UP) bMsg->FindInt32("buttons", &buttons);

				int32 clicks = 1;
				if(bMsg->what == B_MOUSE_DOWN)
				{
#if 0
					bMsg->FindInt32("clicks", &clicks);
#else
					bigtime_t eventTime;
					if(bMsg->FindInt64("when", &eventTime) == B_OK)
					{
						if(eventTime - fPrevMouseDownTime <= CLICK_TIMEOUT)
							clicks = (fPrevMouseDownCount += 1);
						else
							clicks = fPrevMouseDownCount = 1;
						fPrevMouseDownTime = eventTime;
					}
#endif
				}

				EMessage message;
				if(bMsg->what == B_MOUSE_DOWN) message.what = E_MOUSE_DOWN;
				else if(bMsg->what == B_MOUSE_UP) message.what = E_MOUSE_UP;
				else message.what = E_MOUSE_MOVED;

				message.AddBool("etk:msg_from_gui", true);
				message.AddInt64("when", e_real_time_clock_usecs());
				if(bMsg->what != B_MOUSE_UP) message.AddInt32("buttons", buttons);
				if(bMsg->what == B_MOUSE_DOWN) message.AddInt32("clicks", clicks);
				message.AddPoint("where", EPoint(where.x, where.y));
				ConvertToScreen(&where);
				message.AddPoint("screen_where", EPoint(where.x, where.y));

				// TODO: modifiers

				message.AddMessenger("etk:msg_for_target", fContactor);

				etk_app->PostMessage(&message);
			}
			break;

		case B_KEY_DOWN:
		case B_KEY_UP:
		case B_UNMAPPED_KEY_DOWN:
		case B_UNMAPPED_KEY_UP:
			{
				if(fContactor.IsValid() == false) break;

				int8 byte[4];
				const char *bytes = NULL;
				int32 numBytes = 0;
				int32 key = 0;
				int32 key_repeat = 0;
				int32 beModifiers = 0;
				eint32 modifiers = 0;

				bMsg->FindInt32("key", &key);
				bMsg->FindInt32("modifiers", &beModifiers);
				bzero(byte, sizeof(int8) * 4);

				if(bMsg->what == B_KEY_DOWN || bMsg->what == B_KEY_UP)
				{
					for(int32 i = 0; i < 3; i++) bMsg->FindInt8("byte", i, &byte[i]);
					if(bMsg->FindString("bytes", &bytes) == B_OK) numBytes = strlen(bytes);
//					if(bMsg->what == B_KEY_DOWN) bMsg->FindInt32("be:key_repeat", &key_repeat);
				}
				else
				{
					etk_beos_get_byte(beModifiers, key, (char*)byte);
				}

				if(beModifiers & B_SHIFT_KEY) modifiers |= E_SHIFT_KEY;
				if(beModifiers & B_CONTROL_KEY) modifiers |= E_CONTROL_KEY;
				if(beModifiers & B_COMMAND_KEY) modifiers |= E_COMMAND_KEY;

				EMessage message;
				if(bMsg->what == B_KEY_DOWN) message.what = E_KEY_DOWN;
				else if(bMsg->what == B_KEY_UP) message.what = E_KEY_UP;
				else if(bMsg->what == B_UNMAPPED_KEY_DOWN) message.what = E_UNMAPPED_KEY_DOWN;
				else message.what = E_UNMAPPED_KEY_UP;

				message.AddBool("etk:msg_from_gui", true);
				message.AddInt64("when", e_real_time_clock_usecs());
				message.AddInt32("key", key);
				message.AddInt32("modifiers", modifiers);

				if(bMsg->what == B_KEY_DOWN || bMsg->what == B_KEY_UP)
				{
					if(bMsg->what == B_KEY_DOWN) message.AddInt32("etk:key_repeat", key_repeat);
					for(int32 i = 0; i < 3; i++) message.AddInt8("byte", byte[i]);
					if(!(numBytes != 1 || *bytes != byte[0]))
					{
						etk_beos_get_byte(beModifiers, key, (char*)byte);
						message.AddString("bytes", (char*)byte);
					}
					else if(numBytes > 0)
					{
						message.AddString("bytes", bytes);
					}
				}
				else if(byte[0] != 0)
				{
					message.AddInt8("byte", byte[0]);
					message.AddString("bytes", (char*)byte);
				}

				message.AddMessenger("etk:msg_for_target", fContactor);

				etk_app->PostMessage(&message);
			}
			break;

		case B_MODIFIERS_CHANGED:
			{
				if(fContactor.IsValid() == false) break;

				eint32 modifiers = 0;
				eint32 old_modifiers = 0;
				int32 beModifiers = 0;
				int32 old_beModifiers = 0;

				bMsg->FindInt32("modifiers", &beModifiers);
				bMsg->FindInt32("be:old_modifiers", &old_beModifiers);

				if(beModifiers & B_SHIFT_KEY) modifiers |= E_SHIFT_KEY;
				if(beModifiers & B_CONTROL_KEY) modifiers |= E_CONTROL_KEY;
				if(beModifiers & B_COMMAND_KEY) modifiers |= E_COMMAND_KEY;

				if(old_beModifiers & B_SHIFT_KEY) old_modifiers |= E_SHIFT_KEY;
				if(old_beModifiers & B_CONTROL_KEY) old_modifiers |= E_CONTROL_KEY;
				if(old_beModifiers & B_COMMAND_KEY) old_modifiers |= E_COMMAND_KEY;

				EMessage message(E_MODIFIERS_CHANGED);

				message.AddBool("etk:msg_from_gui", true);
				message.AddInt64("when", e_real_time_clock_usecs());
				message.AddInt32("modifiers", modifiers);
				message.AddInt32("etk:old_modifiers", old_modifiers);

				message.AddMessenger("etk:msg_for_target", fContactor);

				etk_app->PostMessage(&message);
			}
			break;

		default:
			handled = false;
			break;
	}

	if(!handled) BWindow::DispatchMessage(bMsg, handler);
}
Пример #25
0
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;
	}
}
Пример #26
0
bool
MainWindow::LoadSettings(const BMessage* message)
{
	// restore window positioning
	BPoint point;
	bool useAdjust = false;
	if (message->FindPoint("window position", &point) == B_OK) {
		fScreenPosition = point;
		useAdjust = true;
	}
	float borderDist;
	if (message->FindFloat("border distance", &borderDist) == B_OK) {
		fBorderDist = borderDist;
	}
	// restore window frame
	BRect frame;
	if (message->FindRect("window frame", &frame) == B_OK) {
		if (useAdjust) {
			_AdjustLocation(frame);
		} else {
			make_sure_frame_is_on_screen(frame, this);
			MoveTo(frame.LeftTop());
			ResizeTo(frame.Width(), frame.Height());
		}
	}

	// restore window look
	window_look look;
	if (message->FindInt32("window look", (int32*)&look) == B_OK)
		SetLook(look);

	// restore orientation
	int32 orientation;
	if (message->FindInt32("orientation", &orientation) == B_OK)
		fPadView->SetOrientation((enum orientation)orientation);

	// restore icon size
	int32 iconSize;
	if (message->FindInt32("icon size", &iconSize) == B_OK)
		fPadView->SetIconSize(iconSize);

	// restore ignore double click
	bool ignoreDoubleClick;
	if (message->FindBool("ignore double click", &ignoreDoubleClick) == B_OK)
		fPadView->SetIgnoreDoubleClick(ignoreDoubleClick);

	// restore buttons
	const char* path;
	bool buttonAdded = false;
	for (int32 i = 0; message->FindString("path", i, &path) >= B_OK; i++) {
		LaunchButton* button = new LaunchButton("launch button",
			NULL, new BMessage(MSG_LAUNCH));
		fPadView->AddButton(button);
		BString signature;
		if (message->FindString("signature", i, &signature) >= B_OK
			&& signature.CountChars() > 0)  {
			button->SetTo(signature.String(), true);
		}

		BEntry entry(path, true);
		entry_ref ref;
		if (entry.Exists() && entry.GetRef(&ref) == B_OK)
			button->SetTo(&ref);

		const char* text;
		if (message->FindString("description", i, &text) >= B_OK)
			button->SetDescription(text);
		buttonAdded = true;
	}

	// restore auto raise setting
	bool autoRaise;
	if (message->FindBool("auto raise", &autoRaise) == B_OK && autoRaise)
		ToggleAutoRaise();

	// store workspace setting
	bool showOnAllWorkspaces;
	if (message->FindBool("all workspaces", &showOnAllWorkspaces) == B_OK)
		fShowOnAllWorkspaces = showOnAllWorkspaces;
		SetWorkspaces(showOnAllWorkspaces
			? B_ALL_WORKSPACES : 1L << current_workspace());
	if (!fShowOnAllWorkspaces) {
		uint32 workspaces;
		if (message->FindInt32("workspaces", (int32*)&workspaces) == B_OK)
			SetWorkspaces(workspaces);
	}

	return buttonAdded;
}
Пример #27
0
void
MainWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_LAUNCH: {
			BView* pointer;
			if (message->FindPointer("be:source", (void**)&pointer) < B_OK)
				break;
			LaunchButton* button = dynamic_cast<LaunchButton*>(pointer);
			if (button == NULL)
				break;
			BString errorMessage;
			bool launchedByRef = false;
			if (button->Ref()) {
				BEntry entry(button->Ref(), true);
				if (entry.IsDirectory()) {
					// open in Tracker
					BMessenger messenger("application/x-vnd.Be-TRAK");
					if (messenger.IsValid()) {
						BMessage trackerMessage(B_REFS_RECEIVED);
						trackerMessage.AddRef("refs", button->Ref());
						status_t ret = messenger.SendMessage(&trackerMessage);
						if (ret < B_OK) {
							errorMessage = "Failed to send 'open folder' "
								"command to Tracker.\n\nError: ";
							errorMessage << strerror(ret);
						} else
							launchedByRef = true;
					} else
						errorMessage = "Failed to open folder - is Tracker "
							"running?";
				} else {
					status_t ret = be_roster->Launch(button->Ref());
					if (ret < B_OK && ret != B_ALREADY_RUNNING) {
						errorMessage = "Failed to launch '";
						BPath path(button->Ref());
						if (path.InitCheck() >= B_OK)
							errorMessage << path.Path();
						else
							errorMessage << button->Ref()->name;
						errorMessage << "'.\n\nError: ";
						errorMessage << strerror(ret);
					} else
						launchedByRef = true;
				}
			}
			if (!launchedByRef && button->AppSignature()) {
				status_t ret = be_roster->Launch(button->AppSignature());
				if (ret != B_OK && ret != B_ALREADY_RUNNING) {
					errorMessage = "Failed to launch application with "
						"signature '";
					errorMessage << button->AppSignature() << "'.\n\nError: ";
					errorMessage << strerror(ret);
				} else {
					// clear error message on success (might have been
					// filled when trying to launch by ref)
					errorMessage = "";
				}
			} else if (!launchedByRef) {
				errorMessage = "Failed to launch 'something', error in "
					"Pad data.";
			}
			if (errorMessage.Length() > 0) {
				BAlert* alert = new BAlert("error", errorMessage.String(),
					"Bummer", NULL, NULL, B_WIDTH_FROM_WIDEST);
				alert->Go(NULL);
			}
			break;
		}
		case MSG_ADD_SLOT: {
			LaunchButton* button;
			if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
				fPadView->AddButton(new LaunchButton("launch button", fLastID++,
					NULL, new BMessage(MSG_LAUNCH)), button);
			}
			break;
		}
		case MSG_CLEAR_SLOT: {
			LaunchButton* button;
			if (message->FindPointer("be:source", (void**)&button) >= B_OK)
				button->SetTo((entry_ref*)NULL);
			break;
		}
		case MSG_REMOVE_SLOT: {
			LaunchButton* button;
			if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
				if (fPadView->RemoveButton(button))
					delete button;
			}
			break;
		}
		case MSG_SET_DESCRIPTION: {
			LaunchButton* button;
			if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
				const char* name;
				if (message->FindString("name", &name) >= B_OK) {
					// message comes from a previous name panel
					button->SetDescription(name);
					message->FindRect("frame", &fNamePanelFrame);
				} else {
					// message comes from pad view
					entry_ref* ref = button->Ref();
					if (ref) {
						BString helper("Description for '");
						helper << ref->name << "'";
						make_sure_frame_is_on_screen(fNamePanelFrame, this);
						new NamePanel(helper.String(), button->Description(),
							this, this, new BMessage(*message),
							fNamePanelFrame);
					}
				}
			}
			break;
		}
		case MSG_ADD_WINDOW: {
			BMessage settings('sett');
			SaveSettings(&settings);
			message->AddMessage("window", &settings);
			be_app->PostMessage(message);
			break;
		}
		case MSG_SHOW_BORDER:
			SetLook(B_TITLED_WINDOW_LOOK);
			break;
		case MSG_HIDE_BORDER:
			SetLook(B_BORDERED_WINDOW_LOOK);
			break;
		case MSG_TOGGLE_AUTORAISE:
			ToggleAutoRaise();
			break;
		case MSG_SHOW_ON_ALL_WORKSPACES:
			fShowOnAllWorkspaces = !fShowOnAllWorkspaces;
			if (fShowOnAllWorkspaces)
				SetWorkspaces(B_ALL_WORKSPACES);
			else
				SetWorkspaces(1L << current_workspace());
			break;
		case B_SIMPLE_DATA:
		case B_REFS_RECEIVED:
		case B_PASTE:
		case B_MODIFIERS_CHANGED:
			break;
		case B_ABOUT_REQUESTED:
			be_app->PostMessage(message);
			break;
		default:
			BWindow::MessageReceived(message);
			break;
	}
}
Пример #28
0
//	AI Main
void	cMobKnight::AI_MainSystem	( void )
{
	if( SCENEMGR->GetNowScene() != MENU && m_Status.m_Status == STATUS_DIE )
	{
		//	스테이터스가 DIE 상태일 경우
		if( m_Status.m_Status == STATUS_DIE )
		{
			m_cMobKnightController.SetRangeNoLoop(m_Status.StartFrame,
				m_Status.EndFrame,
				m_Status.StartFrame,
				m_Status.EndFrame,
				m_Status.PlayTime );
			return ;
		}
	}
	else if( m_Status.m_HP < 1)
	{
		DIE();
	}

	if( SCENEMGR->GetNowScene() != MENU && m_Status.m_Status != STATUS_DIE )
	{
		if( m_cMobKnightController.SetRangeNoLoop( m_Status.StartFrame, m_Status.EndFrame, 
			m_Status.StartFrame, m_Status.EndFrame, m_Status.PlayTime, m_Status. Smotion ) == UPDATE_PAUSE )
		{
			if( m_Status.ActionCansle == true )	//	모션 상태가 진행이 된 후 모션 변경이 가능하면
			{
				m_ActionSwith	=	rand()%2+1;
				m_ActionChoiceCheck = false;
			}
			STANCE();
		}

		switch( m_ActionSwith )
		{
		case 1:
			{
				if ( m_ActionChoiceCheck != true )
				{
					m_ActionStartTime	=	TIMEMGR->GetTotalTIme();
				}
				m_ActionChoiceCheck	=	true;
				//	AI_Look
				SetLook( CHARMGR->GetPos() );

				//	AI_MOVE
				AI_StatusMove( CHARMGR->GetPos() );
				break;
			}
		case 2:
			{
				if ( m_ActionChoiceCheck != true )
				{
					m_ActionStartTime	=	TIMEMGR->GetTotalTIme();
				}
				m_ActionChoiceCheck	=	true;

				SetLook( CHARMGR->GetPos() );
				//	AI Action
				AI_StatusAction();
				break;
			}
		}
		return ;
	}
	else if( m_Status.m_Status != STATUS_DIE )
	{
		if( m_cMobKnightController.SetRange( m_Status.StartFrame, m_Status.EndFrame, m_Status.PlayTime, m_Status.Smotion, false )
			==	UPDATE_RETURN )
		{
			STANCE();
		}
	}

}
Пример #29
0
void
WorkspacesWindow::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case B_SIMPLE_DATA:
		{
			// Drop from Tracker
			entry_ref ref;
			for (int i = 0; (message->FindRef("refs", i, &ref) == B_OK); i++)
				be_roster->Launch(&ref);
			break;
		}

		case B_ABOUT_REQUESTED:
			PostMessage(message, ChildAt(0));
			break;

		case kMsgToggleBorder:
		{
			bool enable = false;
			if (Look() == B_NO_BORDER_WINDOW_LOOK)
				enable = true;

			if (enable)
				if (fSettings->HasTitle())
					SetLook(B_TITLED_WINDOW_LOOK);
				else
					SetLook(B_MODAL_WINDOW_LOOK);
			else
				SetLook(B_NO_BORDER_WINDOW_LOOK);

			fSettings->SetHasBorder(enable);
			break;
		}

		case kMsgToggleTitle:
		{
			bool enable = false;
			if (Look() == B_MODAL_WINDOW_LOOK
				|| Look() == B_NO_BORDER_WINDOW_LOOK)
				enable = true;

			if (enable)
				SetLook(B_TITLED_WINDOW_LOOK);
			else
				SetLook(B_MODAL_WINDOW_LOOK);

			// No matter what the setting for title, we must force the border on
			fSettings->SetHasBorder(true);
			fSettings->SetHasTitle(enable);
			break;
		}

		case kMsgToggleAutoRaise:
			SetAutoRaise(!IsAutoRaising());
			SetFeel(B_NORMAL_WINDOW_FEEL);
			break;

		case kMsgToggleAlwaysOnTop:
		{
			bool enable = false;
			if (Feel() != B_FLOATING_ALL_WINDOW_FEEL)
				enable = true;

			if (enable)
				SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
			else
				SetFeel(B_NORMAL_WINDOW_FEEL);

			fSettings->SetAlwaysOnTop(enable);
			break;
		}

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
Пример #30
0
void
MainWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_LAUNCH: {
			BView* pointer;
			if (message->FindPointer("be:source", (void**)&pointer) < B_OK)
				break;
			LaunchButton* button = dynamic_cast<LaunchButton*>(pointer);
			if (button == NULL)
				break;
			BString errorMessage;
			bool launchedByRef = false;
			if (button->Ref()) {
				BEntry entry(button->Ref(), true);
				if (entry.IsDirectory()) {
					// open in Tracker
					BMessenger messenger("application/x-vnd.Be-TRAK");
					if (messenger.IsValid()) {
						BMessage trackerMessage(B_REFS_RECEIVED);
						trackerMessage.AddRef("refs", button->Ref());
						status_t ret = messenger.SendMessage(&trackerMessage);
						if (ret < B_OK) {
							errorMessage = B_TRANSLATE("Failed to send "
							"'open folder' command to Tracker.\n\nError: ");
							errorMessage << strerror(ret);
						} else
							launchedByRef = true;
					} else
						errorMessage = ("Failed to open folder - is Tracker "
							"running?");
				} else {
					status_t ret = be_roster->Launch(button->Ref());
					if (ret < B_OK && ret != B_ALREADY_RUNNING) {
						BString errStr(B_TRANSLATE("Failed to launch '%1'.\n"
							"\nError:"));
						BPath path(button->Ref());
						if (path.InitCheck() >= B_OK)
							errStr.ReplaceFirst("%1", path.Path());
						else
							errStr.ReplaceFirst("%1", button->Ref()->name);
						errorMessage << errStr.String() << " ";
						errorMessage << strerror(ret);
					} else
						launchedByRef = true;
				}
			}
			if (!launchedByRef && button->AppSignature()) {
				status_t ret = be_roster->Launch(button->AppSignature());
				if (ret != B_OK && ret != B_ALREADY_RUNNING) {
					BString errStr(B_TRANSLATE("\n\nFailed to launch application "
						"with signature '%2'.\n\nError:"));
					errStr.ReplaceFirst("%2", button->AppSignature());
					errorMessage << errStr.String() << " ";
					errorMessage << strerror(ret);
				} else {
					// clear error message on success (might have been
					// filled when trying to launch by ref)
					errorMessage = "";
				}
			} else if (!launchedByRef) {
				errorMessage = B_TRANSLATE("Failed to launch 'something', "
					"error in Pad data.");
			}
			if (errorMessage.Length() > 0) {
				BAlert* alert = new BAlert("error", errorMessage.String(),
					B_TRANSLATE("Bummer"), NULL, NULL, B_WIDTH_FROM_WIDEST);
				alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
				alert->Go(NULL);
			}
			break;
		}
		case MSG_ADD_SLOT: {
			LaunchButton* button;
			if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
				fPadView->AddButton(new LaunchButton("launch button",
					NULL, new BMessage(MSG_LAUNCH)), button);
			}
			break;
		}
		case MSG_CLEAR_SLOT: {
			LaunchButton* button;
			if (message->FindPointer("be:source", (void**)&button) >= B_OK)
				button->SetTo((entry_ref*)NULL);
			break;
		}
		case MSG_REMOVE_SLOT: {
			LaunchButton* button;
			if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
				if (fPadView->RemoveButton(button))
					delete button;
			}
			break;
		}
		case MSG_SET_DESCRIPTION: {
			LaunchButton* button;
			if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
				const char* name;
				if (message->FindString("name", &name) >= B_OK) {
					// message comes from a previous name panel
					button->SetDescription(name);
					BRect namePanelFrame;
					if (message->FindRect("frame", &namePanelFrame) == B_OK) {
						((App*)be_app)->SetNamePanelSize(
							namePanelFrame.Size());
					}
				} else {
					// message comes from pad view
					entry_ref* ref = button->Ref();
					if (ref) {
						BString helper(B_TRANSLATE("Description for '%3'"));
						helper.ReplaceFirst("%3", ref->name);
						// Place the name panel besides the pad, but give it
						// the user configured size.
						BPoint origin = B_ORIGIN;
						BSize size = ((App*)be_app)->NamePanelSize();
						NamePanel* panel = new NamePanel(helper.String(),
							button->Description(), this, this,
							new BMessage(*message), size);
						panel->Layout(true);
						size = panel->Frame().Size();
						BScreen screen(this);
						BPoint mousePos;
						uint32 buttons;
						fPadView->GetMouse(&mousePos, &buttons, false);
						fPadView->ConvertToScreen(&mousePos);
						if (fPadView->Orientation() == B_HORIZONTAL) {
							// Place above or below the pad
							origin.x = mousePos.x - size.width / 2;
							if (screen.Frame().bottom - Frame().bottom
									> size.height + 20) {
								origin.y = Frame().bottom + 10;
							} else {
								origin.y = Frame().top - 10 - size.height;
							}
						} else {
							// Place left or right of the pad
							origin.y = mousePos.y - size.height / 2;
							if (screen.Frame().right - Frame().right
									> size.width + 20) {
								origin.x = Frame().right + 10;
							} else {
								origin.x = Frame().left - 10 - size.width;
							}
						}
						panel->MoveTo(origin);
						panel->Show();
					}
				}
			}
			break;
		}
		case MSG_ADD_WINDOW: {
			BMessage settings('sett');
			SaveSettings(&settings);
			message->AddMessage("window", &settings);
			be_app->PostMessage(message);
			break;
		}
		case MSG_SHOW_BORDER:
			SetLook(B_TITLED_WINDOW_LOOK);
			break;
		case MSG_HIDE_BORDER:
			SetLook(B_BORDERED_WINDOW_LOOK);
			break;
		case MSG_TOGGLE_AUTORAISE:
			ToggleAutoRaise();
			break;
		case MSG_SHOW_ON_ALL_WORKSPACES:
			fShowOnAllWorkspaces = !fShowOnAllWorkspaces;
			if (fShowOnAllWorkspaces)
				SetWorkspaces(B_ALL_WORKSPACES);
			else
				SetWorkspaces(1L << current_workspace());
			break;
		case B_SIMPLE_DATA:
		case B_REFS_RECEIVED:
		case B_PASTE:
		case B_MODIFIERS_CHANGED:
			break;
		default:
			BWindow::MessageReceived(message);
			break;
	}
}