Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

pgwidgetlist.cpp

Go to the documentation of this file.
00001 /*
00002     ParaGUI - crossplatform widgetset
00003     Copyright (C) 2000,2001,2002  Alexander Pipelka
00004  
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009  
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014  
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  
00019     Alexander Pipelka
00020     pipelka@teleweb.at
00021  
00022     Last Update:      $Author: mbickel $
00023     Update Date:      $Date: 2007-04-13 16:16:04 $
00024     Source File:      $Source: /home/cvspsrv/cvsroot/games/asc/source/libs/paragui/src/widgets/pgwidgetlist.cpp,v $
00025     CVS/RCS Revision: $Revision: 1.2 $
00026     Status:           $State: Exp $
00027 */
00028 
00029 #include "pgwidgetlist.h"
00030 #include "pgapplication.h"
00031 #include "pgscrollarea.h"
00032 #include "pglog.h"
00033 
00034 
00035 PG_WidgetList::PG_WidgetList(PG_Widget* parent, const PG_Rect& r, const std::string& style) : PG_ScrollWidget(parent, r, style) {
00036         my_scrollarea->SetShiftOnRemove(false, true);
00037 
00038         if(style != "WidgetList") {
00039                 LoadThemeStyle("WidgetList");
00040         }
00041         LoadThemeStyle(style);
00042 }
00043 
00044 PG_WidgetList::~PG_WidgetList() {}
00045 
00046 void PG_WidgetList::AddChild(PG_Widget* w) {
00047         if(w == NULL) {
00048                 return;
00049         }
00050 
00051         if (my_objVerticalScrollbar == NULL || my_objHorizontalScrollbar == NULL || my_scrollarea == NULL) {
00052                 PG_Widget::AddChild(w);
00053                 return;
00054         }
00055 
00056         w->MoveRect(0, w->my_ypos + my_scrollarea->GetAreaHeight());
00057         my_scrollarea->AddChild(w);
00058 }
00059 
00060 PG_Widget* PG_WidgetList::GetWidgetFromPos(Sint32 y) {
00061         Uint32 dy = 0;
00062         Uint32 min_dy = 100000000;
00063 
00064         PG_Widget* result = NULL;
00065 
00066         PG_Widget* list = GetChildList()->first();
00067         for( ; list != NULL; list = list->next()) {
00068                 dy = abs(0- (list->my_ypos - my_ypos));
00069 
00070                 if(dy < min_dy) {
00071                         min_dy = dy;
00072                         result = list;
00073                 }
00074         }
00075 
00076         return result;
00077 }
00078 
00079 PG_Widget* PG_WidgetList::FindWidget(int index) {
00080 
00081         if((index < 0) || (index >= GetWidgetCount())) {
00082                 return NULL;
00083         }
00084 
00085         int i = 0;
00086         PG_Widget* list = my_scrollarea->GetChildList()->first();
00087         for( ; list != NULL; list = list->next()) {
00088                 if(i == index) {
00089                         return list;
00090                 }
00091                 i++;
00092         }
00093 
00094         return NULL;
00095 }
00096 
00097 int PG_WidgetList::FindIndex(PG_Widget* w) {
00098         int index = 0;
00099 
00100         PG_Widget* list = GetChildList()->first();
00101         for( ; list != NULL; list = list->next()) {
00102                 if(list == w) {
00103                         return index;
00104                 }
00105                 index++;
00106         }
00107 
00108         return -1;
00109 }
00110 
00111 void PG_WidgetList::ScrollTo(Uint16 ypos) {
00112         my_scrollarea->ScrollTo(my_scrollarea->GetScrollPosX(), ypos);
00113         CheckScrollBars();
00114 }
00115 
00116 void PG_WidgetList::PageUp() {
00117         my_scrollarea->ScrollTo(my_scrollarea->GetScrollPosX(), my_scrollarea->GetScrollPosY() - my_height );
00118         CheckScrollBars();
00119 }
00120 
00121 void PG_WidgetList::PageDown() {
00122         my_scrollarea->ScrollTo(my_scrollarea->GetScrollPosX(), my_scrollarea->GetScrollPosY() + my_height );
00123         CheckScrollBars();
00124 }

Generated on Tue Jun 24 01:27:50 2008 for Advanced Strategic Command by  doxygen 1.4.2