Jump to content

I want to register the callback on each window


nicks1980

Recommended Posts

I want to register the callback on each window

By pressing one button all callbacks are called.

 


typedef struct {
   GListener glListener;    
   GHandle   ghContainer;       GContainerObject gObjContainer;    
   GHandle   ghCustoms;         GButtonObject    gObjCustoms;
   GHandle   ghManagedProgramm; GButtonObject    gObjManagedProgramm;
   GHandle   ghPlayList;        GButtonObject    gObjPlayList;
} GUI_MAIN_MENU;

typedef struct {
    GListener glListener;    
    GHandle   ghContainer;       GContainerObject gObjContainer;
    GHandle   ghMainLabel;       GLabelObject     gObjMainLabel;
    GHandle   ghList;            GListObject      gObjList;    
    GHandle   ghReturn;          GButtonObject    gObjReturn;
    GHandle   ghLoad;            GButtonObject    gObjLoad;
} GUI_MANAGEPROG_MENU;
 

//// Плей лист  (360 байт)
typedef struct {
    GListener glListener;    
    GHandle   ghContainer;       GContainerObject gObjContainer;
    GHandle   ghMainLabel;       GLabelObject     gObjMainLabel;
    GHandle   ghList;            GListObject      gObjList;    
    GHandle   ghUpdate;          GButtonObject    gObjUpdate;
    GHandle   ghReturn;          GButtonObject    gObjReturn;
    GHandle   ghLoad;            GButtonObject    gObjLoad;
} GUI_PLAYLIST_MENU;

typedef struct {
   GListener glListener;    
   GHandle   ghContainer;       GContainerObject gObjContainer;
   GHandle   ghMainLabel;       GLabelObject     gObjMainLabel;
   GHandle   ghAmplifier;       GButtonObject    gObjAmplifier;
   GHandle   ghUSB;             GButtonObject    gObjUSB;
   GHandle   ghLAN;             GButtonObject    gObjLAN;    
   GHandle   ghSDCards;         GButtonObject    gObjSDCards;
   GHandle   ghSecurity;        GButtonObject    gObjSecurity;
   GHandle   ghWaterLevel;      GButtonObject    gObjWaterLevel;
   GHandle   ghDataTime;        GButtonObject    gObjDataTime;
   GHandle   ghReturn;          GButtonObject    gObjReturn;
} GUI_CUSTOM_MENU;

GUI_MANAGEPROG_MENU  m_ManageProgMenu;

GUI_CUSTOM_MENU  m_CustomMenu;

GUI_PLAYLIST_MENU  m_PlayListMenu;

GUI_MANAGEPROG_MENU  m_ManageProgMenu;

 

