Create your own GUI in BREW (2)-tabpane implementation

Source: Internet
Author: User
Let's discuss the implementation of the tabpane effect. Based on our experience in igmenuctl, it should not be difficult.

Define several object structures: // custom menu items
Typedef struct
...{
Iimage * pimage; // Image

Uint16 witemid;
Uint32 dwdata;

} Gtabitem;

This is a big image. The entire tabpane is defined as follows: struct _ igtabpanectl ...{

Const aeevtbl (igtabpanectl) * PVT;

Uint32 m_nrefs;
Ishell * m_pishell;
Idisplay * m_pidisplay;
Imodule * m_pimodule;

Tqueuelist * m_pdatalist;

Int m_index;

Boolean m_isactive;

Aeerect m_rect;

};

It is much simpler than the menu, except m_pdatalist. There must be no more defined methods, as shown below: aeeinterface (igtabpanectl)
...{
Declare_ibase (igtabpanectl)

Declare_icontrol (igtabpanectl)

Boolean (* additemex) (igtabpanectl * Po, gtabitem * PAI );
Boolean (* getitemdata) (igtabpanectl * Po, uint16 nitemid, uint32 * pldata );

Void (* setsel) (igtabpanectl * Po, uint16 nitemid );
Uint16 (* getsel) (igtabpanectl * Po );

INT (* getitemcount) (igtabpanectl * Po );
Uint16 (* getitemid) (igtabpanectl * Po, int nidx );
Boolean (* getitem) (igtabpanectl * Po, uint16 WID, gtabitem * PAI );

};

OK. In handleevent, one of the two functions, we need to deal with the left and right direction keys. We only need to modify m_index. You can skip the SELECT statement here.

In redraw, only the images recorded in m_pdatalist are displayed based on m_index.

In fact, the key here is that the tabpane itself does not have any functionality, because it only provides a container, therefore, the key of the dwdata pointer stored in it is another component.
That is to say, we need to put the pointer of a component (such as igmenuctl and ihtmlviewer) in dwdata of a gtabitem so that when this tabitem becomes the current page, we also need to display the bound component.

The general operation is as follows: static void buildtabmenu (Unione * PME)
...{
Tqueuelist * P;
Gtabitem ci;

// Construct the current tab menu
If (! PME-> pmenutab)
If (success = igtabpanectl_new (0, PME-> A. m_pishell, PME-> A. m_pimodule, (imodule **) & PME-> pmenutab ))
...{
Aeerect REC;
Setaeerect (& rec, 0,0, PME-> deviceinfo. cxscreen, PME-> deviceinfo. cyscreen );
Igtabpanectl_setrect (PME-> pmenutab, & REC );
}
Else
Return;


If (PME-> pmenutab)
...{
// Step 1: Clear the original bound data
Cleanmenutaboption (PME-> pmenutab );

Igtabpanectl_reset (PME-> pmenutab );
P = PME-> ptablist;
While (P)
...{
Timagedata * pimgdata;
Titemdata * pdata = (titemdata *) P-> pdata;

Pimgdata = NULL;
If (pdata-> icon> 0)
Pimgdata = mainimagequeue_findbycode (PME-> picolist, pdata-> icon );

...{
Toptiontab * ptopt = (toptiontab *) malloc (sizeof (toptiontab ));
If (! Ptopt)
Return;

Zeroat (ptopt );

// Read the header data of the corresponding file of each project
Loadconfiglista (PME, pdata-> type, pdata-> ID, & ptopt-> tabdata, & ptopt-> itemcount, & ptopt-> pitemlist, & ptopt-> iconcount, & ptopt-> piconlist, & ptopt-> imagecount, & ptopt-> pimagelist );
If (pdata-> type = type_control)
Buildmusicpane (PME, ptopt );
Else if (pdata-> type = type_one)
Buildonepane (PME, ptopt );
Else if (pdata-> type = type_picture)
Buildpicturepane (PME, ptopt );
Else
Buildmenupane (PME, ptopt );

CI. dwdata = (uint32) ptopt;

CI. pimage = pimgdata-> IMG;
CI. witemid = pdata-> ID;

Igtabpanectl_additemex (PME-> pmenutab, & CI );
}
P = p-> pnext;
}

}
}

Construct a tabpane and add the constructed components to its tab pages, such as buildonepane and buildpicturepane.

Then, in handleevent, the key event is sent to tabpane for processing. If it is processed (it indicates that the left and right direction keys are pressed ), you also need to load the menu (that is, load the corresponding component according to the index of the tab currently changed ). If (igtabpanectl_handleevent (PME-> PAPP-> pmenutab, ecode, wparam, dwparam ))
...{
Loadmenu (PME, wparam );
Return true;
}

In this way, you can.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.