wingdi.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. /** @file
  2. * GDI structures and API
  3. *
  4. * @author anlzhao
  5. * @author mandy.wu 2010/01/11 (Add KOK caption support)
  6. * @author tzungming.lin 2010/01/08 (FixCharWidth/FixLineHeight)
  7. * @version 0.1
  8. */
  9. #ifndef _WINGDI_H
  10. #define _WINGDI_H
  11. #include "gui_eng/gel_private.h"
  12. #include "gui_eng/stddefs.h"
  13. #include "gui_eng/device_font.h"
  14. #include "gui_eng/region.h"
  15. #define GDL_SUCCESS (0)
  16. #define GDL_FAILURE (-1)
  17. /* Internal style tranform - use individual style bits 21~31 */
  18. #define GDI_FLAG_PIC_90 (0x100000 << 1)
  19. #define GDI_FLAG_PIC_180 (0x100000 << 2)
  20. #define GDI_FLAG_PIC_270 (0x100000 << 3)
  21. /**
  22. * Get handle to device context.
  23. *
  24. * @param hwnd Handle to the control.
  25. * @param sdRegionHandle Region handle index.
  26. * @return Handle to the device context.
  27. */
  28. HDC GDI_GetDc(HWND hwnd, INT32 sdRegionHandle);
  29. /**
  30. * Free the handle of a device context which was allocated by GDI_get_dc.
  31. *
  32. * @param hdc Handle to the device context.
  33. * @return GUI_SUCCESS if succeed, error codes otherwise.
  34. */
  35. GUIResult_e GDI_ReleaseDc(HDC hdc);
  36. #if 0
  37. /**
  38. * Set a background color to a DC.
  39. *
  40. * @param hdc Handle to the device context.
  41. * @param stBgColor A new background color.
  42. * @return The previous background color.
  43. */
  44. Color_t GDI_SetBgColor(HDC hdc, Color_t stBgColor);
  45. /**
  46. * Set a background mode to a DC.
  47. *
  48. * @param hdc Handle to the device context.
  49. * @param sdBgMode New background mode.
  50. * @return The previous background mode.
  51. */
  52. INT32 GDI_SetBgMode(HDC hdc, INT32 sdBgMode);
  53. #endif
  54. /**
  55. * Set a foreground color to a DC.
  56. *
  57. * @param hdc Handle to the device context.
  58. * @param stFgColor A new foreground color.
  59. * @return The previous foreground color.
  60. */
  61. Color_t GDI_SetFgColor(HDC hdc, Color_t stFgColor);
  62. /**
  63. * Set a pixel value from a DC.
  64. *
  65. * @param hdc Handle to the device context.
  66. * @param sdX X coordinate of a DC.
  67. * @param sdY Y coordinate of a DC.
  68. * @param stColor The pixel value to be set.
  69. * @return GUI_SUCCESS if succeed, error codes otherwise.
  70. */
  71. GUIResult_e GDI_SetPixel(HDC hdc, INT32 sdX, INT32 sdY, Color_t stColor, INT32 *pBlockId);
  72. /**
  73. * Draw a filled rectangle.
  74. *
  75. * @param hdc Handle to the device context.
  76. * @param pRect Pointer to a rectangle.
  77. * @param stColor The color to be filled.
  78. * @return GUI_SUCCESS if succeed, error codes otherwise.
  79. */
  80. GUIResult_e GDI_FastFillRect(HDC hdc, LPRECT pRect, Color_t stColor, INT32 *pBlockId);
  81. /**
  82. * Draw a line.
  83. *
  84. * @param hdc Handle to the device context.
  85. * @param swX1 Start x coordinate.
  86. * @param swY1 Start y coordinate.
  87. * @param swX2 End x coordinate.
  88. * @param swY2 End y coordinate.
  89. * @param wThickness The width of the pen to draw a line.
  90. * @return GUI_SUCCESS if succeed, error codes otherwise.
  91. */
  92. GUIResult_e GDI_DrawLine(HDC hdc, INT16 swX1, INT16 swY1, INT16 swX2, INT16 swY2, UINT16 wThickness, INT32 *pBlockId);
  93. /**
  94. * Draw a rectangle.
  95. *
  96. * @param hdc Handle to the device context.
  97. * @param pRect Rectangle to be drawn.
  98. * @param wThickness The width of the pen to draw a line.
  99. * @return GUI_SUCCESS if succeed, error codes otherwise.
  100. */
  101. GUIResult_e GDI_DrawRect(HDC hdc, PRECT pRect, UINT16 wThickness, INT32 *pBlockId);
  102. /**
  103. * Fill a rectangle.
  104. *
  105. * @param hdc Handle to the device context.
  106. * @param pRect Pointer to a rectangular area to be filled.
  107. * @return GUI_SUCCESS if succeed, error codes otherwise.
  108. */
  109. GUIResult_e GDI_FillRect(HDC hdc, PRECT pRect, INT32 *pBlockId);
  110. /**
  111. * Interface to fill color and do not ignore transparent color.
  112. *
  113. * @param hdc Handle to device context.
  114. * @param pRect Pointer to Rect Struct.
  115. * @return GUI_SUCCESS if succeed, error codes otherwise.
  116. */
  117. GUIResult_e GDI_FillRectWithTransparent(HDC hdc, PRECT pRect, INT32 *pBlockId);
  118. /**
  119. * Interface to draw Icon/bitmap.
  120. *
  121. * @param hdc Handle to device context.
  122. * @param pSrcRect Source area.
  123. * @param pDstRect Destination area.
  124. * @param pImage Pointer to image structure.
  125. * @param pDynSrcPal The pointer of dynamic source palette.
  126. * @param dFlags Flags indicating different draw styles.
  127. * @param bDrawFlag Refer to GDL_XXX definitions in device_gdi.h
  128. * @return GUI_SUCCESS if succeed, error codes otherwise.
  129. */
  130. GUIResult_e GDI_DrawBitmap(HDC hdc, PRECT pSrcRect, PRECT pDstRect, PIMAGEHDR pImage,
  131. PALENTRY *pDynSrcPal, UINT32 dFlags, UINT8 bDrawFlag, INT32 *pBlockId);
  132. /**
  133. * Apply a constant alpha value to draw a bitmap.
  134. *
  135. * @param hdc Handle to device context.
  136. * @param pDstRect Pointer to the dest rectantgle to be drawn.
  137. * @param pImage Pointer to an image structure.
  138. * @param pDynSrcPal Dynamic assigned source palette at runtime.
  139. * @param bAlphaValue The constant alpha value to be applied.
  140. * @return GUI_SUCCESS if succeed, error codes otherwise.
  141. */
  142. GUIResult_e GDI_BlendBitmap(HDC hdc, PRECT pDstRect, PIMAGEHDR pImage, PALENTRY *pDynSrcPal, UINT8 bAlphaValue, INT32 *pBlockId);
  143. /**
  144. * Interface to stretch blit a bitmap.
  145. *
  146. * @param hdc Handle to device context.
  147. * @param pDstRect Pointer to the target rectangle to be drawn.
  148. * @param pImage Pointer to the handle of a bitmap.
  149. * @param pDynSrcPal Dynamic assigned source palette at runtime.
  150. * @param dFlags Flags indicating different draw styles
  151. * @return GUI_SUCCESS if succeed, error codes otherwise.
  152. */
  153. GUIResult_e GDI_StretchBlit(HDC hdc, PRECT pDstRect, PIMAGEHDR pImage, PALENTRY *pDynSrcPal, UINT32 dFlags, INT32 *pBlockId);
  154. #if 0
  155. /**
  156. * Interface to set new object and get previous object.
  157. *
  158. * @param hdc Handle to device context.
  159. * @param newobj Pointer to Object to set like pen, brush.
  160. * @return Poiner to old object if type is found else NULL.
  161. */
  162. obj_ptr GDI_SelectObject(HDC hdc, obj_ptr newobj);
  163. #endif
  164. /**
  165. * Interface to delete the object created using CreateXXX().
  166. *
  167. * @param stObject Pointer to Object to delete like pen, brush.
  168. * @return GUI_SUCCESS if object is valid, error codes otherwise.
  169. */
  170. GUIResult_e GDI_DeleteObject(obj_ptr stObject);
  171. #if 0
  172. /**
  173. * Interface to set the color of the object.
  174. *
  175. * @param object Pointer to Object to be deleted.
  176. * @param stColor Color to be set.
  177. * @return Old color of the object.
  178. */
  179. Color_t GDI_SetObjectColor(obj_ptr object, Color_t stColor);
  180. #endif
  181. /**
  182. * Interface to create solid brush.
  183. *
  184. * @param stcolor Brush color.
  185. * @return Pointer to BRUSH if brush created successfully else NULL.
  186. */
  187. brush_ptr GDI_CreateSolidBrush(Color_t stColor);
  188. /**
  189. * Interface to create pen.
  190. *
  191. * @param stStyle Style of the Pen.
  192. * @param swWidth Width of the pen.
  193. * @param stColor Color of the pen.
  194. * @return Pointer to HPEN if pen created successfully else NULL.
  195. */
  196. pen_ptr GDI_CreatePen(pen_style_t stStyle, INT32 swWidth, Color_t stColor);
  197. /**
  198. * Get the bitmap data from an icon id.
  199. *
  200. * @param hdc Handle to a device context.
  201. * @param swIconId An icon id.
  202. * @param pImgData Return the image data.
  203. * @return GUI_SUCCESS if succeed, error codes otherwise.
  204. */
  205. GUIResult_e GDI_GetBmpData(HDC hdc, INT16 swIconId, IMAGEHDR *pImgData);
  206. /**
  207. * Convert native code string to unicode string depond on Designate or Default Codepage.
  208. *
  209. * @param pNative Native code string
  210. * @param pDest Converted Unicode string
  211. * @param i32DestLen Length limitation of Unicode string, if < 0, ignore dest buffer size
  212. * @return Length of converted unicode string
  213. */
  214. INT32 GDI_Native2UniConvert (HDC hdc, UINT8 *pNative, UINT16 *pDest, INT32 i32DestLen);
  215. /**
  216. * Convert native code string to UTF-8 string depond on Designate or Default Codepage.
  217. *
  218. * @param pNative Native code string
  219. * @param pDest Converted Unicode string
  220. * @param i32DestLen Length limitation of Unicode string, if < 0, ignore dest buffer size
  221. * @return Length of converted unicode string
  222. */
  223. INT32 GDI_Native2Utf8Convert (HDC hdc, UINT8 *pNative, UINT8 *pDest, INT32 i32DestLen);
  224. INT32 GDI_ReleaseBlock(RegionHandle_t sdRegionHandle, INT32 * pBlockId);
  225. INT32 GDI_ReleaseBlockItems(RegionHandle_t sdRegionHandle, INT32 * pBlockId, UINT32 uiItems);
  226. #endif //#ifndef _WINGDI_H