initiate an event Topic is solved

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
toef82
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jan 10, 2008 6:57 am
Location: Hamburg/Germany

initiate an event

Post by toef82 »

Hello in my Update method i need to initiate a wxSizeEvent, how can i throw it and initate it so that it can be catched by my eventhandlers??

Code: Select all

#include "MyPaintPanel.h"
#include<wx/dcclient.h>

MyPaintPanel::MyPaintPanel(wxWindow* parent, wxWindowID id , const wxPoint& pos , const wxSize& size, long style , const wxString& name)
:wxPanel(parent,id,pos,size,style,name){
    //wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
    this->dayx= new wxStaticText(this, -1, wxString("Day X"), wxPoint(0,0));
    this->dayx->SetFont(wxFont(20, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));

    this->uhrzeit = new wxStaticText(this, -1, wxString("   14:32:52"), wxPoint(50,30));
    this->uhrzeit->SetFont(wxFont(50, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));

    this->status = new wxStaticText(this, -1, wxString(" Systemzeit"), wxPoint(200,0));
    this->status->SetFont(wxFont(18, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));


    //sizer->Add(uhrzeit,1,wxGROW|wxALIGN_CENTRE);
    //wxMessageBox(wxString("")<<size.GetWidth()/2);
    this->SetBackgroundColour("WHITE");
    //SetSizerAndFit(sizer);
}


void MyPaintPanel::update(wxString s,int x,bool temp){
    this->uhrzeit->SetLabel(s);
    this->sim=temp;
    if(x!=this->x){
    this->x=x;
    this->SetSize(wxSize(this->GetSize()));
    }
    if(x<0){
       this->dayx->SetLabel(wxString("Day X ")<<x);
        }else{
            if (x>0){
                this->dayx->SetLabel(wxString("Day X +")<<x);
                }
                else{
                    this->dayx->SetLabel(wxString("Day X"));
                    }

    }
    if (temp==true){this->status->SetLabel("Systemzeit");


    }else{
        this->status->SetLabel("Sim Zeit");}
}

//wxPoint(size.GetWidth()/2,size.GetHeight() /2
void MyPaintPanel::OnSize(wxSizeEvent& event){
    if(x!=0){
        this->dayx->SetFont(wxFont(((this->GetSize().GetHeight()/100)*15), wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
        this->dayx->SetPosition(wxPoint(((this->GetSize().GetWidth()/100)*30),this->GetSize().GetHeight()/4));
    }else{
        this->dayx->SetFont(wxFont(((this->GetSize().GetHeight()/100)*15), wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
        this->dayx->SetPosition(wxPoint(((this->GetSize().GetWidth()/100)*36),this->GetSize().GetHeight()/4));
        }
    if(sim){
        this->status->SetFont(wxFont(((this->GetSize().GetHeight()/100)*15), wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
        this->status->SetPosition(wxPoint(((this->GetSize().GetWidth()/100)*27),0));
    }else{
          this->status->SetFont(wxFont(((this->GetSize().GetHeight()/100)*15), wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
        this->status->SetPosition(wxPoint(((this->GetSize().GetWidth()/100)*31),0));
        }

    this->uhrzeit->SetFont(wxFont(((this->GetSize().GetHeight()/100)*20), wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Times New Roman")));
    this->uhrzeit->SetPosition(wxPoint(((this->GetSize().GetWidth()/100)*25),this->GetSize().GetHeight()/2));
    }

BEGIN_EVENT_TABLE(MyPaintPanel,wxPanel)
EVT_SIZE    (           MyPaintPanel::OnSize)

END_EVENT_TABLE()
Sof_T
Can't get richer than this
Can't get richer than this
Posts: 864
Joined: Thu Jul 28, 2005 9:48 pm
Location: New Forest, United Kingdom
Contact:

Post by Sof_T »

Is this to cause your window to repaint? If so you can use Refresh().

Sof.T
The home of Sof.T http://www.sof-t.site88.net/
Author of Programming with wxDevC++
http://sourceforge.net/projects/wxdevcpp-book/
toef82
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jan 10, 2008 6:57 am
Location: Hamburg/Germany

Post by toef82 »

no its not a paintpanel, this panal consists of an static text that must be resized when the windowsize changes, and when the text changes istselfe, the text must be resized to , thats why i need to fire a SizerEvent in my UpdateMethode
toef82
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jan 10, 2008 6:57 am
Location: Hamburg/Germany

Post by toef82 »

no body out there who knows hao to simulate a SizerEvent?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

if i understand your problem correctly, it's probably easier to just put the content of your OnSize() method into another method, e.g. Recalculate(). Then you can call this method from inside your OnSize() handler or whenever you need to.
Use the source, Luke!
tan
wxWorld Domination!
wxWorld Domination!
Posts: 1471
Joined: Tue Nov 14, 2006 7:58 am
Location: Saint-Petersburg, Russia

Post by tan »

Hi,
did you try just to call OnSize from update method:

Code: Select all

void MyPaintPanel::update(wxString s,int x,bool temp){
    this->uhrzeit->SetLabel(s);
    this->sim=temp;
    if(x!=this->x){
    this->x=x;
    this->SetSize(wxSize(this->GetSize()));
    }
    if(x<0){
       this->dayx->SetLabel(wxString("Day X ")<<x);
        }else{
            if (x>0){
                this->dayx->SetLabel(wxString("Day X +")<<x);
                }
                else{
                    this->dayx->SetLabel(wxString("Day X"));
                    }

    }
    if (temp==true){this->status->SetLabel("Systemzeit");


    }else{
        this->status->SetLabel("Sim Zeit");}
    // Call OnSize after it
    wxSizeEvent ev;
    this->OnSize(ev);
}
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10
toef82
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jan 10, 2008 6:57 am
Location: Hamburg/Germany

Post by toef82 »

thank you !! it works!! Greate!!:-)
Post Reply