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