'#define __USE_GTK3__
'#define UNICODE

#include "keys.bi"

#include "dir.bi"

#include Once "gtk/gtk.bi"

#include Once "crt/stdio.bi"

#include Once "crt/string.bi" 

#include Once "crt/stdlib.bi"

#include Once "zlib.bi"

#include Once "X11/Xlib.bi"

#include Once "GL/gl.bi"

#include Once "GL/glu.bi"

#include Once "extwstring.bi"

#ifndef USTRING
	
	#ifdef UNICODE
		Type USTRING As extWstring
	#else
		Type USTRING As String
	#endif
	
#endif

' Class:
' 1 - ButtonGadget
' 2 - EditorGadget
' 3 - ButtonImageGadget
' 4 - ImageGadget
' 5 - TextGadget
' 6 - StringGadget
' 7 - SpinGadget
' 8 - CalendarGadget
' 9 - CheckBoxGadget
' 10 - OptionGadget
' 11 - HyperLinkGadget
' 12 - TrackBarGadget
' 13 - ComboBoxGadget
' 14 - ComboBoxImageGadget
' 15 - ListBoxGadget
' 16 - GroupGadget
' 17 - WebGadget
' 18 - ProgressBarGadget
' 19 - ListViewGadget
' 20 - TreeViewGadget
' 21 - ContainerGadget
' 22 - PanelGadget
' 23 - ScrollBarGadget
' 24 - GadgetToolTip
' 25 - SysTray
' 26 - OpenGlGadget
' 27 - StatusBarGadget

#ifndef BOOL 

#define BOOL Byte

#endif

#ifndef M_PI

#define M_PI 3.14159265358979323846

#endif

#define Integer32 Long

#define Bgr(r, g, b) Cast(Long, (Cast(Ubyte, (r)) Or (Cast(Short, Cast(Ubyte, (g))) Shl 8)) Or (Cast(Long, Cast(Ubyte, (b))) Shl 16))

#define MAKELONG(a, b) Cast(Long, Cast(Ushort, Cast(Ulongint, (a)) And &hffff) Or (Cast(Ulong, Cast(Ushort, Cast(Ulongint, (b)) And &hffff)) Shl 16)) ' low,high

#define FILE_BEGIN SEEK_SET

#define FILE_CURRENT SEEK_CUR

#define FILE_END SEEK_END

#define TBS_HORZ 0

#define TBS_VERT 2

#define WS_POPUP	&h80000000

#define WS_VISIBLE	&h10000000

#define WS_OVERLAPPEDWINDOW	&hCF0000

#define WS_MAXIMIZE	&h1000000

#define WS_MINIMIZE	&h20000000

#define WS_VSCROLL &h00200000

#define WS_HSCROLL &h00100000

#define FB_BS_PUSHLIKE  &h00001000

#define BS_ICON 0

#define BS_BITMAP 0

#define SS_CENTER 1

#define SS_RIGHT 2

#define SS_LEFT 0

#define SS_NOTIFY 256

#define ES_LEFT 0

#define ES_CENTER 1

#define ES_RIGHT 2

#define ES_PASSWORD &h0020

#define ES_READONLY &h0800

#define ES_NUMBER &h2000

#define UDS_WRAP 1

#define OFN_ALLOWMULTISELECT &h200

#define OFN_DIRECTORY &h400

#define LBS_EXTENDEDSEL &h0800

#define LBS_SORT &h0002

#define LVS_NOCOLUMNHEADER &h4000

#define LVS_SINGLESEL &h4

#define LVS_EX_GRIDLINES &h1

#define LVIF_TEXT 1

#define LVIF_IMAGE 2

#define LVIS_SELECTED 1

#define LVIS_FOCUSED 1

#define TVI_FIRST 0

#define TVI_LAST -1

#define PBS_SMOOTH 1

#define PBS_VERTICAL 4

#define PBS_MARQUEE 8

#define SBS_HORZ 0

#define SBS_VERT 1

#define MB_OK 0

#define MB_YESNO 4

#define MB_YESNOCANCEL 3

#define IDOK 1

#define IDYES 6

#define IDNO 7

#define IDCANCEL 2

#define FB_IGNORE 999999

#define CC_RGBINIT 1

#define Eventgadget &h401

#define Eventmenu  &h402

#define Eventclose &h10

#define Eventmousemove  &H200

#define Eventmousewheel &H20A

#define Eventactivate &H6

#define Eventsize     &h5

#define Eventmove     &h3

#define Eventkeydown &h100

#define Eventkeyup   &h101

#define Eventlbdown   &H201

#define Eventlbup     &H202

#define Eventrbdown   &H204

#define Eventrbup     &H205

#define Eventmbdown   &H207

#define Eventmbup     &H208

#define Eventdblclick &H209

#define Eventtimer &H113

#define Eventnumbertoolbar Eventnumber

#define MK_SHIFT GDK_SHIFT_MASK

#define MK_CONTROL GDK_CONTROL_MASK

#define MK_LBUTTON GDK_BUTTON1_MASK

#define MK_MBUTTON GDK_BUTTON2_MASK

#define MK_RBUTTON GDK_BUTTON3_MASK

#define FILE_ATTRIBUTE_HIDDEN &h02

#define FILE_ATTRIBUTE_ARCHIVE &h20

#define FILE_ATTRIBUTE_DIRECTORY &h10

#define FILE_ATTRIBUTE_READONLY &h01

#define FILE_ATTRIBUTE_SYSTEM &h04

#define TBSTYLE_TOOLTIPS &h100

#define SBT_TOOLTIPS &h800

#define STD_CUT 0

#define STD_COPY 1

#define STD_PASTE 2

#define STD_UNDO 3

#define STD_REDOW 4

#define STD_DELETE 5

#define STD_FILENEW 6

#define STD_FILEOPEN 7

#define STD_FILESAVE 8

#define STD_PRINTPRE 9

#define STD_PROPERTIES 10

#define STD_HELP 11

#define STD_FIND 12

#define STD_REPLACE 13

#define STD_PRINT 14

#define TBSTYLE_BUTTON &h0

#define TBSTYLE_CHECK &h2

#define TBSTATE_CHECKED &h1

#define TBSTATE_ENABLED &h4

#define TBSTATE_HIDDEN &h8

#define TBSTATE_INDETERMINATE &h10

#define IDB_STD_SMALL_COLOR 1

#define IDB_STD_LARGE_COLOR 2

Const WS_TABSTOPENABLE = 0

Const PS_SOLID = 0

Const PS_DASH = 1

Const PS_DOT = 2

Const PS_DASHDOT = 3

Const PS_DASHDOTDOT = 4

Const PS_NULL = 5

Const ANTIALIAS_NONE = CAIRO_ANTIALIAS_NONE

Const ANTIALIAS_FAST = CAIRO_ANTIALIAS_FAST

Const ANTIALIAS_GOOD = CAIRO_ANTIALIAS_GOOD

Const ANTIALIAS_BEST = CAIRO_ANTIALIAS_BEST

Const DT_WORDBREAK = &h00000010

Const DT_LEFT = &h00000000

Const DT_CENTER = &h00000001

Const DT_RIGHT = &h00000002

Const DT_NOCLIP = &h00000100

Const DT_SINGLELINE = &h00000020

Enum w9WrapMode
	WrapModeTile
	WrapModeTileFlipX
	WrapModeTileFlipY
	WrapModeTileFlipXY
	WrapModeClamp
End Enum

Enum w9FontStyle
	FontStyleRegular = 0
	FontStyleBold = 1
	FontStyleItalic = 2
	FontStyleBoldItalic = 3
	FontStyleUnderline = 4
	FontStyleStrikeout = 8
End Enum

Enum w9Unit
	UnitWorld
	UnitDisplay
	UnitPixel
	UnitPoint
	UnitInch
	UnitDocument
	UnitMillimeter
End Enum

Type HWND As GtkWidget Ptr

Type Hbitmap As GdkPixbuf Ptr

Type Handle As FILE Ptr

Type HMENU As Any Ptr

Type HDC As Any Ptr

Type COLORREF As Long

Type Node 
	
	As Long x 
	
	As Node Ptr l,r
	
End Type

Type TLikeEvent
	
	w As HWND ' widget
	
	Eventnumber As Long ' number
	
	Eventnumberlistview As Long ' number listview
	
	Eventnumbertreeview As Long ' number treeview
	
	param1 As Long ' any data
	
	event_ As Long ' event	
	
End Type

Type ListT
	
	anyOneData As Integer
	
	anyTwoData As Integer
	
	anyThreeData As Integer
	
	anyFourData As Integer
	
	nextNode As ListT Ptr	
	
End Type

Type LinList
	
	firstNode As ListT Ptr 
	
	lastNode As ListT Ptr 
	
	Declare Sub addNodeSub( g As Integer , w As Integer , cl As Integer = 0 , iAnyData As Integer = 0) 
	
	Declare Sub removeNodeSub (As Integer)
	
	Declare Sub removeList(delList As LinList Ptr)
	
	Declare Function findNodeFunc(As Integer) As ListT Ptr
	
End Type

