From: Luca P. <lpa...@us...> - 2002-12-25 18:38:30
|
Update of /cvsroot/planeshift/planeshift/src/client/aws In directory sc8-pr-cvs1:/tmp/cvs-serv15583 Added Files: psconfirmwindow.h psconfirmwindow.cpp Log Message: confirm window --- NEW FILE: psconfirmwindow.h --- /* * psconfirmwindow.h * * Copyright (C) 2001 PlaneShift Team (in...@pl..., * http://www.planeshift.it) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation (version 2 of the License) * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Class definitions for: * psConfirmWindow - Used to display a yes/no Dialog. */ #ifndef PS_AWS_CONFIRM_WINDOW #define PS_AWS_CONFIRM_WINDOW #include "iclient/iwinmgr.h" #include "psinventorywindow.h" /// This is a generic window used to display a yes/no Dialog. class psConfirmWindow : public iPSWindow { public: psConfirmWindow( iObjectRegistry* object_reg ); virtual ~psConfirmWindow(); virtual char* GetName() { return "Confirm Window"; } virtual iAwsWindow* GetAWSWindow() { return confirmWindow; } bool SendCommand( const char* , void* ) { return false; } bool Create( iAws* aws ); void CreateSink ( iAws* aws ); static void ToggleYes( void* sink, iAwsSource* source ); static void ToggleNo ( void* sink, iAwsSource* source ); void Quit(); protected: iAwsWindow* confirmWindow; iObjectRegistry* object_reg; iAwsSink* sink; }; #endif --- NEW FILE: psconfirmwindow.cpp --- /* * psconfirmwindow.cpp * * Copyright (C) 2001 PlaneShift Team (in...@pl..., * http://www.planeshift.it) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation (version 2 of the License) * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Implements a generic window used to display a yes/no Dialog. */ #include <config.h> // CS INCLUDES #include <iaws/aws.h> #include <iutil/objreg.h> // PS INCLUDES #include "psconfirmwindow.h" #include "iclient/psengine.h" #include "iclient/iwinmgr.h" psConfirmWindow::psConfirmWindow( iObjectRegistry* obj ) { object_reg = obj; } psConfirmWindow::~psConfirmWindow() { } /* * Creates the confirm window. */ bool psConfirmWindow::Create( iAws* aws ) { if ( aws == NULL ) return false; CreateSink(aws); aws->GetPrefMgr()->Load("/planeshift/gui/confirm.def"); confirmWindow = aws->CreateWindowFrom("Confirm Dialog"); if ( !confirmWindow ) { printf("<Confirm Dialog> not found!\n"); return false; } // center window on screen: that assumes the window is 512x256 int x = (aws->G3D()->GetWidth()/2) - 512/2; int y = (aws->G3D()->GetHeight()/2) - 256/2; confirmWindow->MoveTo(x,y); confirmWindow->Show(); return true; } void psConfirmWindow::CreateSink( iAws* aws ) { sink = aws->GetSinkMgr()->CreateSink(this); sink->RegisterTrigger("ToggleYes", &psConfirmWindow::ToggleYes); sink->RegisterTrigger("ToggleNo", &psConfirmWindow::ToggleNo); aws->GetSinkMgr()->RegisterSink("ConfirmWindow", sink); } void psConfirmWindow::ToggleYes( void* sink, iAwsSource* ) { psConfirmWindow* window = ( psConfirmWindow* ) sink; window->Quit(); } void psConfirmWindow::Quit() { csRef<iPSEngine> psengine = CS_QUERY_REGISTRY(object_reg, iPSEngine); psengine->SwitchStatus("quit"); } void psConfirmWindow::ToggleNo( void* sink, iAwsSource* ) { psConfirmWindow* window = ( psConfirmWindow* ) sink; window->GetAWSWindow()->Hide(); } |