Author Topic: problem of paws handle event.  (Read 829 times)

arcus

  • Traveller
  • *
  • Posts: 21
    • View Profile
problem of paws handle event.
« on: August 11, 2005, 04:42:16 am »
hi, all
I\'m using paws to create my own gui system.
First I create the gui xml definition file and its related class, and then I create a class named winmanager to hold all the guis. And now I met a strange problem, when I click the mouse on a button in the VC debug mode, it can transfer this event to the winmanager and its gui widget, and it shows that OnButtonPressed method will be invoke, but then I goto the next step system does not invoke this OnButtonPressed method in my gui class.
It is quite strange, I\'m sure whether I explain my question clearly. Is there any simple independent sample of using paws system? How about the handle event system?

any help and suggestion will be welcome!


Frank

acraig

  • Administrator
  • Veteran
  • *
  • Posts: 1562
    • View Profile
(No subject)
« Reply #1 on: August 11, 2005, 05:13:37 am »
Can you post some code samples?  It sounds like maybe your OnButtonPressed function is not quite right.  All of those functions are virtual from the base pawsWidget so it is important they are correct.
----------
Andrew
"For all I know, she's lying, everyone's lying; welcome to the Internet"

arcus

  • Traveller
  • *
  • Posts: 21
    • View Profile
(No subject)
« Reply #2 on: August 12, 2005, 03:49:49 am »
the WinManager class is like as follow:


#include
#include

#include \"winmanager.h\"
#include \"spengine.h\"
#include
#include
#include

#include \"paws/pawsprogressbar.h\"
#include \"paws/pawsmenu.h\"


WinManager::WinManager(SPEngine* engine,iObjectRegistry* objectReg,const char* skin)
               :PawsManager(objectReg,skin)
{
  myengine=engine;
}

WinManager::~WinManager()
{}


