In the buiw, the MVC design mode is adopted (Figure 10-3), and the MVC (Model
/View/controller) is a frequently used mode in program development. It achieves a good separation between the data layer and the presentation layer. MVC divides an application into three object types: model, maintenance data, and data access methods; view, rendering of partial or all data of the model visual diagram; controller to process events. The view is registered in the model in advance. When the model data changes, each view that has been registered with the model is immediately notified. View to get the latest data from the model and refresh yourself.
Widgets is a fashionable technology on the Internet. Here, Widgets is a plug-in-type extensible UI component framework, a window-based application framework, and introduces the concept of containers, in fact, containers are a special type of widgets.
The model provides the actual data that drives the widget content, manages the registration behavior of listener, and does not focus on the visual expression of data. A bit like STL. Different models support different data types, such as linked lists and vector groups. They also support data types of specific controls or interfaces. When the data changes, the model sends a notification to the initiator who follows the data. Imodel is a basic interface. Other model interfaces are derived from imodel interfaces, including ivaluemodel, iarraymodel, ivectormodel, iinterfacemodel, imenumodel, and itextmodel.
Widgets are small widgets in a window, such as text boxes and image boxes, to complete data expression in a model without knowing the position of the display, you only need to know the content and display area. Widgets listen to data changes in the model and display the data according to the developer's needs. You Can Do Not Display, process, or partially display the data, or even make background changes. Widgets manage focus and key events at the same time. iwidget is a basic interface, and other widget interfaces are derived from the iwidget interface, including icheckwidget, I
Radiowidget, ibuttonwidget, iprogresswidget, itextwidget, isliderwidget, and iwaitcursorwidget.
Container is used to manage the location and layout of a group of widgets and control the display order of widgets on the screen. Generally, a widget
Itself can become a container. According to the layout principle, the container manages widgets like a stack. Widgets are stored from the bottom to the top. When widgets are superimposed, Widgets at the bottom of the stack may be hidden. Only widgets at the top of the stack are displayed on the screen. That is to say, the container first draws the bottom-layer widget and then displays it on the screen layer by layer. Icontainer is a basic interface. Other widget interfaces are derived from iwidget interfaces, including ipropcontainert, iconstraintcontainer, ixycontainer, icardcontainer, and idecorator. A decorator is a special container used to manage and modify specified widgets. Through idecorator, borderwidget, blendwidget, imagewidget, tabwidget, scrollbarwidget, scrollindicatorwidget, viewportwidget, titlewidget, listwidget, gridwidget and pickwidget.
Form is displayed on the page. There are two types: rootform and general form. Rootform provides a general screen layout in advance, manages form stacks, and defines visual elements for forms, including titles, backgrounds, and soft keys, including titles, soft keys, buttons, and backgrounds, set the title area, the display area of the soft key button, and the customer area of a set of forms. The difference between the pop-up dialog box and the full screen display of the mobile phone is as follows, manage unprocessed key events and distribute them to the current form. In addition, the elements in rootform can be replaced or deleted.
Form also contains the title, soft-Key button, background, and other display elements. When the content of the display element changes, a corresponding notification is sent to obtain the events not processed by the current widget. Form is responsible for the application logic, building and placing widgets, setting data in the model, and processing the application execution process. Iform is a basic interface. Other form interfaces are derived from iwidget interfaces, mainly including listform, staticform, and popupform.