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

Popup.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id:  $
00022 */
00023 
00024 
00025 #include "Teddy/PhysicalComponents/Popup.h"
00026 #include "Teddy/PhysicalComponents/ActionButton.h"
00027 #include "Teddy/PhysicalComponents/Style.h"
00028 #include "Teddy/SysSupport/Messages.h"
00029 #include "Teddy/PhysicalComponents/Button.h"
00030 #include "Teddy/SysSupport/StdIO.h"
00031 using namespace Teddy::SysSupport;
00032 using namespace Teddy::Signals;
00033 
00034 
00035 #if defined( _MSC_VER )
00036 # include <limits>
00037 #else
00038 extern "C" {
00039 #include <limits.h>
00040 }
00041 #endif
00042 
00043 
00044 namespace Teddy              {
00045 namespace PhysicalComponents {
00046 
00047 
00049 Popup::Popup( std::string name, Area *closed, Area *open )
00050 :Dock(name)
00051 {
00052     area_closed  = closed;
00053     area_open    = open;
00054     is_open      = false;
00055     insert( area_closed );
00056 }
00057 
00058 
00059 Popup::Popup( std::string name, Area *open )
00060 :Dock(name)
00061 {
00062     area_closed  = new ActionButton( name, functor(this, &Popup::open) );
00063     area_open    = open;
00064     is_open      = false;
00065     insert( area_closed );
00066 }
00067 
00068 
00069 
00070 
00072 /*virtual*/ Popup::~Popup(){
00073 }
00074 
00075 
00076 void Popup::setClosed( Area *closed ){
00077     area_closed = closed;
00078 }
00079 
00080 void Popup::setOpen( Area *open ){
00081     area_open = open;
00082 }
00083 
00084 
00085 bool Popup::isOpen(){
00086     return is_open;
00087 }
00088 
00089 
00090 bool Popup::open(){
00091     if( !is_open ){
00092         is_open = true;
00093         remove( area_closed );
00094         insert( area_open );
00095         if( parent != NULL ){
00096             window_manager->update();
00097         }
00098     }
00099     return true;
00100 }
00101 
00102 
00103 Area *Popup::getCurrent(){
00104     if( is_open ){
00105         return area_open;
00106     }else{
00107         return area_closed;
00108     }
00109 }
00110 
00111 bool Popup::close(){
00112     if( is_open ){
00113         is_open = false;
00114         remove( area_open );
00115         insert( area_closed );
00116         if( parent != NULL ){
00117             window_manager->update();
00118         }
00119     }
00120     return true;
00121 }
00122 
00123 
00124 };  //  namespace PhysicalComponents
00125 };  //  namespace Teddy
00126