⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aw_control.h

📁 AMLOGIC DPF source code
💻 H
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************
**                                                             	**
**  Copyright (C) 2004 Amlogic,Inc.                            	**
**  All rights reserved                                        	**
**        Filename : aw_control.h /Project:AVOS  				** 
**        Revision : 1.0                                       	**
**                                                             	**
*****************************************************************/
#ifndef _AW_CONTROL_H
#define _AW_CONTROL_H
#include "aw_engine.h"

/**
 * @file aw_control.h
 * @author LiChao, chao_li@amlogic.com.cn
 *
 * In order to develop GUI program more easy, we inport object oriented concept. We design a basic 
 * control and develop the AW GUI System on it. This set of routines handle the basic Controls, like 
 * Button, Menu, Edit, etc, all API's run on top of the core graphics engine routines( see aw_engine.h) 
 * and graphic device drivers(OSD). The basic model of any API on top of AW GUI is to hang in initialize 
 * the screen, keyboard and mouse drivers, then hang in a message loop waiting for an event.  When an 
 * event occurs, if it's a system event like keyboard or mouse or remote activity, then this information 
 * is passed to the customize program converted to an expose event, like key_press, paint message, etc.  
 * If it's a user requesting a graphics operation, then the parameters are decoded and passed to the 
 * appropriate engine routine.  Note that the concept of a window various raw graphics operations are 
 * handled at this API level.  That is, the API defines the concepts of what a window is, what the 
 * coordinate systems are, etc, and then the coordinates are all converted to "screen coordinates" and 
 * passed to the core engine routines to do the real work.  This level also defines graphics or 
 * display contexts and passes that information, including clipping information, to the core engine 
 *routines.
 */
 
/** @defgroup gui_control GUI basic control manage routines.
 * @ingroup gui
 */ 

#define MAX_LENGTH_OF_CLASS_NAME		0x20
#define MAX_LENGTH_OF_WIN_CONTROL_NAME	0x20
#define USE_RESOURCE_HANDLE			0x80		//bit7 -- indicate this point to resource haddle or not

#define WS_OVERLAPPED       0x00000000
#define WS_POPUP            0x80000000
#define WS_CHILD            0x40000000
#define WS_MINIMIZE         0x20000000
#define WS_DISVISIBLE       0x10000000
#define WS_DISABLED         0x08000000
#define WS_CLIPSIBLINGS     0x04000000
#define WS_CLIPCHILDREN     0x02000000
#define WS_MAXIMIZE         0x01000000
#define WS_CAPTION          0x00C00000     /* WS_BORDER | WS_DLGFRAME  */
#define WS_BORDER           0x00800000
#define WS_DLGFRAME         0x00400000
#define WS_VSCROLL          0x00200000
#define WS_HSCROLL          0x00100000
#define WS_SYSMENU          0x00080000
#define WS_THICKFRAME       0x00040000
#define WS_GROUP            0x00020000
#define WS_TABSTOP          0x00010000
#define WS_FOCUSABLE		0x00008000

#define AW_CONTROL_AUTO_WARP     0x0001
#define AW_CONTROL_AUTO_CENTER   0x0002

/*
 * Common Window Styles
 */
#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED     | \
                             WS_CAPTION        | \
                             WS_SYSMENU        | \
                             WS_THICKFRAME)

#define WS_POPUPWINDOW      (WS_POPUP          | \
                             WS_BORDER         | \
                             WS_SYSMENU)

#define WS_CHILDWINDOW      (WS_CHILD		   | \
							 WS_FOCUSABLE)

#define DT_RESOURCE_HANDLE		0x01
#define DT_STRING_DATA			0x02
#define DT_RLE_BMP_DATA			0x04
#define DT_STRING_DATA_CENTER   0x80
#define DT_STRING_DATA_WARP     0x40

#define DT_STRING_COLOR		 0x8000

#define DT_RESOURCE_BMP_DATA	(DT_RESOURCE_HANDLE | DT_RLE_BMP_DATA) 
#define DT_RESOURCE_STRING_DATA	(DT_RESOURCE_HANDLE | DT_STRING_DATA) 

