Back to index

nux  3.0.0
ClientArea.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 CLIENTAREA_H
00024 #define CLIENTAREA_H
00025 
00026 #include "InputArea.h"
00027 #include "Painter.h"
00028 #include "View.h"
00029 #include "TimerProc.h"
00030 
00031 namespace nux
00032 {
00033 
00034   class ClientArea;
00035 
00036   struct ClientAreaDraw
00037   {
00038     ClientArea *clientarea;
00039     Geometry clipgeometry;
00040   };
00041 
00042   class ClientArea: public View
00043   {
00044   public:
00045     ClientArea(NUX_FILE_LINE_PROTO);
00046     ~ClientArea();
00047 
00048     virtual void BeginDraw(GraphicsEngine &graphics_engine, bool force_draw);
00049     virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
00050     virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
00051     virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw);
00052     virtual void QueueDraw();
00053 
00054     void EnableClientDraw(bool b)
00055     {
00056       m_IsClientAreaEnabled = b;
00057     };
00058     bool IsClientDrawEnabled() const
00059     {
00060       return m_IsClientAreaEnabled;
00061     };
00062 
00063     virtual void ClientDraw(GraphicsEngine &graphics_engine, DrawAreaContext &ctx, bool force_draw);
00064     virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
00065     virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
00066     virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00067     virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00068     virtual void RecvKeyEvent(
00069       unsigned long       ,   /*event type*/
00070       unsigned long       ,   /*event keysym*/
00071       unsigned long       ,   /*event state*/
00072       const char*        ,   /*character*/
00073       unsigned short          /*key repeat count*/
00074     );
00075 
00076     sigc::signal<void, DrawAreaContext, bool> sigClientDraw;
00077     void SetClientViewport(GraphicsEngine &graphics_engine);
00078     void Setup2DMode(GraphicsEngine &graphics_engine);
00079 
00080     // Before the client start drawing we set up a framebuffer object. We don't want the client to start messing
00081     // up the whole rendering by. If we setup a framebuffer instead, the client can never know the framebuffer
00082     // we use fror the whole rendering. all we have to do is to copy the client framebuffer into the main framebuffer
00083     // after the client as finished with the draw.
00084     ObjectPtr<IOpenGLFrameBufferObject>& GetWindowFrameBufferObject()
00085     {
00086       return m_FrameBufferObject;
00087     }
00088     ObjectPtr<IOpenGLFrameBufferObject> m_FrameBufferObject;
00089 
00090   protected:
00091     virtual bool AcceptKeyNavFocus();
00092 
00093   private:
00094     // We use Rectangle texture to attach to the framebuffer because some GPU like the Geforce FX 5600 do not
00095     // have support for ARB_texture_non_power_of_two. However it does support ARB_texture_recatangle.
00096     ObjectPtr<IOpenGLBaseTexture> m_MainColorRT;
00097     ObjectPtr<IOpenGLBaseTexture> m_MainDepthRT;
00098 
00099     DrawAreaContext m_ctx;
00100     bool m_IsClientAreaEnabled;
00101   };
00102 
00103 
00104 }
00105 
00106 #endif // CLIENTAREA_H