Hi,
i want to write a simple app with wxWidgtes. The app have to:
1] create the main window (with menu, toolbar etc...)
2] create another window that stay *inside* the main window, centered in it, with no border, bars, icons...just a plain square window. I will render in it
something with OpenGL. This second window should be moveable, resizable by code.
Using one of the wxWidgets examples (toolbar) I am at the point 2 but am unable to make the 2° window inside the 1° one. How can i do that?
Thx.
Windows and sub-windows
Re: Windows and sub-windows
moveable second window.
try wxAUI
try wxAUI
Re: Windows and sub-windows
or the MDI framework but you will only get small-window-in-big-window behavior on Windows
"Keyboard not detected. Press F1 to continue"
-- Windows
-- Windows
-
- Knows some wx things
- Posts: 29
- Joined: Fri Sep 09, 2011 9:59 am
Re: Windows and sub-windows
you can use then a panel or does it have to be an wxWindow?with no border, bars, icons...just a plain square window
By using a panel you just have to set an sizer and add this panel to the sizer. You can move and resize the panel using code as you said and you can easily build a canvas in that panel to render using opengl
Re: Windows and sub-windows
Ok, i am trying the auidemo, since it seems really advanced but not too complex to understand.
I would like to add a wxPanel to the wxAuiNotebook control. It is really simple>
wxAuiNotebook* ctrl = new wxAuiNotebook(this, wxID_ANY,
wxPoint(client_size.x, client_size.y),
wxSize(430,200),
m_notebook_style);
ctrl->AddPage( new wxPanel( ctrl ), wxT("MyPanel") );
and it works perfectly.
But, if i create a subclass of wxPanel in order to implement my OnPaint() method, it doens't work:
/**
*/
class CGamePanel : public wxPanel
{
public:
CGamePanel(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr) : wxPanel( parent, winid, pos, size, style, name)
{
}
void OnPaint(wxPaintEvent& event)
{
wxPanel::OnPaint( event );
}
void OnSize(wxSizeEvent& event)
{
// this is also necessary to update the context on some platforms
wxPanel::OnSize(event);
}
void OnEnterWindow( wxMouseEvent& WXUNUSED(event) )
{
SetFocus();
}
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(CGamePanel, wxPanel)
EVT_PAINT(CGamePanel::OnPaint)
EVT_SIZE(CGamePanel::OnSize)
EVT_ENTER_WINDOW( CGamePanel::OnEnterWindow )
END_EVENT_TABLE()
As you can see, the code of CGamePanel is really simple: it just intercept the paint event and call the original Paint method, but it does not work properly.
What am i doing wrong??
I would like to add a wxPanel to the wxAuiNotebook control. It is really simple>
wxAuiNotebook* ctrl = new wxAuiNotebook(this, wxID_ANY,
wxPoint(client_size.x, client_size.y),
wxSize(430,200),
m_notebook_style);
ctrl->AddPage( new wxPanel( ctrl ), wxT("MyPanel") );
and it works perfectly.
But, if i create a subclass of wxPanel in order to implement my OnPaint() method, it doens't work:
/**
*/
class CGamePanel : public wxPanel
{
public:
CGamePanel(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr) : wxPanel( parent, winid, pos, size, style, name)
{
}
void OnPaint(wxPaintEvent& event)
{
wxPanel::OnPaint( event );
}
void OnSize(wxSizeEvent& event)
{
// this is also necessary to update the context on some platforms
wxPanel::OnSize(event);
}
void OnEnterWindow( wxMouseEvent& WXUNUSED(event) )
{
SetFocus();
}
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(CGamePanel, wxPanel)
EVT_PAINT(CGamePanel::OnPaint)
EVT_SIZE(CGamePanel::OnSize)
EVT_ENTER_WINDOW( CGamePanel::OnEnterWindow )
END_EVENT_TABLE()
As you can see, the code of CGamePanel is really simple: it just intercept the paint event and call the original Paint method, but it does not work properly.
What am i doing wrong??
Re: Windows and sub-windows
Hi,
See the first paragraph of the wxPaintDC doc.
Regards,
David
Apart from forgetting to use code-tags, you mean?What am i doing wrong??
See the first paragraph of the wxPaintDC doc.
Regards,
David
Re: Windows and sub-windows
David, thx!! It worked immediately.
What i am trying to do is to use OpenGL and wxWidgets.
But i don't want to follow the cube example, i am trying to do another thing.
Suppose that you have a image, produced in memory after some elaborations (of WxHx4 bytes (an RGBA image)).
This image is produced using OpenGL: in practice i render the scene on an invisible window, 30 times per second.
I would like to draw this image at the center of the panel, using wxPaintDC.
So, my questions are:
1. Given a char * pointing to a WxHx4 RGBA image, how do i draw it to a wxPanel client area? My image will always be an RGBA image.
2. I have a timer called 30 times per seconds. Inside the callback, i call my render method and retrieve the image
from the back buffer. How can i force the update of the wxPanel in order to show the new image? How to do this without
introducing flickering?
Thx!!!
What i am trying to do is to use OpenGL and wxWidgets.
But i don't want to follow the cube example, i am trying to do another thing.
Suppose that you have a image, produced in memory after some elaborations (of WxHx4 bytes (an RGBA image)).
This image is produced using OpenGL: in practice i render the scene on an invisible window, 30 times per second.
I would like to draw this image at the center of the panel, using wxPaintDC.
So, my questions are:
1. Given a char * pointing to a WxHx4 RGBA image, how do i draw it to a wxPanel client area? My image will always be an RGBA image.
2. I have a timer called 30 times per seconds. Inside the callback, i call my render method and retrieve the image
from the back buffer. How can i force the update of the wxPanel in order to show the new image? How to do this without
introducing flickering?
Thx!!!
Re: Windows and sub-windows
http://forums.wxwidgets.org/viewtopic.p ... 267#p862671. Given a char * pointing to a WxHx4 RGBA image, how do i draw it to a wxPanel client area? My image will always be an RGBA image.
After you have the wxBitmap you can blit it onto your wxPaintDC
Just call Refresh() on the panel.How can i force the update of the wxPanel in order to show the new image? How to do this without
introducing flickering?
http://wiki.wxwidgets.org/Drawing_on_a_ ... flickering
Use the source, Luke!