Back to index

nux  3.0.0
View.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 ABSTRACTOBJECTBASE_H
00024 #define ABSTRACTOBJECTBASE_H
00025 
00026 #include "Nux.h"
00027 #include "NuxCore/Property.h"
00028 
00029 #define NeedRedraw QueueDraw
00030 
00031 namespace nux
00032 {
00033   class Layout;
00034 
00035   class View: public InputArea
00036   {
00037     NUX_DECLARE_OBJECT_TYPE(View, InputArea);
00038   public:
00039     View(NUX_FILE_LINE_DECL);
00040     virtual ~View();
00041 
00042   public:
00043 
00044     /*
00045         If ComputeContentSize is called while outside of the layout process (\sa IsInsideLayoutCycle) then the parents of 
00046         this object maybe added to the layout queue if this view size changes. \sa Area::ReconfigureParentLayout.
00047 
00048     */
00049     virtual long ComputeContentSize();
00050     virtual void ComputeContentPosition(float offsetX, float offsetY);
00051 
00053 
00057     virtual void EnableView();
00058 
00060 
00064     virtual void DisableView();
00065 
00067 
00072     virtual void SetEnableView(bool enable);
00073 
00075 
00078     bool IsViewEnabled() const;
00079 
00080   public:
00081     virtual void ProcessDraw(GraphicsEngine &graphics_engine, bool force_draw);
00083 
00086     virtual void QueueDraw();
00087 
00089     virtual void NeedSoftRedraw();
00090     virtual bool IsRedrawNeeded();
00091     virtual void DoneRedraw();
00092 
00093     virtual void OverlayDrawing(GraphicsEngine &graphics_engine) {}
00094 
00095     //Layout Bridge
00096 
00097     bool SearchInAllSubNodes(Area *bo);
00098     bool SearchInFirstSubNodes(Area *bo);
00099 
00101     /*
00102         Set the Geometry of the View and the geometry of the Default Background Area.
00103         For simple interface control UI classes(RGBValuator...), this is enough.
00104         For others, they have to overwrite the function and do the appropriate computations
00105         for their component.
00106     */
00107     virtual void SetGeometry(const Geometry &geo);
00108 
00110     /*
00111         Return true if this object can break the layout, meaning, the layout can be done on the composition layout only without
00112         recomputing the whole window layout.
00113     */
00114     virtual bool CanBreakLayout()
00115     {
00116       return false;
00117     }
00118 
00119     virtual void SetTextColor(const Color &color);
00120     virtual Color GetTextColor();
00121 
00123 
00127     virtual Layout* GetLayout();
00128 
00130 
00135     virtual bool SetLayout(Layout *layout);
00136 
00137     sigc::signal<void, View*, Layout*> LayoutAdded;
00138     sigc::signal<void, View*, Layout*> LayoutRemoved;
00139 
00140     void SetFont(ObjectPtr<FontTexture> font);
00141     ObjectPtr<FontTexture> GetFont();
00142 
00143     sigc::signal<void, View*> OnQueueDraw;  
00144 
00145     virtual Area* KeyNavIteration(KeyNavDirection direction);
00146     virtual bool AcceptKeyNavFocus();
00147 
00148     void IsHitDetectionSkipingChildren(bool skip_children);
00149 
00150 
00151   protected:
00152 
00153     void OnChildFocusChanged(/*Area *parent,*/ Area *child);
00154     sigc::connection _on_focus_changed_handler;
00155 
00156     virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw) = 0;
00157     virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
00158     virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw);
00159     virtual void PreLayoutManagement();
00160     virtual long PostLayoutManagement(long LayoutResult);
00161     virtual void PreResizeGeometry();
00162     virtual void PostResizeGeometry();
00163 
00164 
00165     void InitializeWidgets();
00166     void InitializeLayout();
00167 
00168     Color m_TextColor;
00169 
00171     virtual Layout* GetCompositionLayout();
00172 
00174     virtual bool SetCompositionLayout(Layout *layout);
00175 
00176     void RemoveLayout();
00177     void RemoveCompositionLayout();
00178 
00185     bool IsFullRedraw() const;
00186 
00187     virtual void GeometryChangePending();
00188     virtual void GeometryChanged();
00189 
00190     virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
00191 
00192     virtual Area* FindKeyFocusArea(unsigned int key_symbol,
00193                           unsigned long x11_key_code,
00194                           unsigned long special_keys_state);
00195 
00196     Layout *view_layout_;
00197 
00198     bool draw_cmd_queued_; //<! The rendering of the view needs to be refreshed.
00199 
00200     bool full_view_draw_cmd_; //<! True if Draw is called before ContentDraw. It is read-only and can be accessed by calling IsFullRedraw();
00201 
00202   private:
00203     ObjectPtr<FontTexture> _font;
00204 
00205     friend class WindowCompositor;
00206     friend class Layout;
00207     friend class Area;
00208     friend class LayeredLayout;
00209   };
00210 
00211 }
00212 
00213 #endif // ABSTRACTOBJECTBASE_H