Ucgui window operation records

Source: Internet
Author: User

I. Key Points of window operations

0. global variables WM _ numwindows, WM _ numinvalidwindows, WM _ firstwin, and nextdrawwin observed during debugging.

1. When a window is created, a "CREATE" message is sent to the window to execute its return function. If the status of the window is marked as "visible (wm_cf_show )", the window will be repainted when the gui_exec function is executed. If the wm_cf_activate flag is used for creating a window, the window is also activated when it is created. Otherwise, the window is not activated.
2. The function for sending messages by wm_sendmessage () is also a function for executing messages (by calling the callback function of the receiver). Therefore, messages sent by calling the function for sending messages can only be processed once.
3. wm_selectwindow () the selected window means that the objects in the next operation (painting and writing) are selected windows.
4. When deleting a window, the father will be sent a message of "the child is deleted", and a "Delete message" will also be sent to the deletion window ", when a window is deleted, its child is deleted (recursively called) in turn, and the window associated with the window (for example, its parent window) is also set to invalid, these windows will be repainted when wm_exec () is executed in the future.
5. The re-painting operation, although the last wm_exec () also sends a re-painting message to the window. However, in fact, the re-painting is not executed immediately. You need to re-paint the window. You can make the window invalid and Add 1 to the total number of invalid windows to re-paint the window when you execute gui_exec () or wm_exec.
6. wm_setbkwindowcolor () sets the desktop background and redraws the desktop.
7. If the background of the desktop window is not set, the desktop cannot be repainted. This is because the Default background color of the desktop window is invalid.
8. The gui_clear () function clears the currently activated window during use. The gui_clear () function is the underlying GUI display function. You can see the result immediately after calling it. The color is taken from bkcolor in the global variable gui_context.
9. gui_exec () or wm_exec () will complete all re-painting before exiting the function execution. Wm_selectwindow () can send a re-painting message to the window, and the re-painting is immediately executed. Gui_exec or wm_exec (), which are re-painted according to the order from the desktop to the high-level window, and finally to the top-level window. Therefore, during the re-painting process, different windows will be continuously activated, and other parameter values of the global variable gui_context will be constantly changed. After executing gui_exec or wm_exec (), gui_context can be restored to the status before execution, which we hope to see.
10. The desktop is the bottom-Layer window, and the top is the advanced window.
11. When creating a desktop window, you need to repaint it by default.
12. wm_setcallback sets the callback function of the window, which will invalidate the window and cause the re-painting of the window.
13. wm_showwindow () will invalidate the current window and set the window flag to "wm_sf_isvis ".
14. wm_hidewindow () will invalidate the parent and his siblings, and clear the visible "wm_sf_isvis" of the window.
15. In the gui_tm_normal, gui_tm_rev, and gui_tm_trans modes, the pixel color is not read. Gui_tm_xor reads the pixel color.
16. Create a list box. The first row is selected by default, and the corresponding option number is 0. A list box corresponds to a window, but it occupies several 32 bytes of dynamic memory.

2. Window-related struct

1. wm_obj

