Back to index

nux  3.0.0
RangeValue.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef RANGEVALUE_H
00024 #define RANGEVALUE_H
00025 
00026 namespace nux
00027 {
00028 
00029   class HLayout;
00030   class EditTextBox;
00031 
00032   class RangeValue : public View
00033   {
00034     NUX_DECLARE_OBJECT_TYPE(RangeValue, View);
00035   public:
00036     RangeValue(float Value = 0, float MinValue = 0.0f, float MaxValue = 1.0f, NUX_FILE_LINE_PROTO);
00037     virtual ~RangeValue();
00038 
00039     void DrawMarker(GraphicsEngine &graphics_engine);
00040     virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
00041     virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
00042     virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw);
00043 
00045     //  RECEIVERS  //
00047     void SetRange(float min_value, float max_value);
00048     void SetValue(float value);
00049     float GetValue() const;
00050     float GetMinValue() const
00051     {
00052       return m_min;
00053     }
00054     float GetMaxValue() const
00055     {
00056       return m_max;
00057     }
00058 
00059     void SetBackgroundColor(const Color &color);
00060     const Color GetBackgroundColor() const;
00061 
00062     void setStartToEndColor(Color color_start, Color color_end)
00063     {
00064       m_StartColor = color_start;
00065       m_EndColor = color_end;
00066     }
00067     void setStartColor(Color color)
00068     {
00069       m_StartColor = color;
00070     }
00071     void setEndColor(Color color)
00072     {
00073       m_EndColor = color;
00074     }
00075     void setProgressColor(Color color)
00076     {
00077       m_ProgressColor = color;
00078     }
00079     void EnableDrawProgress(bool b)
00080     {
00081       m_EnableDrawProgress = b;
00082     }
00083 
00085     //  EMITTERS  //
00087     void OnReceiveMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
00088     void OnReceiveMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
00089     void OnReceiveMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00090     void OnKeyboardFocus();
00091     void OnLostKeyboardFocus();
00092     void OnValidateKeyboardEntry(EditTextBox *textbox, const NString &text);
00093 
00094     bool IsCtrlKeyPressed() const
00095     {
00096       return (m_CTRL_KEY ? true : false);
00097     }
00098 
00099     // signals
00100     sigc::signal<void, RangeValue *> sigValueChanged;
00101     sigc::signal<void, float> sigFloatChanged;
00102     sigc::signal<void, float> sigMouseDown;
00103     sigc::signal<void, float> sigMouseUp;
00104     sigc::signal<void, float> sigMouseDrag;
00105     sigc::signal<void, float> sigSetTypedValue;
00106     //sigc::signal<void, const char*> sigValidateKeyboarEntry;
00107 
00108     void EmitFloatChangedSignal();
00109 
00110   protected:
00111     void InitializeWidgets();
00112     void InitializeLayout();
00113 
00114   protected:
00115     HLayout        *hlayout;
00116     EditTextBox    *m_ValueString;
00117     InputArea       *m_Percentage;
00118     Color m_StartColor;
00119     Color m_EndColor;
00120     Color m_ProgressColor;
00121     Color m_BackgroundColor;
00122     bool m_EnableDrawProgress;
00123 
00124     long m_CTRL_KEY;
00125 
00126     float m_Value;
00127     float m_min, m_max;
00128 
00129   };
00130 
00131 }
00132 
00133 #endif // RANGEVALUE_H
00134 
00135