Jump to content
nicks1980

I want to register the callback on each window

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;            

   }

}
   

 

 

 

 

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...