/* A total of 30 bytes of form Management struct */struct wm_obj {gui_rect rect; // 8 bytes of form size (x0, y0, X1, Y1) gui_rect invalidrect; // invalid region (x0, y0, X1, Y1) 8 bytes wm_callback * CB; // callback function 4 bytes wm_hwin hnextlin; // two wm_hwin hparent bytes are directed to the next form in the linked list; // two wm_hwin hfirstchild bytes of the parent form of the current form; // two wm_hwin hnext bytes of the first child form of the current form; // The next brother form has two UTF-8 status; // The flag has two bytes };

2. wm_message

Struct wm_message {int msgid; // type of information wm_hwin hwin; // Receiving Window of Information wm_hwin hwinsrc; // source window of sending information Union {const void * P; int V; gui_color color;} data ;};

① Messages IDS

/***********************************************************************               Messages IdsThe following is the list of windows messages.*/#define WM_CREATE                   0x0001  /* The first message received, right after client has actually been created */#define WM_MOVE                     0x0003  /* window has been moved (Same as WIN32) */#define WM_SIZE                     0x0005  /* Is sent to a window after its size has changed (Same as WIN32, do not change !) */#define WM_DELETE                   11      /* Delete (Destroy) command: This tells the client to free its data strutures since the window                                              it is associates with no longer exists.*/#define WM_TOUCH                    12      /* Touch screen message */#define WM_TOUCH_CHILD              13      /* Touch screen message to ancestors */#define WM_KEY                      14      /* Key has been pressed */#define WM_PAINT                    0x000F  /* Repaint window (because content is (partially) invalid */#if GUI_SUPPORT_MOUSE#define WM_MOUSEOVER                16      /* Mouse has moved, no key pressed */#define WM_MOUSEOVER_END            18      /* Mouse has moved, no key pressed */#endif#define WM_PID_STATE_CHANGED        17      /* Pointer input device state has changed */#define WM_GET_INSIDE_RECT          20      /* get inside rectangle: client rectangle minus pixels lost to effect */#define WM_GET_ID                   21      /* Get id of widget */#define WM_SET_ID                   22      /* Set id of widget */#define WM_GET_CLIENT_WINDOW        23      /* Get window handle of client window. Default is the same as window */#define WM_CAPTURE_RELEASED         24      /* Let window know that mouse capture is over */#define WM_INIT_DIALOG              29      /* Inform dialog that it is ready for init */#define WM_SET_FOCUS                30      /* Inform window that it has gotten or lost the focus */#define WM_GET_ACCEPT_FOCUS         31      /* Find out if window can accept the focus */#define WM_NOTIFY_CHILD_HAS_FOCUS   32      /* Sent to parent when child receives / loses focus */#define WM_NOTIFY_OWNER_KEY         33      /* Some widgets (e.g. listbox) notify owner when receiving key messages */#define WM_GET_BKCOLOR              34      /* Return back ground color (only frame window and similar) */#define WM_GET_SCROLL_STATE         35      /* Query state of scroll bar */#define WM_SET_SCROLL_STATE         36      /* Set scroll info ... only effective for scrollbars */#define WM_NOTIFY_CLIENTCHANGE      37      /* Client area may have changed */#define WM_NOTIFY_PARENT            38      /* Notify parent. Information is detailed as notification code */#define WM_NOTIFY_PARENT_REFLECTION 39      /* Notify parent reflection.                                                Sometimes send back as a result of the WM_NOTIFY_PARENT message                                               to let child react on behalf of its parent.                                               Information is detailed as notification code */#define WM_NOTIFY_ENABLE            40      /* Enable or disable widget */#define WM_NOTIFY_VIS_CHANGED       41      /* Visibility of a window has or may have changed */#define WM_HANDLE_DIALOG_STATUS     42      /* Set or get dialog status */#define WM_GET_RADIOGROUP           43      /* Send to all siblings and children of a radio control when                                               selection changed */#define WM_MENU                     44      /* Send to owner window of menu widget */#define WM_SCREENSIZE_CHANGED       45      /* Send to all windows when size of screen has changed */#define WM_TIMER                    0x0113  /* Timer has expired              (Keep the same as WIN32) */#define WM_WIDGET                   0x0300  /* 256 messages reserved for Widget messages */#define WM_USER                     0x0400  /* Reserved for user messages ... (Keep the same as WIN32) *//***********************************************************************               Notification codes** The following is the list of notification codes send* with the WM_NOTIFY_PARENT message*/#define WM_NOTIFICATION_CLICKED             1#define WM_NOTIFICATION_RELEASED            2#define WM_NOTIFICATION_MOVED_OUT           3#define WM_NOTIFICATION_SEL_CHANGED         4#define WM_NOTIFICATION_VALUE_CHANGED       5#define WM_NOTIFICATION_SCROLLBAR_ADDED     6      /* Scroller added */#define WM_NOTIFICATION_CHILD_DELETED       7      /* Inform window that child is about to be deleted */#define WM_NOTIFICATION_GOT_FOCUS           8#define WM_NOTIFICATION_LOST_FOCUS          9#define WM_NOTIFICATION_SCROLL_CHANGED     10#define WM_NOTIFICATION_WIDGET             11      /* Space for widget defined notifications */#define WM_NOTIFICATION_USER               16      /* Space for  application (user) defined notifications */

Iii. Process of redrawing windows

Gui_exec () -->
Gui_exec1 () -->
Wm_exec () -->
Wm_exec1 () -->
_ Drawnext -->
WM _ paint -->
Wm_paintwinandovlays -->
_ Paint1 -->
Wm_sendmessage -->
Wmcallback (callback function)

Iv. Sign of Window Creation

#define WM_CF_HASTRANS         (1<<0)  /* Has transparency. Needs to be defined for windows which do not fill the entire                                          section of their (client) rectangle. */#define WM_CF_HIDE             (0<<1)  /* Hide window after creation (default !) */#define WM_CF_SHOW             (1<<1)  /* Show window after creation */#define WM_CF_MEMDEV           (1<<2)  /* Use memory device for redraws */#define WM_CF_STAYONTOP        (1<<3)  /* Stay on top */#define WM_CF_DISABLED         (1<<4)  /* Disabled: Does not receive PID (mouse & touch) input *//* Create only flags ... Not available as status flags */#define WM_CF_ACTIVATE         (1<<5)  /* If automatic activation upon creation of window is desired */#define WM_CF_FGND             (0<<6)  /* Put window in foreground after creation (default !) */#define WM_CF_BGND             (1<<6)  /* Put window in background after creation *//* Anchor flags */#define WM_CF_ANCHOR_RIGHT     (1<<7)  /* Right anchor ... If parent is resized, distance to right will remain const (left is default) */#define WM_CF_ANCHOR_BOTTOM    (1<<8)  /* Bottom anchor ... If parent is resized, distance to bottom will remain const (top is default) */#define WM_CF_ANCHOR_LEFT      (1<<9)  /* Left anchor ... If parent is resized, distance to left will remain const (left is default) */#define WM_CF_ANCHOR_TOP       (1<<10) /* Top anchor ... If parent is resized, distance to top will remain const (top is default) */#define WM_CF_CONST_OUTLINE    (1<<11) /* Constant outline. This is relevant for transparent windows only. If a window is transparent                                       and does not have a constant outline, its background is invalided instead of the window itself.                                       This causes add. computation time when redrawing. */#define WM_CF_LATE_CLIP        (1<<12)#define WM_CF_MEMDEV_ON_REDRAW (1<<13)#define WM_CF_RESERVED3        (1<<14)#define WM_CF_RESERVED4        (1<<15)

5. Default callback function of the desktop window

static void cbBackWin( WM_MESSAGE* pMsg) {  const WM_KEY_INFO* pKeyInfo;  switch (pMsg->MsgId) {  case WM_KEY:    pKeyInfo = (const WM_KEY_INFO*)pMsg->Data.p;    if (pKeyInfo->PressedCnt == 1) {      GUI_StoreKey(pKeyInfo->Key);    }    break;  case WM_PAINT:    {      int LayerIndex;      #if GUI_NUM_LAYERS > 1        LayerIndex = _DesktopHandle2Index(pMsg->hWin);      #else        LayerIndex = 0;      #endif      if (WM__aBkColor[LayerIndex] != GUI_INVALID_COLOR) {        GUI_SetBkColor(WM__aBkColor[LayerIndex]);        GUI_Clear();      }    }  default:    WM_DefaultProc(pMsg);  }}

 

Ucgui window operation records

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.