Type GlobalTypeWindow9
	
	ListGadgets As LinList Ptr
	
	ListWinAndContainers As LinList Ptr 
	
	ListRangeForSliders As LinList Ptr 
	
	ListMenus As LinList Ptr
	
	ListIncBin As LinList Ptr
	
	ListToolBar As LinList Ptr
	
	ListShortCut As LinList Ptr
	
	treeNumberGadgets As Node Ptr   
	
	CurentHwnd As Hwnd
	
	OptGroup As Any Ptr ' for OptionGadget
	
	fontDefault As PangoFontDescription Ptr
	
	fontCurent As PangoFontDescription Ptr
	
	indexEvent As Long
	
	Eventhwnd As HWND
	
	Eventkey As Long
	
	EventKeyHardware As Long 
	
	Sizex As Long
	
	Sizey As Long
	
	Mousex As Long
	
	Mousey As Long
	
	Eventnumber As Long
	
	Eventnumberlistview As Long
	
	Eventnumbertreeview As Long
	
	iIndexColumnListView As Long = -1
	
	iItemListView As Long = -1
	
	iSubItemListView As Long = -1
	
	DIMSTOREEVENT(1001) As TLikeEvent 
	
	Declare Constructor()
	
End Type

Type TinputBox
	
	dialog As GtkWidget  Ptr
	
	entry As GtkWidget  Ptr 
	
	sText As Zstring*1024
	
	iFlag As Long 
	
End Type

Type TWinSizeAfterCreating
	
	hw As hwnd
	
	iWidth As Long
	
	iHeight As Long
	
End Type

Common Shared pGlobalTypeWindow9 As GlobalTypeWindow9 Ptr

#ifndef __incany_bi__

#define __incany_bi__

#macro Includebinary(strFile,lpAny)

Dim Shared As Ubyte Ptr ##lpAny

Dim Shared As Long  ##lpAny##__len__mem__

Asm

.section .text

jmp .end_##lpAny

.section .data

.align 16

.start_##lpAny:

__##lpAny##__start__ = .

.incbin ##strFile

__##lpAny##__len = . - __##lpAny##__start__

.section .text

.align 16

.end_##lpAny:

#ifdef __FB_64BIT__

lea rax, .start_##lpAny

mov qword ptr [lpAny], rax

