Exemplo n.º 1
0
void 
ZipOMatic::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case ZIPPO_WINDOW_QUIT:
		{
			snooze(200000);
			if (CountWindows() == 0)
				Quit();
			break;
		}
		case B_SILENT_RELAUNCH:
			_SilentRelaunch();
			break;

		case ZIPPO_QUIT_OR_CONTINUE:
		{
			int32 button;
			if (message->FindInt32("which", &button) == B_OK)
				if (button == 0) {
					_StopZipping();
				} else {
					if (CountWindows() == 0)
						Quit();
				}
			break;
		}

		default:
			BApplication::MessageReceived(message);
			break;			
	}
}
Exemplo n.º 2
0
//////////////////
// Move all the windows. Use DeferWindowPos for speed.
//
void
CWinMgr::SetWindowPositions(HWND hWnd)
{
	int nWindows = CountWindows();
	if (m_map && hWnd && nWindows>0) {
		HDWP hdwp = ::BeginDeferWindowPos(nWindows);
		int count=0;
		for (WINRECT* wrc=m_map; !wrc->IsEnd(); ++wrc) {
			if (wrc->IsWindow()) {
				assert(count < nWindows);
				HWND hwndChild = ::GetDlgItem(hWnd, wrc->GetID());
				if (hwndChild) {
					const RECT& rc = wrc->GetRect();
					::DeferWindowPos(hdwp,
						hwndChild,
						NULL,		// HWND insert after
						rc.left,rc.top,RectWidth(rc),RectHeight(rc),
						SWP_NOZORDER);
					InvalidateRect(hwndChild,NULL,TRUE); // repaint
					++count;
				}
			} else {
				// not a window: still need to repaint background
				InvalidateRect(hWnd, &wrc->GetRect(), TRUE);
			}
		}
		::EndDeferWindowPos(hdwp);
	}
}
Exemplo n.º 3
0
void VisionApp::Broadcast(BMessage* msg)
{
	for (int32 i = 0; i < CountWindows(); ++i) {
		BMessenger msgr(WindowAt(i));
		msgr.SendMessage(msg);
	}
}
Exemplo n.º 4
0
//////////////////
// Move all the windows. Use DeferWindowPos for speed.
//
void CWinMgr::SetWindowPositions(CWnd* pWnd) {
	int nWindows = CountWindows();
	if (m_map && pWnd && nWindows>0) {
		HDWP hdwp = ::BeginDeferWindowPos(nWindows);
		int count=0;
		for (WINRECT* wrc=m_map; !wrc->IsEnd(); wrc++) {
			if (wrc->IsWindow()) {
				ASSERT(count < nWindows);
				HWND hwndChild = ::GetDlgItem(pWnd->m_hWnd, wrc->GetID());
				if (hwndChild) {
					const CRect& rc = wrc->GetRect();
					::DeferWindowPos(hdwp,
						hwndChild,
						NULL,		// HWND insert after
						rc.left,rc.top,rc.Width(),rc.Height(),
						SWP_NOZORDER);
					InvalidateRect(hwndChild, NULL, true); // repaint
					count++;
				}
			} else {
				// not a window: still need to repaint background
				pWnd->InvalidateRect(&wrc->GetRect());
			}
		}
		::EndDeferWindowPos(hdwp);
	}
}
Exemplo n.º 5
0
const char *BeHappy::AddOnTranslate(const HTMLProject *proj, const char *string) const
{
	static MainWindow *s_LastWindowUsed = NULL;
		// pointeur vers la dernière fenêtre qui a fait la traduction. Avec un peu de
		// chance ce sera encore la même
	
	// on regarde si cette dernière fenêtre est la bonne
	if ((s_LastWindowUsed != NULL) && s_LastWindowUsed->HTMLProjectIs(proj))
		// oui!
		return s_LastWindowUsed->AddOnTranslate(string);
	
	// on va boucler dans toutes les fenêtres
	for (int i=0; i<CountWindows(); i++)
	{
		s_LastWindowUsed = dynamic_cast<MainWindow*>(WindowAt(i));

		// est-ce celle là?
		if ((s_LastWindowUsed != NULL) && s_LastWindowUsed->HTMLProjectIs(proj))
			// oui!
			return s_LastWindowUsed->AddOnTranslate(string);
	}
	
	// on n'a pas trouvé la fenêtre
	return string;
}
Exemplo n.º 6
0
Arquivo: hdb.cpp Projeto: mariuz/haiku
void
Debugger::MessageReceived(BMessage *message)
{
    switch (message->what) {
        case kMsgOpenRunningTeamsWindow:
            if (fRunningTeamsWindow == NULL) {
                fRunningTeamsWindow = new RunningTeamsWindow();
                fRunningTeamsWindow->Show();
            } else
                fRunningTeamsWindow->Activate(true);
            break;

        case kMsgRunningTeamsWindowClosed:
            fRunningTeamsWindow = NULL;
            // supposed to fall through
        case kMsgWindowClosed:
            if (CountWindows() == 1)
                // Last window is being closed: quit application
                PostMessage(B_QUIT_REQUESTED);
            break;

        case kMsgOpenTeamWindow:
        {
            team_id team;
            if (message->FindInt32("team_id", &team) == B_OK)
                Debug(team);
            break;
        }

        default:
            BApplication::MessageReceived(message);
            break;
    }
}
Exemplo n.º 7
0
void
App::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_ADD_WINDOW: {
			BMessage* settings = new BMessage('sett');
			bool wasCloned = message->FindMessage("window", settings) == B_OK;
			BString string;
			string << CountWindows() + 1;
			BString name(B_TRANSLATE("Pad %1"));
			name.ReplaceFirst("%1", string);
			MainWindow* window = new MainWindow(name.String(),
				BRect(50.0, 50.0, 65.0, 100.0), settings);
			if (wasCloned)
				window->MoveBy(10, 10);
			window->Show();
			fSettingsChanged = true;
			break;
		}
		case MSG_TOGGLE_AUTOSTART:
			ToggleAutoStart();
			break;
		case MSG_SETTINGS_CHANGED:
			fSettingsChanged = true;
			break;
		default:
			BApplication::MessageReceived(message);
			break;
	}
}
Exemplo n.º 8
0
void MrPeeps::RefsReceived(BMessage *msg)
{
    // We need to put this wait loop into the function so that when the app
    // is started it will wait for the main window to appear.
    while(CountWindows()!=1)
        snooze(1000);

    // Find our window
    BWindow *win=WindowAt(0);

    int32 i=1;
    while(win)
    {
        if(strcmp(win->Title(),"Mr. Peeps!")==0)
        {
            win->PostMessage(msg);
            return;
        }
        win=WindowAt(i++);
    }

    if(!win)
    {
        AboutWindow *ab=new AboutWindow(ABOUT_STARTUP);
        ab->Show();

        mainwindow = new PeepsWindow(ab->GetStatusMessenger());
        mainwindow->Show();

        ab->PostMessage(B_QUIT_REQUESTED);
        mainwindow->PostMessage(msg);
    }
}
Exemplo n.º 9
0
bool
LaunchPadApp::QuitRequested( void )
{
	// Summon all the windows to check if the settings need to be saved.
	for ( int i = 0; i < CountWindows(); i++ )
	{
		LaunchPadWindow*	pad = dynamic_cast<LaunchPadWindow*>(WindowAt(i));
		if ( pad != NULL && pad->SaveNeeded() )
		{
			PRINT(( "Saving settings for %s\n", pad->Name() ));
			BMessage	padSetting( kMsgPadSetting );
			pad->GetSetting( &padSetting );
			SaveSettings( &padSetting, false );
			// writing to file is done after this loop.
		}
	}

	// Then write the settings to the disk. (forceWrite = true)
	SaveSettings( NULL, true );

	// Quit the preference handler. (libprefs)
	delete	mPref;

	return true;
}
Exemplo n.º 10
0
void
TTracker::CloseAllWindows()
{
	// this is a response to the DeskBar sending us a B_QUIT, when it really
	// means to say close all your windows. It might be better to have it
	// send a kCloseAllWindows message and have windowless apps stay running,
	// which is what we will do for the Tracker
	AutoLock<WindowList> lock(&fWindowList);

	int32 count = CountWindows();
	for (int32 index = 0; index < count; index++) {
		BWindow *window = WindowAt(index);
		// avoid the desktop
		if (!dynamic_cast<BDeskWindow *>(window)
			&& !dynamic_cast<BStatusWindow *>(window))
			window->PostMessage(B_CLOSE_REQUESTED);
	}
	// count from end to beginning so we can remove items safely
	for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) {
		BWindow *window = fWindowList.ItemAt(index);
		if (!dynamic_cast<BDeskWindow *>(window)
			&& !dynamic_cast<BStatusWindow *>(window))
				// ToDo:
				// get rid of the Remove here, BContainerWindow::Quit does it
			fWindowList.RemoveItemAt(index);
	}	
}
Exemplo n.º 11
0
void
DjVuApp::ReadyToRun()
{
	InstallMimeType("image/x-djvu");
	
	if (CountWindows() == WINDOWS_TO_IGNORE)
		fOpenPanel->Show();
	else
		StartPulse();
}
Exemplo n.º 12
0
void
DiskProbe::ReadyToRun()
{
	// are there already windows open?
	if (CountWindows() != 1)
		return;

	// if not, ask the user to open a file
	PostMessage(kMsgOpenOpenWindow);
}
Exemplo n.º 13
0
Arquivo: hdb.cpp Projeto: mariuz/haiku
void
Debugger::ReadyToRun()
{
    // are there already windows open?
    if (CountWindows() != 0)
        return;

    // if not, open the running teams window
    PostMessage(kMsgOpenRunningTeamsWindow);
}
Exemplo n.º 14
0
bool XKApp::QuitRequested(void) {
//	BPoint	point=(mainW->Frame()).LeftTop();
//	// save main window position in resources of application file
//	if (appRES->HasResource(B_POINT_TYPE,MAINWINDOW_POSITION))
//		appRES->RemoveResource(B_POINT_TYPE,MAINWINDOW_POSITION);
//	appRES->AddResource(B_POINT_TYPE,MAINWINDOW_POSITION,(void *) (&point), sizeof(point) );
	
	while (CountWindows()>0) {WindowAt(0)->Lock();WindowAt(0)->Quit();}
	return true;
}
Exemplo n.º 15
0
void
FileTypes::ReadyToRun()
{
	// are there already windows open?
	if (CountWindows() != 1)
		return;

	// if not, open the FileTypes window
	PostMessage(kMsgOpenTypesWindow);
}
Exemplo n.º 16
0
void
DjVuApp::Pulse()
{
	// Bug: The BFilePanel is automatically closed if the volume that
	// is displayed is unmounted.
	if (!IsLaunching() && CountWindows() <= WINDOWS_TO_IGNORE)
		// If the application is not launching and
		// all windows are closed except for the file open panel,
		// quit the application
		PostMessage(B_QUIT_REQUESTED);
}
Exemplo n.º 17
0
void
MainApp::RefsReceived(BMessage* message)
{
	// The user dropped a file (or files) on this app's icon,
	// or double clicked a file that's handled by this app.
	// Command line arguments are also redirected to here by
	// ArgvReceived() but without MIME type check.

	// If multiple refs are received in short succession we
	// combine them into a single window/playlist. Tracker
	// will send multiple messages when opening a multi-
	// selection for example and we don't want to spawn large
	// numbers of windows when someone just tries to open an
	// album. We use half a second time and prolong it for
	// each new ref received.
	static bigtime_t sLastRefsReceived = 0;
	static MainWin* sLastRefsWindow = NULL;

	if (system_time() - sLastRefsReceived < 500000) {
		// Find the last opened window
		for (int32 i = CountWindows() - 1; i >= 0; i--) {
			MainWin* playerWindow = dynamic_cast<MainWin*>(WindowAt(i));
			if (playerWindow == NULL)
				continue;

			if (playerWindow != sLastRefsWindow) {
				// The window has changed since the last refs
				sLastRefsReceived = 0;
				sLastRefsWindow = NULL;
				break;
			}

			message->AddBool("append to playlist", true);
			playerWindow->PostMessage(message);
			sLastRefsReceived = system_time();
			return;
		}
	}

	sLastRefsWindow = NewWindow(message);
	sLastRefsReceived = system_time();
}
Exemplo n.º 18
0
Arquivo: hdb.cpp Projeto: mariuz/haiku
status_t
Debugger::Debug(team_id team)
{
    // int32 teamWindows = 0;

    // Do we already have that window open?
    for (int32 i = CountWindows(); i-- > 0; ) {
        TeamWindow *window = dynamic_cast<TeamWindow *>(WindowAt(i));
        if (window == NULL)
            continue;

        if (window->Team() == team) {
            window->Activate(true);
            return B_OK;
        }
        // teamWindows++;
    }

    BWindow *window = new TeamWindow(team);
    window->Show();

    return B_OK;
}
Exemplo n.º 19
0
void
CDocument::SetNamed()
{
	char name[B_FILE_NAME_LENGTH];
	if (m_entry.GetName(name) != B_OK)
		return;

	BMessage message(NAME_CHANGED);
	message.AddString("name", name);

	// send update to master window
	BMessenger messenger(NULL, MasterWindow());
	messenger.SendMessage(&message);

	// send updates to the other windows
	for (int32 i = 0; i < CountWindows(); i++)
	{
		BMessenger messenger(NULL, WindowAt(i));
		messenger.SendMessage(&message);
	}

	m_named = true;
}
Exemplo n.º 20
0
void
App::PostToProjectWindow(BMessage *msg, entry_ref *file)
{
	if (!msg)
		return;
	
	BPath path(file);
	
	for (int32 i = 0; i < CountWindows(); i++)
	{
		ProjectWindow *win = dynamic_cast<ProjectWindow*>(WindowAt(i));
		if (!win)
			continue;
		if ( (file && win->GetProject()->HasFile(path.Path())) ||
				win->GetProject() == gCurrentProject)
		{
			if (win->AreMenusLocked() && win->RequiresMenuLock(msg->what))
				break;
			win->Activate(true);
			win->PostMessage(msg);
			break;
		}
	}
}
Exemplo n.º 21
0
bool
ZipOMatic::QuitRequested(void)
{
	if (CountWindows() <= 0)
		return true;
	
	BWindow* window;
	ZippoWindow* zippo;
	ZippoWindow* lastFoundZippo = NULL;
	int32 zippoCount = 0;
	
	for (int32 i = 0;; i++) {
		window = WindowAt(i);
		if (window == NULL)
			break;
		
		zippo = dynamic_cast<ZippoWindow*>(window);
		if (zippo == NULL)
			continue;
		
		lastFoundZippo = zippo;
		
		if (zippo->Lock()) {
			if (zippo->IsZipping())
				zippoCount++;
			else
				zippo->PostMessage(B_QUIT_REQUESTED);
				
			zippo->Unlock();
		}
	}
	
	if (zippoCount == 1) {
		// This is likely the most frequent case - a single zipper.
		// We post a message to the window so it can put up its own
		// BAlert instead of the app-wide BAlert. This avoids making
		// a difference between having pressed Commmand-W or Command-Q.
		// Closing or quitting, it doesn't matter for a single window.

		if (lastFoundZippo->Lock()) {
			lastFoundZippo->Activate();
			lastFoundZippo->PostMessage(B_QUIT_REQUESTED);
			lastFoundZippo->Unlock();
		}
		return false;
	}

	if (zippoCount > 0) {
		// The multi-zipper case differs from the single-zipper case
		// in that zippers are not paused while the BAlert is up.

		BString question;
		question << TR("You have %ld Zip-O-Matic running.\n\n");
		question << TR("Do you want to stop them?");
		
		BString temp;
		temp << zippoCount;
		question.ReplaceFirst("%ld", temp.String());

		BAlert* alert = new BAlert(NULL, question.String(),
			TR("Stop them"), TR("Let them continue"), NULL, B_WIDTH_AS_USUAL,
			B_WARNING_ALERT);
		alert->Go(fInvoker);
		alert->Activate();
			// BAlert, being modal, does not show on the current workspace
			// if the application has no window there. Activate() triggers
			// a switch to a workspace where it does have a window.
			
			// TODO: See if AS_ACTIVATE_WINDOW should be handled differently
			// in src/servers/app/Desktop.cpp Desktop::ActivateWindow()
			// or if maybe BAlert should (and does not?) activate itself.
			
		return false;
	}

	if (CountWindows() <= 0)
		return true;
	
	return false;
}
Exemplo n.º 22
0
ScriptHandler *
TMailApp::GetSubHandler(
	const char *			propertyName,
	EForm					form,
	const SData &			data)
{
	int propCount = -1;

	if (!strcmp(propertyName, "property") && (form == formIndex)) {
		propCount = data.index;
	}
	if (!strcmp(propertyName, "window") || (0 == --propCount)) {
		long fIndex = -1;
		BWindow *subWindow = NULL;
		switch (form) {
		case formReverseIndex:
			fIndex = CountWindows()+data.index;
			break;
		case formIndex:
			fIndex = data.index-1;
			break;
		case formFirst:
			fIndex = 0;
			break;
		case formLast:
			fIndex = CountWindows()-1;
			break;
		case formName:
			for (int ix=0; ix<CountWindows(); ix++) {
				if (!strcmp(data.name, WindowAt(ix)->Title())) {
					fIndex = ix;
					break;
				}
			}
			break;
		case formDirect:
			// return new DirectWindowProp("window", this);
			break;
		case formID:
		default:
			/*	These forms are not supported
			 */
			break;
		}
		if (fIndex >= 0)
			subWindow = WindowAt(fIndex);
		if (!subWindow)
			return NULL;
		ScriptHandler *ret = dynamic_cast<ScriptHandler *>(subWindow);
		if (ret)
			return ret->Reference();
		/*	For views that are not ScriptHandlers in their own right, 
		 *	we use the stock ViewPropHandler to give a certain sense of scriptability.
		 */
		return new WindowPropHandler(subWindow->Title(), subWindow);
	}
	if (propCount > 0) {
		SData newData;
		newData.index = propCount;
		return ScriptHandler::GetSubHandler(propertyName, formIndex, newData);
	}
	return ScriptHandler::GetSubHandler(propertyName, form, data);
}
Exemplo n.º 23
0
//----------------------------------------------------------------
void mApp::MessageReceived(BMessage *message)
{
	switch(message->what)
	{
	case MSG_EXPORT_HTML:
		Show = true;
		for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_EXPORT_WINDOW[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_ExportWindow = new ExportWindow(BRect(100, 100, 550, 500), STR_EXPORT_WINDOW[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE, _mWindow->_CalenderView->mCalender->Month(), _mWindow->_CalenderView->mCalender->Year());
			_ExportWindow->Show();
			}
			else
			{
			_ExportWindow->Activate();
			}
	
	break;
	case MSG_ABOUT:
		//show about window
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_ABOUT_WINDOW[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_AboutWindow = new AboutWindow(BRect(100, 100, 550, 500), STR_ABOUT_WINDOW[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_AboutWindow->Show();
			}
			else
			{
			_AboutWindow->Activate();
			}
	break;
	case MSG_PREFERENCES:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_PREFERENCES_WINDOW[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_PreferencesWindow = new PreferencesWindow(BRect(100, 100, 500, 500), STR_PREFERENCES_WINDOW[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_PreferencesWindow->Show();
			}
			else
			{
			_PreferencesWindow->Activate(true);
			}
	break;
	case MSG_ADD_SCRIPT_WIN:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_ADD_SCRIPT_WIN[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_EditWindow =  new EditWindow(BRect(100, 100, 500, 500), STR_ADD_SCRIPT_WIN[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_EditWindow->Show();
			_EditWindow->PostMessage(message);
			}
			else
			{
			_EditWindow->Activate();
			}
	break;
	case MSG_EDIT_SCRIPT_WIN:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_EDIT_SCRIPT_WIN[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_EditWindow =  new EditWindow(BRect(100, 100, 500, 500), STR_EDIT_SCRIPT_WIN[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_EditWindow->Show();
			_EditWindow->PostMessage(message);
			}
			else
			{
			_EditWindow->Activate();
			}
	break;
	case MSG_ADD_NOTE_WIN:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_ADD_NOTE_WIN[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_EditWindow =  new EditWindow(BRect(100, 100, 500, 500), STR_ADD_NOTE_WIN[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_EditWindow->Show();
			_EditWindow->PostMessage(message);
			}
			else
			{
			_EditWindow->Activate();
			}
	break;
	case MSG_EDIT_NOTE_WIN:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_EDIT_NOTE_WIN[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_EditWindow =  new EditWindow(BRect(100, 100, 500, 500), STR_EDIT_NOTE_WIN[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_EditWindow->Show();
			_EditWindow->PostMessage(message);
			}
			else
			{
			_EditWindow->Activate();
			}
	break;
	case MSG_ADD_APOINTMENT_WIN:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_ADD_APOINTMENT_WIN[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_EditWindow =  new EditWindow(BRect(100, 100, 500, 500), STR_ADD_APOINTMENT_WIN[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_EditWindow->Show();
			_EditWindow->PostMessage(message);
			}
			else
			{
			_EditWindow->Activate();
			}
	break;
	case MSG_EDIT_APOINTMENT_WIN:
		Show = true;
			for (int a = 1; a <= CountWindows(); a++)
			{
				if (!strcmp(WindowAt(a - 1)->Title(), STR_EDIT_APOINTMENT_WIN[INT_LANGUAGE]))
				{
				Show = false;
				}
			}
			if (Show)
			{
			_EditWindow =  new EditWindow(BRect(100, 100, 500, 500), STR_EDIT_APOINTMENT_WIN[INT_LANGUAGE], B_FOLLOW_ALL, B_NOT_RESIZABLE);
			_EditWindow->Show();
			_EditWindow->PostMessage(message);
			}
			else
			{
			_EditWindow->Activate();
			}
	break;
	//Reload the listview
	case MSG_GET_NOTES:
		_mWindow->LockLooper();
		_mWindow->GetNotes();
		_mWindow->UnlockLooper();
	break;
	case MSG_CALENDER_STYLE:
	{
		_mWindow->LockLooper();
		_mWindow->_CalenderView->mCalender->SetAmericanStyleCalender(_PreferencesWindow->_PreferencesView->mCalenderStyleCheckBox->Value());
		_mWindow->Activate();
		_mWindow->UnlockLooper();
		snooze(30000);
		_PreferencesWindow->LockLooper();
		_PreferencesWindow->Activate();
		_PreferencesWindow->UnlockLooper();
		
		MSave save("save");
		_mWindow->GetSettingsPath(&path);
		//Save Style
		save.AddBool(path, SAVE_FILE_NAME, NAME_CALENDER_STYLE, _PreferencesWindow->_PreferencesView->mCalenderStyleCheckBox->Value(), true);
	break;
	}
	case MSG_CALENDER_COLORFUL:
	{
		_mWindow->_CalenderView->mCalender->SetColorfulCalender(_PreferencesWindow->_PreferencesView->mCalenderColorCheckBox->Value());
		_mWindow->LockLooper();
		_mWindow->_CalenderView->mCalender->Draw(BRect(0, 0, 1600, 1200));
		_mWindow->Activate();
		_mWindow->UnlockLooper();
		snooze(30000);
		_PreferencesWindow->LockLooper();
		_PreferencesWindow->Activate();
		_PreferencesWindow->UnlockLooper();
		
		MSave save("save");
		_mWindow->GetSettingsPath(&path);
		//Save Style
		save.AddBool(path, SAVE_FILE_NAME, NAME_CALENDER_COLORFUL, _PreferencesWindow->_PreferencesView->mCalenderColorCheckBox->Value(), true);
	break;
	}
	case MSG_OPEN_GL_GAME:
		_Wind = new Wind(STR_HIDDEN_OPENGL_GAME[INT_LANGUAGE]);
	break;
	case MSG_CLOSE_GL_GAME:
		_Wind->Lock();
		_Wind->Close();
	break;
	case MSG_LANGUAGE_CHANGED:
	{
			MSave save("save");
			_mWindow->GetSettingsPath(&path);
			
			save.AddInt32(path, SAVE_FILE_NAME, NAME_LANGUAGE, _PreferencesWindow->_PreferencesView->mLanguageMenu->IndexOf(_PreferencesWindow->_PreferencesView->mLanguageMenu->FindMarked()), true);
			
			if (_PreferencesWindow->_PreferencesView->mLanguageMenu->IndexOf(_PreferencesWindow->_PreferencesView->mLanguageMenu->FindMarked()) != INT_LANGUAGE)
			{
			BAlert * mAlert = new BAlert("mAlert", STR_LANGUAGE_ALERT[INT_LANGUAGE], STR_RESTART_NOW[INT_LANGUAGE], STR_RESTART_LATER[INT_LANGUAGE]);
				switch(mAlert->Go())
				{
				case 0:
				{
					BString tempString;
					BString tempString2;
					BPath Path;
					find_directory(B_COMMON_SETTINGS_DIRECTORY, &Path);
					tempString.SetTo(path.Path());
					tempString.Append(SAVE_SETTINGS_PATH);
					save.FindString(tempString.String(), SAVE_FILE_NAME, NAME_EXEC_DIR, &tempString2, "M_ERROR");
					tempString2.Append(SAVE_SCRIPT_PATH);
					tempString2 << "Restart &";
					system(tempString2.String());
				break;
				}
				default:
				
				break;
				}
			}
	break;
	}
	case MSG_EXPORT_HTML_FILE:
	{
	mFilePanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL, B_DIRECTORY_NODE,
	//mFilePanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL, B_FILE_NODE,
					false, NULL , NULL, false, true); 
	mFilePanel->Window()->SetTitle("Save To: ");
	mFilePanel->Show();
	break;
	}
	case MSG_QUIT_PLEASE:
		RunNotification = false;
		//status_t junk;
		kill_thread(Notification);
		kill_thread(CheckForUpdate);
			while (CountWindows() > 0)
			{
			//WindowAt(CountWindows() - 1)->Lock();
			WindowAt(CountWindows() - 1)->Close();
			}
	break;
	default:
	
	break;
	}
}
Exemplo n.º 24
0
/*!	Opens a window containing the file pointed to by the entry_ref.
	This function will fail if that file doesn't exist or could not
	be opened.
	It will check if there already is a window that probes the
	file in question and will activate it in that case.
	This function must be called with the application looper locked.
*/
status_t
DiskProbe::Probe(BEntry& entry, const char* attribute)
{
	entry_ref ref;
	status_t status = entry.GetRef(&ref);
	if (status < B_OK)
		return status;

	ProbeWindow* lastWindow(NULL);

	// Do we already have that window open?
	for (int32 i = CountWindows(); i-- > 0; ) {
		ProbeWindow* window = dynamic_cast<ProbeWindow*>(WindowAt(i));
		if (window == NULL)
			continue;

		if (window->Contains(ref, attribute)) {
			window->Activate(true);
			return B_OK;
		}
		if (lastWindow == NULL)
			lastWindow = window;
	}

	// Does the file really exist?
	if (!entry.Exists())
		return B_ENTRY_NOT_FOUND;

	entry.GetRef(&ref);

	// cascade window
	BRect rect;
	if (lastWindow != NULL)
		rect = lastWindow->Frame();
	else
		rect = fWindowFrame;

	rect.OffsetBy(kCascadeOffset, kCascadeOffset);

	BWindow* window;
	if (attribute != NULL) {
		window = new AttributeWindow(rect, &ref, attribute,
			&fSettings.Message());
	} else
		window = new FileWindow(rect, &ref, &fSettings.Message());

	window->Show();

	// Adjust the cascading... we can only do this after the window was created
	// to adjust to the real size.
	rect.right = window->Frame().right;
	rect.bottom = window->Frame().bottom;

	BScreen screen;
	BRect screenBorder = screen.Frame();

	float left = rect.left;
	if (left + rect.Width() > screenBorder.right)
		left = 7;

	float top = rect.top;
	if (top + rect.Height() > screenBorder.bottom)
		top = 26;

	rect.OffsetTo(BPoint(left, top));
	window->MoveTo(BPoint(left, top));

	fWindowCount++;

	return B_OK;
}
Exemplo n.º 25
0
void SeebaerApp::MessageReceived(BMessage* msg)
{
	
	switch (msg->what) {
		case MSG_OPEN_SHUTDOWN:
			if (stdDownWin != NULL) stdDownWin->Activate();
			else {
				stdDownWin = new StdDownWin(rectDownWin, file);	// Create and View the Window
				stdDownWin->Show();
			}
			break;
		case MSG_OPEN_HOUR_PER_WEEK:
			if (stdWoWin != NULL) stdWoWin->Activate();
			else {
				stdWoWin = new StdWoWin(rectWoWin, file);	// Create and View the Window
				stdWoWin->Show();
			}
			break;
		case MSG_OPEN_HOUR_PER_YEAR:
			if (stdMoWin != NULL) stdMoWin->Activate();
			else {
				stdMoWin = new StdMoWin(rectMoWin, file);	// Create and View the Window
				stdMoWin->Show();
			}
			break;
		case MSG_OPEN_MIN_PER_HOUR:
			if (stdDayWin != NULL) stdDayWin->Activate();
			else {
				stdDayWin = new StdDayWin(rectDayWin, file);	// Create and View the Window
				stdDayWin->Show();
			}
			break;
		case MSG_OPEN_LOGWINDOW:
			if (logWin != NULL) logWin->Activate();
			else {
				logWin = new LogWin(rectLogWin, file);	// Create and View the Window
				logWin->Show();
			}
			break;
		case MSG_OPEN_AVERAGE_RUNTIME:
			if (avRunWin != NULL) avRunWin->Activate();
			else {
				avRunWin = new AvRunWin(rectAvRunWin, file);	// Create and View the Window
				avRunWin->Show();
			}
			break;
		case MSG_OPEN_ENDLESS_DAY:
			if (endlDayWin != NULL) endlDayWin->Activate();
			else {
				endlDayWin = new EndlDayWin(rectEndlDayWin, file);	// Create and View the Window
				endlDayWin->Show();
			}
			break;
		case MSG_OPEN_ENDLESS_WEEK:
			if (endlWeekWin != NULL) endlWeekWin->Activate();
			else {
				endlWeekWin = new EndlWeekWin(rectEndlWeekWin, file);	// Create and View the Window
				endlWeekWin->Show();
			}
			break;

		case MSG_WIN_CLOSE:
			switch (msg->FindInt32("kind")) {
				case WIN_SHUTDOWN:	
					stdDownWin = NULL; 
					msg->FindRect("pos", &rectDownWin);
					break;
				case WIN_MPH: 		
					stdDayWin = NULL; 
					msg->FindRect("pos", &rectDayWin);
					break;
				case WIN_HPDW:		
					stdWoWin = NULL; 
					msg->FindRect("pos", &rectWoWin);
					break;
				case WIN_HPDY:		
					stdMoWin = NULL; 
					msg->FindRect("pos", &rectMoWin);
					break;
				case WIN_LOG:		
					logWin = NULL; 
					msg->FindRect("pos", &rectLogWin);
					break;
				case WIN_AVRUN:		
					avRunWin = NULL; 
					msg->FindRect("pos", &rectAvRunWin);
					break;
				case WIN_ENDLDAY:		
					endlDayWin = NULL; 
					msg->FindRect("pos", &rectEndlDayWin);
					break;
				case WIN_ENDLWEEK:		
					endlWeekWin = NULL; 
					msg->FindRect("pos", &rectEndlWeekWin);
					break;
			}
			if (CountWindows() <= 1) be_app->PostMessage(B_QUIT_REQUESTED);
			break;

		default:
			BApplication::MessageReceived(msg);
			break;
	}
}
Exemplo n.º 26
0
void
App::LoadProject(const entry_ref &givenRef)
{
	if (!givenRef.name)
		return;
	
	entry_ref ref(givenRef);
	
	bool isBeIDE = IsBeIDEProject(ref);
	if (isBeIDE)
	{
		// We were given a BeIDE project, so we will see if it has already
		// been converted to a Paladin project. If it has, open the Paladin
		// project. If not, convert it and open it, if successful.
		DPath beidePath(ref);
		BString palPath = beidePath.GetFolder();
		palPath << "/" << beidePath.GetBaseName() << ".pld";
		BEntry entry(palPath.String());
		if (entry.Exists())
			entry.GetRef(&ref);
		else
		{
			if (BeIDE2Paladin(beidePath.GetFullPath(), palPath) == B_OK)
			{
				entry.SetTo(palPath.String());
				entry.GetRef(&ref);
			}
			else
				return;
		}
	}
		
	for (int32 i = 0; i < CountWindows(); i++)
	{
		ProjectWindow *win = dynamic_cast<ProjectWindow*>(WindowAt(i));
		if (!win)
			continue;
		Project *winProject = win->GetProject();
		if (!winProject)
			continue;
		BEntry entry(winProject->GetPath().GetFullPath());
		if (entry.InitCheck() != B_OK)
			continue;
		entry_ref projRef;
		entry.GetRef(&projRef);
		if (ref == projRef)
			return;
	}
	
	BPath path(&ref);
	Project *proj = new Project;
	
	if (proj->Load(path.Path()) != B_OK)
	{
		delete proj;
		return;
	}
	
	// This will be true only if the project file lacks an entry.
	if (proj->SourceControl() == SCM_INIT && !gBuildMode &&
		!proj->IsReadOnly())
	{
		// No given in the project. Attempt to detect one and if there isn't
		// any, see if the user would like to use the default SCM. At the same
		// time, if the user doesn't *want* to use source control, we won't
		// bother him.
		scm_t scm = DetectSCM(proj->GetPath().GetFolder());
		if (scm == SCM_NONE && gDefaultSCM != SCM_NONE)
		{
			BString scmMsg = B_TRANSLATE(
				"This project is not under source control. Would you "
				"like to use %sourcecontrol% for this project?\n"
				"You will only be asked this one time.");
			scmMsg.ReplaceFirst("%sourcecontrol%", SCM2LongName(gDefaultSCM));
			int32 result = ShowAlert(scmMsg.String(), B_TRANSLATE("No"), B_TRANSLATE("Yes"));
			if (result == 1)
				proj->SetSourceControl(gDefaultSCM);
		}
	}
	
	UpdateRecentItems(ref);
	
	gCurrentProject = proj;
	gProjectList->Lock();
	gProjectList->AddItem(proj);
	gProjectList->Unlock();
	
	BRect r(0,0,200,300);
	/*
	r.OffsetTo(gProjectWindowPoint);
	gProjectWindowPoint.x += 25;
	gProjectWindowPoint.y += 25;
	*/
	ProjectWindow *projwin = new ProjectWindow(r,gCurrentProject);
	projwin->Show();
	
	if (proj->IsReadOnly())
	{
		BString errmsg = B_TRANSLATE(
			"This project is on a read-only disk. You will not be able "
			"to build it, but you can still view its files and do anything "
			"else that does not require saving to the disk.");
		ShowAlert(errmsg.String());
	}
}
Exemplo n.º 27
0
// Closes all windows when the user requested the application to quit.
bool app::QuitRequested() {
	while (CountWindows()>0) {WindowAt(0)->Lock();WindowAt(0)->Quit();}
	return true;
}