Gump_widget.cc

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2000 The Exult Team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (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 
00020 #ifdef HAVE_CONFIG_H
00021 #  include <config.h>
00022 #endif
00023 
00024 #include "gamewin.h"
00025 #include "Gump.h"
00026 #include "Gump_widget.h"
00027 
00028 /*
00029  *  Is a given screen point on this widget?
00030  */
00031 
00032 int Gump_widget::on_widget
00033   (
00034   int mx, int my      // Point in window.
00035   )
00036 {
00037   mx -= parent->get_x() + x;  // Get point rel. to gump.
00038   my -= parent->get_y() + y;
00039   Shape_frame *cshape = get_shape();
00040   return (cshape!=0)?cshape->has_point(mx, my):false;
00041 }
00042 
00043 /*
00044  *  Repaint checkmark, etc.
00045  */
00046 
00047 void Gump_widget::paint
00048   (
00049   )
00050 {
00051   int px = 0;
00052   int py = 0;
00053 
00054   if (parent)
00055   {
00056     px = parent->get_x();
00057     py = parent->get_y();
00058   }
00059 
00060   paint_shape(x+px, y+py);
00061 }
00062 
00063 /*
00064  *  Get screen area used by a gump.
00065  */
00066 
00067 Rectangle Gump_widget::get_rect()
00068 {
00069   int px = x;
00070   int py = y;
00071 
00072   if (parent)
00073   {
00074     px += parent->get_x();
00075     py += parent->get_y();
00076   }
00077 
00078   Shape_frame *s = get_shape();
00079 
00080   if (!s) return Rectangle(0,0,0,0);
00081 
00082   return Rectangle(px - s->get_xleft(),   py - s->get_yabove(),
00083       s->get_width(), s->get_height());
00084 }

Generated on Mon Jul 9 14:42:46 2007 for ExultEngine by  doxygen 1.5.1