...

    geventListenerInit(&m_MainMenu.glListener);
    gwinAttachListener(&m_MainMenu.glListener);
    
    geventRegisterCallback(&m_MainMenu.glListener, gui_MainMenu_cb, (void *)&m_MainMenu.ghCustoms);
    geventRegisterCallback(&m_MainMenu.glListener, gui_MainMenu_cb, (void *)&m_MainMenu.ghManagedProgramm);
    geventRegisterCallback(&m_MainMenu.glListener, gui_MainMenu_cb, (void *)&m_MainMenu.ghPlayList);

 

    geventListenerInit(&m_PlayListMenu.glListener);
    gwinAttachListener(&m_PlayListMenu.glListener);
    geventRegisterCallback(&m_PlayListMenu.glListener, gui_PlayListMenu_cb, (void *)&m_PlayListMenu.ghList);
    geventRegisterCallback(&m_PlayListMenu.glListener, gui_PlayListMenu_cb, (void *)&m_PlayListMenu.ghReturn);
    geventRegisterCallback(&m_PlayListMenu.glListener, gui_PlayListMenu_cb, (void *)&m_PlayListMenu.ghLoad);
    geventRegisterCallback(&m_PlayListMenu.glListener, gui_PlayListMenu_cb, (void *)&m_PlayListMenu.ghUpdate); 

 

    geventListenerInit(&m_ManageProgMenu.glListener);
    gwinAttachListener(&m_ManageProgMenu.glListener);    
    geventRegisterCallback(&m_ManageProgMenu.glListener, gui_ManageProgMenu_cb, (void *)&m_ManageProgMenu.ghList);
    geventRegisterCallback(&m_ManageProgMenu.glListener, gui_ManageProgMenu_cb, (void *)&m_ManageProgMenu.ghReturn);
    geventRegisterCallback(&m_ManageProgMenu.glListener, gui_ManageProgMenu_cb, (void *)&m_ManageProgMenu.ghLoad);

 

    geventListenerInit(&m_CustomMenu.glListener);
    gwinAttachListener(&m_CustomMenu.glListener);    
    geventRegisterCallback(&m_CustomMenu.glListener, gui_CustomMenu_cb, (void *)&m_CustomMenu.ghAmplifier);
    geventRegisterCallback(&m_CustomMenu.glListener, gui_CustomMenu_cb, (void *)&m_CustomMenu.ghUSB);
    geventRegisterCallback(&m_CustomMenu.glListener, gui_CustomMenu_cb, (void *)&m_CustomMenu.ghLAN);
    geventRegisterCallback(&m_CustomMenu.glListener, gui_CustomMenu_cb, (void *)&m_CustomMenu.ghSDCards);
    geventRegisterCallback(&m_CustomMenu.glListener, gui_CustomMenu_cb, (void *)&m_CustomMenu.ghSecurity);    
    geventRegisterCallback(&m_CustomMenu.glListener, gui_CustomMenu_cb, (void *)&m_CustomMenu.ghWaterLevel);
    geventRegisterCallback(&m_CustomMenu.glListener, gui_CustomMenu_cb, (void *)&m_CustomMenu.ghDataTime);    
    geventRegisterCallback(&m_CustomMenu.glListener, gui_CustomMenu_cb, (void *)&m_CustomMenu.ghReturn);

 

 

 

void gui_MainMenu_cb(void* param,GEvent *pe)
{
    switch(pe->type)
    {
        case GEVENT_GWIN_BUTTON:
            printf("000000000000\n\r");
        break;
        default:
        break;            
    };
}

void gui_PlayListMenu_cb(void* param,GEvent *pe)
{
    switch(pe->type)
    {
        case GEVENT_GWIN_BUTTON:
            printf("222222222222\n\r");
        break;
        case GEVENT_GWIN_LIST:
            printf("222222222222\n\r");
        break;
        default:
        break;
        
    };
}

void gui_ManageProgMenu_cb(void* param,GEvent *pe)
{
    switch(pe->type)
    {
        case GEVENT_GWIN_BUTTON:
            printf("111111111111\n\r");
        break;
        case GEVENT_GWIN_LIST:
            printf("111111111111111\n\r");
        break;
        default:
        break;            
    };
}

void gui_CustomMenu_cb(void* param,GEvent *pe)
{
    switch(pe->type)
    { 
        case GEVENT_GWIN_BUTTON:
            printf("3333333333333\n\r");
        break;
        case GEVENT_GWIN_LIST:
            printf("3333333\n\r");
        default:
        break;            

   }

}
   

 

 

 

 

Link to comment
Share on other sites

You only need one gListener object for the entire gwin system. Registering callbacks for gwin objects is unnecessary and is not a good idea.

Create a listen loop instead like in the demo programs. See the widgets demo for a comprehensive example.

In the loop you can always switch on the object handle in the event structure to call individual functions if you want to.

Link to comment
Share on other sites

Have a look at the various GWIN (and widgets) documentation. Especially the /demos directory that comes as part of the library might be a valuable resource. the /demos/modules/gwin and /demos/applications applications will demonstrate the proper use of the event system to dispatch widget events.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...