mov qword ptr [##lpAny##__len__mem__] , offset __##lpAny##__len

#else

lea eax, .start_##lpAny

mov dword ptr [lpAny], eax

mov dword ptr [##lpAny##__len__mem__] , offset __##lpAny##__len

#endif

End Asm

pGlobalTypeWindow9->ListIncBin->addNodeSub(Cint(##lpAny) , ##lpAny##__len__mem__)

#endmacro

#endif ' __incany_bi__


#if __fb_out_exe__ Orelse __fb_out_dll__
	
	#inclib "window9"
	
	#inclib "X11"
	
	#ifndef disable_webgadget
	
		#ifdef __USE_GTK3__
		
		#inclib "webkit2gtk-3.0"
		
		#else
		
		#inclib "webkitgtk-1.0"
		
		#endif

	#endif

	gtk_init (0, 0)	

#else

Declare Function closeWindowFunc Cdecl(Gwindow As HWND, event_ As GdkEvent Ptr, data_ As gpointer) As gBoolean

Declare Function mouseMoveWindowFunc Cdecl (Gwindow As GtkWidget Ptr, event_ As GdkEvent  Ptr,  user_data As gpointer ) As gboolean

Declare Function mouseWheelWindowSub Cdecl (Gwindow As GtkWidget Ptr, event_ As GdkEventScroll  Ptr,  user_data As gpointer ) As gboolean

Declare Function MousePressWindowSub Cdecl(Gwindow As HWND, event_ As GdkEventButton Ptr, data_ As gpointer) As gBoolean

Declare Sub resizeWindowSub Cdecl(Gwindow As GtkWidget Ptr, allocation As GdkRectangle Ptr, user_data As gpointer)

Declare Function configureWindowSub Cdecl(Gwindow As GtkWidget Ptr, ev As GdkEventConfigure Ptr, user_data As gpointer) As gboolean

Declare Function KeyReleaseWindowSub Cdecl (Gwindow As GtkWidget Ptr, event_ As GdkEventKey  Ptr,  user_data As gpointer ) As gboolean

Declare Function KeyPressWindowSub Cdecl (Gwindow As GtkWidget Ptr, event_ As GdkEventKey  Ptr,  user_data As gpointer ) As gboolean

Declare Sub EventsButtonClickSub Cdecl(Gwindow As HWND,  data_ As gpointer)

Declare Function EventsEditorAllFunc Cdecl( text_view As hwnd, gEvent As GdkEvent Ptr, user_data As gpointer) As gboolean

Declare Function EventsImageGadgetAllFunc Cdecl( ImageWidget As hwnd, gEvent As GdkEvent Ptr, user_data As gpointer) As gboolean

Declare Function EventsTextGadgetAllFunc Cdecl( TextWidget As hwnd, gEvent As GdkEvent Ptr, user_data As gpointer) As gboolean

Declare Function EventsStringGadgetAllFunc Cdecl( StringWidget As hwnd, gEvent As GdkEvent Ptr, user_data As gpointer) As gboolean

Declare Sub EventsSpinGadgetSub Cdecl( spin As GtkSpinButton Ptr, user_data As gpointer)

Declare Sub EventsTrackBarGadgetSub Cdecl( range As GtkRange Ptr, user_data As gpointer)

Declare Function EventsCalendarGadgetAllFunc Cdecl( CalendarWidget As hwnd, gEvent As GdkEvent Ptr, user_data As gpointer) As gboolean

Declare Function EventsCheckBoxGadgetAllFunc Cdecl( CheckBoxWidget As hwnd, gEvent As GdkEvent Ptr, user_data As gpointer) As gboolean

Declare Function EventsOptionGadgetAllFunc Cdecl( OptionWidget As hwnd, gEvent As GdkEvent Ptr, user_data As gpointer) As gboolean

Declare Function EventsHyperLinkGadgetAllFunc Cdecl( HyperWidget As hwnd, gEvent As GdkEvent Ptr, user_data As gpointer) As gboolean

Declare Sub EventsComboBoxGadgetSub Cdecl( ComboWidget As hwnd, user_data As gpointer)

Declare Sub EventsListBoxGadgetSub Cdecl( ComboWidget As hwnd, user_data As gpointer)

Declare Sub GetItemSubItemListView(listview As Any Ptr )

Declare Sub EventCursorChangesListViewGadgetSub Cdecl( ListWidget As hwnd, user_data As gpointer)

Declare Sub EventColumnClickListViewGadgetSub Cdecl(column As GtkTreeViewColumn Ptr, data_ As gpointer)

Declare Function MousePressListViewSub Cdecl(Gwindow As HWND, event_ As GdkEventButton Ptr, user_data As gpointer) As gBoolean

Declare Sub RowExpandedTreeViewSub Cdecl (tree_view As GtkTreeView Ptr, iter As GtkTreeIter Ptr , path As GtkTreePath Ptr , user_data As gpointer)

Declare Sub RowCollapsedTreeViewSub Cdecl (tree_view As GtkTreeView Ptr, iter As GtkTreeIter Ptr , path As GtkTreePath Ptr , user_data As gpointer)

Declare Function TabsChangePageFunc Cdecl(notebook As Any Ptr, arg1 As gpointer , arg2 As guint , user_data As gpointer) As gboolean

Declare Sub SetFilterRequester(sInFilter As String , chooser As GtkFileChooser Ptr )

Declare Sub EventbuttonInputBoxSub Cdecl(Gwindow As HWND,  data_ As gpointer)

Declare Function focusWindowFunc Cdecl(Gwindow As HWND, event_ As GdkEvent Ptr, data_ As gpointer) As gBoolean

Declare Function EventEntryInputBoxFunc Cdecl( Gwindow As hwnd, gEvent As GdkEvent Ptr, data_ As gpointer) As gboolean

Declare Function SortListBoxFunc Cdecl(model As GtkTreeModel Ptr, a As GtkTreeIter Ptr, b As GtkTreeIter Ptr ,  user_data As gpointer) As gint

Declare Function timersfunc Cdecl(pData As gpointer) As Gboolean

Declare Function TimerSizeWinAfterCreatingSub Cdecl(pData As gpointer) As Gboolean

Declare Sub addNodeSub(g As Integer , w As Integer)

Declare Function findNodeFunc(fNode As Integer) As ListT Ptr

Declare Sub tree_add_node(x As Long, Byref MyTree As Node Ptr)

Declare Function tree_find_node(ikey As Long, MyTree As Node Ptr) As Node Ptr

Declare Sub EventActivateMenuSub Cdecl(itemMenu As GtkMenuItem Ptr, user_data As gpointer )

Declare Function AcceleratorPressedFunc Cdecl (accel_group As GtkAccelGroup Ptr, acceleratable As GObject Ptr,  keyval As guint,  modifier As GdkModifierType , iUserData As Integer Ptr) As Gboolean

Declare Sub StatusBarSizeSub Cdecl (win As GtkWidget Ptr, allocation As GdkRectangle Ptr, user_data As gpointer)

Declare Sub size_allocate_signals Cdecl(Gwindow As GtkWidget Ptr, allocation As GdkRectangle Ptr, user_data As gpointer)

Declare Function DrawColorLayoutFunc(pwidget As GtkWidget Ptr, cr As cairo_t Ptr,  p As gpointer) As gboolean

Declare Sub disconnect( obj As Any Ptr)

#endif

' ------------------------------------------window
Declare Function Openwindow (sName As String , x As Long , y As Long , width_ As Long , height_ As Long , style As Long = WS_OVERLAPPEDWINDOW Or WS_VISIBLE , style2 As Long = 0, User_data_Sub As Any Ptr = 0 , hParentHwnd As HWND = 0) As HWND

Declare Sub Centerwindow(hw As HWND)

Declare Sub Close_window( hw As HWND )

Declare Sub Disablewindow( hw As HWND , state As Long)

Declare Sub Windowcolor(hw As HWND , BGR_color As Long)

Declare Sub Setwindowtop(hw As HWND , State As Long )

Declare Sub Hidewindow( hw As HWND , state As Long)

Declare Sub Windowbounds(hw As HWND , MinimalWidth  As Long, MinimalHeight  As Long, MaximalWidth  As Long, MaximalHeight  As Long)

Declare Sub Resizewindow(hw As HWND ,  x As Long  = FB_IGNORE, y As Long = FB_IGNORE, width_ As Long  = FB_IGNORE, height As Long = FB_IGNORE)

Declare Function Windowx(hw As HWND) As Long

Declare Function Windowy(hw As HWND) As Long

Declare Function Windowwidth(hw As HWND) As Long

Declare Function Windowheight(hw As HWND) As Long

Declare Function Windowclientheight(hw As HWND) As Long

Declare Function Windowclientwidth(hw As HWND) As Long

Declare Function Getwindowtext (hw As HWND) As String

Declare Sub Setwindowtext (hw As HWND , sText As Zstring Ptr)

Declare Sub Usegadgetlist(hw As HWND)

Declare Function Getcontainerfromwindow ( Gwindow As HWND ) As HWND

Declare Sub Getwindowscaptionbordersize(hw As hwnd , iCaption As gint Ptr , iBorder As gint Ptr)

Declare Function Addkeyboardshortcut(Hwnd As HWND , Syskey As Integer , Shortcut As Integer , IDevent As Integer) As Any Ptr

Declare Sub Deleteallkeyboardshortcut(hwnd As Hwnd)

Declare Sub Setoptionswindowscroll (iParam As Long)

Declare Function Getfocus() As Hwnd

Declare Function Setfocus(hw As Hwnd) As Hwnd

Declare Sub Setwindowproperty(hWin As HWND , sKey As String , pValue As Any Ptr)

Declare Function Getwindowproperty(hWin As HWND , sKey As String) As Any Ptr

Declare Sub Deletewindowproperty(hWin As HWND , sKey As String)


' ---------------------------------------dialogs
Declare Function Messbox(sCaption As String , sText As String , flag As Long  = MB_OK, ParentWin As Hwnd = 0)	As Long

Declare Function Colorrequester(Byval iBgrColor As Long = 0, Byval iFlag As Long = 0, Byval hWin As HWND = 0) As Long

Declare Function Nextselectedfilename() As String

Declare Function Openfilerequester(sTitle As String , sCurDir As String, sPattern As String = "All files (*.*)"+Chr(0)+"*.*"+Chr(0), iFlag As Long = 0, sTemplateFileName As String = "",  hParentWin As HWND = 0) As String

Declare Function Savefilerequester(sTitle As String , sCurDir As String, sPattern As String = "All files (*.*)"+Chr(0)+"*.*"+Chr(0), iDefaultSetPattern As Long = 0, sTemplateFileName As String = "",  hParentWin As HWND = 0) As String

Declare Function Inputbox(sCaption As String  = "" , sMessageText As String = "EnterText:" , sDefaultText As String = "" , iFlag As Long = 0 , iFlag2 As Long = 0  , hParentWin As Hwnd = 0) As String

Declare Function Fontrequester(Byval hwnd As HWND = 0, Byval nColor As Integer = 0) As Integer


'----------------------------------------menu
Declare Function Create_menu() As HMENU
Declare Function Menutitle(menu As HMENU , sTitle As String) As HMENU
Declare Function Menuitem(iNumberMenu As Long  ,titleMenu As HMENU , sTitle As String , iFlag As Long = 0) As HMENU
Declare Function Insert_menu(iNumberMenu As Long  ,titleMenu As HMENU , sTitle As String , iNumberSpace As Long , iFlag As Long = 0) As HMENU
Declare Function Menubar(titleMenu As HMENU) As HMENU
Declare Sub Createiconitemmenu (titleMenu As Hmenu , iNumberMenu As Long , IDimage As HBITMAP)
Declare Sub Deleteitemmenu ( menu As HMENU , iNumberMenu As Long  , iFlag As Long = 0)
Declare Sub Delete_menu ( menu As HMENU )
Declare Sub Menubackcolor( menu As HMENU , iColor As Long , iFlag As Long = 0)
Declare Function Opensubmenu(titleMenu As HMENU , sTitle As String) As HMENU
Declare Function Createpopmenu() As HMENU
Declare Sub Displaypopupmenu(menu As HMENU , iXpos As Long  = FB_IGNORE, iYpos As Long = FB_IGNORE , hwnd As HWND = 0 , iFlag As Long = 0 )
Declare Function Getmenuitemtext (menu As HMENU , iNumberMenu As Long) As String
Declare Sub Modify_menu (iNumberMenu As Long , menu As HMENU  , sTitle As String , iNewNumber As Long = FB_IGNORE, iFlag As Long = 0)
Declare Sub Hidemenu(menu As HMENU , iState As Long)
Declare Sub Setstatemenu(menu As HMENU , iNumberMenu As Long , iState As Long)
Declare Function Getstatemenu(menu As HMENU , iNumberMenu As Long ) As Long


'----------------------------------------SysTray
Declare Function Addsystrayicon(iNumberSysTray As Integer, hwnd As hwnd, hIcon As HBITMAP , sTooltip As String) As Integer
Declare Sub Replacesystrayicon(iNumberSysTray As Integer, hIcon As HBITMAP , sTooltip As String)
Declare Sub Deletesystrayicon(iNumberSysTray As Integer)

'----------------------------------------gadgets
Declare Function Buttongadget( iGadget As Long , x As Long , y As Long , width_ As Long , height_ As Long , sText As String = "" , style As Long = 0) As HWND

Declare Function Buttonimagegadget( iGadget As Long , x As Long , y As Long , width_ As Long , height_ As Long , image As Hbitmap = 0 , style As Long = 0) As HWND

Declare Function Imagegadget( iGadget As Long , x As Long , y As Long , width_ As Long , height As Long  , pImage As hbitmap = 0 , style1 As Long = 0, style2 As Long = 0) As hwnd

Declare Function Textgadget(iGadget As Long , x As Long , y As Long , width_ As Long , height_ As Long , sText As String = "" , style As Long = SS_NOTIFY) As HWND

Declare Function Stringgadget(iGadget As Long , x As Long , y As Long , width_ As Long , height_ As Long , sText As String = "" , style As Long = 0 , style2 As Long = 0) As HWND

Declare Function Spingadget(iGadget As Long , x As Long, y As Long, width_ As Long, height_ As Long, maxvalue As Long, minvalue As Long, curvalue As Long, style1 As Long = 0 , style2 As Long = 0 ) As Hwnd

Declare Function Checkboxgadget( iGadget As Long , x As Long, y As Long, width_ As Long, height_ As Long  , sText As String = "",  style As Long = 0 ) As Hwnd

Declare Function Optiongadget( iGadget As Long , x As Long, y As Long, width_ As Long, height_ As Long  , sText As String = "",  style As Long = 0 ) As Hwnd

Declare Function Hyperlinkgadget( iGadget As Long , x As Long, y As Long, width_ As Long, height_ As Long  , sTextLink As String = "" ) As Hwnd

Declare Function Groupgadget( iGadget As Long , iX As Long , iY As Long , iWidth As Long , iHeight As Long , sText As String = "") As Hwnd

Declare Function Containergadget(iGadget As Long , x As Long , y As Long , width_ As Long , height_ As Long , iStyle As Long = 0 ) As HWND


'statusbar
Declare Sub Tooltipstatusbar(iGadget As Long , iField As Long , sText As String)
Declare Function Setstatusbarfield (iGadget As Long , iNfield As Long , iWidth As Long ,  sText As String) As hwnd
Declare Function Statusbargadget(iGadget As Long , sText As String , iStyle1 As Long  = 0, iStyle2 As Long = 0) As HWND

'combobox
Declare Function Comboboxgadget( iGadget As Long , x As Long, y As Long, width_ As Long, height_ As Long  , iStyle As Long = 0 ) As Hwnd
Declare Function Comboboximagegadget( iGadget As Long , x As Long, y As Long, width_ As Long, height_ As Long  , iSizeIcon As Long = 0, iStyle As Long = 0 ) As Hwnd
Declare Sub Addcomboboximageitem( iGadget As Long ,  sText As String , image As Hbitmap ,  item As Long = -1 )
Declare Sub Addcomboboxitem( iGadget As Long ,  sText As String ,  item As Long = -1 )
Declare Function Countitemcombobox (iGadget As Long) As Long
Declare Sub Deletecomboboxitem(iGadget As Long ,  item As Long)
Declare Function Finditemcombobox(iGadget As Long, sFindString As String, iStartPos As Long =-1 ) As Long
Declare Function Getcomboboxtext(iGadget As Long, iItem As Long ) As String
Declare Function Getitemcombobox (iGadget As Long) As Long
Declare Sub Setitemcombobox (iGadget As Long , iItem As Long)
Declare Function Lenitemtextcombobox(iGadget As Long, iItem As Long ) As Long
Declare Sub Resetallcombobox( iGadget As Long)
Declare Sub Showlistcombobox(iGadget As Long, iState As Long)
Declare Sub Filecomboboxitem(iGadget As Long, sDirPlusMask As String, iAttribut As Long = fbNormal Or fbDirectory)
Declare Sub Setcomboboxitemtext(iGadget As Long, sText As String, iItem As Long)

' ListBox
Declare Function Listboxgadget( iGadget As Long , x As Long, y As Long, width_ As Long, height_ As Long  , iStyle As Long = 0  , iStyle2 As Long = 0 ) As Hwnd
Declare Sub Setselectmanyitem( iGadget As Long , iStart As Long , iFinish As Long , iFlag As Long = 1)
Declare Function Getselcountlistbox (iGadget As Long , iArray As Long Ptr = 0 ) As Long
Declare Sub Setitemlistbox (iGadget As Long , iItem As Long)
Declare Function Getitemlistbox (iGadget As Long) As Long
Declare Function Lenitemtextlistbox (iGadget As Long , iItem As Long) As Long
Declare Function Getlistboxtext (iGadget As Long , iItem As Long) As String
Declare Function Gettopindexlistbox (iGadget As Long) As Long
Declare Sub Settopindexlistbox( iGadget As Long , iItem As Long )
Declare Function Finditemlistbox( iGadget As Long , sFindString As String , iStartPos As Long = -1) As Long
Declare Sub Filelistboxitem(iGadget As Long, sDirPlusMask As String, iAttribut As Long = fbNormal Or fbDirectory)
Declare Sub Resetalllistbox(iGadget As Long)
Declare Sub Deletelistboxitem(iGadget As Long , iItem As Long)
Declare Function Countitemlistbox (iGadget As Long) As Long
Declare Sub Addlistboxitem ( iGadget As Long , sText As String , iItem As Long = -1 )
Declare Sub Setlistboxitemtext (iGadget As Long , sText As String , iItem As Long)

' ListView
Declare Function Listviewgadget(iGadget As Long , iX As Long, iY As Long, iWidth As Long, iHeight As Long  , iExStyle As Long = 0  , iStyle As Long = 0 , iStyle2 As Long  = 0, iSizeIcon As Long  = 0, iStyleIcon As Long = 0) As Hwnd
Declare Function Flagkeylistview(iState As Long = -1) As Long
Declare Function Getcolumnlistview() As Long
Declare Function Getsubitemlistview() As Long
Declare Function Getitemlistview() As Long
Declare Sub Deletelistviewcolumn (iGadget As Long , iIndex As Long)
Declare Function Addlistviewcolumn(iGadget As Long, sText As String, iPos As Long , iSubItem As Long , iWidthColumn As Long = 0 , iStyleColumnTEXT As Long = 0 , iStyleMask As Integer = 0) As Long
Declare Function Addlistviewitem( iGadget As Long, sText As String, IDImage As HBITMAP, iPos As Long, iSubItem As Long, iMaskItem As Long =LVIF_TEXT Or LVIF_IMAGE) As Long
Declare Sub Updateitem(iGadget As Long , iItem As Long)
Declare Function Getitemcountlistview (iGadget As Long) As Long
Declare Sub Setselectlistviewitem( iGadget As Long , iItem As Long)
Declare Sub Deleteitemlistview(iGadget As Long , iItem As Long)
Declare Sub Deletelistviewitemsall( iGadget As Long)
Declare Function Getcolumnwidthlistview(iGadget As Long , iIndex As Long) As Long
Declare Sub Setcolumnwidthlistview(iGadget As Long , iIndex As Long , iWidth As Long  , iFlag As Long = 0)
Declare Function Getselectedcountlistview (iGadget As Long , iArray As Long Ptr = 0 ) As Long
Declare Function Getselectedlistviewitem (iGadget As Long , iItem As Long , iMask As Long = 0 ) As Long
Declare Function Gettextitemlistview( iGadget As Long, iItem As Long, iSubItem As Long) As String
Declare Sub Settextitemlistview( iGadget As Long, iItem As Long, iSubItem As Long , sText As String)
Declare Sub Replaceimagelistview( iGadget As Long, iItem As Long, iSubItem As Long , IDimage As Hbitmap)
Declare Sub Settextcolumnlistview(iGadget As Long , iIndex As Long , sText As String)


' TreeView
Declare Function Treeviewgadget(iGadget As Long , iX As Long, iY As Long, iWidth As Long, iHeight As Long  , iStyle As Long = 0 , iStyle2 As Long  = 0, iSizeIcon As Long  = 0) As Hwnd
Declare Function Addtreeviewitem (iGadget As Long, sText As String, IDImage As HBITMAP, IDImageSelect As HBITMAP , iPos As Integer, iParent As Integer = 0) As Integer
Declare Sub Deletetreeviewitem(iGadget As Long , iItem As Integer)
Declare Function Getcountitemtreeview(iGadget As Long) As Long
Declare Function Getindeximagetreeview(iGadget As Long , iItem As Long , iFlag As Long= 0) As Long 
Declare Function Getitemtreeview(iGadget As Long) As Integer
Declare Function Gettexttreeview(iGadget As Long , iItem As Integer) As String
Declare Function Moveitemtreeview(iGadget As Long, iCurentPos As Integer, iEndPos As Integer, iParent As Integer) As Integer
Declare Sub Settextitemtreeview(iGadget As Long , iItem As Integer , sText As String)
Declare Sub Replaceimageitemtreeview( iGadget As Long , iItem As Integer , IDImage As HBITMAP = 0, IDImageSelect As HBITMAP = 0 )
Declare Sub Setselecttreeviewitem(iGadget As Long  , iPos As Integer )
Declare Function Getparentitemtreeview(iGadget As Long , iItem As Integer) As Integer
Declare Function Getchilditemtreeview(iGadget As Long , iItem As Integer) As Integer
Declare Function Getnextitemtreeview(iGadget As Long , iItem As Integer) As Integer
Declare Function Getprevitemtreeview(iGadget As Long , iItem As Integer) As Integer
Declare Function Getfirstitemtreeview(iGadget As Long) As Integer
Declare Sub Deletetreeviewitemall(iGadget As Long)
Declare Sub Expandtreeviewitem(iGadget As Long  , iItem As Integer , iFlagAll As Long)
Declare Sub Collapsetreeviewitem(iGadget As Long  , iItem As Integer)
Declare Sub Expandtreeviewitemall(iGadget As Long)
Declare Sub Collapsetreeviewitemall(iGadget As Long)

'TrackBar
Declare Function Trackbargadget( iGadget As Long , x As Long, y As Long, width_ As Long, height_ As Long  , iMin As Long , iMax As Long , iStyle As Long = TBS_HORZ ) As Hwnd
Declare Function Gettrackbarpos(iGadget As Long) As Long
Declare Sub Settrackbarpos(iGadget As Long , iValue As Long) 
Declare Sub Settrackbarmaxpos(iGadget As Long , iMaxPos As Long , iFlag As Long = 0)
Declare Sub Settrackbarminpos(iGadget As Long , iMaxPos As Long , iFlag As Long = 0)

'calendar
Declare Function Calendargadget(iGadget As Long , x As Long, y As Long, width_ As Long, height_ As Long  , style As Long = 0 ) As Hwnd
Declare Function Getstatecalendar(iGadget As Long , bFlag As Byte=5) As Long
Declare Sub Setstatecalendar(iGadget As Long, iYear As Long, iMonth As Long, iDay As Long) 

'editor
Declare Function Editorgadget( iGadget As Long , x As Long , y As Long , width_ As Long , height_ As Long , sText As String = "" , style As Long = 0 , tag As Long = 0) As HWND
Declare Sub Readonlyeditor(iGadget As Long , flag As Long) 
Declare Sub Settransfertextlineeditorgadget (iGadget As Long , state As Long = 0)
Declare Function Getlinecounteditor(iGadget As Long) As Long
Declare Sub Pasteeditor ( iGadget As Long , sText As String , param As Integer = -1)
Declare Function Getselecttexteditorgadget (iGadget As Long) As String
Declare Sub Setselecttexteditorgadget(iGadget As Long , iBegin As Long , iEnd As Long)
Declare Function Getcurrentindexchareditor(iGadget As Long) As Long
Declare Function Getlinetexteditor(iGadget As Long , iLine As Long , iSizeBuffer As Long = 512) As String
Declare Function Getmodifyeditor(iGadget As Long) As Long
Declare Sub Setmodifyeditor (iGadget As Long , iFlag As Long = 0)
Declare Function Linefromchareditor (iGadget As Long , iIndex As Long = -1) As Long
Declare Function Getfirstvisiblelineeditor(Byval gadget As Long) As Integer
Declare Function Linescrolleditor(Byval gadget As Long, Byval numberLineScroll As Integer) As Integer
Declare Sub Settabstopseditor(Byval gadget As Long, Byval TabWidth As Integer=0)
Declare Function Linelengtheditor(Byval gadget As Long, Byval index As Integer=-1) As Integer
Declare Function Lineindexeditor(Byval gadget As Long, Byval NumberLine As Integer=-1) As Integer

'ProgressBar
Declare Function Progressbargadget( iGadget As Long , x As Long, y As Long, width_ As Long, height_ As Long  , iBeginPos As Long = 0 , iEndPos As Long = 0 , iStyle As Long = PBS_MARQUEE ) As Hwnd
Declare Sub Setrangeprogressbar(iGadget As Long , iBeginPos As Long , iEndPos As Long )

'WebGadget
Declare Function Webgadget( iGadget As Long , x As Long , y As Long , width_ As Long , height_ As Long , sTextUrl As String = " " , style As Long = 0 , tag As Long = 0) As HWND
Declare Sub Webgadgetnavigate(pBrowser As Hwnd , sUrl As String)
Declare Sub Webgadgetsetbody(pBrowser As Hwnd , sHtml As String)
Declare Sub Webgadgetrefresh(pBrowser As Hwnd)
Declare Function Webgadgetgeturl(pBrowser As Hwnd) As String
Declare Function Webgadgetstate(pBrowser As Hwnd) As gboolean
Declare Sub Webgadgetgoback(pBrowser As Hwnd)
Declare Sub Webgadgetgoforward(pBrowser As Hwnd)
Declare Function Webgadgetgetbody(pBrowser As Hwnd , iFlag As Long = 0) As String

'PanelGadget
Declare Function Panelgadget(iGadget As Long , x As Long , y As Long , iWidth As Long = 0, iHeight As Long  = 0, iSizeIcon As Long = 0 , iStyle As Long = 0) As HWND
Declare Function Addpanelgadgetitem (iGadget As Long , iItem As Long , sText As String , IDImage As HBITMAP = 0 , iFlag As Long = 0 ) As HWND
Declare Sub  Panelgadgetsetcursel( iGadget As Long , iItem As Long)
Declare Function  Panelgadgetgetcursel( iGadget As Long ) As Long
Declare Sub Deleteitempanelgadget(iGadget As Long , iItem As Long)

'ScrollBarGadget
Declare Function Scrollbargadget(iGadget As Long , iX As Long, iY As Long, iWidth As Long, iHeight As Long, iMinValue As Long, iMaxValue As Long, iStyle As Long = SBS_HORZ , iLenStep As Long = 10 ) As Hwnd
Declare Function Getscrollgadgetpos(iGadget As Long) As Long
Declare Sub Setscrollgadgetpos(iGadget As Long , iPos As Long)
Declare Function Getscrollgadgetrange(iGadget As Long , iFlag As Long) As Long
Declare Sub Setscrollgadgetrange(iGadget As Long , iMinValue As Long , iMaxValue As Long)
Declare Sub Setscrollgadgetpage(iGadget As Long , iSizePage As Long)
Declare Sub Setpagestepscrollbar(iGadget As Long , iSizeStepPage As Long)
Declare Sub Showscrollbar(iGadget As Long , iFlag As Long)

'GadgetToolTip
Declare Function Gadgettooltip(iGadgetParent As Long  , sText As String , iGadget As Long = 0) As Integer
Declare Sub Disabletooltip( iGadget As Long , iState As Long)
Declare Sub Deltooltip( iGadgetParent As Long , iGadget As Long)
Declare Sub Settooltiptext(iGadgetParent As Long , iGadget As Long , sText As String)
Declare Function Gettooltiptext(iGadgetParent As Long , iGadget As Long) As String

'Splitter
Declare Sub SplitterGadgetAddGadget(iGadgetSplitter As Long , iGadgetChild1 As Long , iGadgetChild2 As Long)
Declare Function SplitterGadget(iGadget As Long , iX As Long , iY As Long , iWidth As Long , iHeight As Long, iPos As Long , iStyle As Long = 0) As HWND
Declare Sub AddCallbackSplitterPosition(pFunc As Any Ptr)
Declare Sub AddCallbackSplitterResize(pFunc As Any Ptr)
Declare Sub SetSplitterPos(iGadgetSplitter As Long , iPos As Long)
Declare Sub SplitterGadgetUnMapGadget(iGadgetSplitter As Long  , iParam As Long)
Declare Sub SplitterGadgetMapGadget(iGadgetSplitter As Long  , iGadget As Long , iParam As Long)
Declare Function GetSplitterPos(iGadget As Long) As Long

#include "GL/gl.bi"

#include "GL/glu.bi"

'OpenGLGadget
Declare Function Openglgadget(iGadget As Long , iX As Long , iY As Long, iWidth As Long, iHeight As Long, cBits As Long = 0, dBits As Long = 0, sBits As Long = 0, aBits As Long = 0) As HWND
Declare Sub Openglgadgetswapbuffers(iGadget As Long)
Declare Sub Openglgadgetmakecurrent(iGadget As Long)

Declare Sub Resizegadget(iGadget As Long ,  x As Long  = FB_IGNORE, y As Long = FB_IGNORE, width_ As Long  = FB_IGNORE, height As Long = FB_IGNORE)

Declare Function Gadgetid ( iGadget As Integer ) As HWND

Declare Function Id_in_number ( hWin As Hwnd ) As Long

Declare Function Getclassgadget ( iGadget As Integer ) As Long

Declare Sub Freegadget (iGadget As Long)

Declare Sub Setgadgetcolor(iGadget As Long , ColorBG As Long, ColorText As Long , iFlag As Long) 

Declare Function Getgadgetcolor(iGadget As Long , iFlag As Long) As Long

Declare Sub Setimagegadget(iGadget As Long , pImage As Hbitmap)
#define Seticongadget Setimagegadget

Declare Function Gadgetheight(iGadget As Long) As Long

Declare Function Gadgetwidth(iGadget As Long) As Long

Declare Function Gadgetx(iGadget As Long) As Long

Declare Function Gadgety(iGadget As Long) As Long

Declare Sub Setgadgetstate(iGadget As Long , iState As Long)

Declare Function Getgadgetstate(iGadget As Long) As Long

Declare Function Getgadgettext(iGadget As Long ) As String

Declare Sub Setgadgettext(iGadget As Long , sText As String)

Declare Sub Disablegadget( iGadget As Long , iState As Long )

Declare Sub Hidegadget( iGadget As Long , iState As Long )

Declare Sub Setgadgetfont(iGadget As Long = 0 , iFont As Integer = 0)

Declare Sub Freefont(iFont As Integer)

Declare Function Loadfont(sName As String , iSize As Long ,  iCorner As Long = 0,  iBOLD As Long = 0, iItalic As Long = 0, iUnderline As Long = 0, iStrikeOut As Long = 0) As Integer

Declare Function Selectedfontstyle(Byval iStyle As Byte) As Byte 

Declare Function Selectedfontsize() As Long

Declare Function Selectedfontname() As String

Declare Function Getsystemdefaultfont() As Integer

Declare Function Getcurentdefaultfont() As Integer

Declare Function Getnamefromfont(font As Integer) As String

Declare Function Getsizefromfont(font As Integer) As Long

Declare Function Getstylefromfont(font As Integer , iStyle As Long) As Long

Declare Sub Getsizestringfromfont(sText As String , font As Integer , Byref iW As Long , Byref iH As Long)


'----------------------------------------ToolBar
Declare Sub Toolbartooltip(Hwnd As Hwnd, iButtonID As Integer, sToolTipS As String)

Declare Function Createtoolbar(iStyle1 As Long = IDB_STD_SMALL_COLOR , iStyle2 As Long  = 0 , iStyle3 As Long = 0 ) As Integer

Declare Function Toolbarseparator (iHwndToolBar As Integer, iPositionButton As Integer = -1 , iFlagDrawSeparator As Long = 1) As Any Ptr

Declare Function Toolbarstandardbutton(iHwndToolBar As Integer, iButtonID As Integer, iIndexImage  As Integer, sString As String = "", _
iPositionButton As Integer = -1, iStyle As Integer = TBSTATE_ENABLED, iStyle2 As Integer = 0) As Integer

Declare Function Countbuttontoolbar(iHwndToolBar As Integer) As Long

Declare Sub Deletebuttontoolbar (iHwndToolBar As Integer , iIndex As Long)

Declare Sub Deletetoolbar(iHwndToolBar As Integer)

Declare Sub Setbuttontoolbarstate(iHwndToolBar As Integer ,  IDButton As Integer , iFlag As Long , iState As Long)

Declare Function Getbuttontoolbarstate(iHwndToolBar As Integer ,  IDButton As Integer , iFlag As Long ) As Long

Declare Function Gettoolbartextbutton ( iHwndToolBar As Integer ,  IDButton As Integer) As String

Declare Function Toolbarimagebutton(iHwndToolBar As Integer, iButtonID As Integer, idImage  As Hbitmap, sString As String = "", _
iPositionButton As Integer = -1, iStyle As Integer = TBSTATE_ENABLED, iStyle2 As Integer = 0 , iSizeIcon As Long = 16) As Integer


'----------------------------------------2DDraw
Declare Function Imagestartdraw(hBit As HBITMAP) As HDC

Declare Function Windowstartdraw(hwnd As Hwnd, iX As Long = 0 , iY As Long = 0 , iWidth As Long = 0 , iHeight As Long = 0 , iAlpha_Flag As Long = 0 , iAlpha_Value As Long = 0) As HDC

Declare Function Stopdraw() As Integer

Declare Sub Pixdraw( iX As Long , iY As Long , iColor As Long)

Declare Function  Boxdraw (iX As Long , iY As Long , iWidth As Long , iHeight As Long , iColorPen As Long = 0, iColorBG As Long = 0 , iWidthPen As Long = 1 ,iStylePen As Long  = PS_SOLID, iAlpha As Long = 255) As Long

Declare Function  Polygondraw (pPoint As GdkPoint Ptr , iNCount As Long , iFillColor As Long = 0, iBorderColor As Long = 0 , iBorderWidth As Long = 1 ,iBorderStyle As Long  = PS_SOLID) As Long

Declare Function  Polylinedraw (pPoint As GdkPoint Ptr , iNCount As Long , iColorPen As Long = 0 , iWidthPen As Long = 1 ,iStylePen As Long  = PS_SOLID) As Long

Declare Function Linedraw (iX As Long , iY As Long , iX1 As Long , iY1 As Long , iWidthPen As Long = 1 , iColor As Long = 0 , iStylePen As Long  = PS_SOLID) As Long

Declare Function  Circledraw (iX As Long , iY As Long , iRadius As Long , iColorPen As Long = 0, iColorBG As Long = 0 , iWidthPen As Long = 1 ,iStylePen As Long  = PS_SOLID, iAlpha As Long = 255) As Long

Declare Function Imagedraw( pImg As HBITMAP, iX As Long , iY As Long , iAlpha As Long = 255) As Long

Declare Function Getpix( iX As Long , iY As Long) As Ulong

Declare Sub Fillrectdraw( iX  As Long ,  iY As Long , iColor As Long)

Declare Sub Focusdraw( iX As Long , iY As Long , iWidth As Long , iHeight As Long , iColor As Long = 0)

Declare Function  Rounddraw (iX As Long , iY As Long , iWidth As Long , iHeight As Long , iColorPen As Long = 0, iColorBG As Long = 0 , iWidthPen As Long = 1 ,iStylePen As Long  = PS_SOLID, iAlpha As Long = 255) As Long

Declare Function  Gradientfilldraw (iX As Long , iY As Long , iWidth As Long , iHeight As Long ,  Rbegin As Long, Gbegin As Long , Bbegin As Long,  REnd As Long, GEnd As Long, BEnd As Long, GOR_VERT As Long = 0) As Long

Declare Function Piedraw (iX As Long , iY As Long , iWidth As Long , iHeight As Long , iX1 As Long , iY1 As Long , iX2 As Long , iY2 As Long , iColorPen As Long = 0, iColorBG As Long = 0 , iWidthPen As Long = 1 ,iStylePen As Long  = PS_SOLID) As Long

Declare Function Textdraw( iX As Long , iY As Long , sText As String , ColorBK As Long = 0, ColorText  As Long = 0, iAlpha As Long = 255) As Long

Declare Sub Fontdraw(iFont As Integer)


'----------------------------------------2DDrawA
Declare Function Imagestartdrawa(Byref hBit As Any Ptr,Byval iColorFlag As Integer=0,Byval iColor As Integer=&hFFFFFFFF) As Any Ptr
	
Declare Function Windowstartdrawa(Byval hwnd As HWND,Byval x As Integer=0,Byval y As Integer=0,Byval w As Integer=0, Byval h As Integer=0,Byval iColorFlag As Integer=0,Byval iColor As Integer=&hFFFFFFFF) As Any Ptr

Declare Function Stopdrawa() As Integer

Declare Sub Setpixa( iX As Long , iY As Long , iColor As Long = &hff000000)

Declare Function Getpixa(Byval iX As Single,Byval iY As Single) As Integer

Declare Function Createbrusha(Byval x0 As Single=0,Byval y0 As Single=0,Byval x1 As Single=0,Byval y1 As Single=0,_
Byval iColor1 As Integer=&hFF00FF00, Byval iColor2 As Integer=&hFF0000FF,Byval GpImage As Any Ptr=0,Byval WrapMode As Integer=3 ) As Any Ptr

Declare Sub Freebrusha(Byval Brush As Any Ptr)

Declare Sub Boxdrawa(Byval iX As Single , Byval iY As Single , Byval iWidth As Single ,_
Byval iHeight As Single , Byval iColorPen As Integer=&hff000000 , Byval iFlagcolorBK As Integer=1 ,_
Byval iColorBk As Integer=&hff000000 , Byval brushPen As Any Ptr=0 , Byval brushBk As Any Ptr=0 , Byval iWidthPen As Single=1)

Declare Sub Circledrawa(Byval iX As Single , Byval iY As Single , Byval iRadius As Single,_
Byval iColorPen As Integer=&hff000000 , Byval iFlagcolorBK As Integer=1, _
Byval iColorBk As Integer=&hff000000 , Byval brushPen As Any Ptr=0,_
Byval brushBk As Any Ptr=0 , Byval iWidthPen As Single=1)

Declare Sub Rounddrawa(Byval iX As Single , Byval iY As Single , Byval iWidth As Single , Byval iHeight As Single , _
Byval iColorPen As Integer=&hff000000 , Byval iFlagcolorBK As Integer=1 , Byval iColorBk As Integer=&hff000000 , _
Byval brushPen As Any Ptr=0 , Byval brushBk As Any Ptr=0 , Byval iWidthPen As Single=1)

Declare Sub Linedrawa(Byval iX As Single , Byval iY As Single , Byval iX1 As Single , Byval iY1 As Single ,_
Byval iWidthPen As Single=1 , Byval iColorBk As Integer=&hff000000 , Byval brushPen As Any Ptr=0)

Declare Sub Imagedrawa(Byval GpImage As Any Ptr,Byval iX As Single, Byval iY As Single,Byval iWidth0 As Single=0, Byval iHeight0 As Single=0)

Declare Sub Modedrawa(Byval mode As Integer)

Declare Sub Fillrectdrawa(Byval iX As Integer, Byval iY As Integer, Byval iColor As Integer)

Declare Sub Bezierdrawa(Byval x0 As Single,Byval y0 As Single,Byval x1 As Single,Byval y1 As Single,_
Byval x2 As Single,Byval y2 As Single,Byval x3 As Single,Byval y3 As Single,_
Byval iColorPen As Integer=&hff000000,Byval brushPen As Any Ptr=0,Byval iWidthPen As Single=1)

Declare Sub Arcdrawa(Byval iX As Single , Byval iY As Single , Byval iWidth As Single , Byval iHeight As Single,_
Byval startAngle As Single , Byval sweepAngle As Single , Byval iColorPen As Integer=&hff000000 , _
Byval brushPen As Any Ptr=0 , Byval iWidthPen As Single=1)

Declare Sub Piedrawa(Byval iX As Single , Byval iY As Single , Byval iWidth As Single , Byval iHeight As Single ,_
Byval startAngle As Single , Byval sweepAngle As Single , Byval iColorPen As Integer=&hff000000 , _
Byval iFlagcolorBK As Integer=1 , Byval iColorBk As Integer=&hff000000 , Byval brushPen As Any Ptr=0 , _
Byval brushBk As Any Ptr=0 , Byval iWidthPen As Single=1)

Declare Sub Polygondrawa(Byval Points As Any Ptr , Byval iCountPoints As Integer , Byval iColorPen As Integer=&hff000000 , _
Byval iFlagcolorBK As Integer=1 , Byval iColorBk As Integer=&hff000000 , Byval brushPen As Any Ptr=0 , _
Byval brushBk As Any Ptr=0 , Byval iWidthPen As Single=1 , Byval iFillmode As Integer=0)

Declare Function Createfontdrawa(Byval sName As String="Sans" , Byval iSize As Integer=10 , Byval iStyle As Integer=0 , Byval iUnit As Integer=6) As Any Ptr

Declare Sub Freefontdrawa(Byval GpFont As Any Ptr)

Declare Sub Textdrawa(Byref sText As String , Byval iX As Integer , Byval iY As Integer , Byval GpFont As Any Ptr=0 ,_
Byval iColor As Integer=&hFFFFFFFF , Byval brush As Any Ptr=0 , Byval iMode As Integer=0)

'----------------------------------------clipboard
Declare Sub Setclipboardtext (sText As String)

Declare Function Getclipboardtext() As String

Declare Sub Setclipboardimage (bmp As Hbitmap)

Declare Function Getclipboardimage() As HBITMAP

Declare Sub Clearclipboard()


'----------------------------------------desktop
Declare Function Getcurrentsettingsdisplay() As String

Declare Function Getwidthdesktop(Byref setting As String) As Integer

Declare Function Getheightdesktop(Byref setting As String) As Integer

Declare Function Getbitsdesktop(Byref setting As String) As Integer

Declare Function Getfrequencydesktop(Byref setting As String) As Integer

Declare Function GetDesktopWindow() As Any Ptr


'----------------------------------------misc
Declare Function Replacestring(Byval String_ As String,Byval SearchString As String,Byval ReplaceString_ As String,Byval Position As Long=1,Byval searchParam As Long=0, Byval RegisterParam As Long=0) As String

Declare Function Insertstring(Byref DestS As String,Byval InsertS As String,Byval Position As Long) As Long

Declare Function Clearstring(Byref sText As String, Byref sTrimSimbols As String = " ") As String

Declare Function Peeks(Byval Memory As Any Ptr, iLen As Integer = 0) As String

Declare Sub Fastcopy(Byval d As Any Ptr, Byval s As Any Ptr, Byval n As Uinteger)

Declare Function W9sizewidth() As Long

Declare Function W9sizeheight() As Long

Declare Sub Sleepw9(Byval n As Integer)

Declare Function Uboundincbin(pBuf As Any Ptr) As Long

Declare Sub Updateinfoxserver(iCountCicles As Long = 10000)

Declare Function Utf8tounicode(sTextUtf8 As String) As Wstring Ptr

Declare Function Unicodetoutf8(wsText As Wstring Ptr ) As String


'----------------------------------------events

Declare Function Windowevent() As Long

Declare Function Waitevent() As Long

Declare Function Eventnumber() As Long

Declare Function Eventnumberlistview() As Long

Declare Function Eventnumbertreeview() As Long

Declare Function Eventhwnd() As Hwnd

Declare Function Eventkey() As Long

Declare Function Eventhardwarekey() As Long

Declare Sub Sendnullevent()


'----------------------------------------Timers
Declare Sub SetTimer (hwnd As hwnd = 0 , Byref idTimer As Long , iElapse As Long , pTimerProc As Any Ptr)

Declare Sub KillTimer (hwnd As hwnd = 0 , idTimer As Long)


'----------------------------------------Image
Declare Function Load_image (sPath As String , iColorBack As Long = 0) As Hbitmap

#define Load_icon Load_image 

Declare Function Image_width (pImage As Hbitmap) As Long

Declare Function Image_height (pImage As Hbitmap) As Long

Declare Function Copy_image (pImage As Hbitmap) As Hbitmap

Declare Function Grab_image (pImage As Hbitmap ,  iX As Long , iY As Long , iWidth As Long , iHeght As Long) As Hbitmap

Declare Function Create_image (iWidth As Long , iHeght As Long) As Hbitmap

Declare Function Catch_image( pBuf As Any Ptr , iColor As Long = 0) As Hbitmap

Declare Sub Save_image(pImage As Hbitmap, sPath As String)

Declare Sub Free_image (pImage As Hbitmap)

Declare Function Resize_image (pImage As Hbitmap , iWidth As Long , iHeght As Long) As Hbitmap

Declare Function Rotate4_image(pImage As Hbitmap , iFlag As Long) As Hbitmap

Declare Function Createcopyimagedesktop () As Hbitmap

Declare Function Createcopyimagerect (hWin As Any Ptr , iX As Long, iY As Long, iWidth As Long, iHeight As Long , iFlag As Long = 0) As Hbitmap

Declare Function  Createcopyimagewindow (hWin As Any Ptr , iFlag As Long = 0) As Hbitmap

Declare Function  Createcopyimagewindowclient (hWin As Any Ptr , iFlag As Long = 0) As Hbitmap

Declare Sub Rotateandscaleimage(Byval sourcehBmp As HBITMAP, Byref hbmpDest As HBITMAP, Byval X As Integer,_
	Byval Y As Integer,Byval Xr As Integer,Byval Yr As Integer,Byval angle As Single,_
	Byval Xscale As Single=0,Byval Yscale As Single=0,Byval iColor As Integer=0,Byval BGbitmap As HBITMAP=0)


'----------------------------------------ImageA
Declare Function Creategpbitmapfromhbitmap(Byval hBmp As HBITMAP) As Any Ptr

Declare Function Createhbitmapfromgpbitmap(Byval GpBitmap As Any Ptr,Byval BackColor As Integer=&hf0f0f0) As HBITMAP

Declare Function Copy_imagea(Byval GpImage As Any Ptr) As Any Ptr

Declare Function Catch_imagea(Byval array As Ubyte Ptr) As Any Ptr

Declare Function Grab_imagea(Byval GpImage As Any Ptr,Byval iX As Single=0, Byval iY As Single=0, Byref iWidth As Single=0, Byref iHeight As Single=0) As Any Ptr

Declare Function Image_heighta(Byval GpImage As Any Ptr) As Integer

Declare Function Image_widtha(Byval GpImage As Any Ptr) As Integer

Declare Sub Resize_imagea(Byref GpImage As Any Ptr,Byref iWidth As Single=0, Byref iHeight As Single=0)

Declare Function Create_imagea (iWidth As Long , iHeight As Long) As Any Ptr

Declare Function Save_imagea(Byval GpImage As Any Ptr, Byref sFileName As String) As Integer

Declare Sub Rotateandscaleimagea(Byval GpbitmapSource As Any Ptr, Byref hbmpDest As HBITMAP,_
Byval X As Integer, Byval Y As Integer,Byval Xr As Integer,Byval Yr As Integer,_
Byval angle As Single,Byval Xscale As Single=0,Byval Yscale As Single=0,_
Byval iColor As Integer=0,Byval BGbitmap As Any Ptr=0)

Declare Function Load_imagea(Byref sFileName As String) As Any Ptr

Declare Sub Free_imagea(Byval GpBitmap As Any Ptr)


'----------------------------------------File
Declare Function Open_file (sFileName As String, flag As Long = 0) As HANDLE 

Declare Function Create_file (sFileName As String, flag As Long = 0) As HANDLE

Declare Function Read_file (sFileName As String, flag As Long = 0) As HANDLE

Declare Sub Write_string(fp As Handle , s As String)

Declare Sub Write_stringn(fp As Handle , s As String) 

Declare Sub Close_file(fp As Handle)

Declare Sub Set_file_pointer(fp As Handle , position As Long , method As Long = FILE_CURRENT)

Declare Function Get_file_pointer(fp As Handle) As Integer

Declare Function E_o_f(fp As Handle) As Long

Declare Function Size_file(fp As Handle) As Integer

Declare Function Read_string(fp As handle) As String

Declare Function Read_character(fp As handle) As String

Declare Function Read_byte(fp As handle) As Byte

Declare Function Read_word(fp As Handle) As Short

Declare Function Read_integer(fp As Handle) As Integer32

Declare Function Read_longint(fp As Handle) As Longint

Declare Function Read_single(fp As Handle) As Single

Declare Function Read_double(fp As Handle) As Double

Declare Sub Read_data(fp As Handle , pMem As Any Ptr , lenght As Long)

Declare Function Read_dataa(fp As Handle , iLenght As Long) As Any Ptr

Declare Function Read_datas(fp As Handle , iLenght As Long) As Any Ptr

Declare Sub Write_character(fp As Handle , charaster As String)

Declare Sub Write_byte(fp As Handle , bValue As Byte)

Declare Sub Write_longint(fp As Handle , llValue As Longint)

Declare Sub Write_integer(fp As Handle , iValue As Integer32)

Declare Sub Write_word(fp As Handle , shValue As Short)

Declare Sub Write_single(fp As Handle , siValue As Single)

Declare Sub Write_double(fp As Handle , dValue As Double)

Declare Sub Write_data(fp As Handle , Buf As Any Ptr , Lenght As Long)


'----------------------------------------FileSystem
Declare Function Getpathpart(sPath As String) As String

Declare Function Getextensionpart(sPath As String) As String

Declare Function Getfilepart(Byref sPath As String) As String

Declare Sub Deletedir(sDelDir As String, iFlag As Long = 0)

#define Removedir Deletedir

Declare Sub Movedir(sMoveOutDir As String , sMoveInDir As String, iFlag As Long = 0)

Declare Function Getcurentdir() As String

Declare Sub Delete_file(sFile As String)

Declare Sub Copydir(sSourceDir As String , sDestDir As String , iFlag As Long = 0)

Declare Sub Createdir( sDir As String)

Declare Sub Setcurentdir(sCurDir As String)

Declare Sub Renamedir(sOldName As String , sNewName As String , iFlag As Long = 0)

Declare Function Examinedirectory(sDirectoryName As String , sPattern As String) As Integer

Declare Function Directoryentryattributes (hDir As Integer) As Uinteger

Declare Function Nextdirectoryentry(hDir As Integer) As Integer

Declare Sub Finishdirectory(hDir As Integer)

Declare Function Directoryentryname(hDir As Integer) As String

Declare Function Directoryentrysize(hDir As Integer) As Ulongint

Declare Function Directoryentrydate(hDir As Integer , iFlag As Long) As String

Declare Function w9isFile(sFileName As String) As Long

Declare Function w9isFileExists(sFileName As String) As Long

Declare Function w9isDirExists(sFileName As String) As Long


'----------------------------------------Encode\Decode
Declare Function Aesencoder(Byref Text As String, Byref Key As String) As String

Declare Function Aesdecoder(Byref Text As String, Byref Key As String) As String

Declare Function Encode64(Byref bs64 As String) As String

Declare Function Decode64(Byref str_b64 As Const String) As String

Declare Function Fastcrc32(Byval pAnyBuffer As Any Ptr, Byval BufferSize As Uinteger) As Ulong

Declare Function Md5createfilehash(Byref fileName As String) As String

Declare Function Md5createhash(Byref text As String) As String

Declare Function Sha1create(Byref text As String) As String

Declare Function Sha1createfile(sFile As String) As String

Declare Function Sha512createfile(Byref sFile As String) As String

Declare Function Sha512create(Byref text As String) As String


'----------------------------------------Mouse
Declare Function Ismouseover(hWin As Hwnd) As Long

Declare Function Globalmousey() As Long

Declare Function Globalmousex() As Long

Declare Function Mousex() As Long

Declare Function Mousey() As Long


'----------------------------------------Preference
Declare Function Createfbini( Byref filename As String) As handle

Declare Function Openfbini( Byref filename As String,Byval flag As bool=0) As handle

Declare Function Closefbini() As bool

Declare Sub Writegroupfbini(Byref group As String)

Declare Sub Writevaluefbini Overload(Byref group As String,Byref Key As String, Byval value As Byte)

Declare Sub Writevaluefbini Overload(Byref group As String,Byref Key As String, Byval value As Short)

Declare Sub Writevaluefbini Overload(Byref group As String,Byref Key As String, Byval value As Integer32)

Declare Sub Writevaluefbini Overload(Byref group As String,Byref Key As String, Byval value As Longint)

Declare Sub Writevaluefbini Overload(Byref group As String,Byref Key As String, Byval value As Double)

Declare Sub Writevaluefbini Overload(Byref group As String,Byref Key As String, Byref value As String)

Declare Function Readbytevaluefbini(Byref group As String,Byref Key As String) As Byte

Declare Function Readshortvaluefbini(Byref group As String,Byref Key As String) As Short 

Declare Function Readintegervaluefbini(Byref group As String,Byref Key As String) As Integer32 

Declare Function Readlongintvaluefbini(Byref group As String,Byref Key As String) As Longint 

Declare Function Readdoublevaluefbini(Byref group As String,Byref Key As String) As Double 

Declare Function Readstringvaluefbini(Byref group As String,Byref Key As String) As String


'----------------------------------------Process
Declare Function Runprogram(sFilename As String, sParameter As String = "", sWorkingDirectory As String = "", sFlags As String = "", ShowCmd As Integer = 0) As Integer

Declare Sub Killprocess( iPID As Integer , iExitCode As Integer = 9)

Declare Function Getnameprocess() As String

Declare Function Getfullcommandprocess() As String

Declare Function Getidprocess() As Integer

Declare Function Initprocess() As HANDLE

Declare Sub Closehandle( pDir As HANDLE)

Declare Function Firstprocess( pDir As HANDLE) As Long

Declare Function Nextprocess( pDir As HANDLE) As Long

'----------------------------------------Compress
Declare Function Compressmem(Byref BUF_DEST As Byte Ptr,Byval SOURSEDATA As Byte Ptr,Byval SIZEDATA As Ulong, Byval level As Long=5) As Long

Declare Function Decompressmem(Byref BUF_COMPRESSED As Byte Ptr,Byval SIZECOMPRESSED As Long,Byref BUFDESTDATA As Byte Ptr) As Long

Declare Function Compressfile(Byref filename As String, Byref filenameDest As String,Byval level As Long=5) As Long

Declare Function Decompressfile(Byref filename As String, Byref filenameDest As String) As Long

'----------------------------------------Data Container
'hashtable
Declare Function CreateHashTable() As Any Ptr
Declare Function GetSizeHashTable(p As Any Ptr) As Long
Declare Sub SetValueHashTable(p As Any Ptr , sKey As String , anyValue As Any Ptr)
Declare Sub SetValueStrHashTable(p As Any Ptr , sKey As String , anyValue As USTRING)
Declare Function GetValueHashTable(p As Any Ptr , sKey As String) As Any Ptr
Declare Function GetValueStrHashTable(p As Any Ptr , sKey As String) As USTRING
Declare Sub FreeHashTable(p As Any Ptr , bFlagFreeMemoryStrings As Long = 0)
Declare Sub FreeKeyHashTable(p As Any Ptr , sKey As String , bFlagFreeMemoryStrings As Long = 0)
Declare Sub DeleteHashTable(p As Any Ptr , bFlagFreeMemoryStrings As Long = 0)
'list
Declare Function CreateList() As Any Ptr
Declare Function GetSizeList(p As Any Ptr) As Long
Declare Sub AddList(p As Any Ptr , anyValue As Any Ptr)
Declare Sub AddStrList(p As Any Ptr , anyValue As USTRING)
Declare Function GetValueList(p As Any Ptr , iIndex As Long) As Any Ptr
Declare Function GetValueStrList(p As Any Ptr , iIndex As Long) As USTRING
Declare Sub InsertItemList(p As Any Ptr , iIndex As Long , anyValue As Any Ptr)
Declare Sub InsertItemStrList(p As Any Ptr , iIndex As Long , anyValue As USTRING)
Declare Sub SetValueList(p As Any Ptr , iIndex As Long , anyValue As Any Ptr)
Declare Sub SetValueStrList(p As Any Ptr , iIndex As Long , anyValue As USTRING)
Declare Sub MoveItemList(p As Any Ptr , iIndexFrom As Long , iIndexTo As Long)
Declare Sub DeleteItemList(p As Any Ptr , iIndex As Long , bFlagFreeMemoryStrings As Long = 0)
Declare Sub FreeList(p As Any Ptr , bFlagFreeMemoryStrings As Long = 0)
Declare Sub DeleteList(p As Any Ptr, bFlagFreeMemoryStrings As Long = 0)
'map
Declare Function CreateMap() As Any Ptr
Declare Function GetSizeMap(p As Any Ptr) As Long
Declare Function GetValueMap(p As Any Ptr , sKey As String) As Any Ptr
Declare Sub SetValueMap(p As Any Ptr , sKey As String , anyValue As Any Ptr)
Declare Function GetValueStrMap(p As Any Ptr , sKey As String) As USTRING
Declare Sub SetValueStrMap(p As Any Ptr , sKey As String , anyValue As USTRING)
Declare Sub FreeMap(p As Any Ptr , bFlagFreeMemoryStrings As Long = 0)
Declare Sub FreeKeyMap(p As Any Ptr , sKey As String , bFlagFreeMemoryStrings As Long = 0)
Declare Sub DeleteMap(p As Any Ptr , bFlagFreeMemoryStrings As Long = 0)
'queue
Declare Function CreateQueue() As Any Ptr
Declare Function GetSizeQueue(p As Any Ptr) As Long
Declare Function PopQueue(p As Any Ptr , bFlagFreeMemoryStrings As Long = 0) As Any Ptr
Declare Sub PushQueue(p As Any Ptr  , anyValue As Any Ptr)
Declare Sub PushStrQueue(p As Any Ptr  , anyValue As USTRING)
Declare Function BackQueue(p As Any Ptr) As Any Ptr
Declare Function BackStrQueue(p As Any Ptr) As USTRING
Declare Function FrontQueue(p As Any Ptr) As Any Ptr
Declare Function FrontStrQueue(p As Any Ptr) As USTRING
Declare Sub FreeQueue(p As Any Ptr , bFlagFreeMemoryStrings As Long = 0)
Declare Sub DeleteQueue(p As Any Ptr , bFlagFreeMemoryStrings As Long = 0)
'stack
Declare Function CreateStack() As Any Ptr
Declare Function GetSizeStack(p As Any Ptr) As Long
Declare Function PopStack(p As Any Ptr , bFlagFreeMemoryStrings As Long = 0) As Any Ptr
Declare Sub PushStack(p As Any Ptr  , anyValue As Any Ptr)
Declare Sub PushStrStack(p As Any Ptr  , anyValue As USTRING)
Declare Function FrontStack(p As Any Ptr) As Any Ptr
Declare Function FrontStrStack(p As Any Ptr) As USTRING
Declare Sub FreeStack(p As Any Ptr , bFlagFreeMemoryStrings As Long = 0)
Declare Sub DeleteStack(p As Any Ptr , bFlagFreeMemoryStrings As Long = 0)

' config
Declare Function ConfigCreate() As Any Ptr
Declare Sub ConfigDelete(p As Any Ptr)
Declare Sub ConfigClear(p As Any Ptr)
Declare Sub ConfigDeleteValue(p As Any Ptr , sGroup As USTRING  , sKey As USTRING)
Declare Sub ConfigLoad(p As Any Ptr  , sPath As USTRING)
Declare Sub ConfigSave(p As Any Ptr  , sPath As USTRING)
Declare Sub SetConfigValue(p As Any Ptr  , sGroup As USTRING , sKey As USTRING , sValue As USTRING)
Declare Function GetConfigValue(p As Any Ptr  , sGroup As USTRING , sKey As USTRING) As USTRING

'----------------------------------------Printer
 
Namespace window9
	Type FontPrint
		As USTRING Name_
		As Integer size
		As Integer Bold
		As Integer Italic
		As Integer Underline
		As Integer StrikeOut
	End Type
	Type SinglePoint
		As Single x = 1 , y = 1
	End Type
	Declare Function Startprinter(Byref Scale As SinglePoint Ptr=0, Byval Flagstart As Integer=1) As HDC
	Declare Sub Stopprinter()
	Declare Sub Framepage(Byref Left_ As Integer, Byref Right_ As Integer, Byref Top As Integer, Byref Bottom As Integer)
	Declare Sub Printtext(Byref text As String, Byval L As Integer=0, Byval T As Integer=0, Byval R As Integer=0, Byval B As Integer=0, Byval flag As Integer=0)
	Declare Sub Printimage(Byval bitmap_ As HBITMAP,Byval x As Integer, Byval y As Integer)
	Declare Sub Colorprinter(Byval ColorText As Integer=0, Byval colorBK As Integer=-1, Byval Flag As Integer=1)
	Declare Sub Fontprinter(Byval Font As FontPrint Ptr=0)
	Declare Sub Getrealsize(Byref X As Integer, Byref Y As Integer)
	Declare Function Getcountline() As Integer
	Declare Sub Getfullsize(Byref X As Integer, Byref Y As Integer)
	Declare Sub Getlenstring(Byref Str_ As String, Byref X As Integer, Byref Y As Integer)
	Declare Function Getcountdoc() As Integer
	Declare Sub Documentstart()
	Declare Sub Documentend()
	Declare Sub Pagestart()
	Declare Sub Pageend()
End Namespace

Declare Sub Textprinter(Byref sSourceText As String, Byval Font As window9.FontPrint Ptr=0, Byval color_BK As COLORREF=0, Byval color_T As COLORREF=0)

Declare Function Hwndprinter(Byval hWin As Any Ptr, Byval Xpr As Integer=0, Byval Ypr As Integer=0, Byval X As Integer=0,_
 Byval Y As Integer=0, Byval X1 As Integer=0, Byval Y1 As Integer=0) As Integer