f



displaying windows through a window

main.cpp

#ifndef main_cpp
#define main_cpp

#include "wx/wx.h"
#include <wx/splash.h>
#include "MyFrame.h"

class MyApp : public wxApp
{
public:
virtual bool OnInit();
};

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
wxBitmap bitmap;

MyFrame *frame = new MyFrame(_T("Project Mayhem"),
                                 wxPoint(150, 150), wxSize(590, 430));

bitmap.LoadFile("C:/Documents and Settings/JAMIE
BERNIER/Desktop/images/Intro Image.bmp", wxBITMAP_TYPE_BMP);
wxSplashScreen* splash = new wxSplashScreen(bitmap,
wxSPLASH_CENTRE_ON_PARENT |wxSPLASH_TIMEOUT, 6000, frame, -1,
wxDefaultPosition, wxDefaultSize,
wxSIMPLE_BORDER|wxSTAY_ON_TOP);

splash->Show(TRUE);
wxYield();

frame->Show(TRUE);

return TRUE;
}

#endif



MyFrame.h

#ifndef MyFrame_H
#define MyFrame_H

#include "wx/wx.h"
#include "IntroPanel.h"
#include "canvas.h"

class MyFrame : public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
            long style = wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION);

void setIntroPanel();
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);

private:
IntroPanel *intro;
DECLARE_EVENT_TABLE()
};

enum
{
Minimal_Quit = 1,
Minimal_About = wxID_ABOUT
};

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_MENU(Minimal_Quit,  MyFrame::OnQuit)
    EVT_MENU(Minimal_About, MyFrame::OnAbout)