/**
 * @brief Basic struct of draw metadata. We use it to save some basic information of 
 * graphic data and position.
 */
typedef struct {
	/// the graphic left pisition in owner control
	INT16U		draw_pos_x ; 
	/// the graphic top pisition in owner control
	INT16U		draw_pos_y ; 
	/// the graphic width pisition in owner control
	INT16U		draw_width;
	/// the graphic height pisition in owner control
	INT16U		draw_height;
	/// the graphic data, if (draw_type & DT_RESOURCE_HANDLE), this is the 
	/// resource ID, otherwise it is the addr of string or RLE Compress Bmp data
	INT32U		draw_data;	
	///define the type of graphic data, there are four type data we support now:
	///DT_STRING_DATA   normal string data
	///DT_RLE_BMP_DATA  normal RLE Compress Bmp data
	///DT_RESOURCE_BMP_DATA it's a resource handle, represent a RLE Compress Bmp data
	///DT_RESOURCE_STRING_DATA it's a resource handle, represent a string data
	INT16U		draw_type ; 
	///DT_STRING_COLOR it is only for string color,the 0x8000 is the color mask,You need mask the 15th
	//bit when you need set your string color, and reset it after finished it.
	INT16U		draw_color ; 
} DRAWINFO ,*PDRAWINFO;	

typedef struct _hwnd *PHWND;
typedef INT32S (*WINPROC)(PHWND sur_wnd, INT32U msg_type, INT32S msg_para);

/**
 * @brief Basic struct for all Control type.
 * In order to understand the relationship between WNDCLASS Data and HWND Data, we introduce 
 * the Object Oriented Concept -- class and object, WNDCLASS Data and component's stuct are the 
 * calss, WNDCLASS Data define all default action of this type component, and this type component 
 * struct define the properity of this type component. HWND Data is the object, it have a component's 
 * customized data and action. 
 */
typedef struct {
    list_t		link;	 		//class list, for search and register
    CHARSTR*	p_name;
    ///It's a important member which define the component name and it's unique key to 
    ///distinguish other component. 
    CHARSTR		class_name[MAX_LENGTH_OF_CLASS_NAME];	
    ///It's a component extend interface, when we create a component, we'll malloc a space for 
    ///this control which size is sizeof(HWND) + extra_bytes, and you can conver it to another 
    ///struct as you wnat. Please see function AWCreateWinControl to get more detail information.
    INT32U		extra_bytes;
    ///It's a message map function, which decide this component's special action and default 
    ///action of this component. So all same type component have same default action.
	WINPROC 	ClassProc ;
} WNDCLASS, *PWNDCLASS;

/**
 * @brief AW Control have a base struct(HWND), all Controls are inherited from this struct. 
 * Following is the base struct of Control.
 * As said before, the Control's struct is the base struct of all other component, and all other 
 * component share the same struct HWND. There are two kinds of interface for other component to 
 * extend its data. If all component share this struct, we how to distinguish them? We intrduce a 
 * member named pClass in this struct to identify a special component, that's means every component 
 * have a unique WNDCLASS Data. 
 */
