/* * pawsbookreadingwindow.cpp - Author: Daniel Fryer, based on code by Andrew Craig * * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org) * * * 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. * */ #include #include "globals.h" // CS INCLUDES #include #include // COMMON INCLUDES #include // CLIENT INCLUDES #include "pscelclient.h" // PAWS INCLUDES #include "paws/pawstextbox.h" #include "paws/pawsmanager.h" #include "net/messages.h" #include "net/msghandler.h" #include "util/log.h" #include "pawsbookreadingwindow.h" #define EDIT 1001 ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// bool pawsBookReadingWindow::PostSetup() { msgHandler = psengine->GetMsgHandler(); if ( !msgHandler ) return false; if ( !msgHandler->Subscribe( this, MSGTYPE_READ_BOOK ) ) return false; // Store some of our children for easy access later on. name = dynamic_cast (FindWidget("ItemName")); if ( !name ) return false; description = dynamic_cast (FindWidget("ItemDescription")); if ( !description ) return false; writeButton = dynamic_cast (FindWidget("WriteButton")); //if ( !writeButton ) return false; return true; } void pawsBookReadingWindow::HandleMessage( MsgEntry* me ) { Show(); psReadBookTextMessage mesg( me ); description->SetText( mesg.text ); name->SetText( mesg.name ); slotID = mesg.slotID; containerID = mesg.containerID; parentContainerID = mesg.parentContainerID; if( writeButton ){ if( mesg.canWrite ) writeButton->Show(); else writeButton->Hide(); } } bool pawsBookReadingWindow::OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget ) { if(widget->GetID() == EDIT){ //attempt to write on this book psWriteBookMessage msg(slotID, containerID, parentContainerID); msg.SendMessage(); return true; } else { //it must have been the close button Hide(); PawsManager::GetSingleton().SetCurrentFocusedWidget( NULL ); return true; } }