码迷,mamicode.com
首页 > 其他好文 > 详细

uCGUI窗口操作点滴记录

时间:2014-11-05 23:01:00      阅读:1260      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   io   color   ar   os   使用   for   

一、窗口操作的要点

0、调试时观察的全局变量WM__NumWindows、WM__NumInvalidWindows、WM__FirstWin、NextDrawWin。

1、 创建一个窗口的时候,会给此窗口发送“创建”消息,从而执行它的回到函数;如果创建窗口的状态标志为“可视(WM_CF_SHOW)”,那么在执行GUI_Exec函数时会对窗口进行重绘。如果创建窗口的标志带有WM_CF_ACTIVATE,那么这个窗口在创建的时候也会被激活,否则不激活。
2、 WM_SendMessage()发送消息的函数,本身也是执行消息的函数(通过调用接收方的回调函数),所以调用发送消息的函数发送的消息只可能被处理一次
3、 WM_SelectWindow()选中窗口的意思是:接下来操作(画画、写字)的对象是选中的窗口
4、 删除一个窗口的时候,会给它父亲发送“孩子被删除”的消息,也会给删除窗口自己发送“删除消息”,删除一个窗口的时候会把它的孩子依次删除(递归调用)删除一个窗口的时候,也会使与之有黏贴关系的窗口(比方说其父窗口)设置为无效,将来执行WM_Exec()时对这些窗口进行重绘。
5、 重绘的操作,虽然最后WM_Exec()也给窗口发送重绘消息进行的。但是,实际上重绘不是立即执行的,用户为了使窗口重绘。可以使窗口变为无效,而且无效窗口总数加1,来实现在执行GUI_Exec()或者WM_Exec()时对窗口的重绘。
6、 WM_SetBkWindowColor()设置桌面背景,也会对桌面进行重绘
7、 如果不设置桌面窗口背景,桌面是不可能被重绘的。这是因为桌面窗口默认的背景颜色是无效的颜色。
8、 GUI_Clear()函数,使用时清除的是当前激活的窗口。GUI_Clear()函数是底层的GUI显示函数,用户调用马上就能见到效果。它设置的颜色取自全局变量GUI_Context中的BkColor。
9、 GUI_Exec()或者WM_Exec()会完成所有的重绘工作,才退出函数的执行。 WM_SelectWindow()可以给窗口发送重绘消息,而且这种重绘立即被执行。GUI_Exec或者WM_Exec(),它们在重绘的时候按照从桌面依次到高级别的窗口,最后到顶层窗口的顺序进行重绘。因此,重绘的过程中,肯定会不断的激活不同的窗口,而且会不断的更改全局变量GUI_Context其他的参数值。在执行完GUI_Exec或者WM_Exec()的时候,GUI_Context还能恢复到执行之前的状态,这也是我们希望看到的。
10、 桌面是最底层的窗口,依次向上是高级的窗口
11、 创建桌面窗口的时候,默认的是需要对其重绘的。
12、 WM_SetCallback设置窗口的回调函数,会使窗口无效,引起窗口的重绘。
13、WM_ShowWindow()会使当前窗口无效,并设置窗口标志为可视“WM_SF_ISVIS”。
14、WM_HideWindow()会使其父亲和其同胞无效,并将其窗口可视标志“WM_SF_ISVIS”清除。
15、 GUI_TM_NORMAL、GUI_TM_REV、GUI_TM_TRANS这些模式都不会引起对像素颜色的读取。而GUI_TM_XOR会对像素的颜色进行读取。
16、创建一个列表框,默认的选择是第一行,对应的选项序号是0。一个列表框对应的是一个窗口,但是它占用的动态内存却是数个32字节。

二、与窗口有关的结构体

1、WM_Obj

/* 窗体管理结构体 共30个字节 */
struct WM_Obj {
  GUI_RECT Rect;        //窗体尺寸(x0,y0,x1,y1)     8个字节
  GUI_RECT InvalidRect; //无效区域(x0,y0,x1,y1)     8个字节
  WM_CALLBACK* cb;      //回调函数                     4个字节
    
  WM_HWIN hNextLin;     //指向链表中的下一个窗体       2个字节
    
  WM_HWIN hParent;      //当前窗体的父窗体             2个字节
  WM_HWIN hFirstChild;  //当前窗体的第一个子窗体       2个字节
  WM_HWIN hNext;        //下一个兄弟窗体               2个字节
    
  U16 Status;           //标志位                       2个字节
};

2、WM_MESSAGE

struct WM_MESSAGE {
  int MsgId;            //信息的类型
  WM_HWIN hWin;         //信息的接收窗口
  WM_HWIN hWinSrc;      //发送信息的源窗口
  union {
    const void* p;      
    int v;
    GUI_COLOR Color;
  } Data;
};

①Messages Ids

/*********************************************************************
*
*               Messages Ids

The 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 */

三、窗口重绘的过程

GUI_Exec()-->
GUI_Exec1()-->
WM_Exec()-->
WM_Exec1()-->
_DrawNext-->
WM__Paint-->
WM_PaintWinAndOvlays-->
__Paint1-->
WM_SendMessage-->
WmCallback(回调函数)

四、窗口创建的标志

#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)

五、桌面窗口的默认回调函数

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窗口操作点滴记录

标签:des   style   blog   io   color   ar   os   使用   for   

原文地址:http://www.cnblogs.com/amanlikethis/p/4077335.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!