コード例 #1
0
ファイル: win.cpp プロジェクト: svn2github/Themis
void
Win::CreateUrlPopUpWindow()
{
	if( urlpopupwindow == NULL )
	{
		BRect frame( navview->urlview->Frame() );
		frame = navview->ConvertToScreen( frame );
		
		BRect wframe( frame );
		wframe.top = frame.bottom;
		wframe.bottom = wframe.top + 30;
		
		urlpopupwindow = new ThemisUrlPopUpWindow(
			this,
			wframe );
		
		urlpopupwindow->Run();
		urlpopupwindow->Show();
		
		// make the urlview the focusview otherwise
		// the urlpopup wouldnt be navigable by keyb
		if( CurrentFocus() != NULL )
			CurrentFocus()->MakeFocus( false );
	 	navview->urlview->textview->MakeFocus( true );
	}
}
コード例 #2
0
void
PersonWindow::MenusBeginning()
{
	bool enabled = !fView->IsSaved();
	fSave->SetEnabled(enabled);
	fRevert->SetEnabled(enabled);

	bool isRedo = false;
	bool undoEnabled = false;
	bool cutAndCopyEnabled = false;

	BTextView* textView = dynamic_cast<BTextView*>(CurrentFocus());
	if (textView != NULL) {
		undo_state state = textView->UndoState(&isRedo);
		undoEnabled = state != B_UNDO_UNAVAILABLE;

		cutAndCopyEnabled = fView->IsTextSelected();
	}

	if (isRedo)
		fUndo->SetLabel(B_TRANSLATE("Redo"));
	else
		fUndo->SetLabel(B_TRANSLATE("Undo"));

	fUndo->SetEnabled(undoEnabled);
	fCut->SetEnabled(cutAndCopyEnabled);
	fCopy->SetEnabled(cutAndCopyEnabled);

	be_clipboard->Lock();
	fPaste->SetEnabled(be_clipboard->Data()->HasData("text/plain", B_MIME_TYPE));
	be_clipboard->Unlock();
}
コード例 #3
0
ファイル: TeamWindow.cpp プロジェクト: MaddTheSane/haiku
void
TeamWindow::DispatchMessage(BMessage* message, BHandler* handler)
{
	// Handle function key shortcuts for stepping
	switch (message->what) {
		case B_KEY_DOWN:
			if (fActiveThread != NULL && fTraceUpdateRunner == NULL) {
				int32 key;
				uint32 modifiers;
				if (message->FindInt32("key", &key) == B_OK
					&& message->FindInt32("modifiers", (int32*)&modifiers)
					== B_OK) {
					switch (key) {
						case B_F5_KEY:
							fListener->ThreadActionRequested(
								fActiveThread->ID(), MSG_THREAD_RUN);
							break;
						case B_F10_KEY:
							fListener->ThreadActionRequested(
								fActiveThread->ID(), MSG_THREAD_STEP_OVER);
							break;
						case B_F11_KEY:
							if ((modifiers & B_SHIFT_KEY) != 0) {
								fListener->ThreadActionRequested(
									fActiveThread->ID(), MSG_THREAD_STEP_OUT);
							} else {
								fListener->ThreadActionRequested(
									fActiveThread->ID(), MSG_THREAD_STEP_INTO);
							}
							break;
						default:
							break;
					}
				}
			}
			break;

		case B_COPY:
		case B_SELECT_ALL:
			BView* focusView = CurrentFocus();
			if (focusView != NULL) {
				focusView->MessageReceived(message);
				return;
			}
			break;
	}
	BWindow::DispatchMessage(message, handler);
}
コード例 #4
0
void
TSignatureWindow::MenusBeginning()
{
	int32		finish = 0;
	int32		start = 0;
	BTextView	*text_view;

	fDelete->SetEnabled(fFile);
	fSave->SetEnabled(IsDirty());
	fUndo->SetEnabled(false);		// ***TODO***

	text_view = (BTextView *)fSigView->fName->ChildAt(0);
	if (text_view->IsFocus())
		text_view->GetSelection(&start, &finish);
	else
		fSigView->fTextView->GetSelection(&start, &finish);

	fCut->SetEnabled(start != finish);
	fCopy->SetEnabled(start != finish);

	fNew->SetEnabled(text_view->TextLength() | fSigView->fTextView->TextLength());
	be_clipboard->Lock();
	fPaste->SetEnabled(be_clipboard->Data()->HasData("text/plain", B_MIME_TYPE));
	be_clipboard->Unlock();

	// Undo stuff	
	bool		isRedo = false;
	undo_state	undoState = B_UNDO_UNAVAILABLE;

	BTextView *focusTextView = dynamic_cast<BTextView *>(CurrentFocus());
	if (focusTextView != NULL)
		undoState = focusTextView->UndoState(&isRedo);

	fUndo->SetLabel((isRedo) ? kRedoStrings[undoState] : kUndoStrings[undoState]);
	fUndo->SetEnabled(undoState != B_UNDO_UNAVAILABLE);
}
コード例 #5
0
/*!	\brief		Main function of the class.
 *		\param[in]	in		BMessage to respond to.
 */
