00001 #ifndef PERIAPSIS_DATETIME_BOX_H 00002 #define PERIAPSIS_DATETIME_BOX_H 00003 00004 // 00005 // $Id: datetime_box.hpp 2 2008-03-01 20:58:50Z kulibali $ 00006 // 00007 // Copyright (c) 2008, The Periapsis Project. All rights reserved. 00008 // 00009 // Redistribution and use in source and binary forms, with or without 00010 // modification, are permitted provided that the following conditions are 00011 // met: 00012 // 00013 // * Redistributions of source code must retain the above copyright notice, 00014 // this list of conditions and the following disclaimer. 00015 // 00016 // * Redistributions in binary form must reproduce the above copyright 00017 // notice, this list of conditions and the following disclaimer in the 00018 // documentation and/or other materials provided with the distribution. 00019 // 00020 // * Neither the name of the The Periapsis Project nor the names of its 00021 // contributors may be used to endorse or promote products derived from 00022 // this software without specific prior written permission. 00023 // 00024 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00025 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00026 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00027 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 00028 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00029 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00030 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00031 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00032 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00033 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00034 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 // 00036 00037 #include "framework/widget.hpp" 00038 #include "framework/textbox.hpp" 00039 00040 namespace periapsis 00041 { 00042 00043 class datetime_box 00044 : public gsgl::framework::widget 00045 { 00046 gsgl::framework::textbox *label; 00047 gsgl::framework::textbox *julian_input; 00048 gsgl::framework::textbox *text_input; 00049 00050 double jdn; 00051 00052 enum recalc_mode 00053 { 00054 RECALC_NONE = 0, 00055 RECALC_TEXT = 1, 00056 RECALC_JDN = 2, 00057 RECALC_BOTH = 3 00058 }; 00059 00060 recalc_mode mode; 00061 00062 public: 00063 datetime_box(widget *parent, int x, int y, int w, int h, const gsgl::platform::color & fg, const gsgl::platform::color & bg); 00064 virtual ~datetime_box(); 00065 00066 const double & get_jdn() const; 00067 void set_jdn(const double &); 00068 00069 const gsgl::string & get_text() const; 00070 void set_text(const gsgl::string &); 00071 00072 virtual void draw(); 00073 00074 private: 00075 void recalc_text(); 00076 void recalc_jdn(); 00077 }; // class datetime_box 00078 00079 } // namespace periapsis 00080 00081 #endif