00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "app.h"
00026 #include "dlgabout.h"
00027 #include "dlgeditprofile.h"
00028 #include "dlgfind.h"
00029 #include "dlggoto.h"
00030 #include "dlgpath.h"
00031 #include "dlgprofilemanager.h"
00032 #include "dlgupdate.h"
00033 #include "frame.h"
00034 #include "glcanvas.h"
00035 #include "map.h"
00036 #include "profilemanager.h"
00037
00038 #include <wx/splash.h>
00039 #include <wx/textdlg.h>
00040 #include <wx/toolbar.h>
00041 #include <wx/tooltip.h>
00042 #include <wx/valtext.h>
00043
00044
00045 extern ofstream logFile;
00046
00047 namespace WDS
00048 {
00049
00050 BEGIN_EVENT_TABLE(CFrame, wxFrame)
00051 EVT_MENU( wxID_EXIT, CFrame::OnQuit )
00052 EVT_MENU( wxID_OPEN, CFrame::OnOpen )
00053 EVT_MENU( wxID_NEW , CFrame::OnNew )
00054 EVT_MENU( wxID_CLOSE, CFrame::OnClose )
00055
00056 EVT_MENU( IDM_EDIT_PROFILES, CFrame::OnEditProfiles )
00057 EVT_MENU( IDM_UPDATE, CFrame::OnUpdateClient )
00058
00059 EVT_MENU( IDM_ZOOM_IN, CFrame::OnZoomIn )
00060 EVT_MENU( IDM_ZOOM_OUT, CFrame::OnZoomOut )
00061 EVT_COMBOBOX(IDC_CB_ZOOM, CFrame::OnCbZoom )
00062
00063 EVT_MENU( IDM_FOGOFWAR, CFrame::OnMenuFogOfWar )
00064 EVT_MENU( IDM_FULLSCREEN, CFrame::OnMenuFullScreen )
00065 EVT_MENU( IDM_TOOLBAR, CFrame::OnMenuToolbar )
00066 EVT_MENU( IDM_STATUSBAR, CFrame::OnMenuStatusbar )
00067
00068 EVT_MENU( IDM_GOTO, CFrame::OnMenuGoTo )
00069 EVT_MENU( IDM_SEARCH, CFrame::OnMenuFind )
00070 EVT_MENU( IDM_ABOUT, CFrame::OnMenuAbout )
00071
00072 EVT_RIGHT_UP( CFrame::OnRButtonUp )
00073 EVT_MOTION( CFrame::OnMouseMove )
00074 EVT_MOUSEWHEEL( CFrame::OnMouseWheel )
00075 EVT_KEY_DOWN( CFrame::OnKeyDown )
00076 EVT_MENU( IDM_PATH_START, CFrame::OnPathStart )
00077 EVT_MENU( IDM_PATH_END, CFrame::OnPathEnd )
00078 EVT_MENU( IDM_ADD_TO_FAVOURITES, CFrame::OnAddToFavourites )
00079 END_EVENT_TABLE()
00080
00081
00082
00083
00084
00085 CFrame::CFrame(const wxChar *title, int xpos, int ypos, int width, int height)
00086 : wxFrame((wxFrame *) NULL, -1, title, wxPoint(xpos, ypos), wxSize(width, height)),
00087 m_pMap(0), m_pDlgFind(0)
00088 {
00089
00090 InitMenu( );
00091
00092
00093 SetMenuBar( m_pMenuBar );
00094
00095
00096 SetIcon( wxIcon ( "./data/icons/wdsmap.ico", wxBITMAP_TYPE_ICO ) );
00097
00098
00099 InitToolBar( );
00100
00101
00102 m_pCanvas = new CGLCanvas( this );
00103 m_pCanvas->SetNextHandler( this );
00104
00105
00106 m_pDlgFind = new CDlgFind(this);
00107
00108
00109 const int nFields = 2;
00110 CreateStatusBar(nFields);
00111 SetStatusText("Ready", 0);
00112 int aWidths[nFields] = { -1, 150 };
00113 SetStatusWidths( nFields, aWidths );
00114
00115
00116 wxAcceleratorEntry entries[3];
00117 entries[0].Set( wxACCEL_CTRL, (int) 'G', IDM_GOTO );
00118 entries[1].Set( wxACCEL_CTRL, (int) 'F', IDM_SEARCH );
00119 entries[2].Set( wxACCEL_CTRL, (int) 'O', wxID_OPEN );
00120 wxAcceleratorTable accel( 3, entries );
00121 SetAcceleratorTable( accel );
00122
00123
00124 m_bPathStart = false;
00125 }
00126
00127 CFrame::~CFrame()
00128 {
00129 CProfile *pProfile = CProfileManager::GetCurrentProfile( );
00130 if( pProfile )
00131 {
00132 pProfile->SetLastScrollPosition( m_pCanvas->GetXPos(),
00133 m_pCanvas->GetYPos() );
00134 pProfile->SetLastZoom( m_pCanvas->GetZoom() );
00135 }
00136
00137
00138 if( m_pDlgFind )
00139 delete m_pDlgFind;
00140
00141
00142 if( m_pMap )
00143 delete m_pMap;
00144
00145
00146 wxSize szFrameSize = this->GetSize();
00147 wxConfigBase::Get()->SetPath( "/General" );
00148 wxConfigBase::Get()->Write( "window_width", szFrameSize.GetWidth() );
00149 wxConfigBase::Get()->Write( "window_height", szFrameSize.GetHeight() );
00150 wxConfigBase::Get()->Write( "window_maximized", this->IsMaximized() );
00151
00152
00153 CTile::Shut();
00154 }
00155
00156
00157
00158
00159
00160 void CFrame::InitMenu( )
00161 {
00162
00163 m_pMenuBar = new wxMenuBar();
00164
00165
00166 m_pFileMenu = new wxMenu();
00167
00168 m_pFileMenu->Append(wxID_NEW, "&Neues Profil...\tCtrl+N", "Erstellt ein neues Profil.");
00169 m_pFileMenu->AppendSeparator();
00170 m_pFileMenu->Append(IDM_EDIT_PROFILES, "Profile b&earbeiten...\tCtrl+E", "Profile erstellen, bearbeiten, löschen und wechseln.");
00171 m_pFileMenu->AppendSeparator();
00172 m_pFileMenu->Append(wxID_EXIT, "&Beenden", "WDSMap beenden.");
00173 m_pMenuBar->Append(m_pFileMenu, "&Datei");
00174
00175
00176 m_pFuncMenu = new wxMenu();
00177 m_pFuncMenu->Append( IDM_GOTO, "&GoTo...\tCtrl+G", "Zu einer andere x:y-Position springen." );
00178 m_pFuncMenu->Append( IDM_SEARCH, "&Suchen...\tCtrl+F", "Spieler, Gilden und Städte suchen." );
00179 m_pFuncMenu->AppendSeparator();
00180 m_pFuncMenu->Append( IDM_UPDATE, "&Update\tCtrl+U", "Karten-Update vom phpmap server durchführen." );
00181 m_pMenuBar->Append( m_pFuncMenu, "&Tools" );
00182
00183
00184 m_pViewMenu = new wxMenu();
00185 m_pViewMenu->Append( IDM_TOOLBAR, "&Toolbar", "Show / hide the toolbar.", wxITEM_CHECK );
00186 m_pViewMenu->Append( IDM_STATUSBAR, "&Statusbar", "Show / hide the statusbar.", wxITEM_CHECK );
00187 m_pViewMenu->AppendSeparator();
00188 m_pViewMenu->Append( IDM_FOGOFWAR, "&Fog of War", "Fog of War (Nebel des Krieges) zeigen.", wxITEM_CHECK );
00189 m_pViewMenu->Append( IDM_FULLSCREEN, "&Vollbild\tF11", "In den Vollbildmodus wechseln.", wxITEM_CHECK );
00190 m_pMenuBar->Append( m_pViewMenu, "&Ansicht" );
00191
00192
00193 m_pInfoMenu = new wxMenu();
00194 m_pInfoMenu->Append(IDM_ABOUT, "&About...", "Informationen über die WDSMap.");
00195 m_pMenuBar->Append(m_pInfoMenu, "I&nfo");
00196
00197
00198
00199 m_pViewMenu->FindItem(IDM_TOOLBAR )->Check( true );
00200 m_pViewMenu->FindItem(IDM_STATUSBAR)->Check( true );
00201
00202
00203 CProfile *pProfile = CProfileManager::GetCurrentProfile( );
00204 if ( pProfile ) {
00205 m_pViewMenu->FindItem(IDM_FOGOFWAR )->Check( pProfile->GetFogOfWar() );
00206 }
00207 }
00208
00209 void CFrame::InitToolBar( )
00210 {
00211
00212 long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT;
00213 wxToolBar *pToolBar = CreateToolBar( style, IDT_TOOLBAR );
00214
00215
00216 wxBitmap toolBarBitmaps[12];
00217 wxImage img;
00218 img.LoadFile( "./data/icons/new.png" ); toolBarBitmaps[ 0] = wxBitmap( img );
00219 img.LoadFile( "./data/icons/open.png" ); toolBarBitmaps[ 1] = wxBitmap( img );
00220 img.LoadFile( "./data/icons/close.png" ); toolBarBitmaps[ 2] = wxBitmap( img );
00221 img.LoadFile( "./data/icons/profiles.png" ); toolBarBitmaps[ 3] = wxBitmap( img );
00222 img.LoadFile( "./data/icons/search.png" ); toolBarBitmaps[ 4] = wxBitmap( img );
00223 img.LoadFile( "./data/icons/zoomout.png" ); toolBarBitmaps[ 5] = wxBitmap( img );
00224 img.LoadFile( "./data/icons/zoomin.png" ); toolBarBitmaps[ 6] = wxBitmap( img );
00225 img.LoadFile( "./data/icons/goto.png" ); toolBarBitmaps[ 7] = wxBitmap( img );
00226 img.LoadFile( "./data/icons/fogofwar.png" ); toolBarBitmaps[ 8] = wxBitmap( img );
00227 img.LoadFile( "./data/icons/fullscreen.png" ); toolBarBitmaps[ 9] = wxBitmap( img );
00228 img.LoadFile( "./data/icons/nofullscreen.png" ); toolBarBitmaps[10] = wxBitmap( img );
00229 img.LoadFile( "./data/icons/about.png" ); toolBarBitmaps[11] = wxBitmap( img );
00230
00231
00232 m_pCbZoom = new wxComboBox( pToolBar, IDC_CB_ZOOM, "", wxDefaultPosition, wxSize(80,-1) );
00233 m_pCbZoom->Append( "10%", (void*) 10 );
00234 m_pCbZoom->Append( "20%", (void*) 20 );
00235 m_pCbZoom->Append( "30%", (void*) 30 );
00236 m_pCbZoom->Append( "50%", (void*) 50 );
00237 m_pCbZoom->Append( "70%", (void*) 70 );
00238 m_pCbZoom->Append( "80%", (void*) 80 );
00239 m_pCbZoom->Append( "90%", (void*) 90 );
00240 m_pCbZoom->Append( "100%", (void*) 100 );
00241 m_pCbZoom->Append( "150%", (void*) 150 );
00242 m_pCbZoom->Append( "200%", (void*) 200 );
00243 m_pCbZoom->Append( "250%", (void*) 250 );
00244 m_pCbZoom->Append( "300%", (void*) 300 );
00245 m_pCbZoom->Append( "400%", (void*) 400 );
00246 m_pCbZoom->SetSelection( m_pCbZoom->FindString( "100%" ) );
00247
00248
00249 pToolBar->SetToolBitmapSize( wxSize(22, 22) );
00250
00251
00252 pToolBar->AddTool( wxID_NEW, toolBarBitmaps[0], "Neues Profil", "Ein neues Profil erstellen." );
00253 pToolBar->AddTool( wxID_OPEN, toolBarBitmaps[1], "Datei öffnen...", "Eine Map-Datei öffnen." );
00254 pToolBar->AddTool( wxID_CLOSE, toolBarBitmaps[2], "Profil schließen", "Aktuelles Profil schließen." );
00255 pToolBar->AddTool( IDM_EDIT_PROFILES, toolBarBitmaps[3], "Profile bearbeiten", "Profile erstellen, bearbeiten, löschen und wechseln.");
00256 pToolBar->AddSeparator();
00257 pToolBar->AddTool( IDM_SEARCH, toolBarBitmaps[4], "Suchen", "Spieler, Gilden und Städte suchen." );
00258 pToolBar->AddSeparator();
00259 pToolBar->AddTool( IDM_ZOOM_OUT, toolBarBitmaps[5], "Verkleinern", "Sichtbereich vergrößern." );
00260 pToolBar->AddControl( m_pCbZoom );
00261 pToolBar->AddTool( IDM_ZOOM_IN, toolBarBitmaps[6], "Vergrößern", "Sichtbereich verkleinern." );
00262 pToolBar->AddSeparator();
00263 pToolBar->AddTool( IDM_GOTO, toolBarBitmaps[7], "Go To", "Zu einer andere x:y-Position springen." );
00264 pToolBar->AddSeparator();
00265 pToolBar->AddTool( IDM_FOGOFWAR, "", toolBarBitmaps[8], toolBarBitmaps[8], wxITEM_CHECK, "Fog of War", "Fog of War (Nebel des Krieges) zeigen." );
00266 pToolBar->AddSeparator();
00267 pToolBar->AddTool( IDM_FULLSCREEN, "", toolBarBitmaps[9], toolBarBitmaps[10], wxITEM_CHECK, "Vollbild", "In den Vollbildmodus wechseln." );
00268 pToolBar->AddSeparator();
00269 pToolBar->AddTool( IDM_ABOUT, toolBarBitmaps[11], "About", "Informationen über die WDSMap." );
00270
00271
00272 pToolBar->Realize();
00273
00274
00275 CProfile *pProfile = CProfileManager::GetCurrentProfile( );
00276 if ( pProfile ) {
00277 pToolBar->ToggleTool( IDM_FOGOFWAR, pProfile->GetFogOfWar() );
00278 }
00279 }
00280
00287 void CFrame::Init( )
00288 {
00289
00290 m_pCanvas->Init();
00291
00292
00293 wxSplashScreen *pSplash = NULL;
00294
00295 wxBitmap bitmap;
00296 if( bitmap.LoadFile("data/about.png", wxBITMAP_TYPE_PNG) )
00297 {
00298 pSplash = new wxSplashScreen(bitmap, wxSPLASH_CENTRE_ON_SCREEN, 0, NULL, -1 );
00299 }
00300
00301
00302 CTile::Init();
00303
00304
00305 if( pSplash )
00306 delete pSplash;
00307
00308
00309 CProfile *pProfile = CProfileManager::GetCurrentProfile( );
00310 if( pProfile && pProfile->IsValid() )
00311 {
00312 LoadProfile( pProfile );
00313 UpdateCbZoom( );
00314 } else if ( wxGetApp().GetProfileManager()->size() == 0 ) {
00315
00316 }
00317
00318
00319 m_pCanvas->UpdateView();
00320 }
00321
00326 void CFrame::SetFullScreen( bool bFull )
00327 {
00328 if( bFull == IsFullScreen() )
00329 return;
00330
00331 ShowFullScreen( bFull, wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOBORDER |
00332 wxFULLSCREEN_NOCAPTION | wxFULLSCREEN_NOSTATUSBAR );
00333 m_pViewMenu->Check( IDM_FULLSCREEN, bFull );
00334 GetToolBar()->ToggleTool(IDM_FULLSCREEN, bFull);
00335 }
00336
00343 void CFrame::SwitchProfile( CProfile* newProfile )
00344 {
00345 if( newProfile == CProfileManager::GetCurrentProfile( ) )
00346 return;
00347
00348 if ( CProfile* profile = CProfileManager::GetCurrentProfile() ) {
00349
00350
00351 profile->SetLastScrollPosition( m_pCanvas->GetXPos(), m_pCanvas->GetYPos() );
00352 profile->SetLastZoom( m_pCanvas->GetZoom() );
00353 }
00354
00355
00356 if( m_pMap )
00357 delete m_pMap;
00358
00359 CProfileManager::SetCurrentProfile( newProfile );
00360
00361
00362 if( newProfile && newProfile->IsValid() ) {
00363 LoadProfile( newProfile );
00364 } else {
00365 m_pMap = NULL;
00366
00367
00368 m_pCanvas->SetZoom( 1.0f );
00369
00370 m_pCanvas->ScrollTo( 0, 0 );
00371 }
00372
00373 UpdateCbZoom( );
00374
00375
00376 m_bPathStart = false;
00377
00378
00379 m_pCanvas->UpdateView();
00380 }
00381
00386 void CFrame::LoadProfile( CProfile* newProfile )
00387 {
00388
00389 m_pCanvas->SetZoom( newProfile->GetLastZoom() );
00390 m_pCanvas->SetXYPos( newProfile->GetLastScrollPositionX(),
00391 newProfile->GetLastScrollPositionY() );
00392
00393 m_pMap = new CMap( );
00394 m_pMap->Load( newProfile->GetMap(), newProfile->GetDat() );
00395 }
00396
00401 void CFrame::GoTo( int x, int y )
00402 {
00403 if( m_pMap && m_pMap->IsValidField( x, y ) )
00404 {
00405 wxPoint pt = m_pMap->GetPosFromField( x, y );
00406 m_pCanvas->ScrollTo( pt.x, pt.y );
00407 CProfileManager::GetCurrentProfile()->AddRecentGoTo( x, y );
00408 }
00409 else
00410 {
00411 wxMessageBox( wxString::Format( "Feld %d:%d existiert nicht!", x, y ),
00412 "Fehler - WDSMap", wxOK | wxCENTER | wxICON_ERROR );
00413 }
00414 }
00415
00416
00417
00418
00419 void CFrame::OnQuit( wxEvent& event )
00420 {
00421 Close( true );
00422 }
00423
00424
00425
00426
00427
00428
00429 void CFrame::OnNew ( wxEvent &event )
00430 {
00431 CProfile *pProfile = new CProfile( );
00432
00433 CDlgEditProfile dlg( this, CDlgEditProfile::ADD, pProfile );
00434 dlg.Center();
00435 if( dlg.ShowModal() == wxID_OK )
00436 {
00437 wxGetApp().GetProfileManager()->AddProfile( pProfile );
00438
00439
00440 SwitchProfile( pProfile );
00441 } else {
00442 delete pProfile;
00443 }
00444 }
00445
00450 void CFrame::OnOpen( wxEvent &event )
00451 {
00452 }
00453
00458 void CFrame::OnClose( wxEvent &event )
00459 {
00460
00461 if( m_pMap == NULL )
00462 return;
00463
00464
00465 CProfile* p = CProfileManager::GetCurrentProfile();
00466
00467 wxMessageDialog dlg( this, "Profil \"" + p->GetName() + "\" wirklich schließen?",
00468 "Map schließen - WDSMap",
00469 wxYES_NO | wxCENTRE | wxICON_QUESTION );
00470
00471 if( dlg.ShowModal() == wxID_YES ) {
00472 SwitchProfile( 0L );
00473 }
00474 }
00475
00476 void CFrame::OnEditProfiles( wxEvent &event )
00477 {
00478 CDlgProfileManager dlg( this );
00479 dlg.Center( );
00480
00481
00482 dlg.ShowModal();
00483 }
00484
00485 void CFrame::OnZoomIn( wxEvent &event )
00486 {
00487 m_pCanvas->ZoomIn( );
00488 UpdateCbZoom( );
00489 }
00490
00491 void CFrame::OnZoomOut( wxEvent &event )
00492 {
00493 m_pCanvas->ZoomOut( );
00494 UpdateCbZoom( );
00495 }
00496
00497 void CFrame::OnCbZoom( wxCommandEvent& event )
00498 {
00499 int nSel = event.GetSelection( );
00500 int nPercent = (int) m_pCbZoom->GetClientData( nSel );
00501 m_pCanvas->SetZoom( nPercent / 100.0f );
00502 }
00503
00504 void CFrame::UpdateCbZoom()
00505 {
00506 float fZoom = m_pCanvas->GetZoom();
00507 int nPercent = (((int)(fZoom * 100) + 2) / 10) * 10;
00508 m_pCbZoom->SetValue( wxString::Format( "%d%%", nPercent ) );
00509 }
00510
00516 void CFrame::OnMenuGoTo( wxEvent &event )
00517 {
00518 if ( m_pMap ) {
00519 CDlgGoTo dlg( this );
00520 dlg.Center();
00521 if( dlg.ShowModal() == wxID_OK ) {
00522 int x = dlg.GetX();
00523 int y = dlg.GetY();
00524
00525 GoTo( x, y );
00526 }
00527 } else {
00528 wxMessageBox( "Es muss zuerst eine Map geladen werden.", "Fehler - WDSMap",
00529 wxOK | wxCENTER | wxICON_ERROR );
00530 }
00531 }
00532
00538 void CFrame::OnMenuFind( wxEvent &event )
00539 {
00540 m_pDlgFind->Center();
00541 m_pDlgFind->Show( );
00542 }
00543
00544 void CFrame::OnMenuFogOfWar( wxCommandEvent &event )
00545 {
00546 bool bFOW = event.IsChecked( );
00547
00548
00549 CProfile* profile = CProfileManager::GetCurrentProfile( );
00550 if ( profile ) {
00551 profile->SetFogOfWar( bFOW );
00552
00553
00554 m_pCanvas->Refresh( );
00555
00556 m_pViewMenu->Check( IDM_FOGOFWAR, bFOW );
00557 GetToolBar()->ToggleTool(IDM_FOGOFWAR, bFOW);
00558 }
00559 }
00560
00561 void CFrame::OnMenuFullScreen( wxCommandEvent &event )
00562 {
00563 SetFullScreen( !IsFullScreen() );
00564 }
00565
00566 void CFrame::OnMenuToolbar( wxCommandEvent &event )
00567 {
00568
00569 GetToolBar()->Show( event.IsChecked() );
00570 SendSizeEvent( );
00571 }
00572
00573 void CFrame::OnMenuStatusbar( wxCommandEvent &event )
00574 {
00575
00576 GetStatusBar()->Show( event.IsChecked() );
00577 SendSizeEvent( );
00578 }
00579
00580 void CFrame::OnMenuAbout( wxEvent &event )
00581 {
00582
00583 CDlgAbout dlgAbout( this );
00584 dlgAbout.Center();
00585 dlgAbout.ShowModal();
00586 }
00587
00588 void CFrame::OnUpdateClient( wxEvent &event )
00589 {
00590 CDlgUpdate dlg( this, CProfileManager::GetCurrentProfile() );
00591 dlg.Center();
00592 if( dlg.ShowModal() == wxID_OK )
00593 {
00594 string strUpdate = dlg.GetUpdateString( );
00595
00596
00597 m_pMap->Update( strUpdate );
00598
00599
00600 m_pCanvas->Refresh( );
00601 }
00602 }
00603
00604 void CFrame::OnMouseMove( wxMouseEvent &event )
00605 {
00606 static wxPoint ptOldField(-1, -1);
00607
00608
00609 if( m_pMap )
00610 {
00611
00612 wxPoint pt( event.GetX(), event.GetY() );
00613 m_pCanvas->ClientToOpenGL( pt );
00614 wxPoint ptField = m_pMap->GetFieldAtPoint( pt.x, pt.y );
00615
00616 if( ptField != ptOldField )
00617 {
00618 wxString str = wxString::Format( "X: %d, Y: %d", ptField.x, ptField.y );
00619
00620
00621 SetStatusText( str, 1 );
00622
00623 #ifdef SHOW_TOOLTIPS
00624
00625 m_pCanvas->GetToolTip()->SetTip( str );
00626 #endif
00627
00628 ptOldField = ptField;
00629 }
00630 }
00631 #ifdef SHOW_TOOLTIPS
00632
00633
00634
00635 static int n = 0;
00636 if( n++ % 5 == 0 )
00637 {
00638 wxToolTip::Enable( false );
00639 wxToolTip::Enable( true );
00640 }
00641 #endif
00642 }
00643
00648 void CFrame::OnMouseWheel( wxMouseEvent &event )
00649 {
00650 int nRot = event.GetWheelRotation();
00651 if( nRot > 0 )
00652 {
00653 m_pCanvas->ZoomIn( );
00654 }
00655 else if( nRot < 0 )
00656 {
00657 m_pCanvas->ZoomOut( );
00658 }
00659
00660 UpdateCbZoom();
00661 }
00662
00672 void CFrame::OnKeyDown( wxKeyEvent &event )
00673 {
00674 switch( event.GetKeyCode() )
00675 {
00676 case WXK_ESCAPE:
00677 if( IsFullScreen() )
00678 SetFullScreen( false );
00679 break;
00680
00681 case WXK_F11:
00682 SetFullScreen( !IsFullScreen() );
00683 break;
00684
00685 case WXK_NUMPAD_ADD:
00686 case '+':
00687 m_pCanvas->ZoomIn();
00688 UpdateCbZoom();
00689 break;
00690
00691 case WXK_NUMPAD_SUBTRACT:
00692 case '-':
00693 m_pCanvas->ZoomOut();
00694 UpdateCbZoom();
00695 break;
00696 }
00697 }
00698
00699 void CFrame::OnRButtonUp( wxMouseEvent &event )
00700 {
00701
00702 if( m_pMap == NULL )
00703 return;
00704
00705
00706 wxMenu menu;
00707 menu.Append( IDM_ADD_TO_FAVOURITES, "&Bookmark" );
00708 menu.AppendSeparator( );
00709 menu.Append( IDM_PATH_START, "Pfad&anfang" );
00710 menu.Append( IDM_PATH_END, "Pfad&ende" );
00711
00712
00713 if( m_bPathStart == false )
00714 menu.Enable( IDM_PATH_END, false );
00715
00716
00717 m_ptLastMousePos.x = event.GetX();
00718 m_ptLastMousePos.y = event.GetY();
00719
00720
00721 PopupMenu( &menu, event.GetX(), event.GetY() );
00722 }
00723
00724 void CFrame::OnPathStart( wxEvent &event )
00725 {
00726
00727 if( !m_pMap )
00728 return;
00729
00730
00731 int x = m_ptLastMousePos.x;
00732 int y = m_ptLastMousePos.y;
00733 m_pCanvas->ClientToOpenGL( x, y );
00734 m_ptPathStart = m_pMap->GetFieldAtPoint( x, y );
00735
00736
00737 m_bPathStart = true;
00738 }
00739
00740 void CFrame::OnPathEnd( wxEvent &event )
00741 {
00742
00743 if( !m_pMap || !m_bPathStart )
00744 return;
00745
00746
00747 int x = m_ptLastMousePos.x;
00748 int y = m_ptLastMousePos.y;
00749 m_pCanvas->ClientToOpenGL( x, y );
00750 m_ptPathEnd = m_pMap->GetFieldAtPoint( x, y );
00751
00752
00753 m_pMap->FindPath( m_ptPathStart.x, m_ptPathStart.y,
00754 m_ptPathEnd.x, m_ptPathEnd.y );
00755 }
00756
00757 void CFrame::OnAddToFavourites( wxEvent &event )
00758 {
00759 if( m_pMap ) {
00760
00761 int x = m_ptLastMousePos.x;
00762 int y = m_ptLastMousePos.y;
00763 m_pCanvas->ClientToOpenGL( x, y );
00764 wxPoint pt = m_pMap->GetFieldAtPoint( x, y );
00765
00766 CProfile* profile = CProfileManager::GetCurrentProfile();
00767
00768 if ( m_pMap->IsValidField( pt.x, pt.y ) && profile) {
00769 wxTextEntryDialog dlg( this, "Beschreibung eingeben:" );
00770 if ( dlg.ShowModal() == wxID_OK ) {
00771
00772 string lf = "\n";
00773 string space = " ";
00774 wxString tmp = dlg.GetValue();
00775 tmp.Replace( lf.c_str(), space.c_str() );
00776
00777 profile->AddBookmark( pt.x, pt.y, tmp );
00778 }
00779 }
00780 }
00781 }
00782
00783
00784
00785
00786
00787 }
00788
00789