uCGUI窗口操作点滴记录

一、窗口操作的要点

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);
  }
}
时间: 2024-12-16 13:41:59

uCGUI窗口操作点滴记录的相关文章

uCGUI窗口操作要点

1. 创建一个窗口的时候,会给此窗口发送“创建”消息,从而执行它的回到函数:如果创建窗口的状态标志为“可视(WM_CF_SHOW)”,那么在执行GUI_Exec函数时会对窗口进行重绘.如果创建窗口的标志带有WM_CF_ACTIVATE,那么这个窗口在创建的时候也会被激活,否则不激活.2. WM_SendMessage()发送消息的函数,本身也是执行消息的函数(通过调用接收方的回调函数),所以调用发送消息的函数发送的消息只可能被处理一次3. WM_SelectWindow()选中窗口的意思是:接下

学习:窗口操作常用记录

窗口最大/小/正常化操作: 消息:WM_SYSCOMMAND /* D:\Visual_Studio_repos\MFC\8*/ SC_MAXIMIZE (or SC_ZOOM) Maximize the CWnd object. SC_MINIMIZE (or SC_ICON) Minimize the CWnd object. SC_RESTORE Restore window to normal position and size. SendMessage(WM_SYSCOMMAND, S

点滴记录——Ubuntu 14.04中安装Sublime Text 3并使用SublimeClang插件

转载请说明出处:http://blog.csdn.net/cywosp/article/details/32721011 Sublime Text是个跨平台的编辑器,支持Windows.Linux.Mac系统平台,支持各种语言的代码编辑,配合上对应的插件,话上点时间学习,你将会对它爱不释手,大大的提高你的编码效率.本文将讲解在Ubuntu 14.04系统中安装SublimeText 3,并配置SublimeClang插件来配置C/C++开发环境. 1. Sublime Text 3的下载安装 到

点滴记录——Windows 7中安装Sublime Text 3、cynwin、SublimeClang

转载请说明出处:http://blog.csdn.net/cywosp/article/details/34429697 1. 到https://www.cygwin.com/下载setup-x86_64.exe安装文件,下载后采用默认路劲安装,在选库的时候,选择相应的gcc g++ 2.到http://www.sublimetext.com/3下载Windows 64 bit的安装包,下载后安装 3. 安装Package Control 安装好sublime text 3后打开,然后按快捷键"

python 点滴记录6:ubuntu 安装pycharm

想在ubuntu下学习python开发,IDE准备使用pycharm.记录一下安装过程: 要想运行pycharm,需要有java环境,因为pycharm是用java编写的.ubunutn系统默认安装的是openjdk,而我们需要的是oracle java. 搜索oracle的java软件包: apt-cache search oracle-java 搜不到任何包. 搜索openjdk包: apt-cache search java7 出现类似以下安装包: openjdk-7-jdk - Open

window.open()方法用于子窗口数据回调至父窗口,即子窗口操作父窗口

window.open()方法用于子窗口数据回调至父窗口,即子窗口操作父窗口 项目中经常遇到一个业务逻辑:在A窗口中打开B窗口,在B窗口中操作完以后关闭B窗口,同时自动刷新A窗口(或局部更新A窗口)(或将数据传回A窗口) 以下是从实际项目中截取出来和window.open()方法相关的代码,业务逻辑如下: 1. 点击父窗口的div标签(id="addMatchSchedule"),出发点击事件,打开子窗口: 2. 点击子窗口的button按钮,触发点击时间,即调用addSchduleI

点滴记录——Ubuntu 14.04中gedit打开文件出现中文乱码问题

在中文支持配置还不完整的Ubuntu 14.04中,使用gedit打开带有中文字符的文件有时会出现乱码的情况,这是由于gedit对字符编码匹配不正确导致的,解决方法如下: 在终端中输入如下命令,然后重新打开gedit即可: gsettings set org.gnome.gedit.preferences.encodings auto-detected "['GB18030', 'GB2312', 'GBK', 'UTF-8', 'BIG5', 'CURRENT', 'UTF-16']"

点滴记录——在Ubuntu 14.04中使SublimeText 3支持中文输入法

在Ubuntu 14.04中安装了SublimeText 3之后发现既然不支持输入中文,于是在网上搜罗一下,发现很多人遇到了同样的问题,但是解决办法大该就只有一个.下面根据自身的安装及解决办法总结如下: 1. SublimeText 3的安装 安装方式有多种,本文所描述的是从官方网站上下载64位的.deb文件 ,具体为http://c758482.r82.cf2.rackcdn.com/sublime-text_build-3059_amd64.deb文件,下载后双击即会自动使用默认的安装软件安

js子窗口操作父窗口的标签

======================================父窗体 <input id="aaaa" type="button"/> function upfile()         {                         resultValue = window.showModelessDialog("ceshi.aspx?file=DownFile", window, "dialogWidt