#ifndef __IUP_DRAW_BI__ 
#define __IUP_DRAW_BI__

#include once "iup.bi"

enum 
  IUP_DRAW_FILL, 
  IUP_DRAW_STROKE, 
  IUP_DRAW_STROKE_DASH
end enum  

type _IdrawCanvas
  as Ihandle ptr ih
  as integer w, h
#ifdef __FB_WIN32__
  #include once "windows.bi"
  as integer release_dc
  as HBITMAP hBitmap, hOldBitmap
  as HDC     hBitmapDC, hDC
#else
  as any ptr wnd           ' GdkDrawable ptr
  as any ptr pixmap        ' GdkPixmap ptr
  as any ptr gc, pixmap_gc ' GdkGC ptr
#endif
end type

type IdrawCanvas as _IdrawCanvas

extern "c"

' Simple Draw API

' Creates a draw canvas based on an IupCanvas.
' This will create an image for offscreen drawing.
_DF_ iupDrawCreateCanvas(ih as IHandle ptr) as IdrawCanvas ptr

' Destroys the IdrawCanvas.
_DS_ iupDrawKillCanvas(dc as IdrawCanvas ptr)

' Draws the ofscreen image on the screen.
_DS_ iupDrawFlush(dc as IdrawCanvas ptr)

' Rebuild the offscreen image if the canvas size has changed.
' Automatically done in iupDrawCreateCanvas.
_DS_ iupDrawUpdateSize(dc as IdrawCanvas ptr)

' Returns the canvas size available for drawing.
_DS_ iupDrawGetSize(dc as IdrawCanvas ptr, w as integer ptr, h as integer ptr)

' Draws the parent background.
_DS_ iupDrawParentBackground(dc as IdrawCanvas ptr)

' Draws a line.
_DS_ iupDrawLine(dc as IdrawCanvas ptr, x1 as integer, y1 as integer, x2 as integer, y2 as integer, r as ubyte, g as ubyte, b as ubyte, style as integer)

' Draws a filled/hollow rectangle.
_DS_ iupDrawRectangle(dc as IdrawCanvas ptr, x1 as integer, y1 as integer, x2 as integer, y2 as integer, r as ubyte, g as ubyte, b as ubyte,  style as integer)

' Draws a rectangle inverting the color in the canvas.
_DS_ iupDrawRectangleInvert(dc as IdrawCanvas ptr, x1 as integer, y1 as integer, x2 as integer, y2 as integer)

' Draws a filled/hollow arc.
_Ds_ iupDrawArc(dc as IdrawCanvas ptr, x1 as integer, y1 as integer, x2 as integer, y2 as integer, a1 as double, a2 as double, r as ubyte, g as ubyte , b as ubyte, style as integer)

' Draws a filled/hollow polygon. points are arranged xyxyxy...
_DS_ iupDrawPolygon(dc as IdrawCanvas ptr, points as integer ptr, count as integer, r as ubyte, g as ubyte, b as ubyte, style as integer)

' Draws a text. x,y is at left,top corner of the text.
_DS_ iupDrawText(dc as IdrawCanvas ptr, text as const zstring ptr, len_ as integer, x as integer, y as integer, r as ubyte, g as ubyte , b as ubyte, font as const zstring ptr)

' Draws an image. x,y is at left,top corner of the image. Returns the image size.
_DS_ iupDrawImage(dc as IdrawCanvas ptr, name_ as const zstring ptr, make_inactive as integer, x as integer, y as integer, img_w as integer ptr, img_h as integer ptr)

' Sets a rectangle clipping area.
_DS_ iupDrawSetClipRect(dc as IdrawCanvas ptr, x1 as integer, y1 as integer, x2 as integer, y2 as integer)

' Removes clipping.
_DS_ iupDrawResetClip(dc as IdrawCanvas ptr)



end extern


#endif ' __IUP_DRAW_BI__