void EventEditorMainWindow::MessageReceived( BMessage *in )
{
	BView* view;
	BEntry entry;
	BFile  file;
	BString tempString;
	BDirectory directory;
	BMessage saveMessage( kSaveRequested );
	entry_ref	ref;
	
	switch( in->what )
	{
		case B_SELECT_ALL:
		case B_COPY:
		case B_CUT:
		case B_PASTE:
		case B_UNDO:
			view = CurrentFocus();
			if ( view )
				view->MessageReceived( in );
			break;
		
		case kFileOpen:
			fOpenFile->Show();
			break;

			
		case kFileSaveAs:
			fSaveFile->Show();
			break;
		
		case kFileRevert:				// Intentional fall-through
		case kFileOpenConfirmed:
			if ( in->what == kFileRevert ) {		
				if ( fData.GetRef() != NULL )
				{
						// ...Prepare it for usage
					ref = *( fData.GetRef() );
				} else {
						// Ask the user what to do
					fOpenFile->Show();
					break;
				}
			} else {
				if ( B_OK != in->FindRef( "refs", &ref ) ||
					  B_OK != entry.SetTo( &ref, true ) ||
					  B_OK != entry.GetRef( &ref ) )
				{
					entry.Unset();
					break;
				}
			}
			fData.InitFromFile( ref );
			if ( Looper()->Lock() ) {
//				fData.Revert();
				MainView->RemoveSelf();
				delete MainView;
				InitUI();
				Looper()->Unlock();
			}
			entry.Unset();
			break;

		case kFileSave:				// Intentional fall-through			
		case kFileSaveConfirmed:
			
				// Save user's changes
			if ( genView ) genView->MessageReceived( &saveMessage );
			if ( remView ) remView->MessageReceived( &saveMessage );
			if ( actView ) actView->SaveData();
			if ( noteView ) noteView->SaveText();
			
			fData.SetEventActivityFired( false );
			fData.SetReminderActivityFired( false );
		
				// If we have the reference to file...
			if ( in->what == kFileSave ) {
				if ( fData.GetRef() != NULL )
				{
						// ...Prepare it for usage
					ref = *( fData.GetRef() );
				} else {
						// Ask the user what to do
					fSaveFile->Show();
					break;
				}				
				
			} else {
				if ( B_OK != in->FindRef( "directory", &ref ) ||
				     B_OK != in->FindString( "name", &tempString ) ||
				     B_OK != directory.SetTo( &ref ) ||
				     B_OK != directory.CreateFile( tempString.String(), NULL, false ) ||
				     B_OK != directory.FindEntry( tempString.String(), &entry, true ) ||
				     B_OK != entry.GetRef( &ref ) )
				{
					break;
				}
			}
			if ( fData.SaveToFile( &ref ) != B_OK ) {
				utl_Deb = new DebuggerPrintout( "Couldn't save file!" );	
			}
			break;
		
		case B_ABOUT_REQUESTED:
			be_app->AboutRequested();
		
		default:
		  BWindow::MessageReceived( in );
		  break;
	}
}	// <-- end of function EventEditorMainWindow::MessageReceived
コード例 #6
0
void
PersonWindow::MessageReceived(BMessage* msg)
{
	msg->PrintToStream();
	char			str[256];
	BDirectory		directory;
	BEntry			entry;
	BFile			file;
//	BNodeInfo		*node;

	switch (msg->what) {
		case M_SAVE:
			if (!fRef) {
				SaveAs();
				break;
			}
			// supposed to fall through
		case M_REVERT:
		case M_SELECT:
			fView->MessageReceived(msg);
			break;

		case M_SAVE_AS:
			int32 format;
			if (msg->FindInt32("format", &format) == B_OK)
				SaveAs(format);
			break;

		case M_ADD_FIELD:
		case M_SHOW_LOCATIONS:
		case M_SHOW_GROUPS:
			fView->MessageReceived(msg);
			break;
		case B_UNDO: // fall through
		case B_CUT:
		case B_COPY:
		case B_PASTE:
		{
			BView* view = CurrentFocus();
			if (view != NULL)
				view->MessageReceived(msg);
			break;
		}

		case B_SAVE_REQUESTED:
		{
			entry_ref dir;
			if (msg->FindRef("directory", &dir) == B_OK) {
				const char* name = NULL;
				msg->FindString("name", &name);
				directory.SetTo(&dir);
				if (directory.InitCheck() == B_NO_ERROR) {
					directory.CreateFile(name, &file);
					if (file.InitCheck() == B_NO_ERROR) {
						int32 format;
						if (msg->FindInt32("format", &format) == B_OK) {
							directory.FindEntry(name, &entry);
							entry.GetRef(&dir);
							_SetToRef(new entry_ref(dir));
							SetTitle(fRef->name);
							fView->CreateFile(fRef, format);
						}
					}
					else {
						sprintf(str, B_TRANSLATE("Could not create %s."), name);
						(new BAlert("", str, B_TRANSLATE("Sorry")))->Go();
					}
				}
			}
			break;
		}

		case B_CONTACT_REMOVED:
			// We lost our file. Close the window.
			PostMessage(B_QUIT_REQUESTED);
			break;
		
		case B_CONTACT_MOVED:
		{
			// We may have renamed our entry. Obtain relevant data
			// from message.
			BString name;
			msg->FindString("name", &name);

			int64 directory;
			msg->FindInt64("to directory", &directory);

			int32 device;
			msg->FindInt32("device", &device);

			// Update our file
			fRef = new entry_ref(device,
				directory, name.String());
			fWatcher->SetRef(fRef);
			fView->Reload(fRef);

			// And our window title.
			SetTitle(name);

			// If moved to Trash, close window.
			BVolume volume(device);
			BPath trash;
			find_directory(B_TRASH_DIRECTORY, &trash, false,
				&volume);
			BPath folder(fRef);
			folder.GetParent(&folder);
			if (folder == trash)
				be_app->PostMessage(B_QUIT_REQUESTED);	
			break;
		}
		
		case B_CONTACT_MODIFIED:
		{
			fView->Reload();
			break;
		}

		default:
			BWindow::MessageReceived(msg);
	}
}
コード例 #7
0
ファイル: PersonWindow.cpp プロジェクト: AmirAbrams/haiku
void
PersonWindow::MessageReceived(BMessage* msg)
{
	char			str[256];
	BDirectory		directory;
	BEntry			entry;
	BFile			file;
	BNodeInfo		*node;

	switch (msg->what) {
		case M_SAVE:
			if (!fRef) {
				SaveAs();
				break;
			}
			// supposed to fall through
		case M_REVERT:
		case M_SELECT:
			fView->MessageReceived(msg);
			break;

		case M_SAVE_AS:
			SaveAs();
			break;

		case B_UNDO: // fall through
		case B_CUT:
		case B_COPY:
		case B_PASTE:
		{
			BView* view = CurrentFocus();
			if (view != NULL)
				view->MessageReceived(msg);
			break;
		}

		case B_SAVE_REQUESTED:
		{
			entry_ref dir;
			if (msg->FindRef("directory", &dir) == B_OK) {
				const char* name = NULL;
				msg->FindString("name", &name);
				directory.SetTo(&dir);
				if (directory.InitCheck() == B_NO_ERROR) {
					directory.CreateFile(name, &file);
					if (file.InitCheck() == B_NO_ERROR) {
						node = new BNodeInfo(&file);
						node->SetType("application/x-person");
						delete node;

						directory.FindEntry(name, &entry);
						entry.GetRef(&dir);
						_SetToRef(new entry_ref(dir));
						SetTitle(fRef->name);
						fView->CreateFile(fRef);
					}
					else {
						sprintf(str, B_TRANSLATE("Could not create %s."), name);
						BAlert* alert = new BAlert("", str, B_TRANSLATE("Sorry"));
						alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
						alert->Go();
					}
				}
			}
			break;
		}

		case B_NODE_MONITOR:
		{
			int32 opcode;
			if (msg->FindInt32("opcode", &opcode) == B_OK) {
				switch (opcode) {
					case B_ENTRY_REMOVED:
						// We lost our file. Close the window.
						PostMessage(B_QUIT_REQUESTED);
						break;

					case B_ENTRY_MOVED:
					{
						// We may have renamed our entry. Obtain relevant data
						// from message.
						BString name;
						msg->FindString("name", &name);

						int64 directory;
						msg->FindInt64("to directory", &directory);

						int32 device;
						msg->FindInt32("device", &device);

						// Update our ref.
						delete fRef;
						fRef = new entry_ref(device, directory, name.String());

						// And our window title.
						SetTitle(name);

						// If moved to Trash, close window.
						BVolume volume(device);
						BPath trash;
						find_directory(B_TRASH_DIRECTORY, &trash, false,
							&volume);
						BPath folder(fRef);
						folder.GetParent(&folder);
						if (folder == trash)
							PostMessage(B_QUIT_REQUESTED);

						break;
					}

					case B_ATTR_CHANGED:
					{
						// An attribute was updated.
						BString attr;
						if (msg->FindString("attr", &attr) == B_OK)
							fView->SetAttribute(attr.String(), true);
						break;
					}
					case B_STAT_CHANGED:
						fView->UpdatePicture(fRef);
						break;
				}
			}
			break;
		}

		default:
			BWindow::MessageReceived(msg);
	}
}
コード例 #8
0
ファイル: appwindow.cpp プロジェクト: HaikuArchives/ArmyKnife
void
AppWindow::MessageReceived(BMessage* message)
{
	//PRINT(("AppWindow::MessageReceived(BMessage*)\n"));

	switch(message->what)
	{
		case MSG_FILE_OPEN:
		{
			fOpenPanel->Show();
			break;
		}
		case B_ABOUT_REQUESTED:
			AboutRequested();
			break;

		case MSG_EDITOR_MODE:
			m_app_view->SelectView(0);
			break;
		case MSG_TA_MODE:
			m_app_view->SelectView(1);
			break;
		case MSG_NA_MODE:
			m_app_view->SelectView(2);
			break;
		case MSG_MPEG_MODE:
			m_app_view->SelectView(3);
			break;
#ifdef _TTE_
		case MSG_TT_INFO_MODE:
			m_app_view->SelectView(4);
			break;
#endif
		case MSG_PREVIOUS_MODE:
			m_app_view->SetPreviousMode();
			break;
		case MSG_NEXT_MODE:
			m_app_view->SetNextMode();
			break;

		case MSG_RESET:
			m_app_view->Reset();
			break;
		case MSG_CLEAR_LIST:
			m_app_view->ClearList();
			break;

		case MSG_PREVIOUS_FILE:
			m_app_view->SelectPreviousFile();
			break;
		case MSG_NEXT_FILE:
			m_app_view->SelectNextFile();
			break;

		case MSG_FIRST_FILE:
			m_app_view->SelectFirstFile();
			break;
		case MSG_LAST_FILE:
			m_app_view->SelectLastFile();
			break;

		case B_REFS_RECEIVED:
			m_app_view->MessageReceived(message);
			break;

		case MSG_MAKE_APPLY_BUTTON_DEFAULT:
			m_app_view->m_apply_button->MakeDefault(true);
			break;

		case MSG_MAKE_APPLY_BUTTON_NOT_DEFAULT:
			m_app_view->m_apply_button->MakeDefault(false);
			break;

		case MSG_EDIT_CUT:
			{
				message->what = B_CUT;
				BView *view = CurrentFocus();
				if (view)
					view->MessageReceived(message);
			}
			break;

		case MSG_EDIT_COPY:
			{
				message->what = B_COPY;
				BView *view = CurrentFocus();
				if (view)
					view->MessageReceived(message);
			}
			break;

		case MSG_EDIT_PASTE:
			{
				message->what = B_PASTE;
				BView *view = CurrentFocus();
				if (view)
					view->MessageReceived(message);
			}
			break;

		case MSG_SELECT_ALL:
			{
				message->what = B_SELECT_ALL;
				BView *view = CurrentFocus();
				if (view)
					view->MessageReceived(message);
				else
					m_app_view->SelectAll();
			}
			break;

		case MSG_SELECT_ALL_UNSUPPORTED:
			m_app_view->SelectAllUnsupported();
			break;
		
		case MSG_README:
		{
			BPath path;
			app_info info;
			be_roster->GetActiveAppInfo(&info);
			BEntry entry(&info.ref);
			
			entry.GetPath(&path);
			path.GetParent(&path);
			path.Append(DOCUMENTATION_DIR);
			path.Append(README_FILE);
			
			BMessage message(B_REFS_RECEIVED);
 			message.AddString("url", path.Path());
 			be_roster->Launch("text/html", &message);
			break;
		}

		case MSG_CHANGELOG:
		{
			BPath path;
			app_info info;
			be_roster->GetActiveAppInfo(&info);
			BEntry entry(&info.ref);
			
			entry.GetPath(&path);
			path.GetParent(&path);
			path.Append(DOCUMENTATION_DIR);
			path.Append(CHANGELOG_FILE);
			
			BMessage message(B_REFS_RECEIVED);
 			message.AddString("url", path.Path());
 			be_roster->Launch("text/html", &message);
			break;
		}
		
		default:
			BWindow::MessageReceived(message);
	}
}
コード例 #9
0
ファイル: win.cpp プロジェクト: svn2github/Themis
Win::Win(
	BRect frame,
	const char *title,
	window_type type,
	uint32 flags,
	uint32 wspace )
    : BWindow( frame, title, type, flags, wspace ), MessageSystem("Themis Window")
{
	MsgSysRegister(this);
	// size limits
	BScreen Screen;
	SetSizeLimits( 300, Screen.Frame().right, 200, Screen.Frame().bottom );
	
	protocol=0;
	startup=true;
	urlpopupwindow = NULL;
	fNextWindow = NULL;
	fOldFrame = Frame();
	fMaximized = false;
	fQuitConfirmed = false;

	LoadInterfaceGraphics();
	
	BRect rect;
	rect = Bounds();
	
	// lets add a menubar
	menubar = new BMenuBar( BRect(0,0,0,0), "MENUBAR" );
	AddChild( menubar );
	
	// menu messages
	BMessage* tabaddmsg = new BMessage( TAB_ADD );
	tabaddmsg->AddBool( "force_non_hidden", true );
		
	// filemenu
	filemenu = new BMenu( "File" );
	menubar->AddItem( filemenu );
	BMenuItem* newwinitem = new BMenuItem( "New Window", new BMessage( WINDOW_NEW ), 'N');
	filemenu->AddItem( newwinitem );
	BMenuItem* newtabitem = new BMenuItem( "New Tab", tabaddmsg, 'T' );
	filemenu->AddItem( newtabitem );
	BMenuItem* aboutitem = new BMenuItem( "About Themis", new BMessage( B_ABOUT_REQUESTED ), 'A', B_SHIFT_KEY );
	filemenu->AddItem( aboutitem );
	BMenuItem* quitwentry = new BMenuItem( "Close Window", new BMessage( B_QUIT_REQUESTED ), 'W' );
	filemenu->AddItem( quitwentry );
	BMenuItem* quitentry = new BMenuItem( "Quit Themis", new BMessage( B_QUIT_REQUESTED ), 'Q' );
	filemenu->AddItem( quitentry );
	quitentry->SetTarget( be_app );

	// optionsmenu
	optionsmenu=new BMenu( "Options" );
	menubar->AddItem(optionsmenu);
	BMenuItem* prefsentry = new BMenuItem( "Preferences", new BMessage( PREFSWIN_SHOW ), 'P' );
	prefsentry->SetTarget( be_app );
	optionsmenu->AddItem( prefsentry );
	
		
	// now we need the navigation view
	navview = new ThemisNavView(
		BRect( rect.left, menubar->Bounds().Height() + 1,
			rect.right,	menubar->Bounds().Height() + 31 ) );
	AddChild( navview );
	
	// and finally the statusview at the bottom
	statusview = new ThemisStatusView(
		BRect(
			rect.left,
			rect.bottom - 13,	// heigth of the lower-right doc-view corner
			rect.right,			// - 13 taken out because of dano decors
			rect.bottom ) );
	AddChild( statusview );
	
	// the tabview-system comes last as we need the height of the statusview
	CreateTabView();
	
	// make the urlview the focusview for fast pasting :D
	if( CurrentFocus() != NULL )
		CurrentFocus()->MakeFocus( false );
	navview->urlview->TextView()->MakeFocus( true );
}
コード例 #10
0
ファイル: win.cpp プロジェクト: svn2github/Themis
status_t Win::ReceiveBroadcast(BMessage *message) 
{
//	printf( "Win::ReceiveBroadcast()\n" );
//	message->PrintToStream();
	uint32 command=0;
	message->FindInt32("command",(int32*)&command);

	int16 win_uid = -1;
	if( message->HasInt16( "window_uid" ) )
	{
		message->FindInt16( "window_uid", &win_uid );
	}
					
	switch(command)
	{
		case COMMAND_INFO :
		{
			switch( message->what )
			{
				case RENDERVIEW_POINTER :
				{
//					printf( "  RENDERVIEW_POINTER\n" );
					
					message->PrintToStream();
					
					int32 site_id = 0;
					message->FindInt32( "site_id", &site_id );
					if( site_id == 0 )
						break;
					
					int32 tabindex;
					ThemisTab* tab = FindTabFor( site_id, &tabindex );
					if( tab == NULL )
						break;
					
					TRenderView* renderview = NULL;
					message->FindPointer( "renderview_pointer", ( void** )&renderview );
					if( renderview == NULL )
						break;
					
					/* Attach the renderview to the correct tab. */

					Lock();
					
					//int32 tabindex = tabview->IndexForTab( tab );
					
					/*
					 * We don't need to resize the renderview here, as this is done in
					 * ThemisTabView::Select().
					 */
					
					tabview->TabAt( tabindex )->SetView( renderview );
					
					if( tabview->Selection() == tabindex )
					{
						tabview->Select( tabindex );
						
						if( CurrentFocus() != NULL )
							CurrentFocus()->MakeFocus( false );
						tabview->TabAt( tabindex )->View()->MakeFocus( true );
					}
					
					Unlock();
					
					break;
				}
				case SH_WIN_LOADING_PROGRESS :
				{
//					printf( "WIN: UH_WIN_LOADING_PROGRESS\n" );
					
					int32 id = 0;
					message->FindInt32( "site_id", &id );
					
					int32 tabindex;
					ThemisTab* tab = FindTabFor( id, &tabindex );
					if( !tab )
						break;
					
					SiteHandler* sh = ( ( App* )be_app )->GetSiteHandler();
					if( !sh )
						break;
					
					if( sh->EntryValid( id ) )
					{
						Lock();					

						/* Update the tabs label and icon */
						tab->SetLabel( sh->GetTitleFor( id ) );
						tab->SetFavIcon( sh->GetFavIconFor( id ) );
						tabview->DrawTabs();
						
						if( tabindex == tabview->Selection() )
						{
							/*
							 * I could introduce some checking here, if things have changed at all.
							 * But imo this is ok for now.
							 */
							
							/* Update the window title */
							BString wtitle( "Themis - " );
							wtitle.Append( sh->GetTitleFor( id ) );
							SetTitle( wtitle.String() );
							
							/* Update the FavIcon and Text in the NavView */
							navview->urlview->SetText( sh->GetUrlFor( id ) );
							navview->urlview->SetFavIcon( sh->GetFavIconFor( id ) );
							
							/* Update the StatusView */
							statusview->SetLoadingInfo(
								sh->GetLoadingProgressFor( id ),
								sh->GetStatusTextFor( id ) );
						}

						Unlock();
					}
					break;
				}
			} // switch( message->what )
			break;
		} // case COMMAND_INFO :
	} // switch( command )
	return B_OK;
}