END_EVENT_TABLE()

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize&
size, long style)
       : wxFrame(NULL, -1, title, pos, size, style)
{
wxIcon icon;
icon.LoadFile("C:/Documents and Settings/JAMIE
BERNIER/Desktop/images/gameIcon.bmp", wxBITMAP_TYPE_ICO);
    SetIcon(icon);

    wxMenu *menuFile = new wxMenu;
    wxMenu *helpMenu = new wxMenu;
    helpMenu->Append(Minimal_About, _T("&About...\tF1"), _T("Information
About Project Mayhem"));
    menuFile->Append(Minimal_Quit, _T("E&xit\tAlt-X"), _T("Quit Project
Mayhem"));

    wxMenuBar *menuBar = new wxMenuBar();
    menuBar->Append(menuFile, _T("&File"));
    menuBar->Append(helpMenu, _T("&Help"));

    SetMenuBar(menuBar);

    CreateStatusBar(1);
    SetStatusText(_T("Prepare For Battle!"));

intro = new IntroPanel(this, wxDefaultPosition, wxDefaultSize, _T("Intro"));
}

void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    Close(TRUE);
}

void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
    wxString msg;
    msg.Printf("Project Mayhem.\nCreated By Jamie Bernier.");
    wxMessageBox(msg, _T("About Project Mayhem"), wxOK , this);
}

#endif



IntroPanel.h

#ifndef IntroPanel_H
#define IntroPanel_H

#include "wx/wx.h"
#include "canvas.h"

class IntroPanel : public wxPanel
{
public:
IntroPanel(wxWindow* parent, const wxPoint& pos, const wxSize& size, const
wxString& name,
                long style = wxCAPTION);

void OnButton(wxCommandEvent& event);

private:
wxTextCtrl * dialogText;
canvas *gl;
wxWindow *alex;
DECLARE_EVENT_TABLE()
};

enum
{
ID_BUTTON_SELECT = 1000
};

BEGIN_EVENT_TABLE(IntroPanel, wxPanel)
    EVT_BUTTON(ID_BUTTON_SELECT, IntroPanel::OnButton)
END_EVENT_TABLE()

IntroPanel::IntroPanel(wxWindow* parent, const wxPoint& pos, const wxSize&
size, const wxString& name, long style)
          : wxPanel(parent, -1, pos, size, style, name)
{
alex = parent;
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
wxBitmap mp;
wxStaticBitmap *sb;
wxButton *subBut;

mp.LoadFile("C:/Documents and Settings/JAMIE
BERNIER/Desktop/images/NameEnterImage.bmp", wxBITMAP_TYPE_BMP);
sb = new wxStaticBitmap(this, -1, mp, wxDefaultPosition, wxDefaultSize, 0,
"Intro");

topsizer->Add(sb, 1, wxEXPAND | wxALL, 10);

dialogText = new wxTextCtrl(this, -1,
                               "",
                               wxDefaultPosition,
                               wxSize(35, 25),
                               wxTE_PROCESS_ENTER
                             );

dialogText->SetMaxLength(3);

wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );

wxBitmap ini;
ini.LoadFile("C:/Documents and Settings/JAMIE
BERNIER/Desktop/images/initials.bmp", wxBITMAP_TYPE_BMP);

wxStaticBitmap *initials;
initials = new wxStaticBitmap(this, -1, ini, wxDefaultPosition,
wxDefaultSize, 0, "Initials");

button_sizer->Add( initials,
                 1,
                 wxEXPAND | wxALL,
                 10
               );
button_sizer->Add(dialogText, 0, wxALL, 10);
subBut = new wxButton(this, ID_BUTTON_SELECT, "Submit");
SetDefaultItem(subBut);
button_sizer->Add(subBut, 0, wxALL, 10);

topsizer->Add(button_sizer, 0, wxALIGN_CENTER );

wxColour color(24, 69, 160);

SetBackgroundColour(color);

SetAutoLayout( TRUE );
SetSizer( topsizer );
Show(TRUE);
}

void IntroPanel::OnButton(wxCommandEvent& WXUNUSED(event))
{
wxString temp;

temp = dialogText->GetLineText(0);
Show(FALSE);

gl = new canvas(alex, wxDefaultPosition, wxDefaultSize, _T("GLCanvas"));
}

#endif



canvas.h

#ifndef canvas_H
#define canvas_H

#include "wx/wx.h"
#include <wx/glcanvas.h>

class canvas : public wxGLCanvas
{
public:
canvas(wxWindow* parent, const wxPoint& pos, const wxSize& size, const
wxString& name,
                long style = wxCAPTION, int* attribList = 0, const
wxPalette palette = wxNullPalette);

};

canvas::canvas(wxWindow* parent, const wxPoint& pos, const wxSize& size,
const wxString& name, long style, int* attribList, const wxPalette
palette)
          : wxGLCanvas(parent, -1, pos, size, style, name, attribList,
palette)
{
wxColour color(0, 0, 0);
SetBackgroundColour(color);

Show(TRUE);
}

#endif


I want to display the IntroPanel within the frame and when the button is
pushed that is in the IntroPanel, un-display the IntroPanel and display
canvas. This is the code I have right now. I dont know what I am logically
doing wrong.

-Jamie

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wx-users-help@lists.wxwidgets.org

0
jbernier
3/27/2005 4:40:40 AM
comp.soft-sys.wxwindows 21076 articles. 0 followers. Post Follow

1 Replies
627 Views

Similar Articles

[PageSpeed] 2

Hi Jamie,

Most people are not likely to spend the time reading through your long code
listing in order to locate a bug or problem.  The best way to get help is to
use the absolute minimal code necessary to recreate the problem, or even
better, modify an existing sample application to exhibit the behavior you're
experiencing.

Based on your written description, it sounds like you want to add and remove
elements from a sizer after initial window creation, which you certainly can
do.  IIRC, you need to use Layout() after making a change to make everything
update.

HTH,

Kevin

----- Original Message ----- 
From: "Jamie Bernier" <jbernier@mcla.edu>
To: <wx-users@lists.wxwidgets.org>
Sent: Saturday, March 26, 2005 11:40 PM
Subject: displaying windows through a window


> main.cpp
>
> #ifndef main_cpp
> #define main_cpp
>
> #include "wx/wx.h"
> #include <wx/splash.h>
> #include "MyFrame.h"
>
> class MyApp : public wxApp
> {
> public:
> virtual bool OnInit();
> };
>
> IMPLEMENT_APP(MyApp)
>
> bool MyApp::OnInit()
> {
> wxBitmap bitmap;
>
> MyFrame *frame = new MyFrame(_T("Project Mayhem"),
>                                  wxPoint(150, 150), wxSize(590, 430));
>
> bitmap.LoadFile("C:/Documents and Settings/JAMIE
> BERNIER/Desktop/images/Intro Image.bmp", wxBITMAP_TYPE_BMP);
> wxSplashScreen* splash = new wxSplashScreen(bitmap,
> wxSPLASH_CENTRE_ON_PARENT |wxSPLASH_TIMEOUT, 6000, frame, -1,
> wxDefaultPosition, wxDefaultSize,
> wxSIMPLE_BORDER|wxSTAY_ON_TOP);
>
> splash->Show(TRUE);
> wxYield();
>
> frame->Show(TRUE);
>
> return TRUE;
> }
>
> #endif
>
>
>
> MyFrame.h
>
> #ifndef MyFrame_H
> #define MyFrame_H
>
> #include "wx/wx.h"
> #include "IntroPanel.h"
> #include "canvas.h"
>
> class MyFrame : public wxFrame
> {
> public:
> MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
>             long style = wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION);
>
> void setIntroPanel();
> void OnQuit(wxCommandEvent& event);
> void OnAbout(wxCommandEvent& event);
>
> private:
> IntroPanel *intro;
> DECLARE_EVENT_TABLE()
> };
>
> enum
> {
> Minimal_Quit = 1,
> Minimal_About = wxID_ABOUT
> };
>
> BEGIN_EVENT_TABLE(MyFrame, wxFrame)
>     EVT_MENU(Minimal_Quit,  MyFrame::OnQuit)
>     EVT_MENU(Minimal_About, MyFrame::OnAbout)
> END_EVENT_TABLE()
>
> MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize&
> size, long style)
>        : wxFrame(NULL, -1, title, pos, size, style)
> {
> wxIcon icon;
> icon.LoadFile("C:/Documents and Settings/JAMIE
> BERNIER/Desktop/images/gameIcon.bmp", wxBITMAP_TYPE_ICO);
>     SetIcon(icon);
>
>     wxMenu *menuFile = new wxMenu;
>     wxMenu *helpMenu = new wxMenu;
>     helpMenu->Append(Minimal_About, _T("&About...\tF1"), _T("Information
> About Project Mayhem"));
>     menuFile->Append(Minimal_Quit, _T("E&xit\tAlt-X"), _T("Quit Project
> Mayhem"));
>
>     wxMenuBar *menuBar = new wxMenuBar();
>     menuBar->Append(menuFile, _T("&File"));
>     menuBar->Append(helpMenu, _T("&Help"));
>
>     SetMenuBar(menuBar);
>
>     CreateStatusBar(1);
>     SetStatusText(_T("Prepare For Battle!"));
>
> intro = new IntroPanel(this, wxDefaultPosition, wxDefaultSize,
_T("Intro"));
> }
>
> void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
> {
>     Close(TRUE);
> }
>
> void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
> {
>     wxString msg;
>     msg.Printf("Project Mayhem.\nCreated By Jamie Bernier.");
>     wxMessageBox(msg, _T("About Project Mayhem"), wxOK , this);
> }
>
> #endif
>
>
>
> IntroPanel.h
>
> #ifndef IntroPanel_H
> #define IntroPanel_H
>
> #include "wx/wx.h"
> #include "canvas.h"
>
> class IntroPanel : public wxPanel
> {
> public:
> IntroPanel(wxWindow* parent, const wxPoint& pos, const wxSize& size, const
> wxString& name,
>                 long style = wxCAPTION);
>
> void OnButton(wxCommandEvent& event);
>
> private:
> wxTextCtrl * dialogText;
> canvas *gl;
> wxWindow *alex;
> DECLARE_EVENT_TABLE()
> };
>
> enum
> {
> ID_BUTTON_SELECT = 1000
> };
>
> BEGIN_EVENT_TABLE(IntroPanel, wxPanel)
>     EVT_BUTTON(ID_BUTTON_SELECT, IntroPanel::OnButton)
> END_EVENT_TABLE()
>
> IntroPanel::IntroPanel(wxWindow* parent, const wxPoint& pos, const wxSize&
> size, const wxString& name, long style)
>           : wxPanel(parent, -1, pos, size, style, name)
> {
> alex = parent;
> wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
> wxBitmap mp;
> wxStaticBitmap *sb;
> wxButton *subBut;
>
> mp.LoadFile("C:/Documents and Settings/JAMIE
> BERNIER/Desktop/images/NameEnterImage.bmp", wxBITMAP_TYPE_BMP);
> sb = new wxStaticBitmap(this, -1, mp, wxDefaultPosition, wxDefaultSize, 0,
> "Intro");
>
> topsizer->Add(sb, 1, wxEXPAND | wxALL, 10);
>
> dialogText = new wxTextCtrl(this, -1,
>                                "",
>                                wxDefaultPosition,
>                                wxSize(35, 25),
>                                wxTE_PROCESS_ENTER
>                              );
>
> dialogText->SetMaxLength(3);
>
> wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
>
> wxBitmap ini;
> ini.LoadFile("C:/Documents and Settings/JAMIE
> BERNIER/Desktop/images/initials.bmp", wxBITMAP_TYPE_BMP);
>
> wxStaticBitmap *initials;
> initials = new wxStaticBitmap(this, -1, ini, wxDefaultPosition,
> wxDefaultSize, 0, "Initials");
>
> button_sizer->Add( initials,
>                  1,
>                  wxEXPAND | wxALL,
>                  10
>                );
> button_sizer->Add(dialogText, 0, wxALL, 10);
> subBut = new wxButton(this, ID_BUTTON_SELECT, "Submit");
> SetDefaultItem(subBut);
> button_sizer->Add(subBut, 0, wxALL, 10);
>
> topsizer->Add(button_sizer, 0, wxALIGN_CENTER );
>
> wxColour color(24, 69, 160);
>
> SetBackgroundColour(color);
>
> SetAutoLayout( TRUE );
> SetSizer( topsizer );
> Show(TRUE);
> }
>
> void IntroPanel::OnButton(wxCommandEvent& WXUNUSED(event))
> {
> wxString temp;
>
> temp = dialogText->GetLineText(0);
> Show(FALSE);
>
> gl = new canvas(alex, wxDefaultPosition, wxDefaultSize, _T("GLCanvas"));
> }
>
> #endif
>
>
>
> canvas.h
>
> #ifndef canvas_H
> #define canvas_H
>
> #include "wx/wx.h"
> #include <wx/glcanvas.h>
>
> class canvas : public wxGLCanvas
> {
> public:
> canvas(wxWindow* parent, const wxPoint& pos, const wxSize& size, const
> wxString& name,
>                 long style = wxCAPTION, int* attribList = 0, const
> wxPalette palette = wxNullPalette);
>
> };
>
> canvas::canvas(wxWindow* parent, const wxPoint& pos, const wxSize& size,
> const wxString& name, long style, int* attribList, const wxPalette
> palette)
>           : wxGLCanvas(parent, -1, pos, size, style, name, attribList,
> palette)
> {
> wxColour color(0, 0, 0);
> SetBackgroundColour(color);
>
> Show(TRUE);
> }
>
> #endif
>
>
> I want to display the IntroPanel within the frame and when the button is
> pushed that is in the IntroPanel, un-display the IntroPanel and display
> canvas. This is the code I have right now. I dont know what I am logically
> doing wrong.
>
> -Jamie


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wx-users-help@lists.wxwidgets.org

0
hockkn
3/27/2005 4:55:27 AM
Reply: