/** * pawswritingwindow.cpp - Author: Daniel Fryer * * Copyright (C) 2006 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" #include "pawswritingwindow.h" // PAWS INCLUDES #include "paws/pawstextwrap.h" #include "paws/pawsmanager.h" #include "net/messages.h" #include "net/msghandler.h" #include "util/log.h" #define SAVE 103 pawsWritingWindow::pawsWritingWindow(){ } pawsWritingWindow::~pawsWritingWindow(){ psengine->GetMsgHandler()->Unsubscribe(this, MSGTYPE_WRITE_BOOK); } bool pawsWritingWindow::PostSetup() { // lefttext = dynamic_castFindWidget("left_text"); // righttext = dynamic_castFindWidget("right_text"); lefttext = dynamic_cast(FindWidget("body")); psengine->GetMsgHandler()->Subscribe(this, MSGTYPE_WRITE_BOOK); return true; } void pawsWritingWindow::HandleMessage( MsgEntry* me ) { psWriteBookMessage mesg(me); if(mesg.messagetype == mesg.RESPONSE){ slotID = mesg.slotID; containerID = mesg.containerID; parentContainerID = mesg.parentContainerID; //if I wasn't retarded I"d just keep mesg around instead if(mesg.success){ lefttext->SetText(mesg.content); Show(); } else { //this is bogus of course lefttext->SetText(mesg.content); Show(); } } } //When we close the window, we should send some sort of save or cancel message in case server //is tracking current writing task. Right now it doesn't. bool pawsWritingWindow::OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget ) { switch(widget->GetID()){ case SAVE: csString contents = lefttext->GetText(); psWriteBookMessage mesg(slotID, containerID, parentContainerID, contents); mesg.SendMessage(); return true; //just for fun: break; } return false; }