typedef struct _hwnd {
	////It's point to the parent component of this component;
	PHWND 		parent;		
	////It's point to the first children of this component;
	PHWND 		children;	
	///It's point to the next child of its parent component; parent, children, siblings 
	///make up a hierarchy struct for all HWND data(all component)  
	PHWND 		siblings;	
	///control class type, Define the component's class name and default action;
	PWNDCLASS	pClass;	
	///Rember the component's status and style	
	INT32U		style;		
	///Define this component's position and size(width and height);
	RECT		winrect;
	///Define this component's name, used to search the component by name, see function AWFindWinCtrlByName;
	CHARSTR		win_name[MAX_LENGTH_OF_WIN_CONTROL_NAME];	
	///Define this component's unique ID;
	INT16U		win_id ;
	INT8U		draw_info_num;
	///Recorder the draw metadata number of this component, see struct DRAWINFO;
	PDRAWINFO	draw_info ;
	/**This is a customized message handle function, when we create a component, this component's 
	* class type decided this component's default action, but if we don't want to some default 
	* action and want replace or enhanve it with other function, then we can given a message 
	* procss and assign it to this member when create this component, if customized function 
	* WinProc return 0, then system will call this customized function WinProc first, and call 
	* default function pClass->ClassProc, this is more like the inheritance of Object Oriented 
	* Programming. Otherwise system will call this customized function WinProc only, this is more 
	* like the overwrite of Object Oriented Programming.
	*/
	WINPROC		WinProc ;
	///This is another way to extend struct HWND to hold more data for other component, we can malloc 
	///an additional data and assign it to this member at this type component's create action process, 
	///like component RcaInfoBar. 
	INT32S		userdata;	/* set window long user data or the point of extra_bytes*/
} HWND ;

//#define AW_DYNAMIC_MALLOC_CLASS
#ifdef AW_DYNAMIC_MALLOC_CLASS
	#define AWClassInit()
	#define AWClassMalloc()	(WNDCLASS *)AVMem_umalloc(sizeof(WNDCLASS))
	#define AWClassFree(a)	AVMem_ufree((void *)a)	
#else
	/** 
	 * @brief Initialize class(control type) list 
	 */
	void AWClassInit(void) ;
	/** 
	 * @brief Malloc a space to save a special control type 
	 */
	PWNDCLASS AWClassMalloc(void) ;
	/** 
	 * @brief Free a special control type 
	 */
	void AWClassFree(PWNDCLASS pAWClass) ;
#endif

/** 
 * @brief Get a class point by it name.
 * @param [in] lpClassName the name string which you want to search.
 * @return If found the class, return the class point, otherwise, return NULL.
 */
PWNDCLASS AWFindClassByName(CHARSTR *lpClassName) ;
/** 
 * @brief Add a new class to class list, you can create a new control of this type class after 
 * register it.
 * @param [in] lpWndClass the class data which you want to register.
 * @return If register success, return 0.
 * @retval 0 success.
 * @retval 1 the class name have exist.
 * @retval 2 Malloc a new space to save new class failure.
 */
INT32S AWRegisterClass(WNDCLASS *lpWndClass) ;

/** 
 * @brief Remove one class from class list.
 * @param [in] lpClassName the class data which you want to remove.
 * @return If register success, return 0.
 * @retval 0 success.
 * @retval 1 don't found the class which you want to remove.
 */
INT32S AWUnregisterClass(CHARSTR *lpClassName) ;

#define AWControlInit()
#define AWControlMalloc(pClass)	\
		(HWND*)AVMem_umalloc(sizeof(HWND) + pClass->extra_bytes)
#define AWControlFree(a)	AVMem_ufree((void *)a)	

/** 
 * @brief Create a special win control.
 * @param [in] lpClassName the class name which is the type of control you want to create.
 * @param [in] lpWindowName this is control's name, you can get this control handle by call 
 * function AWFindWinCtrlByName or AWFindChildCtrlByName.
 * @param [in] dwStyle this is control's special style, like disable, child, can get focus,ect
 * @param [in] x define the left position in it's parent control
 * @param [in] y define the top position in it's parent control
 * @param [in] nWidth define the control's width
 * @param [in] nHeight define the control's height
 * @param [in] hwndParent define the control's parent control.
 * @param [in] lpParam this is a special parameter, which'll send to this control's class 
 * create function to pass some special parameter to create this control, it's a extend 
 * parameter, can be a int data or any ponit's addr value
 * @param [in] pCustomerProc this is a call back function, normally, every class have a call 
 * back function to deal with the window message, like paint or any other event, this is the 
 * default action of class, but user can supply a similar function to do some special customer 
 * action, this is the handle of this kind of function, when a control get a window message, 
 * it'll call this function first, then if this function return 0, system'll call class 
 * process message function, otherwise don't call class process function.
 * @return If create control success, return the handle of this control, otherwise return NULL.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -