Пример #1
0
/* Main window procedure */
static LRESULT CALLBACK
WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch(uMsg) {
        case WM_COMMAND:
            /* Handle clicks to the button: create new tab. */
            if(LOWORD(wParam) == IDC_BUTTON_NEW) {
                AddNewTab();
            }
            break;

        case WM_SIZE:
            if(wParam == SIZE_MAXIMIZED || wParam == SIZE_RESTORED) {
                WORD width = LOWORD(lParam);
                WORD height = HIWORD(lParam);

                SetWindowPos(hwndMdiTab, NULL, 0, 0, width, 30, SWP_NOZORDER);
                SetWindowPos(hwndBtn, NULL, 10, height - 34, 80, 24, SWP_NOZORDER);
            }
            break;

        case WM_GETMINMAXINFO:
        {
            MINMAXINFO* lpMmi = (MINMAXINFO*) lParam;
            lpMmi->ptMinTrackSize.x = MINIMAL_WIDTH;
            lpMmi->ptMinTrackSize.y = MINIMAL_HEIGHT;
            return 0;
        }

        case WM_CREATE:
            /* Create mditab child window  */
            hwndMdiTab = CreateWindow(MC_WC_MDITAB, _T(""), WS_CHILD | WS_VISIBLE |
                MC_MTS_CLOSEONMCLICK | MC_MTS_DOUBLEBUFFER | MC_MTS_ANIMATE,
                0, 0, 0, 0, hWnd, (HMENU) IDC_MDITAB, hInst, NULL);

            /* Set an imagelist */
            SendMessage(hwndMdiTab, MC_MTM_SETIMAGELIST, 0, (LPARAM) hImgList);

            /* Create button for creating new tabs */
            hwndBtn = CreateWindow(_T("BUTTON"), _T("New tab"),
                WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
                hWnd, (HMENU) IDC_BUTTON_NEW, hInst, NULL);
            return 0;

        case WM_SETFONT:
            SendMessage(hwndMdiTab, WM_SETFONT, wParam, lParam);
            SendMessage(hwndBtn, WM_SETFONT, wParam, lParam);
            return 0;

        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
    }

    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
