nux-0.9.46

Nux/RangeValueInteger.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 RANGEVALUEINTEGER_H
00024 #define RANGEVALUEINTEGER_H
00025 
00026 namespace nux
00027 {
00028 
00029   class HLayout;
00030   class EditTextBox;
00031 
00032   class RangeValueInteger : public View
00033   {
00034   public:
00035     RangeValueInteger (int Value = 0, int MinValue = 0, int MaxValue = 100, NUX_FILE_LINE_PROTO);
00036     ~RangeValueInteger();
00037 
00038     virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00039     void DrawMarker (GraphicsEngine &GfxContext);
00040     virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
00041     virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);
00042     virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
00043 
00045     //  RECEIVERS  //
00047     void SetRange (int min_value, int max_value);
00048     void SetValue (int value);
00049     int GetValue() const;
00050     int GetMinValue() const
00051     {
00052       return m_min;
00053     }
00054     int GetMaxValue() const
00055     {
00056       return m_max;
00057     }
00058 
00059     void SetBackgroundColor (const Color &color)
00060     {
00061       m_ValueString->SetTextBackgroundColor (color);
00062     }
00063     const Color GetBackgroundColor() const
00064     {
00065       return m_ValueString->GetTextBackgroundColor();
00066     }
00067 
00068     void setStartToEndColor (Color color_start, Color color_end)
00069     {
00070       m_StartColor = color_start;
00071       m_EndColor = color_end;
00072     }
00073     void setStartColor (Color color)
00074     {
00075       m_StartColor = color;
00076     }
00077     void setEndColor (Color color)
00078     {
00079       m_EndColor = color;
00080     }
00081     void setProgressColor (Color color)
00082     {
00083       m_ProgressColor = color;
00084     }
00085     void EnableDrawProgress (bool b)
00086     {
00087       m_EnableDrawProgress = b;
00088     }
00089 
00091     //  EMITTERS  //
00093     void OnReceiveMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00094     void OnReceiveMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
00095     void OnReceiveMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00096     void OnKeyboardFocus();
00097     void OnLostKeyboardFocus();
00098     void OnValidateKeyboardEntry (EditTextBox *textbox, const NString &text);
00099 
00100     bool IsCtrlKeyPressed() const
00101     {
00102       return (m_CTRL_KEY ? true : false);
00103     }
00104 
00105     // signals
00106     sigc::signal<void, RangeValueInteger *> sigValueChanged;
00107     sigc::signal<void, int> sigMouseDown;
00108     sigc::signal<void, int> sigMouseUp;
00109     sigc::signal<void, int> sigMouseDrag;
00110     sigc::signal<void, int> sigSetTypedValue;
00111     sigc::signal<void, int> sigValueChanged2;
00112     //sigc::signal<void, const char*> sigValidateKeyboarEntry;
00113 
00114     void BroadcastValue ();
00115   protected:
00116     void InitializeWidgets();
00117     void InitializeLayout();
00118     void DestroyLayout();
00119 
00120   protected:
00121     HLayout        *hlayout;
00122     EditTextBox    *m_ValueString;
00123     InputArea       *m_Percentage;
00124     Color m_StartColor;
00125     Color m_EndColor;
00126     Color m_ProgressColor;
00127     Color m_BackgroundColor;
00128     bool m_EnableDrawProgress;
00129 
00130     long m_CTRL_KEY;
00131 
00132     float m_MarkerPosition;
00133     int m_Value;
00134     int m_min, m_max;
00135 
00136   };
00137 
00138 }
00139 
00140 #endif // RANGEVALUEINTEGER_H
00141 
00142