/*
** window.c: the implements of window.h
**
** Copyright (C) 2007-2008 SKY-MOBI AS. All rights reserved.
**
** Create date: 2007-12-27 by wandonglin
**
** This file is part of the simple gui library.
** It may not be redistributed under any circumstances.
*/
#include "window.h"
#include "rect.h"
#include "mrc_network.h"
//test point(x, y) is in window hWnd
#define PtInWnd(hWnd, x, y) \
(x >= _LEFT(hWnd) && x < _LEFT(hWnd) + _WIDTH(hWnd) \
&& y >= _TOP(hWnd) && y < _TOP(hWnd) + _HEIGHT(hWnd))
/**
* \brief A type definition for handle to block heap.
*/
typedef DWORD HBLOCKHEAP;
//current top level window
#define HTOPWND \
desktop.top_window_list
//current popup menu
#define HPOPUPMENU \
desktop.popup_menu
//current modal window
#define HMODALDLG \
desktop.modal_window
//current mouse tracker window
#define HMOUSETRACKER \
desktop.mouse_tracker
//current active edit window
#define HACTIVEEDIT \
desktop.hEdit
//current active platform edit handle
#define HPLTEDIT \
desktop.pltEdit
//current application events filter
#define HAPPEVENTFILTER \
desktop.evtfilter
//get the window list
#define _FIRST_CHILD(hWnd) \
((hWnd == HWND_DESKTOP)? HTOPWND : _CHILD(hWnd))
//get the window list reference
#define _CHILDREN_LIST(hWnd) \
((hWnd == HWND_DESKTOP)? &HTOPWND : &_CHILD(hWnd))
// DATA TYPES
///////////////////////////////////////////////////////////////////////////////////////////////
typedef struct SGL_Desktop
{
/* keep the current system font */
HFONT system_font;
/* top level window list */
HWND top_window_list;
/*
* indicator of drawing suspend,
* SGL_SuspendDrawing will increase it,
* and SGL_UnsuspendDrawing will decrease it,
* these two functions must be called as pairs
*/
Sint32 drawing_lock;
/* current popup menu */
HMENU popup_menu;
/* current modal window */
HWND modal_window;
/* current mouse tracker window */
HWND mouse_tracker;
/* current edit window handle */
HWND hEdit;
/* platform edit handle */
int32 pltEdit;
/* application event filter */
SGL_AppEventFilter evtfilter;
#ifdef ENABLE_SGL_KEYREPEAT
int32 hTimer;
BOOL isRepeat;
#endif
}SGL_Desktop;
// GLOBAL DATAS
////////////////////////////////////////////////////////////////////////////////////////////
/**
* \brief Initialize the block heap.
*
* \attention the buffersize and blocksize must can be divided exactly by 4,
* And the buffersize must can be divided exactly by blocksize.
*
* \param buffer the pointer to data buffer
* \param buffersize the data buffer size
* \param blocksize the block size
* \return
* - the heap handle on success
* - NULL otherwise
*/
extern HBLOCKHEAP BlockHeap_Initialize(VOID* buffer, int buffersize, int blocksize);
/**
* \brief Allocate a block from a the block heap.
*
* \param pHeap the pointer to block heap handle
* \return the allocated block address, NUL when no empty block.
*/
extern VOID* BlockHeap_Alloc(HBLOCKHEAP* pHeap);
/**
* \brief Free a block to the block heap.
*
* \param pHeap the pointer to block heap handle
* \param pBlock the block address
*/
extern VOID BlockHeap_Free(HBLOCKHEAP* pHeap, VOID* pBlock);
static SGL_Desktop desktop; //the single instance of desktop
static SGL_Window windows[SGL_MAX_WINDOW_COUNT]; //so winodw will not allow from global heap
static HBLOCKHEAP hWindowsHeap;
// FUNCTION IMPLEMENTS
/////////////////////////////////////////////////////////////////////////////////////////////
/*
* This macro is to help to apply command to all children in the children list.
*
* \param list the children list
* \param first the first child
* \param child to hold the current child the command can access this var
* \param next how to get the next child
* \param command the command apply to the child
*/
#define SGL_MAP_ON_CHILDREN(list, first, child, next, command) {\
if(NULL != (list)) \
{\
(child) = (first);\
do{\
{command;}\
}while(((child) = (next)) != (first));\
}\
}
static VOID
SGL_AddToWindowList(HWND* pHead, HWND hWnd)
{
/*
* here we not search the list before add the child window,
* so user should ensure that the child window not exists in the list
*/
if(*pHead)
{
//not empty, add to head
_NEXT(hWnd) = *pHead;
_PREV(hWnd) = _PREV(*pHead);
_NEXT(_PREV(*pHead)) = hWnd;
_PREV(*pHead) = hWnd;
}else{
//empty list, set prev,next to itself
_NEXT(hWnd) = hWnd;
_PREV(hWnd) = hWnd;
}
*pHead = hWnd;
}
static VOID
SGL_RemoveFromWindowList(HWND* pHead, HWND hWnd)
{
//the child is the first item in the z-order
if(hWnd == *pHead)
*pHead = _NEXT(*pHead);
if(hWnd == *pHead)
{
//the removed child is the only child
*pHead = NULL;
}else{
//remove from the children list
_NEXT(_PREV(hWnd)) = _NEXT(hWnd);
_PREV(_NEXT(hWnd)) = _PREV(hWnd);
}
//reset the child window's pointers
_PARENT(hWnd) = _NEXT(hWnd) = _PREV(hWnd) = NULL;
}
static VOID
SGL_BringToTopOfWindowList(HWND* pHead, HWND hWnd)
{
//remove from the children list
_NEXT(_PREV(hWnd)) = _NEXT(hWnd);
_PREV(_NEXT(hWnd)) = _PREV(hWnd);
//add to the children list
_NEXT(hWnd) = *pHead;
_PREV(hWnd) = _PREV(*pHead);
_NEXT(_PREV(*pHead)) = hWnd;
_PREV(*pHead) = hWnd;
//set the head pointer to the new window
*pHead = hWnd;
}
VOID GUIAPI
SGL_Initialize(VOID)
{
GAL_Initialize();
desktop.system_font = (HFONT)MR_FONT_MEDIUM;
//keep the default
//desktop.drawing_lock = 0;
//desktop.top_window_list = 0;
hWindowsHeap = BlockHeap_Initialize(windows, sizeof(windows), sizeof(SGL_Window));
}
VOID GUIAPI
SGL_Terminate(VOID)
{
//release some resource
GAL_Terminate();
SGL_TRACE("%s, %d: Terminate SGL\n", __FILE__, __LINE__);
}
VOID GUIAPI
SGL_SuspendDrawing(VOID)
{
++desktop.drawing_lock;
}
VOID GUIAPI
SGL_UnsuspendDrawing(VOID)
{
--desktop.drawing_lock;
}
BOOL GUIAPI
SGL_IsSuspendDrawing(VOID)
{
return desktop.drawing_lock > 0;
}
VOID GUIAPI
SGL_GetScreenSize(PSIZE pSize)
{
if(!pSize) return;
pSize->cx = GAL_Width(PHYSICALGC);
pSize->cy = GAL_Height(PHYSICALGC);
}
HFONT GUIAPI
SGL_GetSystemFont(VOID)
{
return desktop.system_font;
}
VOID GUIAPI
SGL_SetSystemFont(HFONT font)
{
desktop.system_font = font;
}
HWND GUIAPI
SGL_GetNextChild (HWND hWnd, HWND hChild)
{
HWND hHead;
if(NULL == hWnd || HWND_DESKTOP == hChild)
return NULL;
hHead = _FIRST_CHILD(hWnd);
if (hChild == NULL)
return hHead;
if (hWnd != _PARENT(hChild))
return NULL;
return _NEXT(hChild) == hHead? NULL : _NEXT(hChild);
}
HWND GUIAPI
SGL_GetTopWindow(HWND hWnd)
{
HWND hTopWnd;
for(hTopWnd = hWnd;
IS_NORMAL_WINDOW(_PARENT(hTopWnd)) && !_IS_SET_ANY(hTopWnd, WS_MODAL);
hTopWnd = _PARENT(hTopWnd));
return hTopWnd;
}
HWND GUIAPI
SGL_FindChildWindow(HWND hWnd, WID id)
{
HWND hChild, pHead;
if(NULL == hWnd) return NULL;
pHead = _FIRST_CHILD(hWnd);
SGL_MAP_ON_CHILDREN(pHead, pHead, hChild, _NEXT(hChild),
if(_WID(hChild) == id)
return hChild
);
return NULL;
}
HWND GUIAPI
SGL_FindChildWindowByPosition(HWND hWnd, int x, int y)
{
HWND hChild;
if(!IS_NORMAL_WINDOW(hWnd))
return NULL;
SGL_MAP_ON_CHILDREN(_CHILD(hWnd), _CHILD(hWnd), hChild, _NEXT(hChild),
if(PtInWnd(hChild, x, y))
return hChild
);
return NULL;
}
VOID GUIAPI
SGL_WindowToScreen(HWND hWnd, int* x, int* y)
{
for(; IS_NORMAL_WINDOW(hWnd); hWnd = _PARENT(hWnd))
{
*x += _LEFT(hWnd);
*y += _TOP(hWnd);
}
}
VOID GUIAPI
SGL_ScreenToWindow (HWND hWnd, int* x, int* y)
{
for(; IS_NORMAL_WINDOW(hWnd); hWnd = _PARENT(hWnd))
{
*x -= _LEFT(hWnd);
*y -= _TOP(hWnd);
}
}
VOID GUIAPI
SGL_PaintWindowEx(HWND hWnd, PRECT pClipRect)
{
HWND hChild;
int x = 0, y = 0;
RECT rchild, rclip;
//draw the background
if(!_IS_SET_ANY(hWnd, WS_TRANSPARENT))
{
SGL_WindowToScreen(hWnd, &x, &y);
GAL_FillBox(PHYSICALGC, x + pClipRect->left, y + pClipRect->top, pClipRect->width, pClipRect->height, _BGCOLOR(hWnd));
}
//send message to hWnd, when return non-zero means that the window will handle the children i
没有合适的资源?快使用搜索试试~ 我知道了~
斯凯MRP源码——SGLUI框架
共158个文件
h:45个
c:39个
bmp:33个
14 下载量 61 浏览量
2011-05-28
15:22:13
上传
评论
收藏 948KB ZIP 举报
温馨提示
SGL为斯凯MRP开发的窗口管理库 本实例为SGL源码 使用本UI你可以开发出强大的MRP应用程序
资源推荐
资源详情
资源评论
收起资源包目录
斯凯MRP源码——SGLUI框架 (158个子文件)
res.7z 67KB
build.bat 69B
game_lib.bat 59B
final.bat 56B
bg.bmp 183KB
ico11.bmp 11KB
ico2.bmp 11KB
ico10.bmp 11KB
ico8.bmp 11KB
ico3.bmp 11KB
ico7.bmp 11KB
ico12.bmp 11KB
ico5.bmp 11KB
ico1.bmp 11KB
ico9.bmp 11KB
ico4.bmp 11KB
ico6.bmp 11KB
signin2.bmp 3KB
signin4.bmp 3KB
signin1.bmp 3KB
signin5.bmp 3KB
signin8.bmp 3KB
signin7.bmp 3KB
signin3.bmp 3KB
signin6.bmp 3KB
toolbar.bmp 2KB
block.bmp 2KB
busy.bmp 2KB
away.bmp 2KB
spin_p.bmp 1KB
spin.bmp 1KB
arrdown.bmp 918B
arrdown_p.bmp 918B
arrright_p.bmp 822B
arrleft.bmp 822B
arrleft_p.bmp 822B
arrright.bmp 822B
window.c 29KB
des.c 22KB
smp_menu.c 18KB
smp_list.c 11KB
smp_edit.c 11KB
smp_tabwindow.c 11KB
smp_calendar.c 10KB
gal.c 8KB
smp_scrollbar.c 7KB
i18n.c 6KB
smp_datepicker.c 6KB
smp_combobox.c 6KB
string.c 6KB
login.c 6KB
smp_button.c 5KB
smp_textinfo.c 5KB
mainwnd.c 5KB
smp_label.c 5KB
smp_msgbox.c 5KB
smp_spin.c 5KB
smp_scrollview.c 4KB
platform.c 4KB
smp_toolbar.c 3KB
base64_decode.c 3KB
smp_flashbox.c 3KB
smp_menuwnd.c 3KB
smp.c 2KB
base64_encode.c 2KB
smp_icownd.c 2KB
plt_msgbox.c 2KB
topwnd.c 2KB
smp_progbar.c 2KB
rect.c 2KB
plt_text.c 1KB
sound.c 1KB
bmp.c 1KB
plt_menu.c 1KB
application.c 534B
md5.c 381B
Thumbs.db 74KB
Thumbs.db 42KB
Thumbs.db 37KB
Thumbs.db 28KB
sglib.h 71KB
window.H 35KB
types.h 8KB
smp_menu.h 7KB
smp_list.h 6KB
gal.h 6KB
smp_edit.H 4KB
smp_tabwindow.h 4KB
string.h 4KB
smp_combobox.h 4KB
smp_scrollbar.h 4KB
smp_button.h 3KB
smp.h 3KB
smp_label.h 3KB
smp_datepicker.h 3KB
smp_spin.h 3KB
base64.h 3KB
platform.h 2KB
smp_msgbox.h 2KB
i18n.h 2KB
共 158 条
- 1
- 2
资源评论
天使之翼
- 粉丝: 152
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功