00001 // 00002 // $Id: scrollbar.cpp 2 2008-03-01 20:58:50Z kulibali $ 00003 // 00004 // Copyright (c) 2008, The Periapsis Project. All rights reserved. 00005 // 00006 // Redistribution and use in source and binary forms, with or without 00007 // modification, are permitted provided that the following conditions are 00008 // met: 00009 // 00010 // * Redistributions of source code must retain the above copyright notice, 00011 // this list of conditions and the following disclaimer. 00012 // 00013 // * Redistributions in binary form must reproduce the above copyright 00014 // notice, this list of conditions and the following disclaimer in the 00015 // documentation and/or other materials provided with the distribution. 00016 // 00017 // * Neither the name of the The Periapsis Project nor the names of its 00018 // contributors may be used to endorse or promote products derived from 00019 // this software without specific prior written permission. 00020 // 00021 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00022 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00023 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00024 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 00025 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00026 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00027 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00028 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00029 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00030 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00031 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 // 00033 00034 #include "framework/scrollbar.hpp" 00035 #include "math/vector.hpp" 00036 #include "platform/lowlevel.hpp" 00037 00038 namespace gsgl 00039 { 00040 00041 using namespace data; 00042 using namespace math; 00043 using namespace platform; 00044 00045 namespace framework 00046 { 00047 00048 config_variable<int> scrollbar::ARROW_SIZE(L"framework/scrollbar/arrow_size", 10); 00049 00050 00051 scrollbar::scrollbar(widget *parent, 00052 int x, int y, int w, int h, 00053 const color & fg, const color & bg, 00054 bar_mode mode) 00055 : widget(parent, x, y, w, h, fg, bg), min_val(0), max_val(0), pos(0), extent(0), mode(mode) 00056 { 00057 //LOG_BASIC(L"ui: creating scrollbar"); 00058 } // scrollbar::scrollbar() 00059 00060 00061 scrollbar::~scrollbar() 00062 { 00063 //LOG_BASIC(L"ui: destroying scrollbar"); 00064 } // scrollbar::~scrollbar() 00065 00066 00067 void scrollbar::draw() 00068 { 00069 assert(max_val >= min_val); 00070 assert(pos >= min_val); 00071 assert(pos <= max_val); 00072 assert(pos + extent <= max_val); 00073 00074 widget::draw(); 00075 00076 glPushAttrib(GL_ALL_ATTRIB_BITS); 00077 glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); 00078 00079 get_foreground().set(); 00080 glLineWidth(3.0f); 00081 00082 if (mode == VERTICAL) 00083 { 00084 // draw up arrow 00085 00086 // draw down arrow 00087 } 00088 else 00089 { 00090 } 00091 00092 glPopClientAttrib(); 00093 glPopAttrib(); 00094 } // scrollbar::draw() 00095 00096 } // namespace framework 00097 00098 } // namespace gsgl