Back to index

nux  3.0.0
HSplitter.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 HSPLITTER_H
00024 #define HSPLITTER_H
00025 
00026 namespace nux
00027 {
00028   class Layout;
00029 
00030   class HSplitter: public View
00031   {
00032     NUX_DECLARE_OBJECT_TYPE(HSplitter, View);
00033   public:
00034     HSplitter(NUX_FILE_LINE_PROTO);
00035     ~HSplitter();
00036 
00037     virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
00038     virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
00039     virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw);
00040 
00041     void AddWidget(Area *ic, float stretchfactor);
00042     void ResetSplitConfig();
00043 
00044     void clearContent();
00045 
00046     void OnSplitterMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags, int header_pos);
00047     void OnSplitterMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags, int header_pos);
00048     void OnSplitterMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags, int header_pos);
00049 
00050     virtual void OverlayDrawing(GraphicsEngine &graphics_engine);
00051 
00053     /*
00054         Return true if this object can break the layout, meaning, the layout can be done on the composition layout only without
00055         recomputing the whole window layout.
00056         Inherited from Area
00057     */
00058     virtual bool CanBreakLayout()
00059     {
00060       return true;
00061     }
00062 
00063     virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
00064 
00065   protected:
00066     virtual long ComputeContentSize();
00067     virtual void DoneRedraw();
00068     void ResizeSplitter(int header_pos);
00069     //void ContinuousSplitterAdjustment();
00070     void setResizeOnSplitterRelease(bool b)
00071     {
00072       m_ResizeOnSplitterRelease = b;
00073     }
00074     bool getResizeOnSplitterRelease()
00075     {
00076       return m_ResizeOnSplitterRelease;
00077     }
00078 
00079     virtual bool AcceptKeyNavFocus();
00080     virtual Area* KeyNavIteration(KeyNavDirection direction);
00081 
00082   private:
00083     typedef InputArea MySplitter;
00084     std::vector<Area *> m_InterfaceObject;
00085     std::vector<MySplitter *> m_SplitterObject;
00086     std::vector<float> m_SplitConfig;
00087 
00088     Point m_point;
00089     bool new_addition;
00090 
00091     bool m_ResizeOnSplitterRelease;
00092     int m_current_width;
00093     int m_current_height;
00094     int m_current_x;
00095     int m_current_y;
00096 
00097     bool m_initial_config;
00098 
00099     // splitter bar differential position;
00100     int mvt_dx, mvt_dy;
00101     int m_focus_splitter_index;
00102   };
00103 
00104 }
00105 
00106 #endif // HSPLITTER_H
00107 
00108