void WinManager::Init()
{
    RegisterFactories();
    LoadWidget(\"conf/login.xml\");
}

void WinManager::Start()
{
       
    login = (LoginWindow*)FindWidget(\"loginwindow\");
  login->SetEngine(myengine);
 login->Show();
  pawsMouse *pm = new pawsMouse(this);//?õ????pawsMouse?????
   pm->ChangeImage(\"Standard Mouse Pointer\");
}


void WinManager::RegisterFactories()
{
    pawsWidgetFactory* factory;
   
   factory = new LoginWindowFactory(this);
 }


WinManager class is a child class of PawsManager.

arcus

  • Traveller
  • *
  • Posts: 21
    • View Profile
(No subject)
« Reply #3 on: August 12, 2005, 03:58:59 am »
the class of loginwindow is like this (header file ):


#ifndef __LOGINWIN_H__
#define __LOGINWIN_H__

/**
  *@file LoginWindow???????
  *
  *????????????LoginWindow??
  *
  *@author qcli
  */

#include \"paws/pawswidget.h\"
#include \"messagesubscriber.h\"
#include \"paws/pawstextbox.h\"
#include \"paws/pawsbutton.h\"
#include \"message.h\"
#include \"svraccountmessage.h\"
#include \"SPEngine.h\"
#include \"selectwin.h\"

/**
  *@brief LoginWindow??????¼????
  *
  *??????????¼???????????????????????????????????
  *??????????????????????????
  */
class LoginWindow:public pawsWidget, public MessageSubscriber
{
public:
 LoginWindow(PawsManager* manager);
  ~LoginWindow();
 bool PostSetup();
    /**
     *@brief Called whenever a button is pressed.
      *@param button The button pressed.
      *@param keyModifier Modifier key in effect.
      *@param widget The widget the button belongs to.
      *@return bool Parent\'s result or FALSE if no parent.
      */
 bool OnButtonPressed(int mouseButton,int keyModifier,pawsWidget* widget);
   bool OnMouseDown( int button, int modifiers, int x, int y );
    /**
   *@brief ??????????????????
      *@param message ????????????????LOGIN_ACK(??¼???)
   */
    void HandleMessage(Message* message);

   void SetEngine(SPEngine* engine);

   SelectWindow *GetSelect(){return select;}

private:
   /**
   *@brief ????????????????????
    */
    void ConnectToServer();
 
    ///??¼??š?
   pawsEditTextBox* login;  
   ///??¼????
   pawsEditTextBox* password;  

    SelectWindow* select;

   SPEngine* loginengine;

  pawsButton* okbtn;

  pawsButton* cancelbtn;

};
CREATE_PAWS_FACTORY(LoginWindow);
#endif




the .cpp file is like this:


#include
#include
#include
#include
#include \"log.h\"

#include \"loginwin.h\"
#include \"clientnetmanager.h\"
#include \"clientaccountmessage.h\"
#include \"winmanager.h\"
#include \"paws/pawsmanager.h\"
#include \"string.h\"

#define LOGIN_WINDOW_QUIT       100
#define LOGIN_WINDOW_LOGIN      101
LoginWindow::LoginWindow(PawsManager* manager)
                :pawsWidget(manager)
{}

LoginWindow::~LoginWindow()
{}

bool LoginWindow::PostSetup()
{
/*
   login = (pawsEditTextBox*)FindWidget(\"account\");
    if (login == NULL)
        return false;

    password = (pawsEditTextBox*)FindWidget(\"password\");
    if (password == NULL)
        return false;
    password->SetPassword(true);*/

 okbtn = (pawsButton*)FindWidget(\"ok\");
    //cancelbtn = (pawsButton*)FindWidget(\"cancel\");

  //login->SetParent(this);
   //password->SetParent(this);
    okbtn->SetParent(this);
 //cancelbtn->SetParent(this);
   return true;

}

void LoginWindow::SetEngine(SPEngine* engine)
{
 loginengine=engine;
 return;
}

bool LoginWindow::OnMouseDown( int button, int modifiers, int x, int y )
{
   printf(\"login window mouse down!!!!!!!!!!!!!!!!!!!!!\\n\");
    //pawsWidget::OnMouseDown( button, modifiers, x, y );

    BringToTop((pawsEditTextBox*)this->FindWidget(\"account\"));

    BringToTop((pawsEditTextBox*)this->FindWidget(\"password\"));

    BringToTop((pawsButton*)this->FindWidget(\"ok\"));

  //BringToTop((pawsButton*)this->FindWidget(\"cancel\"));

    // WinManager* win = loginengine->GetWinManager();
          //  win->ShowOKWindow( \"û?????û?????????\" );  
   return true;
}

bool LoginWindow::OnButtonPressed( int button, int keyModifier, pawsWidget* widget )
{
 printf(\"login window button pressed******************************************\\n\");
    switch( widget->GetID() )
    {
        case LOGIN_WINDOW_QUIT:
        {  
            printf(\"********quit*********\");
            loginengine->QuitClient();
            return true;
        }
       
        case LOGIN_WINDOW_LOGIN:
        {
            if ( strlen(login->GetText()) == 0 ||
                 strlen(password->GetText()) == 0)
            {
                WinManager* win = loginengine->GetWinManager();
              //win->ShowOKWindow( \"û?????û?????????\" );        
                return true;
            }                
           
            ConnectToServer();
            return true;
        }
           
    return false;
    }
    return false;
}
void LoginWindow::ConnectToServer()
{
  // char* account=login->GetText();
   //char* code=password->GetText();
  // LoginMsg* message=new LoginMsg(login->GetText(),password->GetText());
  // ClientNetManager* netmanager = loginengine->GetNetManager();
  // netmanager->SendMessage(message);
   
}
void LoginWindow::HandleMessage(Message* message)
{
 /*switch(message->type)
 {
   case MSG_LOGIN_ACK:
     {
            LoginAckMsg* recvmessage = new LoginAckMsg(message);

             switch( recvmessage->loginAck)
             {
           case 0:
                 {
                   WinManager* win = loginengine->GetWinManager();
                     win->ShowOKWindow( \"????????????????????!\" );
                   return ;
                }
           case 1:
                 {
                   WinManager* win = loginengine->GetWinManager();
                     win->ShowOKWindow( \"??????????????????????!\" );
                   return ;
                }
           case 2:
                 {
                   WinManager* win = loginengine->GetWinManager();
                     win->ShowOKWindow( \"????????????,???????¼????????????!\" );
                    return ;
                }
           case 3:
                 {
                    return ;
                }
              return ;
           }
       }
   case MSG_CHAR_LIST:
     {
           WinManager* win = loginengine->GetWinManager();
         select=(SelectWindow*)win->FindWidget(\"data/gui/selectperson.xml\");
           if(!select)
         {
               win->LoadWidget(\"data/gui/selectperson.xml\");
             select = (SelectWindow*)win->FindWidget(\"selectwindow\");
           }
             select->HandleMessage(message);
           select->Show();
             Hide();
             return;
        }
           return ;
    }*/

}

arcus

  • Traveller
  • *
  • Posts: 21
    • View Profile
(No subject)
« Reply #4 on: August 12, 2005, 08:10:57 am »
I feel the problem maybe the calling convention. Because I\'m using the MSVC to compile my project, and the compile option set __cdecl, but some method is called with a wrong stack sequence. For example, when calling widget class\' OnButtonPressed() and SetSize() method.
How do you think?

Thanks a lot!
Have a nice weekend!

Frank

arcus

  • Traveller
  • *
  • Posts: 21
    • View Profile
(No subject)
« Reply #5 on: August 15, 2005, 03:06:25 am »
hi,
the problem has been solved. It is the CS version confiliction problem. Now it is Ok.

frank