From 7a0e89ef24d73506bf442ccdced4f1d5488cec46 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 7 Nov 2020 09:46:00 +0100 Subject: Define more menu manipulation functions and constants Signed-off-by: Simon Rozman --- menu.go | 69 ++++++++++++++++++++++-------- user32.go | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+), 17 deletions(-) diff --git a/menu.go b/menu.go index 0773f29a..c9dad192 100644 --- a/menu.go +++ b/menu.go @@ -21,27 +21,27 @@ const ( // Constants for MENUITEMINFO.fType const ( - MFT_BITMAP = 4 - MFT_MENUBARBREAK = 32 - MFT_MENUBREAK = 64 - MFT_OWNERDRAW = 256 - MFT_RADIOCHECK = 512 - MFT_RIGHTJUSTIFY = 0x4000 - MFT_SEPARATOR = 0x800 - MFT_RIGHTORDER = 0x2000 - MFT_STRING = 0 + MFT_STRING = MF_STRING + MFT_BITMAP = MF_BITMAP + MFT_MENUBARBREAK = MF_MENUBARBREAK + MFT_MENUBREAK = MF_MENUBREAK + MFT_OWNERDRAW = MF_OWNERDRAW + MFT_RADIOCHECK = 0x00000200 + MFT_SEPARATOR = MF_SEPARATOR + MFT_RIGHTORDER = 0x00002000 + MFT_RIGHTJUSTIFY = MF_RIGHTJUSTIFY ) // Constants for MENUITEMINFO.fState const ( - MFS_CHECKED = 8 - MFS_DEFAULT = 4096 - MFS_DISABLED = 3 - MFS_ENABLED = 0 - MFS_GRAYED = 3 - MFS_HILITE = 128 - MFS_UNCHECKED = 0 - MFS_UNHILITE = 0 + MFS_GRAYED = 0x00000003 + MFS_DISABLED = MFS_GRAYED + MFS_CHECKED = MF_CHECKED + MFS_HILITE = MF_HILITE + MFS_ENABLED = MF_ENABLED + MFS_UNCHECKED = MF_UNCHECKED + MFS_UNHILITE = MF_UNHILITE + MFS_DEFAULT = MF_DEFAULT ) // Constants for MENUITEMINFO.hbmp* @@ -80,8 +80,43 @@ const ( ) const ( + // Menu flags for Add/Check/EnableMenuItem() + MF_INSERT = 0x00000000 + MF_CHANGE = 0x00000080 + MF_APPEND = 0x00000100 + MF_DELETE = 0x00000200 + MF_REMOVE = 0x00001000 + MF_BYCOMMAND = 0x00000000 MF_BYPOSITION = 0x00000400 + + MF_SEPARATOR = 0x00000800 + + MF_ENABLED = 0x00000000 + MF_GRAYED = 0x00000001 + MF_DISABLED = 0x00000002 + + MF_UNCHECKED = 0x00000000 + MF_CHECKED = 0x00000008 + MF_USECHECKBITMAPS = 0x00000200 + + MF_STRING = 0x00000000 + MF_BITMAP = 0x00000004 + MF_OWNERDRAW = 0x00000100 + + MF_POPUP = 0x00000010 + MF_MENUBARBREAK = 0x00000020 + MF_MENUBREAK = 0x00000040 + + MF_UNHILITE = 0x00000000 + MF_HILITE = 0x00000080 + + MF_DEFAULT = 0x00001000 + MF_SYSMENU = 0x00002000 + MF_HELP = 0x00004000 + MF_RIGHTJUSTIFY = 0x00004000 + + MF_MOUSESELECT = 0x00008000 ) type MENUITEMINFO struct { diff --git a/user32.go b/user32.go index 5be421cc..fd5eb4e1 100644 --- a/user32.go +++ b/user32.go @@ -1775,6 +1775,7 @@ var ( createWindowEx *windows.LazyProc deferWindowPos *windows.LazyProc defWindowProc *windows.LazyProc + deleteMenu *windows.LazyProc destroyIcon *windows.LazyProc destroyMenu *windows.LazyProc destroyWindow *windows.LazyProc @@ -1785,6 +1786,7 @@ var ( drawFocusRect *windows.LazyProc drawTextEx *windows.LazyProc emptyClipboard *windows.LazyProc + enableMenuItem *windows.LazyProc enableWindow *windows.LazyProc endDeferWindowPos *windows.LazyProc endDialog *windows.LazyProc @@ -1806,12 +1808,17 @@ var ( getForegroundWindow *windows.LazyProc getIconInfo *windows.LazyProc getKeyState *windows.LazyProc + getMenuCheckMarkDimensions *windows.LazyProc getMenuInfo *windows.LazyProc + getMenuItemCount *windows.LazyProc + getMenuItemID *windows.LazyProc + getMenuItemInfo *windows.LazyProc getMessage *windows.LazyProc getMonitorInfo *windows.LazyProc getParent *windows.LazyProc getRawInputData *windows.LazyProc getScrollInfo *windows.LazyProc + getSubMenu *windows.LazyProc getSysColor *windows.LazyProc getSysColorBrush *windows.LazyProc getSystemMenu *windows.LazyProc @@ -1848,6 +1855,7 @@ var ( peekMessage *windows.LazyProc postMessage *windows.LazyProc postQuitMessage *windows.LazyProc + redrawWindow *windows.LazyProc registerClassEx *windows.LazyProc registerRawInputDevices *windows.LazyProc registerWindowMessage *windows.LazyProc @@ -1868,6 +1876,7 @@ var ( setMenu *windows.LazyProc setMenuDefaultItem *windows.LazyProc setMenuInfo *windows.LazyProc + setMenuItemBitmaps *windows.LazyProc setMenuItemInfo *windows.LazyProc setParent *windows.LazyProc setRect *windows.LazyProc @@ -1881,6 +1890,7 @@ var ( showWindow *windows.LazyProc systemParametersInfo *windows.LazyProc trackMouseEvent *windows.LazyProc + trackPopupMenu *windows.LazyProc trackPopupMenuEx *windows.LazyProc translateMessage *windows.LazyProc unhookWinEvent *windows.LazyProc @@ -1915,6 +1925,7 @@ func init() { createWindowEx = libuser32.NewProc("CreateWindowExW") deferWindowPos = libuser32.NewProc("DeferWindowPos") defWindowProc = libuser32.NewProc("DefWindowProcW") + deleteMenu = libuser32.NewProc("DeleteMenu") destroyIcon = libuser32.NewProc("DestroyIcon") destroyMenu = libuser32.NewProc("DestroyMenu") destroyWindow = libuser32.NewProc("DestroyWindow") @@ -1925,6 +1936,7 @@ func init() { drawMenuBar = libuser32.NewProc("DrawMenuBar") drawTextEx = libuser32.NewProc("DrawTextExW") emptyClipboard = libuser32.NewProc("EmptyClipboard") + enableMenuItem = libuser32.NewProc("EnableMenuItem") enableWindow = libuser32.NewProc("EnableWindow") endDeferWindowPos = libuser32.NewProc("EndDeferWindowPos") endDialog = libuser32.NewProc("EndDialog") @@ -1946,12 +1958,17 @@ func init() { getForegroundWindow = libuser32.NewProc("GetForegroundWindow") getIconInfo = libuser32.NewProc("GetIconInfo") getKeyState = libuser32.NewProc("GetKeyState") + getMenuCheckMarkDimensions = libuser32.NewProc("GetMenuCheckMarkDimensions") getMenuInfo = libuser32.NewProc("GetMenuInfo") + getMenuItemCount = libuser32.NewProc("GetMenuItemCount") + getMenuItemID = libuser32.NewProc("GetMenuItemID") + getMenuItemInfo = libuser32.NewProc("GetMenuItemInfoW") getMessage = libuser32.NewProc("GetMessageW") getMonitorInfo = libuser32.NewProc("GetMonitorInfoW") getParent = libuser32.NewProc("GetParent") getRawInputData = libuser32.NewProc("GetRawInputData") getScrollInfo = libuser32.NewProc("GetScrollInfo") + getSubMenu = libuser32.NewProc("GetSubMenu") getSysColor = libuser32.NewProc("GetSysColor") getSysColorBrush = libuser32.NewProc("GetSysColorBrush") getSystemMenu = libuser32.NewProc("GetSystemMenu") @@ -1993,6 +2010,7 @@ func init() { peekMessage = libuser32.NewProc("PeekMessageW") postMessage = libuser32.NewProc("PostMessageW") postQuitMessage = libuser32.NewProc("PostQuitMessage") + redrawWindow = libuser32.NewProc("RedrawWindow") registerClassEx = libuser32.NewProc("RegisterClassExW") registerRawInputDevices = libuser32.NewProc("RegisterRawInputDevices") registerWindowMessage = libuser32.NewProc("RegisterWindowMessageW") @@ -2013,6 +2031,7 @@ func init() { setMenu = libuser32.NewProc("SetMenu") setMenuDefaultItem = libuser32.NewProc("SetMenuDefaultItem") setMenuInfo = libuser32.NewProc("SetMenuInfo") + setMenuItemBitmaps = libuser32.NewProc("SetMenuItemBitmaps") setMenuItemInfo = libuser32.NewProc("SetMenuItemInfoW") setRect = libuser32.NewProc("SetRect") setParent = libuser32.NewProc("SetParent") @@ -2031,6 +2050,7 @@ func init() { showWindow = libuser32.NewProc("ShowWindow") systemParametersInfo = libuser32.NewProc("SystemParametersInfoW") trackMouseEvent = libuser32.NewProc("TrackMouseEvent") + trackPopupMenu = libuser32.NewProc("TrackPopupMenu") trackPopupMenuEx = libuser32.NewProc("TrackPopupMenuEx") translateMessage = libuser32.NewProc("TranslateMessage") unhookWinEvent = libuser32.NewProc("UnhookWinEvent") @@ -2252,6 +2272,15 @@ func DefWindowProc(hWnd HWND, Msg uint32, wParam, lParam uintptr) uintptr { return ret } +func DeleteMenu(hMenu HMENU, uPosition uint32, uFlags uint32) bool { + ret, _, _ := syscall.Syscall(deleteMenu.Addr(), 3, + uintptr(hMenu), + uintptr(uPosition), + uintptr(uFlags)) + + return ret != 0 +} + func DestroyIcon(hIcon HICON) bool { ret, _, _ := syscall.Syscall(destroyIcon.Addr(), 1, uintptr(hIcon), @@ -2354,6 +2383,15 @@ func EmptyClipboard() bool { return ret != 0 } +func EnableMenuItem(hMenu HMENU, uIDEnableItem uint32, uEnable uint32) bool { + ret, _, _ := syscall.Syscall(enableMenuItem.Addr(), 3, + uintptr(hMenu), + uintptr(uIDEnableItem), + uintptr(uEnable)) + + return ret != 0 +} + func EnableWindow(hWnd HWND, bEnable bool) bool { ret, _, _ := syscall.Syscall(enableWindow.Addr(), 2, uintptr(hWnd), @@ -2552,6 +2590,15 @@ func GetKeyState(nVirtKey int32) int16 { return int16(ret) } +func GetMenuCheckMarkDimensions() int32 { + ret, _, _ := syscall.Syscall(getMenuCheckMarkDimensions.Addr(), 0, + 0, + 0, + 0) + + return int32(ret) +} + func GetMenuInfo(hmenu HMENU, lpcmi *MENUINFO) bool { ret, _, _ := syscall.Syscall(getMenuInfo.Addr(), 2, uintptr(hmenu), @@ -2561,6 +2608,36 @@ func GetMenuInfo(hmenu HMENU, lpcmi *MENUINFO) bool { return ret != 0 } +func GetMenuItemCount(hMenu HMENU) int32 { + ret, _, _ := syscall.Syscall(getMenuItemCount.Addr(), 1, + uintptr(hMenu), + 0, + 0) + + return int32(ret) +} + +func GetMenuItemID(hMenu HMENU, nPos int32) uint32 { + ret, _, _ := syscall.Syscall(getMenuItemID.Addr(), 2, + uintptr(hMenu), + uintptr(nPos), + 0) + + return uint32(ret) +} + +func GetMenuItemInfo(hmenu HMENU, item uint32, fByPosition BOOL, lpmii *MENUITEMINFO) bool { + ret, _, _ := syscall.Syscall6(getMenuItemInfo.Addr(), 4, + uintptr(hmenu), + uintptr(item), + uintptr(fByPosition), + uintptr(unsafe.Pointer(lpmii)), + 0, + 0) + + return ret != 0 +} + func GetMessage(msg *MSG, hWnd HWND, msgFilterMin, msgFilterMax uint32) BOOL { ret, _, _ := syscall.Syscall6(getMessage.Addr(), 4, uintptr(unsafe.Pointer(msg)), @@ -2612,6 +2689,15 @@ func GetScrollInfo(hwnd HWND, fnBar int32, lpsi *SCROLLINFO) bool { return ret != 0 } +func GetSubMenu(hMenu HMENU, nPos int32) HMENU { + ret, _, _ := syscall.Syscall(getSubMenu.Addr(), 2, + uintptr(hMenu), + uintptr(nPos), + 0) + + return HMENU(ret) +} + func GetSysColor(nIndex int) uint32 { ret, _, _ := syscall.Syscall(getSysColor.Addr(), 1, uintptr(nIndex), @@ -2964,6 +3050,38 @@ func PostQuitMessage(exitCode int32) { 0) } +const ( + // RedrawWindow() flags + RDW_INVALIDATE = 0x0001 + RDW_INTERNALPAINT = 0x0002 + RDW_ERASE = 0x0004 + + RDW_VALIDATE = 0x0008 + RDW_NOINTERNALPAINT = 0x0010 + RDW_NOERASE = 0x0020 + + RDW_NOCHILDREN = 0x0040 + RDW_ALLCHILDREN = 0x0080 + + RDW_UPDATENOW = 0x0100 + RDW_ERASENOW = 0x0200 + + RDW_FRAME = 0x0400 + RDW_NOFRAME = 0x0800 +) + +func RedrawWindow(hWnd HWND, lprcUpdate *RECT, hrgnUpdate HRGN, flags uint32) bool { + ret, _, _ := syscall.Syscall6(redrawWindow.Addr(), 4, + uintptr(hWnd), + uintptr(unsafe.Pointer(lprcUpdate)), + uintptr(hrgnUpdate), + uintptr(flags), + 0, + 0) + + return ret != 0 +} + func RegisterClassEx(windowClass *WNDCLASSEX) ATOM { ret, _, _ := syscall.Syscall(registerClassEx.Addr(), 1, uintptr(unsafe.Pointer(windowClass)), @@ -3151,6 +3269,18 @@ func SetMenuInfo(hmenu HMENU, lpcmi *MENUINFO) bool { return ret != 0 } +func SetMenuItemBitmaps(hMenu HMENU, uPosition uint32, uFlags uint32, hBitmapUnchecked HBITMAP, hBitmapChecked HBITMAP) bool { + ret, _, _ := syscall.Syscall6(setMenuItemBitmaps.Addr(), 5, + uintptr(hMenu), + uintptr(uPosition), + uintptr(uFlags), + uintptr(hBitmapUnchecked), + uintptr(hBitmapChecked), + 0) + + return ret != 0 +} + func SetMenuItemInfo(hMenu HMENU, uItem uint32, fByPosition bool, lpmii *MENUITEMINFO) bool { ret, _, _ := syscall.Syscall6(setMenuItemInfo.Addr(), 4, uintptr(hMenu), @@ -3300,6 +3430,21 @@ func TrackMouseEvent(lpEventTrack *TRACKMOUSEEVENT) bool { return ret != 0 } +func TrackPopupMenu(hMenu HMENU, uFlags uint32, x, y int32, nReserved int32, hWnd HWND, prcRect *RECT) uint32 { + ret, _, _ := syscall.Syscall9(trackPopupMenu.Addr(), 7, + uintptr(hMenu), + uintptr(uFlags), + uintptr(x), + uintptr(y), + uintptr(nReserved), + uintptr(hWnd), + uintptr(unsafe.Pointer(prcRect)), + 0, + 0) + + return uint32(ret) +} + func TrackPopupMenuEx(hMenu HMENU, fuFlags uint32, x, y int32, hWnd HWND, lptpm *TPMPARAMS) BOOL { ret, _, _ := syscall.Syscall6(trackPopupMenuEx.Addr(), 6, uintptr(hMenu), -- cgit v1.2.3-59-g8ed1b From 12ccdd60ac7ac388850372af725a6e4d5b3ef6ae Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 7 Nov 2020 09:47:48 +0100 Subject: Extend RichEdit support Signed-off-by: Simon Rozman --- richedit.go | 639 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 628 insertions(+), 11 deletions(-) diff --git a/richedit.go b/richedit.go index 947247f0..aa51204b 100644 --- a/richedit.go +++ b/richedit.go @@ -65,15 +65,15 @@ const ( EM_GETTEXTMODE = WM_USER + 90 ) -type TEXTMODE int +type TEXTMODE int32 const ( TM_PLAINTEXT TEXTMODE = 1 - TM_RICHTEXT TEXTMODE = 2 // Default behavior - TM_SINGLELEVELUNDO TEXTMODE = 4 - TM_MULTILEVELUNDO TEXTMODE = 8 // Default behavior - TM_SINGLECODEPAGE TEXTMODE = 16 - TM_MULTICODEPAGE TEXTMODE = 32 // Default behavior + TM_RICHTEXT = 2 // Default behavior + TM_SINGLELEVELUNDO = 4 + TM_MULTILEVELUNDO = 8 // Default behavior + TM_SINGLECODEPAGE = 16 + TM_MULTICODEPAGE = 32 // Default behavior ) const ( @@ -461,7 +461,7 @@ const ( EM_SETELLIPSISMODE = WM_USER + 306 ) -// DWORD: *lparam for EM_GETELLIPSISMODE, lparam for EM_SETELLIPSISMODE +// uint32: *lparam for EM_GETELLIPSISMODE, lparam for EM_SETELLIPSISMODE const ( ELLIPSIS_MASK = 0x00000003 // all meaningful bits ELLIPSIS_NONE = 0x00000000 // ellipsis disabled @@ -567,10 +567,8 @@ const ( ES_SAVESEL = 0x00008000 ES_SUNKEN = 0x00004000 ES_DISABLENOSCROLL = 0x00002000 - // Same as WS_MAXIMIZE, but that doesn't make sense so we re-use the value - ES_SELECTIONBAR = 0x01000000 - // Same as ES_UPPERCASE, but re-used to completely disable OLE drag'n'drop - ES_NOOLEDRAGDROP = 0x00000008 + ES_SELECTIONBAR = 0x01000000 // Same as WS_MAXIMIZE, but that doesn't make sense so we re-use the value + ES_NOOLEDRAGDROP = 0x00000008 // Same as ES_UPPERCASE, but re-used to completely disable OLE drag'n'drop ) // Obsolete Edit Style @@ -654,3 +652,622 @@ const ( WBF_BREAKLINE byte = 0x20 WBF_BREAKAFTER byte = 0x40 ) + +type CHARFORMAT struct { + CbSize uint32 + DwMask uint32 + DwEffects uint32 + YHeight int32 + YOffset int32 + CrTextColor COLORREF + BCharSet byte + BPitchAndFamily byte + SzFaceName [LF_FACESIZE]uint16 +} + +type CHARFORMAT2 struct { + CHARFORMAT + WWeight uint16 // Font weight (LOGFONT value) + SSpacing int16 // Amount to space between letters + CrBackColor COLORREF // Background color + Lcid LCID // Locale ID + DwCookie uint32 // Client cookie opaque to RichEdit + SStyle int16 // Style handle + WKerning uint16 // Twip size above which to kern char pair + BUnderlineType byte // Underline type + BAnimation byte // Animated text like marching ants + BRevAuthor byte // Revision author index + BUnderlineColor byte // Underline color +} + +// CHARFORMAT masks +const ( + CFM_BOLD = 0x00000001 + CFM_ITALIC = 0x00000002 + CFM_UNDERLINE = 0x00000004 + CFM_STRIKEOUT = 0x00000008 + CFM_PROTECTED = 0x00000010 + CFM_LINK = 0x00000020 // Exchange hyperlink extension + CFM_SIZE = 0x80000000 + CFM_COLOR = 0x40000000 + CFM_FACE = 0x20000000 + CFM_OFFSET = 0x10000000 + CFM_CHARSET = 0x08000000 +) + +// CHARFORMAT effects +const ( + CFE_BOLD = 0x00000001 + CFE_ITALIC = 0x00000002 + CFE_UNDERLINE = 0x00000004 + CFE_STRIKEOUT = 0x00000008 + CFE_PROTECTED = 0x00000010 + CFE_LINK = 0x00000020 + CFE_AUTOCOLOR = 0x40000000 // NOTE: this corresponds to CFM_COLOR, which controls it + + // Masks and effects defined for CHARFORMAT2 -- an (*) indicates that the data is stored by RichEdit 2.0/3.0, but not displayed + CFM_SMALLCAPS = 0x00000040 // (*) + CFM_ALLCAPS = 0x00000080 // Displayed by 3.0 + CFM_HIDDEN = 0x00000100 // Hidden by 3.0 + CFM_OUTLINE = 0x00000200 // (*) + CFM_SHADOW = 0x00000400 // (*) + CFM_EMBOSS = 0x00000800 // (*) + CFM_IMPRINT = 0x00001000 // (*) + CFM_DISABLED = 0x00002000 + CFM_REVISED = 0x00004000 + + CFM_REVAUTHOR = 0x00008000 + CFE_SUBSCRIPT = 0x00010000 // Superscript and subscript are + CFE_SUPERSCRIPT = 0x00020000 // mutually exclusive + CFM_ANIMATION = 0x00040000 // (*) + CFM_STYLE = 0x00080000 // (*) + CFM_KERNING = 0x00100000 + CFM_SPACING = 0x00200000 // Displayed by 3.0 + CFM_WEIGHT = 0x00400000 + CFM_UNDERLINETYPE = 0x00800000 // Many displayed by 3.0 + CFM_COOKIE = 0x01000000 // RE 6.0 + CFM_LCID = 0x02000000 + CFM_BACKCOLOR = 0x04000000 // Higher mask bits defined above + + CFM_SUBSCRIPT = (CFE_SUBSCRIPT | CFE_SUPERSCRIPT) + CFM_SUPERSCRIPT = CFM_SUBSCRIPT + + // CHARFORMAT "ALL" masks + CFM_EFFECTS = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_COLOR | CFM_STRIKEOUT | CFE_PROTECTED | CFM_LINK + CFM_ALL = CFM_EFFECTS | CFM_SIZE | CFM_FACE | CFM_OFFSET | CFM_CHARSET + CFM_EFFECTS2 = CFM_EFFECTS | CFM_DISABLED | CFM_SMALLCAPS | CFM_ALLCAPS | CFM_HIDDEN | CFM_OUTLINE | CFM_SHADOW | CFM_EMBOSS | CFM_IMPRINT | CFM_REVISED | CFM_SUBSCRIPT | CFM_SUPERSCRIPT | CFM_BACKCOLOR + CFM_ALL2 = CFM_ALL | CFM_EFFECTS2 | CFM_BACKCOLOR | CFM_LCID | CFM_UNDERLINETYPE | CFM_WEIGHT | CFM_REVAUTHOR | CFM_SPACING | CFM_KERNING | CFM_STYLE | CFM_ANIMATION | CFM_COOKIE + + CFE_SMALLCAPS = CFM_SMALLCAPS + CFE_ALLCAPS = CFM_ALLCAPS + CFE_HIDDEN = CFM_HIDDEN + CFE_OUTLINE = CFM_OUTLINE + CFE_SHADOW = CFM_SHADOW + CFE_EMBOSS = CFM_EMBOSS + CFE_IMPRINT = CFM_IMPRINT + CFE_DISABLED = CFM_DISABLED + CFE_REVISED = CFM_REVISED + + // CFE_AUTOCOLOR and CFE_AUTOBACKCOLOR correspond to CFM_COLOR and + // CFM_BACKCOLOR, respectively, which control them + CFE_AUTOBACKCOLOR = CFM_BACKCOLOR + + CFM_FONTBOUND = 0x00100000 + CFM_LINKPROTECTED = 0x00800000 // Word hyperlink field + CFM_EXTENDED = 0x02000000 + CFM_MATHNOBUILDUP = 0x08000000 + CFM_MATH = 0x10000000 + CFM_MATHORDINARY = 0x20000000 + + CFM_ALLEFFECTS = (CFM_EFFECTS2 | CFM_FONTBOUND | CFM_EXTENDED | CFM_MATHNOBUILDUP | CFM_MATH | CFM_MATHORDINARY) + + CFE_FONTBOUND = 0x00100000 // Font chosen by binder, not user + CFE_LINKPROTECTED = 0x00800000 + CFE_EXTENDED = 0x02000000 + CFE_MATHNOBUILDUP = 0x08000000 + CFE_MATH = 0x10000000 + CFE_MATHORDINARY = 0x20000000 + + // Underline types. RE 1.0 displays only CFU_UNDERLINE + CFU_CF1UNDERLINE = 0xFF // Map charformat's bit underline to CF2 + CFU_INVERT = 0xFE // For IME composition fake a selection + CFU_UNDERLINETHICKLONGDASH = 18 // (*) display as dash + CFU_UNDERLINETHICKDOTTED = 17 // (*) display as dot + CFU_UNDERLINETHICKDASHDOTDOT = 16 // (*) display as dash dot dot + CFU_UNDERLINETHICKDASHDOT = 15 // (*) display as dash dot + CFU_UNDERLINETHICKDASH = 14 // (*) display as dash + CFU_UNDERLINELONGDASH = 13 // (*) display as dash + CFU_UNDERLINEHEAVYWAVE = 12 // (*) display as wave + CFU_UNDERLINEDOUBLEWAVE = 11 // (*) display as wave + CFU_UNDERLINEHAIRLINE = 10 // (*) display as single + CFU_UNDERLINETHICK = 9 + CFU_UNDERLINEWAVE = 8 + CFU_UNDERLINEDASHDOTDOT = 7 + CFU_UNDERLINEDASHDOT = 6 + CFU_UNDERLINEDASH = 5 + CFU_UNDERLINEDOTTED = 4 + CFU_UNDERLINEDOUBLE = 3 // (*) display as single + CFU_UNDERLINEWORD = 2 // (*) display as single + CFU_UNDERLINE = 1 + CFU_UNDERLINENONE = 0 +) + +const YHeightCharPtsMost = 1638 + +const ( + // EM_SETCHARFORMAT wParam masks + SCF_SELECTION = 0x0001 + SCF_WORD = 0x0002 + SCF_DEFAULT = 0x0000 // Set default charformat or paraformat + SCF_ALL = 0x0004 // Not valid with SCF_SELECTION or SCF_WORD + SCF_USEUIRULES = 0x0008 // Modifier for SCF_SELECTION; says that came from a toolbar, etc., and UI formatting rules should be instead of literal formatting + SCF_ASSOCIATEFONT = 0x0010 // Associate fontname with bCharSet (one possible for each of Western, ME, FE, Thai) + SCF_NOKBUPDATE = 0x0020 // Do not update KB layout for this change even if autokeyboard is on + SCF_ASSOCIATEFONT2 = 0x0040 // Associate plane-2 (surrogate) font + SCF_SMARTFONT = 0x0080 // Apply font only if it can handle script (5.0) + SCF_CHARREPFROMLCID = 0x0100 // Get character repertoire from lcid (5.0) + + SPF_DONTSETDEFAULT = 0x0002 // Suppress setting default on empty control + SPF_SETDEFAULT = 0x0004 // Set the default paraformat +) + +type CHARRANGE struct { + CpMin int32 + CpMax int32 +} + +type TEXTRANGE struct { + Chrg CHARRANGE + LpstrText *uint16 // Allocated by caller, zero terminated by RichEdit +} + +type EDITSTREAM struct { + DwCookie uintptr // User value passed to callback as first parameter + DwError uint32 // Last error + PfnCallback uintptr +} + +const ( + // Stream formats. Flags are all in low word, since high word gives possible codepage choice. + SF_TEXT = 0x0001 + SF_RTF = 0x0002 + SF_RTFNOOBJS = 0x0003 // Write only + SF_TEXTIZED = 0x0004 // Write only + + SF_UNICODE = 0x0010 // Unicode file (UCS2 little endian) + SF_USECODEPAGE = 0x0020 // CodePage given by high word + SF_NCRFORNONASCII = 0x40 // Output \uN for nonASCII + SFF_WRITEXTRAPAR = 0x80 // Output \par at end + + // Flag telling stream operations to operate on selection only + // EM_STREAMIN replaces current selection + // EM_STREAMOUT streams out current selection + SFF_SELECTION = 0x8000 + + // Flag telling stream operations to ignore some FE control words having to do with FE word breaking and horiz vs vertical text. + // Not used in RichEdit 2.0 and later + SFF_PLAINRTF = 0x4000 + + // Flag telling file stream output (SFF_SELECTION flag not set) to persist // \viewscaleN control word. + SFF_PERSISTVIEWSCALE = 0x2000 + + // Flag telling file stream input with SFF_SELECTION flag not set not to // close the document + SFF_KEEPDOCINFO = 0x1000 + + // Flag telling stream operations to output in Pocket Word format + SFF_PWD = 0x0800 + + // 3-bit field specifying the value of N - 1 to use for \rtfN or \pwdN + SF_RTFVAL = 0x0700 +) + +type FINDTEXT struct { + Chrg CHARRANGE + LpstrText *uint16 +} + +type FINDTEXTEX struct { + chrg CHARRANGE + lpstrText *uint16 + chrgText CHARRANGE +} + +type FORMATRANGE struct { + hdc HDC + hdcTarget HDC + rc RECT + rcPage RECT + chrg CHARRANGE +} + +// All paragraph measurements are in twips +const ( + MAX_TAB_STOPS = 32 + LDefaultTab = 720 + MAX_TABLE_CELLS = 63 +) + +type PARAFORMAT struct { + CbSize uint32 + DwMask uint32 + WNumbering uint16 + WEffects uint16 + DxStartIndent int32 + DxRightIndent int32 + DxOffset int32 + WAlignment uint16 + CTabCount int16 + RgxTabs [MAX_TAB_STOPS]int32 +} + +type PARAFORMAT2 struct { + PARAFORMAT + DySpaceBefore int32 // Vertical spacing before para + DySpaceAfter int32 // Vertical spacing after para + DyLineSpacing int32 // Line spacing depending on Rule + SStyle int16 // Style handle + BLineSpacingRule byte // Rule for line spacing (see tom.doc) + BOutlineLevel byte // Outline level + WShadingWeight uint16 // Shading in hundredths of a per cent + WShadingStyle uint16 // Nibble 0: style, 1: cfpat, 2: cbpat + WNumberingStart uint16 // Starting value for numbering + WNumberingStyle uint16 // Alignment, roman/arabic, (), ), ., etc. + WNumberingTab uint16 // Space bet FirstIndent & 1st-line text + WBorderSpace uint16 // Border-text spaces (nbl/bdr in pts) + WBorderWidth uint16 // Pen widths (nbl/bdr in half pts) + WBorders uint16 // Border styles (nibble/border) +} + +const ( + // PARAFORMAT mask values + PFM_STARTINDENT = 0x00000001 + PFM_RIGHTINDENT = 0x00000002 + PFM_OFFSET = 0x00000004 + PFM_ALIGNMENT = 0x00000008 + PFM_TABSTOPS = 0x00000010 + PFM_NUMBERING = 0x00000020 + PFM_OFFSETINDENT = 0x80000000 + + // PARAFORMAT 2.0 masks and effects + PFM_SPACEBEFORE = 0x00000040 + PFM_SPACEAFTER = 0x00000080 + PFM_LINESPACING = 0x00000100 + PFM_STYLE = 0x00000400 + PFM_BORDER = 0x00000800 // (*) + PFM_SHADING = 0x00001000 // (*) + PFM_NUMBERINGSTYLE = 0x00002000 // RE 3.0 + PFM_NUMBERINGTAB = 0x00004000 // RE 3.0 + PFM_NUMBERINGSTART = 0x00008000 // RE 3.0 + + PFM_RTLPARA = 0x00010000 + PFM_KEEP = 0x00020000 // (*) + PFM_KEEPNEXT = 0x00040000 // (*) + PFM_PAGEBREAKBEFORE = 0x00080000 // (*) + PFM_NOLINENUMBER = 0x00100000 // (*) + PFM_NOWIDOWCONTROL = 0x00200000 // (*) + PFM_DONOTHYPHEN = 0x00400000 // (*) + PFM_SIDEBYSIDE = 0x00800000 // (*) + + // The following two paragraph-format properties are read only + PFM_COLLAPSED = 0x01000000 // RE 3.0 + PFM_OUTLINELEVEL = 0x02000000 // RE 3.0 + PFM_BOX = 0x04000000 // RE 3.0 + PFM_RESERVED2 = 0x08000000 // RE 4.0 + PFM_TABLEROWDELIMITER = 0x10000000 // RE 4.0 + PFM_TEXTWRAPPINGBREAK = 0x20000000 // RE 3.0 + PFM_TABLE = 0x40000000 // RE 3.0 + + // PARAFORMAT "ALL" masks + PFM_ALL = PFM_STARTINDENT | PFM_RIGHTINDENT | PFM_OFFSET | PFM_ALIGNMENT | PFM_TABSTOPS | PFM_NUMBERING | PFM_OFFSETINDENT | PFM_RTLPARA + + // Note: PARAFORMAT has no effects (BiDi RichEdit 1.0 does have PFE_RTLPARA) + PFM_EFFECTS = PFM_RTLPARA | PFM_KEEP | PFM_KEEPNEXT | PFM_TABLE | PFM_PAGEBREAKBEFORE | PFM_NOLINENUMBER | PFM_NOWIDOWCONTROL | PFM_DONOTHYPHEN | PFM_SIDEBYSIDE | PFM_TABLE | PFM_TABLEROWDELIMITER + + PFM_ALL2 = PFM_ALL | PFM_EFFECTS | PFM_SPACEBEFORE | PFM_SPACEAFTER | PFM_LINESPACING | PFM_STYLE | PFM_SHADING | PFM_BORDER | PFM_NUMBERINGTAB | PFM_NUMBERINGSTART | PFM_NUMBERINGSTYLE + + PFE_RTLPARA = PFM_RTLPARA >> 16 + PFE_KEEP = PFM_KEEP >> 16 // (*) + PFE_KEEPNEXT = PFM_KEEPNEXT >> 16 // (*) + PFE_PAGEBREAKBEFORE = PFM_PAGEBREAKBEFORE >> 16 // (*) + PFE_NOLINENUMBER = PFM_NOLINENUMBER >> 16 // (*) + PFE_NOWIDOWCONTROL = PFM_NOWIDOWCONTROL >> 16 // (*) + PFE_DONOTHYPHEN = PFM_DONOTHYPHEN >> 16 // (*) + PFE_SIDEBYSIDE = PFM_SIDEBYSIDE >> 16 // (*) + PFE_TEXTWRAPPINGBREAK = PFM_TEXTWRAPPINGBREAK >> 16 // (*) + + // The following four effects are read only + PFE_COLLAPSED = PFM_COLLAPSED >> 16 // (+) + PFE_BOX = PFM_BOX >> 16 // (+) + PFE_TABLE = PFM_TABLE >> 16 // Inside table row. RE 3.0 + PFE_TABLEROWDELIMITER = PFM_TABLEROWDELIMITER >> 16 // Table row start. RE 4.0 + + // PARAFORMAT numbering options + PFN_BULLET = 1 // tomListBullet + + // PARAFORMAT2 wNumbering options + PFN_ARABIC = 2 // tomListNumberAsArabic: 0, 1, 2, ... + PFN_LCLETTER = 3 // tomListNumberAsLCLetter: a, b, c, ... + PFN_UCLETTER = 4 // tomListNumberAsUCLetter: A, B, C, ... + PFN_LCROMAN = 5 // tomListNumberAsLCRoman: i, ii, iii, ... + PFN_UCROMAN = 6 // tomListNumberAsUCRoman: I, II, III, ... + + // PARAFORMAT2 wNumberingStyle options + PFNS_PAREN = 0x000 // default, e.g., 1) + PFNS_PARENS = 0x100 // tomListParentheses/256, e.g., (1) + PFNS_PERIOD = 0x200 // tomListPeriod/256, e.g., 1. + PFNS_PLAIN = 0x300 // tomListPlain/256, e.g., 1 + PFNS_NONUMBER = 0x400 // Used for continuation w/o number + + PFNS_NEWNUMBER = 0x8000 // Start new number with wNumberingStart + // (can be combined with other PFNS_xxx) + // PARAFORMAT alignment options + PFA_LEFT = 1 + PFA_RIGHT = 2 + PFA_CENTER = 3 + + // PARAFORMAT2 alignment options + PFA_JUSTIFY = 4 // New paragraph-alignment option 2.0 (*) + PFA_FULL_INTERWORD = 4 // These are supported in 3.0 with advanced +) + +type MSGFILTER struct { + Nmhdr NMHDR + Msg uint32 + WParam uintptr + LParam uintptr +} + +type REQRESIZE struct { + Nmhdr NMHDR + Rc RECT +} + +type SELCHANGE struct { + Nmhdr NMHDR + Chrg CHARRANGE + Seltyp uint16 +} + +type GROUPTYPINGCHANGE struct { + Nmhdr NMHDR + FGroupTyping BOOL +} + +type CLIPBOARDFORMAT struct { + Nmhdr NMHDR + Cf CLIPFORMAT +} + +const ( + SEL_EMPTY = 0x0000 + SEL_TEXT = 0x0001 + SEL_OBJECT = 0x0002 + SEL_MULTICHAR = 0x0004 + SEL_MULTIOBJECT = 0x0008 +) + +const ( + // Used with IRichEditOleCallback::GetContextMenu, this flag will be passed as a "selection type". It indicates that a context menu for a right-mouse drag drop should be generated. The IOleObject parameter will really be the IDataObject for the drop + GCM_RIGHTMOUSEDROP = 0x8000 +) + +type GETCONTEXTMENUEX struct { + Chrg CHARRANGE + DwFlags uint32 + Pt POINT + PvReserved uintptr +} + +const ( + // bits for GETCONTEXTMENUEX::dwFlags + GCMF_GRIPPER = 0x00000001 + GCMF_SPELLING = 0x00000002 // pSpellingSuggestions is valid and points to the list of spelling suggestions + GCMF_TOUCHMENU = 0x00004000 + GCMF_MOUSEMENU = 0x00002000 +) + +type ENDROPFILES struct { + Nmhdr NMHDR + HDrop HANDLE + Cp int32 + FProtected BOOL +} + +type ENPROTECTED struct { + Nmhdr NMHDR + Msg uint32 + WParam uintptr + LParam uintptr + Chrg CHARRANGE +} + +type ENSAVECLIPBOARD struct { + Nmhdr NMHDR + CObjectCount int32 + Cch int32 +} + +type ENOLEOPFAILED struct { + Nmhdr NMHDR + Iob int32 + LOper int32 + Hr HRESULT +} + +const OLEOP_DOVERB = 1 + +type OBJECTPOSITIONS struct { + Nmhdr NMHDR + CObjectCount int32 + PcpPositions *int32 +} + +type ENLINK struct { + Nmhdr NMHDR + Msg uint32 + WParam uintptr + LParam uintptr + Chrg CHARRANGE +} + +type ENLOWFIRTF struct { + Nmhdr NMHDR + SzControl *byte +} + +// PenWin specific +type ENCORRECTTEXT struct { + Nmhdr NMHDR + Chrg CHARRANGE + Seltyp uint16 +} + +// East Asia specific +type PUNCTUATION struct { + ISize uint32 + SzPunctuation *byte +} + +// East Asia specific +type COMPCOLOR struct { + CrText COLORREF + CrBackground COLORREF + DwEffects uint32 +} + +const ( + // Clipboard formats - use as parameter to RegisterClipboardFormat() + CF_RTF = "Rich Text Format" + CF_RTFNOOBJS = "Rich Text Format Without Objects" + CF_RETEXTOBJ = "RichEdit Text and Objects" +) + +// Paste Special +type REPASTESPECIAL struct { + DwAspect uint32 + DwParam uintptr +} + +// UndoName info +type UNDONAMEID int32 + +const ( + UID_UNKNOWN UNDONAMEID = 0 + UID_TYPING = 1 + UID_DELETE = 2 + UID_DRAGDROP = 3 + UID_CUT = 4 + UID_PASTE = 5 + UID_AUTOTABLE = 6 +) + +const ( + // Flags for the SETEXTEX data structure + ST_DEFAULT = 0 + ST_KEEPUNDO = 1 + ST_SELECTION = 2 + ST_NEuint16S = 4 + ST_UNICODE = 8 +) + +// EM_SETTEXTEX info; this struct is passed in the wparam of the message +type SETTEXTEX struct { + Flags uint32 // Flags (see the ST_XXX defines) + Codepage uint32 // Code page for translation (CP_ACP for sys default, 1200 for Unicode, -1 for control default) +} + +const ( + // Flags for the GETEXTEX data structure + GT_DEFAULT = 0 + GT_USECRLF = 1 + GT_SELECTION = 2 + GT_RAWTEXT = 4 + GT_NOHIDDENTEXT = 8 +) + +// EM_GETTEXTEX info; this struct is passed in the wparam of the message +type GETTEXTEX struct { + Cb uint32 // Count of bytes in the string + Flags uint32 // Flags (see the GT_XXX defines + Codepage uint32 // Code page for translation (CP_ACP for sys default, 1200 for Unicode, -1 for control default) + LpDefaultChar *byte // Replacement for unmappable chars + LpUsedDefChar *BOOL // Pointer to flag set when def char used +} + +const ( + // Flags for the GETTEXTLENGTHEX data structure + GTL_DEFAULT = 0 // Do default (return # of chars) + GTL_USECRLF = 1 // Compute answer using CRLFs for paragraphs + GTL_PRECISE = 2 // Compute a precise answer + GTL_CLOSE = 4 // Fast computation of a "close" answer + GTL_NUMCHARS = 8 // Return number of characters + GTL_NUMBYTES = 16 // Return number of _bytes_ +) + +// EM_GETTEXTLENGTHEX info; this struct is passed in the wparam of the msg +type GETTEXTLENGTHEX struct { + Flags uint32 // Flags (see GTL_XXX defines) + Codepage uint32 // Code page for translation (CP_ACP for default, 1200 for Unicode) +} + +// BiDi specific features +type BIDIOPTIONS struct { + CbSize uint32 + WMask uint16 + WEffects uint16 +} + +const ( + // BIDIOPTIONS masks + BOM_NEUTRALOVERRIDE = 0x0004 // Override neutral layout (obsolete) + BOM_CONTEXTREADING = 0x0008 // Context reading order + BOM_CONTEXTALIGNMENT = 0x0010 // Context alignment + BOM_LEGACYBIDICLASS = 0x0040 // Legacy Bidi classification (obsolete) + BOM_UNICODEBIDI = 0x0080 // Use Unicode BiDi algorithm + + // BIDIOPTIONS effects + BOE_NEUTRALOVERRIDE = 0x0004 // Override neutral layout (obsolete) + BOE_CONTEXTREADING = 0x0008 // Context reading order + BOE_CONTEXTALIGNMENT = 0x0010 // Context alignment + BOE_FORCERECALC = 0x0020 // Force recalc and redraw + BOE_LEGACYBIDICLASS = 0x0040 // Legacy Bidi classification (obsolete) + BOE_UNICODEBIDI = 0x0080 // Use Unicode BiDi algorithm + + // Additional EM_FINDTEXT[EX] flags + FR_MATCHDIAC = 0x20000000 + FR_MATCHKASHIDA = 0x40000000 + FR_MATCHALEFHAMZA = 0x80000000 + + // UNICODE embedding character + WCH_EMBEDDING uint16 = 0xFFFC +) + +// khyph - Kind of hyphenation +type KHYPH int32 + +const ( + KhyphNil KHYPH = iota // No Hyphenation + KhyphNormal // Normal Hyphenation + KhyphAddBefore // Add letter before hyphen + KhyphChangeBefore // Change letter before hyphen + KhyphDeleteBefore // Delete letter before hyphen + KhyphChangeAfter // Change letter after hyphen + KhyphDelAndChange // Delete letter before hyphen and change letter preceding hyphen +) + +type HYPHRESULT struct { + Khyph KHYPH // Kind of hyphenation + IchHyph int32 // Character which was hyphenated + ChHyph uint16 // Depending on hyphenation type, character added, changed, etc. +} + +type HYPHENATEINFO struct { + CbSize int16 // Size of HYPHENATEINFO structure + DxHyphenateZone int16 // If a space character is closer to the margin than this value, don't hyphenate (in TWIPs) + PfnHyphenate uintptr +} + +const ( + // Additional class for Richedit 6.0 + RICHEDIT60_CLASS = "RICHEDIT60W" +) -- cgit v1.2.3-59-g8ed1b From 86c95bacda4f7d53e25a0b161babc4bcd5634bcf Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 7 Nov 2020 09:51:04 +0100 Subject: Add RGB "macro" Signed-off-by: Simon Rozman --- gdi32.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gdi32.go b/gdi32.go index ba8dd91d..69e43c35 100644 --- a/gdi32.go +++ b/gdi32.go @@ -765,6 +765,10 @@ const ( FR_NOT_ENUM = 0x20 ) +func RGB(r, g, b byte) COLORREF { + return COLORREF(r) | (COLORREF(g) << 8) | (COLORREF(b) << 16) +} + type ( COLORREF uint32 HBITMAP HGDIOBJ -- cgit v1.2.3-59-g8ed1b From 7611bb921256d89a6c9061e760e96e91c670323e Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 7 Nov 2020 09:53:08 +0100 Subject: Add CLIPFORMAT type Signed-off-by: Simon Rozman --- gdi32.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gdi32.go b/gdi32.go index 69e43c35..1842b9e5 100644 --- a/gdi32.go +++ b/gdi32.go @@ -780,6 +780,7 @@ type ( HPALETTE HGDIOBJ HPEN HGDIOBJ HRGN HGDIOBJ + CLIPFORMAT uint16 ) type PIXELFORMATDESCRIPTOR struct { -- cgit v1.2.3-59-g8ed1b From c69f391b4b0ae1486a468efff1e39995fa1d1e9e Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 7 Nov 2020 09:53:29 +0100 Subject: Add CP_... constants Signed-off-by: Simon Rozman --- winnls.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 winnls.go diff --git a/winnls.go b/winnls.go new file mode 100644 index 00000000..13845962 --- /dev/null +++ b/winnls.go @@ -0,0 +1,20 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +const ( + // Code Page Default Values. + // Please Use Unicode, either UTF-16 (as in WCHAR) or UTF-8 (code page CP_ACP) + CP_ACP = 0 // default to ANSI code page + CP_OEMCP = 1 // default to OEM code page + CP_MACCP = 2 // default to MAC code page + CP_THREAD_ACP = 3 // current thread's ANSI code page + CP_SYMBOL = 42 // SYMBOL translations + + CP_UTF7 = 65000 // UTF-7 translation + CP_UTF8 = 65001 // UTF-8 translation +) -- cgit v1.2.3-59-g8ed1b From 441d9836c3655081ef1750c54f2f1a648309006e Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 7 Nov 2020 10:13:50 +0100 Subject: Add text editing OLE interfaces Signed-off-by: Simon Rozman --- oaidl.go | 81 +++++ objidl.go | 47 +++ richole.go | 213 +++++++++++++ tom.go | 989 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1330 insertions(+) create mode 100644 oaidl.go create mode 100644 objidl.go create mode 100644 richole.go create mode 100644 tom.go diff --git a/oaidl.go b/oaidl.go new file mode 100644 index 00000000..c209866a --- /dev/null +++ b/oaidl.go @@ -0,0 +1,81 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +import ( + "syscall" + "unsafe" +) + +type SCODE int32 + +type EXCEPINFO struct { + wCode uint16 + wReserved uint16 + bstrSource *uint16 /*BSTR*/ + bstrDescription *uint16 /*BSTR*/ + bstrHelpFile *uint16 /*BSTR*/ + dwHelpContext uint32 + pvReserved uintptr + pfnDeferredFillIn uintptr + scode SCODE +} + +var ( + IID_ITypeInfo = IID{0x00020401, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} +) + +type ITypeInfoVtbl struct { + IUnknownVtbl + GetTypeAttr uintptr + GetTypeComp uintptr + GetFuncDesc uintptr + GetVarDesc uintptr + GetNames uintptr + GetRefTypeOfImplType uintptr + GetImplTypeFlags uintptr + GetIDsOfNames uintptr + Invoke uintptr + GetDocumentation uintptr + GetDllEntry uintptr + GetRefTypeInfo uintptr + AddressOfMember uintptr + CreateInstance uintptr + GetMops uintptr + GetContainingTypeLib uintptr + ReleaseTypeAttr uintptr + ReleaseFuncDesc uintptr + ReleaseVarDesc uintptr +} + +type ITypeInfo struct { + LpVtbl *ITypeInfoVtbl +} + +func (obj *ITypeInfo) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(riid)), + uintptr(unsafe.Pointer(ppvObject))) + return HRESULT(ret) +} + +func (obj *ITypeInfo) AddRef() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +func (obj *ITypeInfo) Release() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} diff --git a/objidl.go b/objidl.go new file mode 100644 index 00000000..12f1ceb3 --- /dev/null +++ b/objidl.go @@ -0,0 +1,47 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +type IDataObjectVtbl struct { + IUnknownVtbl + GetData uintptr + GetDataHere uintptr + QueryGetData uintptr + GetCanonicalFormatEtc uintptr + SetData uintptr + EnumFormatEtc uintptr + DAdvise uintptr + DUnadvise uintptr + EnumDAdvise uintptr +} + +type IDataObject struct { + LpVtbl *IDataObjectVtbl +} + +type IStorageVtbl struct { + IUnknownVtbl + CreateStream uintptr + OpenStream uintptr + CreateStorage uintptr + OpenStorage uintptr + CopyTo uintptr + MoveElementTo uintptr + Commit uintptr + Revert uintptr + EnumElements uintptr + DestroyElement uintptr + RenameElement uintptr + SetElementTimes uintptr + SetClass uintptr + SetStateBits uintptr + Stat uintptr +} + +type IStorage struct { + LpVtbl *IStorageVtbl +} diff --git a/richole.go b/richole.go new file mode 100644 index 00000000..e1e3fa65 --- /dev/null +++ b/richole.go @@ -0,0 +1,213 @@ +// Copyright 2010 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +import ( + "syscall" + "unsafe" +) + +type REOBJECT struct { + cbStruct uint32 // Size of structure + cp int32 // Character position of object + clsid CLSID // Class ID of object + poleobj *IOleObject // OLE object interface + pstg *IStorage // Associated storage interface + polesite *IOleClientSite // Associated client site interface + sizel SIZE // Size of object (may be 0,0) + dvaspect uint32 // Display aspect to use + dwFlags uint32 // Object status flags + dwUser uint32 // Dword for user's use +} + +type IRichEditOleVtbl struct { + IUnknownVtbl + GetClientSite uintptr + GetObjectCount uintptr + GetLinkCount uintptr + GetObject uintptr + InsertObject uintptr + ConvertObject uintptr + ActivateAs uintptr + SetHostNames uintptr + SetLinkAvailable uintptr + SetDvaspect uintptr + HandsOffStorage uintptr + SaveCompleted uintptr + InPlaceDeactivate uintptr + ContextSensitiveHelp uintptr + GetClipboardData uintptr + ImportDataObject uintptr +} + +type IRichEditOle struct { + LpVtbl *IRichEditOleVtbl +} + +func (obj *IRichEditOle) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(riid)), + uintptr(unsafe.Pointer(ppvObject))) + return HRESULT(ret) +} + +func (obj *IRichEditOle) AddRef() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +func (obj *IRichEditOle) Release() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +func (obj *IRichEditOle) GetClientSite(lplpolesite **IOleClientSite) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetClientSite, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(lplpolesite)), + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) GetObjectCount() int32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetObjectCount, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return int32(ret) +} + +func (obj *IRichEditOle) GetLinkCount() int32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetLinkCount, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return int32(ret) +} + +func (obj *IRichEditOle) GetObject(iob int32, lpreobject *REOBJECT, dwFlags uint32) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.GetObject, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(iob), + uintptr(unsafe.Pointer(lpreobject)), + uintptr(dwFlags), + 0, + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) InsertObject(lpreobject *REOBJECT) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.InsertObject, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(lpreobject)), + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) ConvertObject(iob int32, rclsidNew REFCLSID, lpstrUserTypeNew *byte) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ConvertObject, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(iob), + uintptr(unsafe.Pointer(rclsidNew)), + uintptr(unsafe.Pointer(lpstrUserTypeNew)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) ActivateAs(rclsid REFCLSID, rclsidAs REFCLSID) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.ActivateAs, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(rclsid)), + uintptr(unsafe.Pointer(rclsidAs))) + return HRESULT(ret) +} + +func (obj *IRichEditOle) SetHostNames(lpstrContainerApp *byte, lpstrContainerObj *byte) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.SetHostNames, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(lpstrContainerApp)), + uintptr(unsafe.Pointer(lpstrContainerObj))) + return HRESULT(ret) +} + +func (obj *IRichEditOle) SetLinkAvailable(iob int32, fAvailable BOOL) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.SetLinkAvailable, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(iob), + uintptr(fAvailable)) + return HRESULT(ret) +} + +func (obj *IRichEditOle) SetDvaspect(iob int32, dvaspect uint32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.SetDvaspect, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(iob), + uintptr(dvaspect)) + return HRESULT(ret) +} + +func (obj *IRichEditOle) HandsOffStorage(iob int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.HandsOffStorage, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(iob), + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) SaveCompleted(iob int32, lpstg *IStorage) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.SaveCompleted, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(iob), + uintptr(unsafe.Pointer(lpstg))) + return HRESULT(ret) +} + +func (obj *IRichEditOle) InPlaceDeactivate() HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.InPlaceDeactivate, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) ContextSensitiveHelp(fEnterMode BOOL) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.ContextSensitiveHelp, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(fEnterMode), + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) GetClipboardData(lpchrg *CHARRANGE, reco uint32, lplpdataobj **IDataObject) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.GetClipboardData, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(lpchrg)), + uintptr(reco), + uintptr(unsafe.Pointer(lplpdataobj)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *IRichEditOle) ImportDataObject(lpdataobj *IDataObject, cf CLIPFORMAT, hMetaPict HGLOBAL) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.ImportDataObject, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(lpdataobj)), + uintptr(cf), + uintptr(hMetaPict), + 0, + 0) + return HRESULT(ret) +} diff --git a/tom.go b/tom.go new file mode 100644 index 00000000..7587c2fb --- /dev/null +++ b/tom.go @@ -0,0 +1,989 @@ +// Copyright 2011 The win Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package win + +import ( + "syscall" + "unsafe" +) + +type TomConstants uint32 + +const ( + TomFalse TomConstants = 0 + TomTrue = -1 + TomUndefined = -9999999 + TomToggle = -9999998 + TomAutoColor = -9999997 + TomDefault = -9999996 + TomSuspend = -9999995 + TomResume = -9999994 + TomApplyNow = 0 + TomApplyLater = 1 + TomTrackParms = 2 + TomCacheParms = 3 + TomApplyTmp = 4 + TomDisableSmartFont = 8 + TomEnableSmartFont = 9 + TomUsePoints = 10 + TomUseTwips = 11 + TomBackward = 0xc0000001 + TomForward = 0x3fffffff + TomMove = 0 + TomExtend = 1 + TomNoSelection = 0 + TomSelectionIP = 1 + TomSelectionNormal = 2 + TomSelectionFrame = 3 + TomSelectionColumn = 4 + TomSelectionRow = 5 + TomSelectionBlock = 6 + TomSelectionInlineShape = 7 + TomSelectionShape = 8 + TomSelStartActive = 1 + TomSelAtEOL = 2 + TomSelOvertype = 4 + TomSelActive = 8 + TomSelReplace = 16 + TomEnd = 0 + TomStart = 32 + TomCollapseEnd = 0 + TomCollapseStart = 1 + TomClientCoord = 256 + TomAllowOffClient = 512 + TomTransform = 1024 + TomObjectArg = 2048 + TomAtEnd = 4096 + TomNone = 0 + TomSingle = 1 + TomWords = 2 + TomDouble = 3 + TomDotted = 4 + TomDash = 5 + TomDashDot = 6 + TomDashDotDot = 7 + TomWave = 8 + TomThick = 9 + TomHair = 10 + TomDoubleWave = 11 + TomHeavyWave = 12 + TomLongDash = 13 + TomThickDash = 14 + TomThickDashDot = 15 + TomThickDashDotDot = 16 + TomThickDotted = 17 + TomThickLongDash = 18 + TomLineSpaceSingle = 0 + TomLineSpace1pt5 = 1 + TomLineSpaceDouble = 2 + TomLineSpaceAtLeast = 3 + TomLineSpaceExactly = 4 + TomLineSpaceMultiple = 5 + TomLineSpacePercent = 6 + TomAlignLeft = 0 + TomAlignCenter = 1 + TomAlignRight = 2 + TomAlignJustify = 3 + TomAlignDecimal = 3 + TomAlignBar = 4 + TomDefaultTab = 5 + TomAlignInterWord = 3 + TomAlignNewspaper = 4 + TomAlignInterLetter = 5 + TomAlignScaled = 6 + TomSpaces = 0 + TomDots = 1 + TomDashes = 2 + TomLines = 3 + TomThickLines = 4 + TomEquals = 5 + TomTabBack = -3 + TomTabNext = -2 + TomTabHere = -1 + TomListNone = 0 + TomListBullet = 1 + TomListNumberAsArabic = 2 + TomListNumberAsLCLetter = 3 + TomListNumberAsUCLetter = 4 + TomListNumberAsLCRoman = 5 + TomListNumberAsUCRoman = 6 + TomListNumberAsSequence = 7 + TomListNumberedCircle = 8 + TomListNumberedBlackCircleWingding = 9 + TomListNumberedWhiteCircleWingding = 10 + TomListNumberedArabicWide = 11 + TomListNumberedChS = 12 + TomListNumberedChT = 13 + TomListNumberedJpnChS = 14 + TomListNumberedJpnKor = 15 + TomListNumberedArabic1 = 16 + TomListNumberedArabic2 = 17 + TomListNumberedHebrew = 18 + TomListNumberedThaiAlpha = 19 + TomListNumberedThaiNum = 20 + TomListNumberedHindiAlpha = 21 + TomListNumberedHindiAlpha1 = 22 + TomListNumberedHindiNum = 23 + TomListParentheses = 0x10000 + TomListPeriod = 0x20000 + TomListPlain = 0x30000 + TomListNoNumber = 0x40000 + TomListMinus = 0x80000 + TomIgnoreNumberStyle = 0x1000000 + TomParaStyleNormal = -1 + TomParaStyleHeading1 = -2 + TomParaStyleHeading2 = -3 + TomParaStyleHeading3 = -4 + TomParaStyleHeading4 = -5 + TomParaStyleHeading5 = -6 + TomParaStyleHeading6 = -7 + TomParaStyleHeading7 = -8 + TomParaStyleHeading8 = -9 + TomParaStyleHeading9 = -10 + TomCharacter = 1 + TomWord = 2 + TomSentence = 3 + TomParagraph = 4 + TomLine = 5 + TomStory = 6 + TomScreen = 7 + TomSection = 8 + TomTableColumn = 9 + TomColumn = 9 + TomRow = 10 + TomWindow = 11 + TomCell = 12 + TomCharFormat = 13 + TomParaFormat = 14 + TomTable = 15 + TomObject = 16 + TomPage = 17 + TomHardParagraph = 18 + TomCluster = 19 + TomInlineObject = 20 + TomInlineObjectArg = 21 + TomLeafLine = 22 + TomLayoutColumn = 23 + TomProcessId = 0x40000001 + TomMatchWord = 2 + TomMatchCase = 4 + TomMatchPattern = 8 + TomUnknownStory = 0 + TomMainTextStory = 1 + TomFootnotesStory = 2 + TomEndnotesStory = 3 + TomCommentsStory = 4 + TomTextFrameStory = 5 + TomEvenPagesHeaderStory = 6 + TomPrimaryHeaderStory = 7 + TomEvenPagesFooterStory = 8 + TomPrimaryFooterStory = 9 + TomFirstPageHeaderStory = 10 + TomFirstPageFooterStory = 11 + TomScratchStory = 127 + TomFindStory = 128 + TomReplaceStory = 129 + TomStoryInactive = 0 + TomStoryActiveDisplay = 1 + TomStoryActiveUI = 2 + TomStoryActiveDisplayUI = 3 + TomNoAnimation = 0 + TomLasVegasLights = 1 + TomBlinkingBackground = 2 + TomSparkleText = 3 + TomMarchingBlackAnts = 4 + TomMarchingRedAnts = 5 + TomShimmer = 6 + TomWipeDown = 7 + TomWipeRight = 8 + TomAnimationMax = 8 + TomLowerCase = 0 + TomUpperCase = 1 + TomTitleCase = 2 + TomSentenceCase = 4 + TomToggleCase = 5 + TomReadOnly = 0x100 + TomShareDenyRead = 0x200 + TomShareDenyWrite = 0x400 + TomPasteFile = 0x1000 + TomCreateNew = 0x10 + TomCreateAlways = 0x20 + TomOpenExisting = 0x30 + TomOpenAlways = 0x40 + TomTruncateExisting = 0x50 + TomRTF = 0x1 + TomText = 0x2 + TomHTML = 0x3 + TomWordDocument = 0x4 + TomBold = 0x80000001 + TomItalic = 0x80000002 + TomUnderline = 0x80000004 + TomStrikeout = 0x80000008 + TomProtected = 0x80000010 + TomLink = 0x80000020 + TomSmallCaps = 0x80000040 + TomAllCaps = 0x80000080 + TomHidden = 0x80000100 + TomOutline = 0x80000200 + TomShadow = 0x80000400 + TomEmboss = 0x80000800 + TomImprint = 0x80001000 + TomDisabled = 0x80002000 + TomRevised = 0x80004000 + TomSubscriptCF = 0x80010000 + TomSuperscriptCF = 0x80020000 + TomFontBound = 0x80100000 + TomLinkProtected = 0x80800000 + TomInlineObjectStart = 0x81000000 + TomExtendedChar = 0x82000000 + TomAutoBackColor = 0x84000000 + TomMathZoneNoBuildUp = 0x88000000 + TomMathZone = 0x90000000 + TomMathZoneOrdinary = 0xa0000000 + TomAutoTextColor = 0xc0000000 + TomMathZoneDisplay = 0x40000 + TomParaEffectRTL = 0x1 + TomParaEffectKeep = 0x2 + TomParaEffectKeepNext = 0x4 + TomParaEffectPageBreakBefore = 0x8 + TomParaEffectNoLineNumber = 0x10 + TomParaEffectNoWidowControl = 0x20 + TomParaEffectDoNotHyphen = 0x40 + TomParaEffectSideBySide = 0x80 + TomParaEffectCollapsed = 0x100 + TomParaEffectOutlineLevel = 0x200 + TomParaEffectBox = 0x400 + TomParaEffectTableRowDelimiter = 0x1000 + TomParaEffectTable = 0x4000 + TomModWidthPairs = 0x1 + TomModWidthSpace = 0x2 + TomAutoSpaceAlpha = 0x4 + TomAutoSpaceNumeric = 0x8 + TomAutoSpaceParens = 0x10 + TomEmbeddedFont = 0x20 + TomDoublestrike = 0x40 + TomOverlapping = 0x80 + TomNormalCaret = 0 + TomKoreanBlockCaret = 0x1 + TomNullCaret = 0x2 + TomIncludeInset = 0x1 + TomUnicodeBiDi = 0x1 + TomMathCFCheck = 0x4 + TomUnlink = 0x8 + TomUnhide = 0x10 + TomCheckTextLimit = 0x20 + TomIgnoreCurrentFont = 0 + TomMatchCharRep = 0x1 + TomMatchFontSignature = 0x2 + TomMatchAscii = 0x4 + TomGetHeightOnly = 0x8 + TomMatchMathFont = 0x10 + TomCharset = 0x80000000 + TomCharRepFromLcid = 0x40000000 + TomAnsi = 0 + TomEastEurope = 1 + TomCyrillic = 2 + TomGreek = 3 + TomTurkish = 4 + TomHebrew = 5 + TomArabic = 6 + TomBaltic = 7 + TomVietnamese = 8 + TomDefaultCharRep = 9 + TomSymbol = 10 + TomThai = 11 + TomShiftJIS = 12 + TomGB2312 = 13 + TomHangul = 14 + TomBIG5 = 15 + TomPC437 = 16 + TomOEM = 17 + TomMac = 18 + TomArmenian = 19 + TomSyriac = 20 + TomThaana = 21 + TomDevanagari = 22 + TomBengali = 23 + TomGurmukhi = 24 + TomGujarati = 25 + TomOriya = 26 + TomTamil = 27 + TomTelugu = 28 + TomKannada = 29 + TomMalayalam = 30 + TomSinhala = 31 + TomLao = 32 + TomTibetan = 33 + TomMyanmar = 34 + TomGeorgian = 35 + TomJamo = 36 + TomEthiopic = 37 + TomCherokee = 38 + TomAboriginal = 39 + TomOgham = 40 + TomRunic = 41 + TomKhmer = 42 + TomMongolian = 43 + TomBraille = 44 + TomYi = 45 + TomLimbu = 46 + TomTaiLe = 47 + TomNewTaiLue = 48 + TomSylotiNagri = 49 + TomKharoshthi = 50 + TomKayahli = 51 + TomUsymbol = 52 + TomEmoji = 53 + TomGlagolitic = 54 + TomLisu = 55 + TomVai = 56 + TomNKo = 57 + TomOsmanya = 58 + TomPhagsPa = 59 + TomGothic = 60 + TomDeseret = 61 + TomTifinagh = 62 + TomCharRepMax = 63 + TomRE10Mode = 0x1 + TomUseAtFont = 0x2 + TomTextFlowMask = 0xc + TomTextFlowES = 0 + TomTextFlowSW = 0x4 + TomTextFlowWN = 0x8 + TomTextFlowNE = 0xc + TomNoIME = 0x80000 + TomSelfIME = 0x40000 + TomNoUpScroll = 0x10000 + TomNoVpScroll = 0x40000 + TomNoLink = 0 + TomClientLink = 1 + TomFriendlyLinkName = 2 + TomFriendlyLinkAddress = 3 + TomAutoLinkURL = 4 + TomAutoLinkEmail = 5 + TomAutoLinkPhone = 6 + TomAutoLinkPath = 7 + TomCompressNone = 0 + TomCompressPunctuation = 1 + TomCompressPunctuationAndKana = 2 + TomCompressMax = 2 + TomUnderlinePositionAuto = 0 + TomUnderlinePositionBelow = 1 + TomUnderlinePositionAbove = 2 + TomUnderlinePositionMax = 2 + TomFontAlignmentAuto = 0 + TomFontAlignmentTop = 1 + TomFontAlignmentBaseline = 2 + TomFontAlignmentBottom = 3 + TomFontAlignmentCenter = 4 + TomFontAlignmentMax = 4 + TomRubyBelow = 0x80 + TomRubyAlignCenter = 0 + TomRubyAlign010 = 1 + TomRubyAlign121 = 2 + TomRubyAlignLeft = 3 + TomRubyAlignRight = 4 + TomLimitsDefault = 0 + TomLimitsUnderOver = 1 + TomLimitsSubSup = 2 + TomUpperLimitAsSuperScript = 3 + TomLimitsOpposite = 4 + TomShowLLimPlaceHldr = 8 + TomShowULimPlaceHldr = 16 + TomDontGrowWithContent = 64 + TomGrowWithContent = 128 + TomSubSupAlign = 1 + TomLimitAlignMask = 3 + TomLimitAlignCenter = 0 + TomLimitAlignLeft = 1 + TomLimitAlignRight = 2 + TomShowDegPlaceHldr = 8 + TomAlignDefault = 0 + TomAlignMatchAscentDescent = 2 + TomMathVariant = 0x20 + TomStyleDefault = 0 + TomStyleScriptScriptCramped = 1 + TomStyleScriptScript = 2 + TomStyleScriptCramped = 3 + TomStyleScript = 4 + TomStyleTextCramped = 5 + TomStyleText = 6 + TomStyleDisplayCramped = 7 + TomStyleDisplay = 8 + TomMathRelSize = 0x40 + TomDecDecSize = 0xfe + TomDecSize = 0xff + TomIncSize = (1 | TomMathRelSize) + TomIncIncSize = (2 | TomMathRelSize) + TomGravityUI = 0 + TomGravityBack = 1 + TomGravityFore = 2 + TomGravityIn = 3 + TomGravityOut = 4 + TomGravityBackward = 0x20000000 + TomGravityForward = 0x40000000 + TomAdjustCRLF = 1 + TomUseCRLF = 2 + TomTextize = 4 + TomAllowFinalEOP = 8 + TomFoldMathAlpha = 16 + TomNoHidden = 32 + TomIncludeNumbering = 64 + TomTranslateTableCell = 128 + TomNoMathZoneBrackets = 0x100 + TomConvertMathChar = 0x200 + TomNoUCGreekItalic = 0x400 + TomAllowMathBold = 0x800 + TomLanguageTag = 0x1000 + TomConvertRTF = 0x2000 + TomApplyRtfDocProps = 0x4000 + TomPhantomShow = 1 + TomPhantomZeroWidth = 2 + TomPhantomZeroAscent = 4 + TomPhantomZeroDescent = 8 + TomPhantomTransparent = 16 + TomPhantomASmash = (TomPhantomShow | TomPhantomZeroAscent) + TomPhantomDSmash = (TomPhantomShow | TomPhantomZeroDescent) + TomPhantomHSmash = (TomPhantomShow | TomPhantomZeroWidth) + TomPhantomSmash = ((TomPhantomShow | TomPhantomZeroAscent) | TomPhantomZeroDescent) + TomPhantomHorz = (TomPhantomZeroAscent | TomPhantomZeroDescent) + TomPhantomVert = TomPhantomZeroWidth + TomBoxHideTop = 1 + TomBoxHideBottom = 2 + TomBoxHideLeft = 4 + TomBoxHideRight = 8 + TomBoxStrikeH = 16 + TomBoxStrikeV = 32 + TomBoxStrikeTLBR = 64 + TomBoxStrikeBLTR = 128 + TomBoxAlignCenter = 1 + TomSpaceMask = 0x1c + TomSpaceDefault = 0 + TomSpaceUnary = 4 + TomSpaceBinary = 8 + TomSpaceRelational = 12 + TomSpaceSkip = 16 + TomSpaceOrd = 20 + TomSpaceDifferential = 24 + TomSizeText = 32 + TomSizeScript = 64 + TomSizeScriptScript = 96 + TomNoBreak = 128 + TomTransparentForPositioning = 256 + TomTransparentForSpacing = 512 + TomStretchCharBelow = 0 + TomStretchCharAbove = 1 + TomStretchBaseBelow = 2 + TomStretchBaseAbove = 3 + TomMatrixAlignMask = 3 + TomMatrixAlignCenter = 0 + TomMatrixAlignTopRow = 1 + TomMatrixAlignBottomRow = 3 + TomShowMatPlaceHldr = 8 + TomEqArrayLayoutWidth = 1 + TomEqArrayAlignMask = 0xc + TomEqArrayAlignCenter = 0 + TomEqArrayAlignTopRow = 4 + TomEqArrayAlignBottomRow = 0xc + TomMathManualBreakMask = 0x7f + TomMathBreakLeft = 0x7d + TomMathBreakCenter = 0x7e + TomMathBreakRight = 0x7f + TomMathEqAlign = 0x80 + TomMathArgShadingStart = 0x251 + TomMathArgShadingEnd = 0x252 + TomMathObjShadingStart = 0x253 + TomMathObjShadingEnd = 0x254 + TomFunctionTypeNone = 0 + TomFunctionTypeTakesArg = 1 + TomFunctionTypeTakesLim = 2 + TomFunctionTypeTakesLim2 = 3 + TomFunctionTypeIsLim = 4 + TomMathParaAlignDefault = 0 + TomMathParaAlignCenterGroup = 1 + TomMathParaAlignCenter = 2 + TomMathParaAlignLeft = 3 + TomMathParaAlignRight = 4 + TomMathDispAlignMask = 3 + TomMathDispAlignCenterGroup = 0 + TomMathDispAlignCenter = 1 + TomMathDispAlignLeft = 2 + TomMathDispAlignRight = 3 + TomMathDispIntUnderOver = 4 + TomMathDispFracTeX = 8 + TomMathDispNaryGrow = 0x10 + TomMathDocEmptyArgMask = 0x60 + TomMathDocEmptyArgAuto = 0 + TomMathDocEmptyArgAlways = 0x20 + TomMathDocEmptyArgNever = 0x40 + TomMathDocSbSpOpUnchanged = 0x80 + TomMathDocDiffMask = 0x300 + TomMathDocDiffDefault = 0 + TomMathDocDiffUpright = 0x100 + TomMathDocDiffItalic = 0x200 + TomMathDocDiffOpenItalic = 0x300 + TomMathDispNarySubSup = 0x400 + TomMathDispDef = 0x800 + TomMathEnableRtl = 0x1000 + TomMathBrkBinMask = 0x30000 + TomMathBrkBinBefore = 0 + TomMathBrkBinAfter = 0x10000 + TomMathBrkBinDup = 0x20000 + TomMathBrkBinSubMask = 0xc0000 + TomMathBrkBinSubMM = 0 + TomMathBrkBinSubPM = 0x40000 + TomMathBrkBinSubMP = 0x80000 + TomSelRange = 0x255 + TomHstring = 0x254 + TomFontPropTeXStyle = 0x33c + TomFontPropAlign = 0x33d + TomFontStretch = 0x33e + TomFontStyle = 0x33f + TomFontStyleUpright = 0 + TomFontStyleOblique = 1 + TomFontStyleItalic = 2 + TomFontStretchDefault = 0 + TomFontStretchUltraCondensed = 1 + TomFontStretchExtraCondensed = 2 + TomFontStretchCondensed = 3 + TomFontStretchSemiCondensed = 4 + TomFontStretchNormal = 5 + TomFontStretchSemiExpanded = 6 + TomFontStretchExpanded = 7 + TomFontStretchExtraExpanded = 8 + TomFontStretchUltraExpanded = 9 + TomFontWeightDefault = 0 + TomFontWeightThin = 100 + TomFontWeightExtraLight = 200 + TomFontWeightLight = 300 + TomFontWeightNormal = 400 + TomFontWeightRegular = 400 + TomFontWeightMedium = 500 + TomFontWeightSemiBold = 600 + TomFontWeightBold = 700 + TomFontWeightExtraBold = 800 + TomFontWeightBlack = 900 + TomFontWeightHeavy = 900 + TomFontWeightExtraBlack = 950 + TomParaPropMathAlign = 0x437 + TomDocMathBuild = 0x80 + TomMathLMargin = 0x81 + TomMathRMargin = 0x82 + TomMathWrapIndent = 0x83 + TomMathWrapRight = 0x84 + TomMathPostSpace = 0x86 + TomMathPreSpace = 0x85 + TomMathInterSpace = 0x87 + TomMathIntraSpace = 0x88 + TomCanCopy = 0x89 + TomCanRedo = 0x8a + TomCanUndo = 0x8b + TomUndoLimit = 0x8c + TomDocAutoLink = 0x8d + TomEllipsisMode = 0x8e + TomEllipsisState = 0x8f + TomEllipsisNone = 0 + TomEllipsisEnd = 1 + TomEllipsisWord = 3 + TomEllipsisPresent = 1 + TomVTopCell = 1 + TomVLowCell = 2 + TomHStartCell = 4 + TomHContCell = 8 + TomRowUpdate = 1 + TomRowApplyDefault = 0 + TomCellStructureChangeOnly = 1 + TomRowHeightActual = 0x80b +) + +type OBJECTTYPE int32 + +const ( + TomSimpleText OBJECTTYPE = 0 + TomRuby = (TomSimpleText + 1) + TomHorzVert = (TomRuby + 1) + TomWarichu = (TomHorzVert + 1) + TomEq = 9 + TomMath = 10 + TomAccent = TomMath + TomBox = (TomAccent + 1) + TomBoxedFormula = (TomBox + 1) + TomBrackets = (TomBoxedFormula + 1) + TomBracketsWithSeps = (TomBrackets + 1) + TomEquationArray = (TomBracketsWithSeps + 1) + TomFraction = (TomEquationArray + 1) + TomFunctionApply = (TomFraction + 1) + TomLeftSubSup = (TomFunctionApply + 1) + TomLowerLimit = (TomLeftSubSup + 1) + TomMatrix = (TomLowerLimit + 1) + TomNary = (TomMatrix + 1) + TomOpChar = (TomNary + 1) + TomOverbar = (TomOpChar + 1) + TomPhanTom = (TomOverbar + 1) + TomRadical = (TomPhanTom + 1) + TomSlashedFraction = (TomRadical + 1) + TomStack = (TomSlashedFraction + 1) + TomStretchStack = (TomStack + 1) + TomSubscript = (TomStretchStack + 1) + TomSubSup = (TomSubscript + 1) + TomSuperscript = (TomSubSup + 1) + TomUnderbar = (TomSuperscript + 1) + TomUpperLimit = (TomUnderbar + 1) + TomObjectMax = TomUpperLimit +) + +type ITextRangeVtbl struct { + IDispatchVtbl + GetText uintptr + SetText uintptr + GetChar uintptr + SetChar uintptr + GetDuplicate uintptr + GetFormattedText uintptr + SetFormattedText uintptr + GetStart uintptr + SetStart uintptr + GetEnd uintptr + SetEnd uintptr + GetFont uintptr + SetFont uintptr + GetPara uintptr + SetPara uintptr + GetStoryLength uintptr + GetStoryType uintptr + Collapse uintptr + Expand uintptr + GetIndex uintptr + SetIndex uintptr + SetRange uintptr + InRange uintptr + InStory uintptr + IsEqual uintptr + Select uintptr + StartOf uintptr + EndOf uintptr + Move uintptr + MoveStart uintptr + MoveEnd uintptr + MoveWhile uintptr + MoveStartWhile uintptr + MoveEndWhile uintptr + MoveUntil uintptr + MoveStartUntil uintptr + MoveEndUntil uintptr + FindText uintptr + FindTextStart uintptr + FindTextEnd uintptr + Delete uintptr + Cut uintptr + Copy uintptr + Paste uintptr + CanPaste uintptr + CanEdit uintptr + ChangeCase uintptr + GetPoint uintptr + SetPoint uintptr + ScrollIntoView uintptr + GetEmbeddedObject uintptr +} + +type ITextRange struct { + LpVtbl *ITextRangeVtbl +} + +type ITextSelectionVtbl struct { + ITextRangeVtbl + GetFlags uintptr + SetFlags uintptr + GetType uintptr + MoveLeft uintptr + MoveRight uintptr + MoveUp uintptr + MoveDown uintptr + HomeKey uintptr + EndKey uintptr + TypeText uintptr +} + +type ITextSelection struct { + LpVtbl *ITextSelectionVtbl +} + +type ITextDocumentVtbl struct { + IDispatchVtbl + GetName uintptr + GetSelection uintptr + GetStoryCount uintptr + GetStoryRanges uintptr + GetSaved uintptr + SetSaved uintptr + GetDefaultTabStop uintptr + SetDefaultTabStop uintptr + New uintptr + Open uintptr + Save uintptr + Freeze uintptr + Unfreeze uintptr + BeginEditCollection uintptr + EndEditCollection uintptr + Undo uintptr + Redo uintptr + Range uintptr + RangeFromPoint uintptr +} + +type ITextStoryRangesVtbl struct { + IDispatchVtbl + NewEnum uintptr + Item uintptr + GetCount uintptr +} + +type ITextStoryRanges struct { + LpVtbl *ITextStoryRangesVtbl +} + +var ( + IID_ITextDocument = IID{0x8CC497C0, 0xA1DF, 0x11CE, [8]byte{0x80, 0x98, 0x00, 0xAA, 0x00, 0x47, 0xBE, 0x5D}} +) + +type ITextDocument struct { + LpVtbl *ITextDocumentVtbl +} + +func (obj *ITextDocument) QueryInterface(riid REFIID, ppvObject *unsafe.Pointer) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.QueryInterface, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(riid)), + uintptr(unsafe.Pointer(ppvObject))) + return HRESULT(ret) +} + +func (obj *ITextDocument) AddRef() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.AddRef, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +func (obj *ITextDocument) Release() uint32 { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Release, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return uint32(ret) +} + +func (obj *ITextDocument) GetTypeInfoCount(pctinfo *uint32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetTypeInfoCount, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pctinfo)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetTypeInfo(iTInfo uint32, lcid LCID, ppTInfo **ITypeInfo) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.GetTypeInfo, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(iTInfo), + uintptr(lcid), + uintptr(unsafe.Pointer(ppTInfo)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetIDsOfNames(riid REFIID, rgszNames **uint16, cNames uint32, lcid LCID, rgDispId *DISPID) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.GetIDsOfNames, 6, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(riid)), + uintptr(unsafe.Pointer(rgszNames)), + uintptr(cNames), + uintptr(lcid), + uintptr(unsafe.Pointer(rgDispId))) + return HRESULT(ret) +} + +func (obj *ITextDocument) Invoke(dispIdMember DISPID, riid REFIID, lcid LCID, wFlags uint16, pDispParams *DISPPARAMS, pVarResult *VARIANT, pExcepInfo *EXCEPINFO, puArgErr *uint32) HRESULT { + ret, _, _ := syscall.Syscall9(obj.LpVtbl.Invoke, 9, + uintptr(unsafe.Pointer(obj)), + uintptr(dispIdMember), + uintptr(unsafe.Pointer(riid)), + uintptr(lcid), + uintptr(wFlags), + uintptr(unsafe.Pointer(pDispParams)), + uintptr(unsafe.Pointer(pVarResult)), + uintptr(unsafe.Pointer(pExcepInfo)), + uintptr(unsafe.Pointer(puArgErr))) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetName(pName **uint16 /*BSTR*/) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetName, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pName)), + 0) + return HRESULT(ret) + +} + +func (obj *ITextDocument) GetSelection(ppSel **ITextSelection) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetSelection, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(ppSel)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetStoryCount(pCount *int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetStoryCount, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pCount)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetStoryRanges(ppStories **ITextStoryRanges) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetStoryRanges, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(ppStories)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetSaved(pValue *int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetSaved, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pValue)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) SetSaved(Value int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.SetSaved, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(Value), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) GetDefaultTabStop(pValue *float32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.GetDefaultTabStop, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pValue)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) SetDefaultTabStop(Value float32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.SetDefaultTabStop, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(Value), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) New() HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.New, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) Open(pVar *VARIANT, Flags int32, CodePage int32) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.Open, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pVar)), + uintptr(Flags), + uintptr(CodePage), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) Save(pVar *VARIANT, Flags int32, CodePage int32) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.Save, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pVar)), + uintptr(Flags), + uintptr(CodePage), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) Freeze(pCount *int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Freeze, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pCount)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) Unfreeze(pCount *int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Freeze, 2, + uintptr(unsafe.Pointer(obj)), + uintptr(unsafe.Pointer(pCount)), + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) BeginEditCollection() HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.BeginEditCollection, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) EndEditCollection() HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.EndEditCollection, 1, + uintptr(unsafe.Pointer(obj)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) Undo(Count int32, pCount *int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Undo, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(Count), + uintptr(unsafe.Pointer(pCount))) + return HRESULT(ret) +} + +func (obj *ITextDocument) Redo(Count int32, pCount *int32) HRESULT { + ret, _, _ := syscall.Syscall(obj.LpVtbl.Redo, 3, + uintptr(unsafe.Pointer(obj)), + uintptr(Count), + uintptr(unsafe.Pointer(pCount))) + return HRESULT(ret) +} + +func (obj *ITextDocument) Range(cpActive int32, cpAnchor int32, ppRange **ITextRange) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.Range, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(cpActive), + uintptr(cpAnchor), + uintptr(unsafe.Pointer(ppRange)), + 0, + 0) + return HRESULT(ret) +} + +func (obj *ITextDocument) RangeFromPoint(x int32, y int32, ppRange **ITextRange) HRESULT { + ret, _, _ := syscall.Syscall6(obj.LpVtbl.RangeFromPoint, 4, + uintptr(unsafe.Pointer(obj)), + uintptr(x), + uintptr(y), + uintptr(unsafe.Pointer(ppRange)), + 0, + 0) + return HRESULT(ret) +} -- cgit v1.2.3-59-g8ed1b