void CEditorRoot::OnFileSelected( KeyValues *pKV )
{
	KeyValues *pContext = pKV->FindKey( "FileOpenContext" );
	if ( !pContext )
		return;
	const char *__c = pContext->GetString( "context" );
	bool bSaving = true;
	if ( !Q_stricmp( __c, "openc" ) )
		bSaving = false;
	
	const char *pathIn = pKV->GetString( "fullpath" );
	if ( Q_strlen( pathIn ) <= 1 )
		return;

	bool bDoViewReset = false;

	if ( !bSaving )
	{
		int iPageIndex = -1;
		for ( int i = 0; i < pNodeSheet->GetNumPages(); i++ )
		{
			const char *pszShadername = ((CFlowGraphPage*)pNodeSheet->GetPage(i))->GetFlowGraph()->GetShadername();
			if ( pszShadername && !Q_stricmp( pszShadername, pathIn ) )
				iPageIndex = i;
		}
		bool bExists = iPageIndex >= 0;

		if ( bExists )
		{
			pNodeSheet->SetActivePage( pNodeSheet->GetPage( iPageIndex ) );
			//return;
		}
		else if ( ( input()->IsKeyDown( KEY_LCONTROL ) || input()->IsKeyDown( KEY_RCONTROL ) ) )
		{
			AddNewTab();
			bDoViewReset = true;
		}
	}
	else
	{
		Panel *p = pNodeSheet->GetActivePage();
		for ( int i = 0; i < pNodeSheet->GetNumPages(); i++ )
		{
			Panel *pCur = pNodeSheet->GetPage(i);
			if (pCur == p)
				continue;

			const char *pszShadername = ((CFlowGraphPage*)pCur)->GetFlowGraph()->GetShadername();
			if ( pszShadername && !Q_stricmp( pszShadername, pathIn ) )
			{
				pNodeSheet->DeletePage(pCur);
				i--;
			}
		}
	}

	SetCurrentShaderName( pathIn );
	CNodeView *pView = GetSafeFlowgraph();

	if ( bSaving )
		pView->SaveToFile( pView->GetShadername() ); //m_szShaderName );
	else
	{
		pView->LoadFromFile( pView->GetShadername() ); //m_szShaderName );

		if ( bDoViewReset )
		{
			pView->InvalidateLayout( true, true );
			pView->ResetView_User( false );
		}

		PageChanged();
	}

	pView->RequestFocus();
}
CEditorRoot::CEditorRoot( const char *pElementName ) : BaseClass( NULL, "editor" )
{
	pEditorRoot = this;
	Q_memset( hFonts, 0, sizeof(hFonts) );
	Q_memset( hFonts2, 0, sizeof(hFonts2) );
//	m_pKV_MainPreviewMat = NULL;
	//m_pMat_MainPreview = NULL;
//	m_pKV_BGPreviewMat = NULL;
	//m_pMat_BGPreview = NULL;
	m_bPainting = false;
	m_bAutoCompile = true;
	m_bAutoFullcompile = false;
	m_bAutoShaderPublish = true;
	m_bAutoPrecacheUpdate = true;
	m_bWarnOnClose = true;

	InitColors();

	pPreview = NULL;
	m_pKV_NodeHelp = NULL;

	m_iNumMaterials = 0;
	m_pszMaterialList = NULL;

	m_pLastFullCompiledShader = NULL;

	//vgui::VPANEL GameUIRoot = enginevgui->GetPanel( PANEL_GAMEUIDLL );
	vgui::VPANEL EngineRoot = enginevgui->GetPanel( PANEL_ROOT );
	//vgui::VPANEL DLLRoot = VGui_GetClientDLLRootPanel();

	vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFile("resource/SourceScheme.res", "SourceScheme");
	SetScheme( scheme );

	m_pLabelTitle = new Label( this, "title_label", "" );

	pNodeSheet = new CFlowGraphSheet( this, "flowgraphsheets", true, true );
	pNodeSheet->AddActionSignalTarget( this );
	pNodeSheet->SetAddTabButtonEnabled( true );
	//pNodeSheet->ShowContextButtons(true);
	/*pNodeView =*/
	AddNewTab();

	//CFlowGraphPage *page = new CFlowGraphPage( this );
	//m_hFlowGraphPages.AddToTail( page );
	//CNodeView *view = new CNodeView( page, this, "main_nodeview" );
	//m_hNodeViews.AddToTail( pNodeView );
	//page->SetFlowGraph( pNodeView );
	//pNodeSheet->AddPage( page, GetDefaultTabName() );

	m_pLabel_Coords = new Label( this, "mouse_node_coords", "" );
	m_pLabel_FrameTime = new Label( this, "framespeed", "" );


	m_pMenuBar = new MenuBar( this, "menu_bar" );
	m_pMBut_File = new MenuButton( this, "mbut_file", "File" );
	m_pMBut_File->AddActionSignalTarget( this );
	Menu *pMenu_File = new Menu( m_pMBut_File, "" );
	pMenu_File->AddMenuItem( "New", new KeyValues("onmenufile","entry",ER_FMENU_NEW), this );
	pMenu_File->AddSeparator();
	pMenu_File->AddMenuItem( "Open", new KeyValues("onmenufile","entry",ER_FMENU_OPEN), this );
	pMenu_File->AddSeparator();
	pMenu_File->AddMenuItem( "Save", new KeyValues("onmenufile","entry",ER_FMENU_SAVE), this );
	pMenu_File->AddMenuItem( "Save as", new KeyValues("onmenufile","entry",ER_FMENU_SAVE_AS), this );
	pMenu_File->AddMenuItem( "Save all", new KeyValues("onmenufile","entry",ER_FMENU_SAVE_ALL), this );
	pMenu_File->AddSeparator();
	pMenu_File->AddMenuItem( "Undo", new KeyValues("onmenufile","entry",ER_FMENU_UNDO), this );
	pMenu_File->AddMenuItem( "Redo", new KeyValues("onmenufile","entry",ER_FMENU_REDO), this );
	pMenu_File->AddSeparator();
	pMenu_File->AddMenuItem( "Take screenshot", new KeyValues("onmenufile","entry",ER_FMENU_SCREENSHOT), this );
	pMenu_File->AddMenuItem( "Editor config", new KeyValues("onmenufile","entry",ER_FMENU_ECONFIG), this );
	m_pMBut_File->SetMenu( pMenu_File );
	m_pMenuBar->AddButton( m_pMBut_File );

	m_pMBut_Shader = new MenuButton( this, "mbut_shader", "Shader" );
	Menu *pMenu_Shader = new Menu( m_pMBut_Shader, "" );
	pMenu_Shader->AddMenuItem( "Shader settings", new KeyValues("onmenushader","entry",ER_SMENU_SCONFIG), this );
	pMenu_Shader->AddMenuItem( "Shader precache", new KeyValues("onmenushader","entry",ER_SMENU_SPRECACHE), this );
	pMenu_Shader->AddSeparator();
	pMenu_Shader->AddMenuItem( "Full compile", new KeyValues("onmenushader","entry",ER_SMENU_FULLCOMPILE), this );
	pMenu_Shader->AddMenuItem( "Compile all precached", new KeyValues("onmenushader","entry",ER_SMENU_ALLCOMPILE), this );
	pMenu_Shader->AddMenuItem( "Terminate compilers", new KeyValues("onmenushader","entry",ER_SMENU_KILLCOMPILER), this );
	pMenu_Shader->AddSeparator();
	pMenu_Shader->AddMenuItem( "Inject shader into world", new KeyValues("onmenushader","entry",ER_SMENU_INJECT), this );
	pMenu_Shader->AddMenuItem( "Paint world", new KeyValues("onmenushader","entry",ER_SMENU_PAINT), this );
	m_pMBut_Shader->SetMenu( pMenu_Shader );
	m_pMenuBar->AddButton( m_pMBut_Shader );

	m_pMBut_PostProc = new MenuButton( this, "mbut_postproc", "Post processing" );
	Menu *pMenu_PostProc = new Menu( m_pMBut_PostProc, "" );
	pMenu_PostProc->AddMenuItem( "Effect settings", new KeyValues("onmenupostprocessing","entry",ER_PMENU_PCONFIG), this );
	pMenu_PostProc->AddMenuItem( "Effect precache", new KeyValues("onmenupostprocessing","entry",ER_PMENU_PPRECACHE), this );
	pMenu_PostProc->AddMenuItem( "Manage rendertargets", new KeyValues("onmenupostprocessing","entry",ER_PMENU_RTS), this );
	m_pMBut_PostProc->SetMenu( pMenu_PostProc );
	m_pMenuBar->AddButton( m_pMBut_PostProc );

	//m_pLabel_CurrentFileName = new Label( this, "filename", "-" );

	LoadControlSettings("shadereditorui/vgui/shadereditor_root.res");
	OnShaderNameChanged();

	Activate();
	SetVisible( true );
	SetPaintBorderEnabled( false );
	SetPaintBackgroundEnabled( true );
	SetPaintEnabled( true );
	SetParent( EngineRoot );

	m_pKV_SelectionCopy = NULL;
	bFontsLoaded = false;

	m_bHalfView = false;
	m_bHasInput = true;
	//m_bNeedsButtonPush = false;

	m_bDraw_Datatypes = true;
	m_bDraw_Shadows = true;
	m_bDraw_AllLimits = true;
	m_bDoTooltips = true;

	//m_szShaderName[0] = '\0';
	px = py = psx = psy = 0;
	cedit_x = cedit_y = cedit_sx = cedit_sy = -1;
	//m_flErrorTime = 0;

	AllocProceduralMaterials();
	UpdateVariablePointer();

	//m_iLastCompileIndex = GetSafeFlowgraph()->GetStackIndex();
}
void CEditorRoot::OpenShaderFlowgraph( int mode, bool bSM20, bool bForceNewTab )
{
	//CNodeView::FlowGraphType_t curType = GetSafeFlowgraph()->GetFlowgraphType();

	CNodeView::FlowGraphType_t targetType = CNodeView::FLOWGRAPH_HLSL;
	switch (mode)
	{
	case CANVASINIT_PPEFFECT:
		targetType = CNodeView::FLOWGRAPH_POSTPROC;
		break;
	}

	bool bPushHistory = false;

	if ( bForceNewTab ||
		input()->IsKeyDown( KEY_LCONTROL ) || input()->IsKeyDown( KEY_RCONTROL ) )
		AddNewTab(targetType);
	else
		bPushHistory = true;

	OnNewFile();

	CNodeView *pView = GetSafeFlowgraph();
	pView->PurgeCanvas();

	const char *FileToLoad = NULL;

	switch (mode)
	{
	default:
	case CANVASINIT_SCRATCH:
		{
			GenericShaderData *data = new GenericShaderData();
			if ( bSM20 )
				data->shader->iShaderModel = SM_20B;

			pView->InitCanvas(targetType,data);
			delete data;
		}
		break;

	case CANVASINIT_MODEL_SIMPLE:
#ifdef SHADER_EDITOR_DLL_SWARM
		FileToLoad = "def_model_simple_swarm.def";
#else
		FileToLoad = "def_model_simple.def";
#endif
		break;

	case CANVASINIT_MODEL_COMPLEX:
#ifdef SHADER_EDITOR_DLL_SWARM
		FileToLoad = "def_model_complex_swarm.def";
#else
		FileToLoad = "def_model_complex.def";
#endif
		break;

	case CANVASINIT_POSTPROC:
		FileToLoad = "def_pp.def";
		break;

	case CANVASINIT_LIGHTMAPPED_SIMPLE:
#ifdef SHADER_EDITOR_DLL_SWARM
		FileToLoad = "def_lightmap_simple_swarm.def";
#else
		FileToLoad = "def_lightmap_simple.def";
#endif
		break;

	case CANVASINIT_LIGHTMAPPED_BUMP:
#ifdef SHADER_EDITOR_DLL_SWARM
		FileToLoad = "def_lightmap_bump_swarm.def";
#else
		FileToLoad = "def_lightmap_bump.def";
#endif
		break;
	case CANVASINIT_PPEFFECT:
		pView->InitCanvas(targetType);
		break;
	}

	if ( FileToLoad )
	{
		char fPath[ MAX_PATH ];
		Q_snprintf( fPath, MAX_PATH, "%s/shadereditorui/canvas_default/%s", GetGamePath(), FileToLoad );
		pView->LoadFromFile( fPath );
	}

	OnShaderNameChanged();
	UpdateTabColor( pView );

	pView->InvalidateLayout( true, true );
	pView->ResetView_User( false );

	if ( bPushHistory )
		pView->MakeHistoryDirty();

	PageChanged();

	pView->UnDirtySave();
}
Пример #5
0
void Win::MessageReceived(BMessage *msg) {
	switch(msg->what) {
		case B_ABOUT_REQUESTED: {
			be_app_messenger.SendMessage(B_ABOUT_REQUESTED);
		}break;
		case B_QUIT_REQUESTED: {
			PostMessage(B_QUIT_REQUESTED);
		}break;
		case PlugInLoaded: {
//			printf("WIN: PlugInLoaded\n");		
			protocol_plugin *pobj=NULL;
//			msg->PrintToStream();
			msg->FindPointer("plugin",(void**)&pobj);
//			printf("pobj: %p\n",pobj);
			if (pobj!=NULL) {
//				printf("Window: plugin loaded %c%c%c%c\n",(int)pobj->PlugID()>>24,(int)pobj->PlugID()>>16,(int)pobj->PlugID()>>8,(int)pobj->PlugID());
				pobj->Window=this;
				pobj->AddMenuItems(optionsmenu);
			} else {
				;//printf("Win: pobj was null\n");
				
			}
			
		}break;
		case B_MOUSE_WHEEL_CHANGED :
		{
			//cout << "B_MOUSE_WHEEL_CHANGED" << endl;
			
			// need to do the scrolling of the urlpopup here
			// as the urlpopupwindow never gets focus and thus
			// never get the mouse wheel messages
			if( urlpopupwindow != NULL )
			{
				if( urlpopupwindow->vscroll != NULL )
				{
					float value = msg->FindFloat( "be:wheel_delta_y" );
					value *= 10;
					
					urlpopupwindow->Lock();
					urlpopupwindow->urlpopupview->ulv->ScrollBy( 0, value );
					urlpopupwindow->Unlock();
				}
			}
			// i dunno where the scroll-recognition of the rendered site shall
			// happen.. if here, then it should go into here later :D
			
		}break;
		case BUTTON_BACK :
		{
//			printf( "WIN: BUTTON_BACK\n" );
			
			const char* previous = NULL;
			previous = ( ( ThemisTab* )tabview->TabAt( tabview->Selection() ) )->GetHistory()->GetPreviousEntry();
			if( previous != NULL )
			{
//				printf( "previous != NULL [ %s ]\n", previous );
				BMessage* backmsg = new BMessage( URL_OPEN );
				backmsg->AddString( "url_to_open", previous );
				backmsg->AddBool( "no_history_add", true );
				BMessenger* msgr = new BMessenger( this );
				msgr->SendMessage( backmsg );
				delete backmsg;
				delete msgr;
			}
			
			break;
		};
		case BUTTON_FORWARD :
		{
//			printf( "WIN: BUTTON_FORWARD\n" );
			
			const char* next = NULL;
			next = ( ( ThemisTab* )tabview->TabAt( tabview->Selection() ) )->GetHistory()->GetNextEntry();
			if( next != NULL )
			{
//				printf( "next != NULL [ %s ]\n", next );
				BMessage* fwdmsg = new BMessage( URL_OPEN );
				fwdmsg->AddString( "url_to_open", next );
				fwdmsg->AddBool( "no_history_add", true );
				BMessenger* msgr = new BMessenger( this );
				msgr->SendMessage( fwdmsg );
				delete fwdmsg;
				delete msgr;
			}
			else
			{
				tabview->SetNavButtonsByTabHistory();	// needed to disable the fwd button
			}
						
			break;
		}
		case BUTTON_STOP :
		{
			break;
		}
		case BUTTON_HOME :
		{
//			printf( "WIN: BUTTON_HOME\n" );
			
			BString homepage;
			AppSettings->FindString( kPrefsHomePage, &homepage );
			
			BMessage* homemsg = new BMessage( URL_OPEN );
			homemsg->AddString( "url_to_open", homepage.String() );
			BMessenger* msgr = new BMessenger( this );
			msgr->SendMessage( homemsg );
			delete homemsg;
			delete msgr;
			
			break;
		}
		case CLOSE_OTHER_TABS :
		{
			// this function is used for the tab-pop-up-menu function
			// "Close other Tabs" and also for the closetabview_button
//			cout << "WIN: CLOSE_OTHER_TABS" << endl;
			
			Lock();
			
			// if the newtab button is disabled, enable it again
			navview->buttons[4]->SetMode( 0 );
						
			uint32 current_tab = 0;
			uint32 count = tabview->CountTabs();
			
			if( msg->HasInt32( "tabindex" ) )
				current_tab = msg->FindInt32( "tabindex" );
			else
				current_tab = tabview->Selection();
			
			while( count > 1 )
			{
				if( count - 1 > current_tab )
				{
					tabview->RemoveTab( count - 1 );
				}
				else
				{
					current_tab = current_tab - 1;
					tabview->RemoveTab( current_tab );
				}
				
				tabview->DynamicTabs( false );
				
				count = tabview->CountTabs();
			}
			
			// used by the closetabview button
			if( msg->HasBool( "close_last_tab" ) )
				if( msg->FindBool( "close_last_tab" ) == true )
					tabview->SetFakeSingleView();
			
			Unlock();
			
			
		}break;
		case CLOSE_URLPOPUP :
		{
//			cout << "WIN: CLOSE_URLPOPUP" << endl;
			if( urlpopupwindow )
			{
				urlpopupwindow->Lock();
				urlpopupwindow->Quit();
				urlpopupwindow = NULL;
			}			
				
		}break;
		case RE_INIT_TABHISTORY :
		{
			ReInitTabHistory();
			break;
		}
		case TAB_ADD :
		{
//			cout << "WIN: TAB_ADD received" << endl;
			
			// dissallow adding of new tabs, if they wouldnt fit in the
			// window anymore, and disable newtab button
			if( tabview->tab_width <= 30 )
			{
				// calculate if still one tab would fit and not cover
				// the closetabview button partially
				float width = ( tabview->CountTabs() + 1 ) * 25;
				
				if( Bounds().right - width <= 22 )
				{
					// disable the newtab button
					navview->buttons[4]->SetMode( 3);
					break;
				}
				// if we won't cover the button, go on...
			}
						
			// if the prefs are not set to sth like "open new tabs hidden"
			// we pass hidden = false to AddNewTab
			// this selects the last tab ( the new one )
			bool hidden = true;
			AppSettings->FindBool( "OpenTabsInBackground", &hidden );
			// OPTION+T shortcut for new tab should open tabs non hidden
			bool force_non_hidden = false;
			msg->FindBool( "force_non_hidden", &force_non_hidden );
			if( force_non_hidden == true )
				hidden = false;
			AddNewTab( hidden );
			
			if( msg->HasString( "url_to_open" ) )
			{
				BMessage* urlopenmsg = new BMessage( URL_OPEN );
				urlopenmsg->AddString( "url_to_open", msg->FindString( "url_to_open" ) );
				urlopenmsg->AddInt32( "tab_to_open_in", tabview->CountTabs() - 1 );
				urlopenmsg->AddBool( "hidden", hidden );
				
				BMessenger* target = new BMessenger( this );
				target->SendMessage( urlopenmsg );
				
				delete urlopenmsg;
				delete target;				
			}				
			break;
		}
		case BUTTON_RELOAD :
		case URL_OPEN :
		{
//			if( msg->what == URL_OPEN )
//				printf( "WIN: URL_OPEN\n" );
//			else
//				printf( "WIN: BUTTON_RELOAD\n" );
			
			// close urlpopup if needed
			if( urlpopupwindow  )
			{	
				urlpopupwindow->Lock();
				urlpopupwindow->Quit();
				urlpopupwindow = NULL;
			}			
						
			// get the url
			BString url;
			if( msg->HasString( "url_to_open" ) )
				url = msg->FindString( "url_to_open" );
			else
				url = navview->urlview->Text();
			
//			cout << "  requested url: " << url.String() << endl;
			
			// stop, if there is no url, or about:blank
			if( url.Length() == 0 )
				break;
			if( strcmp( url.String(), kAboutBlankPage ) == 0 )
				break;
			
			uint32 selection = tabview->Selection();
			int32 site_id = ( ( App* )be_app )->GetNewID();
						
			if( msg->HasInt32( "tab_to_open_in" ) )
			{
				int32 tab_index = msg->FindInt32( "tab_to_open_in" );
				
				( ( ThemisTab* )tabview->TabAt( tab_index ) )->SetSiteID( site_id );
				
				// add history entry for tab
				if( msg->HasBool( "no_history_add" ) == false )
					( ( ThemisTab* )tabview->TabAt( tab_index ) )->GetHistory()->AddEntry( url.String() );
			}
			else
			{
				( ( ThemisTab* )tabview->TabAt( selection ) )->SetSiteID( site_id );
				
				// add history entry for tab
				if( msg->HasBool( "no_history_add" ) == false )
					( ( ThemisTab* )tabview->TabAt( selection ) )->GetHistory()->AddEntry( url.String() );
			}
			
			/* add url to global history
			 * ( You ask, why I am also adding the url on RELOAD, and not only on URL_OPEN?
			 *   Simple. Imagine a browser being open for longer then GlobalHistoryDepthInDays.
			 *   The url would be deleted after this period of days. If the user would then reload
			 *   the page, it would not be saved in the history. If he closes the browser, his url
			 *   would be lost. Ok, this is somewhat unlikely, but could happen. ) 
			*/
			( ( App* )be_app )->GetGlobalHistory()->AddEntry( url.String() );
			
			/* get this out of here */
			
//			char *usepass=NULL;
//			char *workurl=NULL;
//			BString urlS=url.String();
//			int len=strlen(url.String());
//			char *url_=new char[len+1];
//			workurl=new char[len+1];
//			memset(url_,0,len+1);
//			memset(workurl,0,len+1);
//			strcpy(url_,url.String());
//			strcpy(workurl,url_);
//			protocol=HTTPPlugin;
//			urlS=url;
//			
//			if (urlS.Length()>0) {
//				int32 pos=urlS.FindFirst("://");
//				int32 atpos=urlS.FindFirst('@');
//				int32 firstslash=urlS.FindFirst('/',7);
//				printf("pos: %ld\tat: %ld\tfs: %ld\n",pos,atpos,firstslash);
//				
//				if (atpos>0) {
//					int32 secondat=urlS.FindFirst('@',atpos+1);
//					if (((secondat!=B_ERROR) && (firstslash!=B_ERROR) && (secondat<firstslash)) 
//						||  ((firstslash==B_ERROR) && (secondat!=B_ERROR))) {
//							
//						atpos=secondat;
//					}			
//					printf("second at: %ld\n",secondat);
//					if (atpos<firstslash) {
//						if (pos!=B_ERROR) {
//							int32 plen=atpos-(pos+3);
//							usepass=new char[plen+1];
//							memset(usepass,0,plen+1);
//							urlS.MoveInto(usepass,pos+3,plen);
//							printf("usepass: %s\tlen: %ld\n",usepass,plen);
//							
//						} else {
//							usepass=new char[atpos+1];
//							memset(usepass,0,atpos+1);
//							urlS.MoveInto(usepass,0,atpos);
//							printf("usepass: %s\tlen: %ld\n",usepass,atpos);
//							
//						}
//						urlS.RemoveFirst("@");
//						
//					} else {
//						if (firstslash==B_ERROR) {
//							usepass=new char[atpos+1];
//							memset(usepass,0,atpos+1);
//							urlS.MoveInto(usepass,0,atpos);
//							urlS.RemoveFirst("@");
//						}
//					}
//				}
//				
//				printf("urlS: %s\n",urlS.String());
//				if (pos!=B_ERROR) {
//					char *protostr=new char[pos+1];
//					memset(protostr,0,pos+1);
//					strncpy(protostr,url_,pos);
//					for (int i=0; i<pos;i++)
//						protostr[i]=tolower(protostr[i]);
//					protocol=strtoval(protostr);
//					delete protostr;
//				}
//			}
//			delete url_;
//			ProtocolPlugClass *pobj=(ProtocolPlugClass*)PluginManager->FindPlugin(protocol);
//			printf("protocol: %ld\npobj: %p\n",protocol,pobj);
//			if (urlS.Length()==0) {
//				return;
//			}
//			if ((urlS.FindFirst("://")==B_ERROR) || (urlS.FindFirst("://")>=6)) {
//				urlS.Prepend("http://");
//				printf("url: %s\n",urlS.String());
//				printf("workurl: %s\n",workurl);
//				delete workurl;
//				workurl=new char[urlS.Length()+1];
//				memset(workurl,0,urlS.Length()+1);
//				urlS.CopyInto(workurl,0,urlS.Length());
//			} else {
//				memset(workurl,0,strlen(workurl)+1);
//				delete workurl;
//				workurl=new char[urlS.Length()+1];
//				memset(workurl,0,urlS.Length()+1);
//				urlS.CopyInto(workurl,0,urlS.Length());
//				
//			}
//			
//			// ok, lets make a copy of url.
//			BString target_url( url );
			
//			url=workurl;


//			printf( "Win: creating info message\n" );			
//
//			BMessage *info=new BMessage;
//			info->AddInt32( "view_id", view_id );
//			info->AddPointer("plug_manager",PluginManager);
//			info->AddPointer("main_menu_bar",menubar);
//			info->AddPointer("file_menu",filemenu);
//			info->AddPointer("options_menu",optionsmenu);
//			info->AddString("target_url",workurl);
//			
//			if( msg->what == URL_OPEN )
//				info->AddInt32("action",LoadingNewPage);
//			else
//				info->AddInt32("action",ReloadData);
//
//			delete workurl;
//			
//			if (usepass!=NULL) {
//					info->AddString("username:password",usepass);
//					memset(usepass,0,strlen(usepass)+1);
//					delete usepass;
//			}
				
//			if( msg->what == URL_OPEN )
//			{
//				printf("WIN: telling MS_TARGET_ALL that a new page is being loaded.\n");
//		
//				BMessage *lnp=new BMessage(LoadingNewPage);
//				lnp->AddInt32("command",COMMAND_INFO);
//				Broadcast(MS_TARGET_ALL,lnp);
//				delete lnp;
//			}
//
//			info->AddInt32("command",COMMAND_RETRIEVE);
//			info->AddInt32("targets",TARGET_PROTOCOL);
//			info->AddInt32("source",TARGET_VIEW);
			
//			info->PrintToStream();
			
//			printf("WIN: Sending request broadcast to MS_TARGET_PROTOCOL.\n");
//			Broadcast(MS_TARGET_PROTOCOL,info);
//			delete info;
//			printf("WIN: Done with request broadcast.\n");
			
			/*********/
			
			
			// I don't want to destroy anything working right now. So let's just
			// get something new in.
			
			BMessage* load = NULL;
			if( msg->what == URL_OPEN )
				load = new BMessage( SH_LOAD_NEW_PAGE );
			else
				load = new BMessage( SH_RELOAD_PAGE );
			
			load->AddInt32( "command", COMMAND_INFO );
			load->AddInt32( "site_id", site_id );
			load->AddString( "url", url.String() );
			
			/* We need to directly trigger the SiteHandler. Yap, bad. */
			( ( App* )be_app )->GetSiteHandler()->ReceiveBroadcast( load );
			
			delete load;

			/*
			 * Trigger this after the UrlHandler knows about the URL.
			 * Otherwise we wouldn't see any URL in UrlView during load.
			 * Sad, but true.
			 */
						
			if( msg->FindBool( "hidden" ) == true )
				tabview->DrawTabs();
			else
				tabview->Select( selection );
			
		}break;
		case URL_TYPED :
		{
//			cout << "URL_TYPED received" << endl;
			
			bool show_all = false;
			msg->FindBool( "show_all", &show_all );
			
			bool prefs_show_type_ahead = false;
			AppSettings->FindBool( kPrefsShowTypeAheadWindow, &prefs_show_type_ahead );
									
			if( ( prefs_show_type_ahead == true ) || ( show_all == true ) )
			{
				if( show_all == true )
					UrlTypedHandler( true );
				else
					UrlTypedHandler( false );
			}
			
			
		}break;
		case WINDOW_NEW :
		{
			// resend the message to the app
			be_app_messenger.SendMessage( msg );
			break;
		}
		default:
		{
			BWindow::MessageReceived(msg);
			break;
		}
	}
}