g4tools  5.4.0
Public Member Functions | Protected Member Functions | List of all members
tools::WinTk::OpenGLArea Class Reference
Inheritance diagram for tools::WinTk::OpenGLArea:
Inheritance graph
[legend]
Collaboration diagram for tools::WinTk::OpenGLArea:
Collaboration graph
[legend]

Public Member Functions

 OpenGLArea (Component &aParent)
 
virtual ~OpenGLArea ()
 
bool write_gl2ps (const std::string &, const std::string &)
 
- Public Member Functions inherited from tools::WinTk::Component
 Component (const std::string &aType)
 
 Component (const std::string &aType, Component &aParent)
 
virtual ~Component ()
 
std::string name () const
 
void setName (const std::string &aName)
 
const std::string & type () const
 
HWND nativeWindow ()
 
Componentparent () const
 
virtual void show ()
 
void hide ()
 
virtual bool size (unsigned int &aWidth, unsigned int &aHeight)
 
virtual bool position (int &aX, int &aY)
 
ComponentfindFather (const std::string &aType)
 
bool setBackground (double aR, double aG, double aB)
 
void addCallback (const std::string &aName, Callback aFunction, void *aTag)
 
void removeCallback (const std::string &aName, Callback aFunction, void *aTag)
 
bool executeCallbacks (const std::string &aName, CallbackData &aData)
 
bool hasCallbacks (const std::string &aName) const
 

Protected Member Functions

 OpenGLArea (OpenGLArea &a_from)
 
OpenGLAreaoperator= (OpenGLArea &)
 
- Protected Member Functions inherited from tools::WinTk::Component
 Component (Component &)
 
Componentoperator= (Component &)
 
void destroy ()
 
void rubberDrawLine (POINT &aBegin, POINT &aEnd)
 
void rubberDrawRect (POINT &aBegin, POINT &aEnd)
 

Additional Inherited Members

- Static Protected Member Functions inherited from tools::WinTk::Component
static void wm__destroy (HWND aWindow)
 
static LRESULT CALLBACK containerProc (HWND aWindow, UINT aMessage, WPARAM aWParam, LPARAM aLParam)
 
- Protected Attributes inherited from tools::WinTk::Component
HWND fWindow
 
ComponentfParent
 
std::vector< NamedCallbacks > fCallbacks
 
std::string fName
 

Detailed Description

Definition at line 626 of file WinTk.

Constructor & Destructor Documentation

◆ OpenGLArea() [1/2]

tools::WinTk::OpenGLArea::OpenGLArea ( Component aParent)
inline

Definition at line 628 of file WinTk.

629  :Component("OpenGLArea",aParent)
630  ,fContext(0)
631  ,fHDC(0)
632  {
633  if(!fParent || !fParent->nativeWindow()) return;
634  HWND parent = fParent->nativeWindow();
635 
636  static char sOpenGLAreaClassName[] = "WinTk::OpenGLArea";
637  static bool done = false;
638  if(!done) {
639  WNDCLASS wc;
640  wc.style = CS_HREDRAW | CS_VREDRAW;
641  wc.lpfnWndProc = (WNDPROC)OpenGLArea::proc;
642  wc.cbClsExtra = 0;
643  wc.cbWndExtra = 0;
644  wc.hInstance = GetWindowInstance(parent),
645  wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
646  wc.hCursor = LoadCursor(NULL,IDC_ARROW);
647  wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
648  wc.lpszMenuName = sOpenGLAreaClassName;
649  wc.lpszClassName = sOpenGLAreaClassName;
650  ::RegisterClass(&wc);
651  done = true;
652  }
653 
654  // The WS_BORDER is needed. Else probleme of size at startup.
655  RECT rect;
656  ::GetClientRect(parent,&rect);
657  fWindow = ::CreateWindow(sOpenGLAreaClassName,
658  NULL,
659  WS_CHILD | WS_VISIBLE,
660  0,0,
661  rect.right-rect.left,
662  rect.bottom-rect.top,
663  parent,NULL,
664  GetWindowInstance(parent),
665  NULL);
666  if(!fWindow) return;
667  ::SetWindowLongPtr(fWindow,GWLP_USERDATA,LONG_PTR(this));
668 
669  // initialize OpenGL rendering :
670  fHDC = ::GetDC(fWindow);
671  if( fHDC && SetWindowPixelFormat(fHDC) ) {
672  fContext = ::wglCreateContext(fHDC);
673  }
674  }

◆ ~OpenGLArea()

virtual tools::WinTk::OpenGLArea::~OpenGLArea ( )
inlinevirtual

Definition at line 675 of file WinTk.

675  {
676  if(wglGetCurrentContext()!=NULL) wglMakeCurrent(NULL,NULL);
677  if(fContext) {
678  wglDeleteContext(fContext);
679  fContext = 0;
680  }
681  destroy();
682  }

◆ OpenGLArea() [2/2]

tools::WinTk::OpenGLArea::OpenGLArea ( OpenGLArea a_from)
inlineprotected

Definition at line 684 of file WinTk.

684 :Component(a_from) {}

Member Function Documentation

◆ operator=()

OpenGLArea& tools::WinTk::OpenGLArea::operator= ( OpenGLArea )
inlineprotected

Definition at line 685 of file WinTk.

685 {return *this;}

◆ write_gl2ps()

bool tools::WinTk::OpenGLArea::write_gl2ps ( const std::string &  ,
const std::string &   
)

The documentation for this class was generated from the following file:
tools::WinTk::Component::nativeWindow
HWND nativeWindow()
Definition: WinTk:69
tools::WinTk::Component::destroy
void destroy()
Definition: WinTk:297
tools::WinTk::Component::fParent
Component * fParent
Definition: WinTk:343
tools::WinTk::Component::Component
Component(const std::string &aType)
Definition: WinTk:42
tools::WinTk::Component::fWindow
HWND fWindow
Definition: WinTk:342
tools::WinTk::Component::parent
Component * parent() const
Definition: WinTk:70