TargetGump.cpp

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2004-2005  The Pentagram Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #include "pent_include.h"
00020 #include "TargetGump.h"
00021 
00022 #include "GUIApp.h"
00023 #include "GumpNotifyProcess.h"
00024 #include "Item.h"
00025 #include "getObject.h"
00026 
00027 #include "IDataSource.h"
00028 #include "ODataSource.h"
00029 
00030 DEFINE_RUNTIME_CLASSTYPE_CODE(TargetGump,ModalGump);
00031 
00032 TargetGump::TargetGump() : ModalGump(), target_tracing(false)
00033 {
00034 
00035 }
00036 
00037 
00038 TargetGump::TargetGump(int x, int y)
00039         : ModalGump(x, y, 0, 0), target_tracing(false)
00040 {
00041 
00042 }
00043 
00044 TargetGump::~TargetGump()
00045 {
00046 
00047 }
00048 
00049 void TargetGump::PaintThis(RenderSurface* surf, sint32 lerp_factor, bool scaled)
00050 {
00051         // we're invisible
00052 }
00053 
00054 void TargetGump::InitGump(Gump* newparent, bool take_focus)
00055 {
00056         ModalGump::InitGump(newparent, take_focus);
00057 
00058         // we need a notifier process
00059         CreateNotifier();
00060 
00061         GUIApp* guiapp = GUIApp::get_instance();
00062         guiapp->pushMouseCursor();
00063         guiapp->setMouseCursor(GUIApp::MOUSE_TARGET);
00064 }
00065 
00066 void TargetGump::Close(bool no_del)
00067 {
00068         GUIApp* guiapp = GUIApp::get_instance();
00069         guiapp->popMouseCursor();
00070 
00071         ModalGump::Close(no_del);
00072 }
00073 
00074 bool TargetGump::PointOnGump(int mx, int my)
00075 {
00076         // HACK alert: if we're currently tracing from TargetGump::OnMouseUp,
00077         //  then we do NOT want to intercept the trace
00078         if (target_tracing) return false;
00079 
00080         return ModalGump::PointOnGump(mx, my);
00081 }
00082 
00083 void TargetGump::OnMouseUp(int button, int mx, int my)
00084 {
00085         target_tracing = true;
00086 
00087         parent->GumpToScreenSpace(mx, my);
00088 
00089         Gump* desktopgump = parent;
00090         ObjId objid = desktopgump->TraceObjId(mx, my);
00091         Item *item = getItem(objid);
00092 
00093         if (item) {
00094                 // done
00095                 pout << "Target result: ";
00096                 item->dumpInfo();
00097 
00098                 process_result = objid;
00099                 Close();
00100         }
00101 
00102         target_tracing = false;
00103 }
00104 
00105 uint32 TargetGump::I_target(const uint8* /*args*/, unsigned int /*argsize*/)
00106 {
00107         TargetGump* targetgump = new TargetGump(0, 0);
00108         targetgump->InitGump(0);
00109 
00110         return targetgump->GetNotifyProcess()->getPid();
00111 }
00112 
00113 
00114 
00115 void TargetGump::saveData(ODataSource* ods)
00116 {
00117         CANT_HAPPEN_MSG("Trying to save ModalGump");
00118 }
00119 
00120 bool TargetGump::loadData(IDataSource* ids, uint32 versin)
00121 {
00122         CANT_HAPPEN_MSG("Trying to load ModalGump");
00123         return false;
00124 }

Generated on Fri Jul 27 22:27:41 2007 for pentagram by  doxygen 1.4.7