diff options
Diffstat (limited to 'private/oleutest/letest/gizmobar')
-rw-r--r-- | private/oleutest/letest/gizmobar/api.c | 846 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/book1632.h | 154 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/daytona/gizmobar.src | 51 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/daytona/makefile | 6 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/daytona/makefile.inc | 1 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/daytona/sources | 50 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/dirs | 37 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/dllentry.c | 55 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/gizmo.c | 766 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/gizmo.h | 103 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/gizmobar.c | 467 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/gizmobar.h | 178 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/gizmobar.rc | 20 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/gizmobar.rcv | 53 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/gizmoint.h | 105 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/init.c | 233 | ||||
-rw-r--r-- | private/oleutest/letest/gizmobar/paint.c | 132 |
17 files changed, 3257 insertions, 0 deletions
diff --git a/private/oleutest/letest/gizmobar/api.c b/private/oleutest/letest/gizmobar/api.c new file mode 100644 index 000000000..526d66a5f --- /dev/null +++ b/private/oleutest/letest/gizmobar/api.c @@ -0,0 +1,846 @@ +/* + * API.C + * GizmoBar Version 1.00, Win32 version August 1993 + * + * API functions affecting a GizmoBar and a message processing function to + * handle the equivalent called through messages. + * + * Copyright (c)1993 Microsoft Corporation, All Rights Reserved + * + * Kraig Brockschmidt, Software Design Engineer + * Microsoft Systems Developer Relations + * + * Internet : kraigb@microsoft.com + * Compuserve: >INTERNET:kraigb@microsoft.com + */ + + +#include <windows.h> +#include "gizmoint.h" + + + +/* + * GBMessageHandler + * + * Purpose: + * Processes control messages that are equivalents of available + * control API. The data passed with these messages is simply + * extracted from structures and passed as parameters to their + * equivalent function. + * + * Parameters: + * <Standard Message Parameters> plus + * pGB LPGIZMOBAR providing control-specific data. + * + * Return Value: + * LRESULT Return value from equivalent API function. + */ + +LRESULT GBMessageHandler(HWND hWnd, UINT iMsg, WPARAM wParam + , LPARAM lParam, LPGIZMOBAR pGB) + { + LRESULT lRet=0L; + LPCREATEGIZMO pCG; + LPGBMSG pMsg; + LPGBGETTEXT pGT; + LPGBGETINT pGI; + LPGBSETINT pSI; + + if (NULL==pGB) + return 0L; + + switch (iMsg) + { + case GBM_HWNDASSOCIATESET: + lRet=(LRESULT)(UINT)GBHwndAssociateSet(hWnd, (HWND)wParam); + break; + + case GBM_HWNDASSOCIATEGET: + lRet=(LRESULT)(UINT)GBHwndAssociateGet(hWnd); + break; + + case GBM_GIZMOADD: + pCG=(LPCREATEGIZMO)lParam; + lRet=(LRESULT)GBGizmoAdd(pCG->hWndParent, pCG->iType, pCG->iGizmo + , pCG->uID, pCG->dx, pCG->dy, pCG->pszText, pCG->hBmp + , pCG->iImage, pCG->uState); + break; + + case GBM_GIZMOREMOVE: + lRet=(LRESULT)GBGizmoRemove(hWnd, wParam); + break; + + case GBM_GIZMOSENDMESSAGE: + pMsg=(LPGBMSG)lParam; + lRet=GBGizmoSendMessage(hWnd, wParam, pMsg->iMsg, pMsg->wParam, pMsg->lParam); + break; + + case GBM_GIZMOSHOW: + lRet=(LRESULT)GBGizmoShow(hWnd, wParam, (BOOL)LOWORD(lParam)); + break; + + case GBM_GIZMOENABLE: + lRet=(LRESULT)GBGizmoEnable(hWnd, wParam, (BOOL)LOWORD(lParam)); + break; + + case GBM_GIZMOCHECK: + lRet=(LRESULT)GBGizmoCheck(hWnd, wParam, (BOOL)LOWORD(lParam)); + break; + + case GBM_GIZMOFOCUSSET: + lRet=(LRESULT)GBGizmoFocusSet(hWnd, wParam); + break; + + case GBM_GIZMOEXIST: + lRet=(LRESULT)GBGizmoExist(hWnd, wParam); + break; + + case GBM_GIZMOTYPEGET: + lRet=(LRESULT)GBGizmoTypeGet(hWnd, wParam); + break; + + case GBM_GIZMODATASET: + lRet=(LRESULT)GBGizmoDataSet(hWnd, wParam, (DWORD)lParam); + break; + + case GBM_GIZMODATAGET: + lRet=(LRESULT)GBGizmoDataGet(hWnd, wParam); + break; + + case GBM_GIZMONOTIFYSET: + lRet=(LRESULT)GBGizmoNotifySet(hWnd, wParam, (BOOL)LOWORD(lParam)); + break; + + case GBM_GIZMONOTIFYGET: + lRet=(LRESULT)GBGizmoNotifyGet(hWnd, wParam); + break; + + case GBM_GIZMOTEXTGET: + pGT=(LPGBGETTEXT)lParam; + lRet=(LRESULT)GBGizmoTextGet(hWnd, wParam, pGT->psz, pGT->cch); + break; + + case GBM_GIZMOTEXTSET: + GBGizmoTextSet(hWnd, wParam, (LPTSTR)lParam); + break; + + case GBM_GIZMOINTGET: + pGI=(LPGBGETINT)lParam; + lRet=(LRESULT)GBGizmoIntGet(hWnd, wParam, &pGI->fSuccess, pGI->fSigned); + break; + + + case GBM_GIZMOINTSET: + pSI=(LPGBSETINT)lParam; + GBGizmoIntSet(hWnd, wParam, pSI->uValue, pSI->fSigned); + break; + + default: + break; + } + + return lRet; + } + + + + + + + + + + +/* + * PGizmoFromHwndID + * + * Purpose: + * Retrieves the pGizmo for the given GizmoBar and the gizmo ID. + * + * Parameters: + * hWnd HWND of a GizmoBar. + * uID UINT gizmo identifier. + * + * Return Value: + * LPGIZMO NULL if the gizmo does not exist or hWnd is invalid. + * non-NULL LPGIZMO otherwise. + */ + +LPGIZMO PGizmoFromHwndID(HWND hWnd, UINT uID) + { + LPGIZMOBAR pGB; + + if (!IsWindow(hWnd)) + return FALSE; + + pGB=(LPGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE); + + if (NULL==pGB) + return FALSE; + + return GizmoPFind(&pGB->pGizmos, uID); + } + + + + + + +/* + * GBHwndAssociateSet + * + * Purpose: + * Changes the associate window of a GizmoBar. + * + * Parameters: + * hWnd HWND of the control window. + * + * Set Parameters: + * hWndAssociate HWND of new associate. + * + * Return Value: + * HWND Handle of previous associate. + */ + +HWND WINAPI GBHwndAssociateSet(HWND hWnd, HWND hWndNew) + { + HWND hWndOld=NULL; + LPGIZMOBAR pGB; + + pGB=(LPGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE); + + if (NULL!=pGB) + { + hWndOld=pGB->hWndAssociate; + pGB->hWndAssociate=hWndNew; + + if (NULL!=hWndOld) + SendCommand(hWndOld, pGB->uID, GBN_ASSOCIATELOSS, hWnd); + + if (NULL!=hWndNew) + SendCommand(hWndNew, pGB->uID, GBN_ASSOCIATEGAIN, hWnd); + } + + return hWndOld; + } + + + + + +/* + * GBHwndAssociateGet + * + * Purpose: + * Retrieves the associate window of a GizmoBar + * + * Parameters: + * hWnd HWND of the control window. + * + * Set Parameters: + * hWndAssociate HWND of new associate. + * + * Return Value: + * HWND Handle of current associate. + */ + +HWND WINAPI GBHwndAssociateGet(HWND hWnd) + { + HWND hWndOld=NULL; + LPGIZMOBAR pGB; + + pGB=(LPGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE); + + if (NULL!=pGB) + hWndOld=pGB->hWndAssociate; + + return hWndOld; + } + + + + + +/* + * GBGizmoAdd + * + * Purpose: + * Creates a new gizmo on the GizmoBar. Subsequent operations should + * be done using the identifier, uID, for this gizmo. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * iType UINT type of the gizmo to create. + * iGizmo UINT position (zero-based) at which to place the gizmo. + * uID UINT identifier for WM_COMMAND from this gizmo. + * dx, dy UINT dimensions of the gizmo. + * pszText LPTSTR initial text for edit, list, combo, and text gizmos. + * hBitmap HBITMAP for gizmos of the button types (COMMAND or + * ATTRIBUTE) specifies a source bitmap from which the + * button image is taken. + * iImage UINT index into hBitmap for the image for this button. + * uState UINT initial state of the gizmo. + * + * Return Value: + * BOOL TRUE if creation succeeded, FALSE otherwise. + */ + +BOOL WINAPI GBGizmoAdd(HWND hWnd, UINT iType, UINT iGizmo, UINT uID + , UINT dx, UINT dy, LPTSTR pszText, HBITMAP hBmp, UINT iImage, UINT uState) + { + BOOL fSuccess; + LPGIZMOBAR pGB; + LPGIZMO pGizmo; + + if (!IsWindow(hWnd)) + return FALSE; + + pGB=(LPGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE); + + if (NULL==pGB) + return FALSE; + + /* + * This automatically creates the windows, allocates structures, includes + * the gizmo in pGB->pGizmos, and so forth. + */ + pGizmo=GizmoPAllocate((LPINT)&fSuccess, &pGB->pGizmos, hWnd, iType + , iGizmo, uID, dx, dy, pszText, hBmp, iImage, uState); + + if (fSuccess) + { + if (NULL!=pGB->hWndAssociate) + SendCommand(pGB->hWndAssociate,GBN_GIZMOADDED, pGB->uID, hWnd); + + InvalidateRect(hWnd, NULL, TRUE); + UpdateWindow(hWnd); + } + else + GizmoPFree(&pGB->pGizmos, pGizmo); + + return fSuccess; + } + + + + + +/* + * GBGizmoRemove + * + * Purpose: + * Removes an existing gizmo from the GizmoBar. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * uID UINT identifier for this gizmo. + * + * Return Value: + * BOOL TRUE if deletion succeeded, FALSE otherwise. + */ + +BOOL WINAPI GBGizmoRemove(HWND hWnd, UINT uID) + { + LPGIZMOBAR pGB; + LPGIZMO pGizmo; + + if (!IsWindow(hWnd)) + return FALSE; + + pGB=(LPGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE); + + if (NULL==pGB) + return FALSE; + + pGizmo=GizmoPFind(&pGB->pGizmos, uID); + + if (NULL==pGizmo) + return FALSE; + + GizmoPFree(&pGB->pGizmos, pGizmo); + + if (NULL!=pGB->hWndAssociate) + SendCommand(pGB->hWndAssociate, GBN_GIZMOREMOVED, pGB->uID, hWnd); + + InvalidateRect(hWnd, NULL, TRUE); + UpdateWindow(hWnd); + return TRUE; + } + + + + + + +/* + * GBGizmoSendMessage + * + * Purpose: + * Implements the equivalent of SendMessage to a gizmo in the + * GizmoBar. Separators, command buttons, and attribute buttons + * do not accept messages. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * uID UINT identifier of the gizmo to affect. + * iMsg UINT message to send. + * wParam WPARAM of the message. + * lParam LPARAM of the message. + * + * Return Value: + * LRESULT Return value from the message. 0L if the + * gizmo does not accept messages. + */ + +LRESULT WINAPI GBGizmoSendMessage(HWND hWnd, UINT uID, UINT iMsg + , WPARAM wParam, LPARAM lParam) + { + LPGIZMO pGizmo; + LONG lRet=0L; + + pGizmo=PGizmoFromHwndID(hWnd, uID); + + if (NULL!=pGizmo && NULL!=pGizmo->hWnd) + lRet=SendMessage(pGizmo->hWnd, iMsg, wParam, lParam); + + return lRet; + } + + + + + + +/* + * GBGizmoShow + * + * Purpose: + * Shows or hides a control, adjusting the positions of all others + * to make room for or reuse the space for this control. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * uID UINT identifier of the gizmo to affect. + * fShow BOOL TRUE to show the gizmo, FALSE to hide it. + * + * Return Value: + * BOOL TRUE if the function was successful, FALSE otherwise. + */ + +BOOL WINAPI GBGizmoShow(HWND hWnd, UINT uID, BOOL fShow) + { + BOOL fRet=FALSE; + LPGIZMO pGizmo; + + pGizmo=PGizmoFromHwndID(hWnd, uID); + + if (NULL!=pGizmo) + { + if (fShow && pGizmo->fHidden) + { + if (NULL!=pGizmo->hWnd) + ShowWindow(pGizmo->hWnd, SW_SHOWNORMAL); + + GizmosExpand(pGizmo); + } + + if (!fShow && !pGizmo->fHidden) + { + if (NULL!=pGizmo->hWnd) + ShowWindow(pGizmo->hWnd, SW_HIDE); + + GizmosCompact(pGizmo); + } + + //This will be right even if we didn't change anything. + pGizmo->fHidden=!fShow; + } + + InvalidateRect(hWnd, NULL, TRUE); + UpdateWindow(hWnd); + return fRet; + } + + + + + + +/* + * GBGizmoEnable + * + * Purpose: + * Enables or disables a control on the GizmoBar. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * uID UINT identifier of the gizmo to affect. + * fEnable BOOL TRUE to enable the gizmo, FALSE otherwise. + * + * Return Value: + * BOOL TRUE if the gizmo was previously disabled, FALSE + * otherwise. + */ + +BOOL WINAPI GBGizmoEnable(HWND hWnd, UINT uID, BOOL fEnable) + { + LPGIZMO pGizmo; + BOOL fRet=FALSE; + + pGizmo=PGizmoFromHwndID(hWnd, uID); + + if (NULL==pGizmo) + return FALSE; + + fRet=(BOOL)(BUTTONGROUP_DISABLED & pGizmo->uState); + + //Use windows to enable or disable window gizmos + if (NULL!=pGizmo->hWnd) + EnableWindow(pGizmo->hWnd, fEnable); + else + { + //If we're not down, command and attribute buttons act the same. + if (!(BUTTONGROUP_DOWN & pGizmo->uState)) + GizmoPStateSet(hWnd, pGizmo, fEnable ? COMMANDBUTTON_UP : COMMANDBUTTON_DISABLED); + else + { + //Attribute buttons are a little more sensitive with DOWNDISABLED + GizmoPStateSet(hWnd, pGizmo + , fEnable ? ATTRIBUTEBUTTON_DOWN : ATTRIBUTEBUTTON_DOWNDISABLED); + } + } + + return fRet; + } + + + + + + + +/* + * GBGizmoCheck + * + * Purpose: + * Checks or unchecks an attribute button in the GizmoBar. If the + * gizmo is part of a group of mutually exclusive attributes, then + * other gizmos are unchecked when this one is checked. If this is + * the only one checked in these circumstances, this function is a NOP. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * uID UINT identifier of the gizmo to affect. + * fCheck BOOL TRUE to check this gizmo, FALSE to uncheck. + * + * Return Value: + * BOOL TRUE if the change took place. FALSE otherwise. + */ + +BOOL WINAPI GBGizmoCheck(HWND hWnd, UINT uID, BOOL fCheck) + { + LPGIZMOBAR pGB; + LPGIZMO pGizmo; + + if (!IsWindow(hWnd)) + return FALSE; + + pGB=(LPGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE); + + if (NULL==pGB) + return FALSE; + + pGizmo=GizmoPFind(&pGB->pGizmos, uID); + + if (NULL!=pGizmo) + GizmoPCheck(hWnd, pGizmo, fCheck); + + return TRUE; + } + + + + + + +/* + * GBGizmoFocusSet + * + * Purpose: + * Sets the focus to a partuclar gizmo in the gizmo if that gizmo + * can accept the focus. Separators, attribute buttons, text, + * and command buttons cannot have the focus. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * uID UINT identifier of the gizmo to affect. + * + * Return Value: + * BOOL TRUE if the focus was set. FALSE otherwise, such as + * when uID identifies a control that cannot have focus. + */ + +UINT WINAPI GBGizmoFocusSet(HWND hWnd, UINT uID) + { + LPGIZMO pGizmo; + BOOL fRet=FALSE; + + pGizmo=PGizmoFromHwndID(hWnd, uID); + + if (NULL!=pGizmo && NULL!=pGizmo->hWnd) + { + fRet=TRUE; + SetFocus(pGizmo->hWnd); + } + + return fRet; + } + + + + + +/* + * GBGizmoExist + * + * Purpose: + * Determines if a gizmo of a given identifier exists in the GizmoBar. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * uID UINT identifier to verify. + * + * Return Value: + * BOOL TRUE if the gizmo exists, FALSE otherwise. + */ + +BOOL WINAPI GBGizmoExist(HWND hWnd, UINT uID) + { + return (NULL!=PGizmoFromHwndID(hWnd, uID)); + } + + + + + +/* + * GBGizmoTypeGet + * + * Purpose: + * Returns the type of the gizmo specified by the given identifer. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * uID UINT identifier to find. + * + * Return Value: + * int A GIZMOTYPE_* value if the function is successful, + * otherwise -1. + */ + +int WINAPI GBGizmoTypeGet(HWND hWnd, UINT uID) + { + int iRet=-1; + LPGIZMO pGizmo; + + pGizmo=PGizmoFromHwndID(hWnd, uID); + + if (NULL!=pGizmo) + iRet=pGizmo->iType; + + return iRet; + } + + + + + +/* + * GBGizmoDataSet + * GBGizmoDataGet + * + * Purpose: + * Sets or retrieves an extra DWORD value associated with the given gizmo. + * Applications can store any information here they please. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * uID UINT identifier of the gizmo. + * dwData (Set only) DWORD data to store with the gizmo. + * + * Return Value: + * DWORD Set: Previous value + * Get: Current value + */ + +DWORD WINAPI GBGizmoDataSet(HWND hWnd, UINT uID, DWORD dwData) + { + LPGIZMO pGizmo; + DWORD dw=0L; + + pGizmo=PGizmoFromHwndID(hWnd, uID); + + if (NULL!=pGizmo) + { + dw=pGizmo->dwData; + pGizmo->dwData=dwData; + } + + return dw; + } + + + +DWORD WINAPI GBGizmoDataGet(HWND hWnd, UINT uID) + { + LPGIZMO pGizmo; + DWORD dw=0L; + + pGizmo=PGizmoFromHwndID(hWnd, uID); + + if (NULL!=pGizmo) + dw=pGizmo->dwData; + + return dw; + } + + + + + + +/* + * GBGizmoNotifySet + * GBGizmoNotifyGet + * + * Purpose: + * Sets or retrieves the notify status of a gizmo. If notify is FALSE, + * the no WM_COMMAND messages are sent from the GizmoBar to the parent + * window when this gizmo is used. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * uID UINT identifier of the gizmo. + * fNotify (Set only) BOOL new notify status to set. + * + * Return Value: + * BOOL Set: Previous value of the notify flag. + * Get: Current value of the notify flag. + */ + +BOOL WINAPI GBGizmoNotifySet(HWND hWnd, UINT uID, BOOL fNotify) + { + LPGIZMO pGizmo; + BOOL fRet=FALSE; + + pGizmo=PGizmoFromHwndID(hWnd, uID); + + if (NULL!=pGizmo) + { + fRet=pGizmo->fNotify; + pGizmo->fNotify=fNotify; + } + + return fRet; + } + + +BOOL WINAPI GBGizmoNotifyGet(HWND hWnd, UINT uID) + { + LPGIZMO pGizmo; + BOOL fRet=FALSE; + + pGizmo=PGizmoFromHwndID(hWnd, uID); + + if (NULL!=pGizmo) + fRet=pGizmo->fNotify; + + return fRet; + } + + + + + + + +/* + * GBGizmoTextSet + * GBGizmoTextGet + * + * Purpose: + * Retrieves or sets text in a GizmoBar gizmo. Separators, command buttons, + * and attribute buttons are not affected by this call. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * uID UINT identifying the gizmo. + * psz LPTSTR (Set) providing the text to show in the window + * or (Get) pointing to a buffer to receive the text. + * cch (Get only) UINT maximum number of chars to copy to psz. + * + * Return Value: + * int Number of characters copied to psz. + */ + +void WINAPI GBGizmoTextSet(HWND hWnd, UINT uID, LPTSTR psz) + { + //This fails on non-windowed gizmos anyway, so we don't check. + SetDlgItemText(hWnd, uID, psz); + return; + } + + +int WINAPI GBGizmoTextGet(HWND hWnd, UINT uID, LPTSTR psz, UINT cch) + { + //This fails on non-windowed gizmos anyway, so we don't check. + return GetDlgItemText(hWnd, uID, psz, cch); + } + + + + + + + + +/* + * GBGizmoIntSet + * GBGizmoIntGet + * + * Purpose: + * Retrieves or sets an integer in a GizmoBar gizmo. Separators, command + * buttons, and attribute buttons are not affected by this call. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * uID UINT identifying the gizmo. + * + * (Set only) + * u UINT value to set in the gizmo. + * fSigned BOOL TRUE to indicate if the value is signed. + * + * (Get only) + * pfTrans BOOL FAR * in which the success of the function is returned. + * fSigned BOOL TRUE to indicate if the value is signed. + * + * Return Value: + * (Set): None + * (Get): UINT Integer translation of the gizmo's text. + */ + +void WINAPI GBGizmoIntSet(HWND hWnd, UINT uID, UINT u, BOOL fSigned) + { + //This fails on non-windowed gizmos anyway, so we don't check. + SetDlgItemInt(hWnd, uID, u, fSigned); + return; + } + + + +UINT WINAPI GBGizmoIntGet(HWND hWnd, UINT uID, BOOL FAR *pfTrans, BOOL fSigned) + { + //This fails on non-windowed gizmos anyway, so we don't check. + return GetDlgItemInt(hWnd, uID, pfTrans, fSigned); + } diff --git a/private/oleutest/letest/gizmobar/book1632.h b/private/oleutest/letest/gizmobar/book1632.h new file mode 100644 index 000000000..435fb200c --- /dev/null +++ b/private/oleutest/letest/gizmobar/book1632.h @@ -0,0 +1,154 @@ +/* + * WIN1632.H + * + * Macros and other definitions that assist in porting between Win16 + * and Win32 applications. Define WIN32 to enable 32-bit versions. + * + * Copyright (c)1993 Microsoft Corporation, All Rights Reserved + * + * Kraig Brockschmidt, Software Design Engineer + * Microsoft Systems Developer Relations + * + * Internet : kraigb@microsoft.com + * Compuserve: INTERNET>kraigb@microsoft.com + */ + + +#ifndef _BOOK1632_H_ +#define _BOOK1632_H_ + +//Macros to handle control message packing between Win16 and Win32 +#ifdef WIN32 + +#define MAKEPOINT MAKEPOINTS + +#ifndef COMMANDPARAMS +#define COMMANDPARAMS(wID, wCode, hWndMsg) \ + WORD wID = LOWORD(wParam); \ + WORD wCode = HIWORD(wParam); \ + HWND hWndMsg = (HWND)(UINT)lParam; +#endif //COMMANDPARAMS + +#ifndef SendCommand +#define SendCommand(hWnd, wID, wCode, hControl) \ + SendMessage(hWnd, WM_COMMAND, MAKELONG(wID, wCode) \ + , (LPARAM)hControl) +#endif //SendCommand + +#ifndef MENUSELECTPARAMS +#define MENUSELECTPARAMS(wID, wFlags, hMenu) \ + WORD wID = LOWORD(wParam); \ + WORD wFlags = HIWORD(wParam); \ + HMENU hMenu = (HMENU)lParam; +#endif //MENUSELECTPARAMS + + +#ifndef SendMenuSelect +#define SendMenuSelect(hWnd, wID, wFlags, hMenu) \ + SendMessage(hWnd, WM_MENUSELECT, MAKELONG(wID, wFlags) \ + , (LPARAM)hMenu) +#endif //SendMenuSelect + +#ifndef SendScrollPosition +#define SendScrollPosition(hWnd, iMsg, iPos) \ + SendMessage(hWnd, iMsg, MAKELONG(SB_THUMBPOSITION, iPos), 0) +#endif //SendScrollPosition + +#ifndef ScrollThumbPosition +#define ScrollThumbPosition(w, l) HIWORD(w) +#endif //ScrollThumbPosition + +#ifndef GETWINDOWINSTANCE +#define GETWINDOWINSTANCE(h) (HINSTANCE)GetWindowLong(h, GWL_HINSTANCE) +#endif //GETWINDOWINSTANCE + +#ifndef GETWINDOWID +#define GETWINDOWID(h) (UINT)GetWindowLong(h, GWW_ID) +#endif //GETWINDOWID + +#ifndef POINTFROMLPARAM +#define POINTFROMLPARAM(p, l) {p.x=(LONG)(SHORT)LOWORD(l); \ + p.y=(LONG)(SHORT)HIWORD(l);} +#endif //POINTEFROMLPARAM + +#ifndef EXPORT +#define EXPORT +#endif //EXPORT + +#ifndef MDIREFRESHMENU +#define MDIREFRESHMENU(h) SendMessage(h, WM_MDIREFRESHMENU, 0, 0L) +#endif //MDIREFRESHMENU + + +//****END WIN32 + + + +#else + + + +//****START !WIN32 + +#ifndef COMMANDPARAMS +#define COMMANDPARAMS(wID, wCode, hWndMsg) \ + WORD wID = LOWORD(wParam); \ + WORD wCode = HIWORD(lParam); \ + HWND hWndMsg = (HWND)(UINT)lParam; +#endif //COMMANDPARAMS + +#ifndef SendCommand +#define SendCommand(hWnd, wID, wCode, hControl) \ + SendMessage(hWnd, WM_COMMAND, wID \ + , MAKELONG(hControl, wCode)) +#endif //SendCommand + +#ifndef MENUSELECTPARAMS +#define MENUSELECTPARAMS(wID, wFlags, hMenu) \ + WORD wID = LOWORD(wParam); \ + WORD wFlags = LOWORD(lParam); \ + HMENU hMenu = (HMENU)HIWORD(lParam); +#endif //MENUSELECTPARAMS + +#ifndef SendMenuSelect +#define SendMenuSelect(hWnd, wID, wFlags, hMenu) \ + SendMessage(hWnd, WM_MENUSELECT, wID \ + , MAKELONG(wFlags, hMenu)) +#endif //SendMenuSelect + +#ifndef SendScrollPosition +#define SendScrollPosition(hWnd, iMsg, iPos) \ + SendMessage(hWnd, iMsg, SB_THUMBPOSITION, MAKELONG(iPos, 0)) +#endif //Send ScrollPosition + +#ifndef ScrollThumbPosition +#define ScrollThumbPosition(w, l) LOWORD(l) +#endif //ScrollThumbPosition + +#ifndef GETWINDOWINSTANCE +#define GETWINDOWINSTANCE(h) (HINSTANCE)GetWindowWord(h, GWW_HINSTANCE) +#endif //GETWINDOWINSTANCE + +#ifndef GETWINDOWID +#define GETWINDOWID(h) (UINT)GetWindowWord(h, GWW_ID) +#endif //GETWINDOWID + +#ifndef POINTFROMLPARAM +#define POINTFROMLPARAM(p, l) {p.x=LOWORD(l); p.y=HIWORD(l);} +#endif //POINTEFROMLPARAM + +#ifndef EXPORT +#define EXPORT __export +#endif //EXPORT + + +#ifndef MDIREFRESHMENU +#define MDIREFRESHMENU(h) SendMessage(h, WM_MDISETMENU, TRUE, 0L) +#endif //MDIREFRESHMENU + + + + +#endif //!WIN32 + +#endif //_BOOK1632_H_ diff --git a/private/oleutest/letest/gizmobar/daytona/gizmobar.src b/private/oleutest/letest/gizmobar/daytona/gizmobar.src new file mode 100644 index 000000000..b59771e9a --- /dev/null +++ b/private/oleutest/letest/gizmobar/daytona/gizmobar.src @@ -0,0 +1,51 @@ +#if 0 + + Microsoft Windows + Copyright (C) Microsoft Corporation, 1992 - 1992. + All rights reserved. + + This .def file is preprocessed by the compiler to create the version for + the current build in the appropriate subdir. Basically, whatever you + would have used in your code to control what is compiled when can be + used in this file for the same purpose. The following defines are in + use at the time this file was written: + + FLAT - Used to indicate a NT/DOS7 build + i386 - Intel i386/i486 build + MIPS - MIPS R3000/R4000 build + ALPHA - DEC Alpha build + DBG - Used to control Debug/Retail. Set to 1 if Debug, + 0 if Retail. + WIN31 - Win16 build + __OS2__ - OS/2 build (used by CT mostly) + + If none of these are used, it is assumed the entire file can be used + for all builds. + +#endif + +#ifdef FLAT + +LIBRARY gizmobar + +DESCRIPTION 'GIZMOBAR' + +EXPORTS + GizmoPAllocate + GizmosExpand + GizmoPFree + GizmosCompact + GizmoPFind + GizmoPEnum + GizmoPStateSet + GizmoPCheck + GBGizmoAdd + GBGizmoEnable + GBGizmoFocusSet + GBGizmoSendMessage + GBGizmoTextGet + GBGizmoTextSet + GBHwndAssociateSet + + +#endif // FLAT diff --git a/private/oleutest/letest/gizmobar/daytona/makefile b/private/oleutest/letest/gizmobar/daytona/makefile new file mode 100644 index 000000000..6ee4f43fa --- /dev/null +++ b/private/oleutest/letest/gizmobar/daytona/makefile @@ -0,0 +1,6 @@ +# +# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source +# file to this component. This file merely indirects to the real make file +# that is shared by all the components of NT OS/2 +# +!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/private/oleutest/letest/gizmobar/daytona/makefile.inc b/private/oleutest/letest/gizmobar/daytona/makefile.inc new file mode 100644 index 000000000..afd853b6b --- /dev/null +++ b/private/oleutest/letest/gizmobar/daytona/makefile.inc @@ -0,0 +1 @@ +obj\*\gizmobar.def: gizmobar.src diff --git a/private/oleutest/letest/gizmobar/daytona/sources b/private/oleutest/letest/gizmobar/daytona/sources new file mode 100644 index 000000000..bbce019a8 --- /dev/null +++ b/private/oleutest/letest/gizmobar/daytona/sources @@ -0,0 +1,50 @@ +# This links against bttncur.lib so block all threads to assure that +# bttncur is built. +SYNCHRONIZE_BLOCK=1 +SYNCHRONIZE_DRAIN=1 + +TARGETNAME=gizmobar + +TARGETPATH=obj + +TARGETTYPE=DYNLINK + +DLLDEF= obj\*\gizmobar.def + +TARGETLIBS=$(GUI32_LIBS) \ + $(WIN32_LIBS) \ + ..\..\bttncur\daytona\obj\*\bttncur.lib + +DLLBASE=@$(BASEDIR)\PUBLIC\SDK\LIB\coffbase.txt,usermode + +DLLENTRY= DllEntryPoint + +UMTYPE=windows + +C_DEFINES=-DWIN32 -DFLAT + +INCLUDES=..\..\bttncur; \ + .. + +BLDCRT=1 + +SOURCES= \ + ..\gizmobar.rc \ + ..\api.c \ + ..\init.c \ + ..\dllentry.c \ + ..\paint.c \ + ..\gizmo.c \ + ..\gizmobar.c + +!IF $(386) +NTTARGETFILE0=$(DLLDEF:*=i386) +!ENDIF + +!IF $(MIPS) +NTTARGETFILE0=$(DLLDEF:*=mips) +!ENDIF + +!IF $(ALPHA) +NTTARGETFILE0=$(DLLDEF:*=alpha) +!ENDIF diff --git a/private/oleutest/letest/gizmobar/dirs b/private/oleutest/letest/gizmobar/dirs new file mode 100644 index 000000000..c33a3de9b --- /dev/null +++ b/private/oleutest/letest/gizmobar/dirs @@ -0,0 +1,37 @@ +!IF 0 + +Copyright (c) 1989 Microsoft Corporation + +Module Name: + + dirs. + +Abstract: + + This file specifies the subdirectories of the current directory that + contain component makefiles. + + +Author: + + JohannP 01/11/95 + +!ENDIF + +# +# This is a list of all subdirectories that build required components. +# Each subdirectory name should appear on a line by itself. The build +# follows the order in which the subdirectories are specified. +# + +DIRS= + +# +# This is a list of all subdirectories that build optional components. +# Each subdirectory name should appear on a line by itself. The build +# follows the order in which the subdirectories are specified. +# + +OPTIONAL_DIRS= \ + \ + daytona diff --git a/private/oleutest/letest/gizmobar/dllentry.c b/private/oleutest/letest/gizmobar/dllentry.c new file mode 100644 index 000000000..1cd1159e4 --- /dev/null +++ b/private/oleutest/letest/gizmobar/dllentry.c @@ -0,0 +1,55 @@ +//+------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1991 - 1992. +// +// File: dllentry.c +// +// Contents: Dll Entry point code. Calls the appropriate run-time +// init/term code and then defers to LibMain for further +// processing. +// +// Classes: <none> +// +// Functions: DllEntryPoint - Called by loader +// +// History: 10-May-92 BryanT Created +// 22-Jul-92 BryanT Switch to calling _cexit/_mtdeletelocks +// on cleanup. +// 06-Oct-92 BryanT Call RegisterWithCommnot on entry +// and DeRegisterWithCommnot on exit. +// This should fix the heap dump code. +// 27-Dec-93 AlexT Post 543 builds don't need special code. +// +//-------------------------------------------------------------------- + +#define USE_CRTDLL +#include <windows.h> + +BOOL WINAPI _CRT_INIT (HANDLE hDll, DWORD dwReason, LPVOID lpReserved); + +BOOL DllEntryPoint (HANDLE hDll, DWORD dwReason, LPVOID lpReserved); + +BOOL _CRTAPI1 LibMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved); + +BOOL DllEntryPoint (HANDLE hDll, DWORD dwReason, LPVOID lpReserved) +{ + BOOL fRc = FALSE; + + switch (dwReason) + { + case DLL_PROCESS_ATTACH: + _CRT_INIT(hDll, dwReason, lpReserved); + + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + fRc = LibMain (hDll, dwReason, lpReserved); + break; + + case DLL_PROCESS_DETACH: + fRc = LibMain (hDll, dwReason, lpReserved); + _CRT_INIT(hDll, dwReason, lpReserved); + } + + return(fRc); +} diff --git a/private/oleutest/letest/gizmobar/gizmo.c b/private/oleutest/letest/gizmobar/gizmo.c new file mode 100644 index 000000000..c763c3bba --- /dev/null +++ b/private/oleutest/letest/gizmobar/gizmo.c @@ -0,0 +1,766 @@ +/* + * GIZMO.C + * GizmoBar Version 1.00, Win32 version August 1993 + * + * Allocate, free, find, and enumerate functions for the GIZMO structure + * and a generic subclass procedure to handle tabbing between gizmos. + * + * Copyright (c)1993 Microsoft Corporation, All Rights Reserved + * + * Kraig Brockschmidt, Software Design Engineer + * Microsoft Systems Developer Relations + * + * Internet : kraigb@microsoft.com + * Compuserve: >INTERNET:kraigb@microsoft.com + */ + + +#include <windows.h> +#include "gizmoint.h" + + +/* + * In order to control tabbing in the gizmos, we need to subclass + * real pushbuttons, edit controls, listboxes, and comboboxes. So + * we keep an array of the four original procs for such controls. + */ +WNDPROC pfnOrg[CSUBGIZMOS]={NULL, NULL, NULL, NULL}; + + +TCHAR szStatic[]=TEXT("static"); +TCHAR szEdit[]=TEXT("edit"); +TCHAR szCombobox[]=TEXT("combobox"); +TCHAR szListbox[]=TEXT("listbox"); +TCHAR szButton[]=TEXT("button"); + + +//Here so PAINT.C can get at it. +TOOLDISPLAYDATA tdd; + + + +/* + * GizmoPAllocate + * + * Purpose: + * Allocates and initializes a GIZMO data structure. + * + * Parameters: + * pfSuccess LPINT flag indicating success of failure. + * ppFirst LPLPGIZMO providing the first gizmo in this list. + * hWndParent HWND of the parent of this gizmo. Can be NULL for + * iType==GIZMOTYPE_BUTTON* or GIZMOTYPE_SEPARATOR. + * iType UINT gizmo control type. + * iGizmo UINT index of this gizmo in the GizmoBar. + * uID UINT identifier to send with WM_COMMAND for this control. + * dx, dy UINT width and height of the gizmo. + * pszText LPTSTR to the text for edits, listboxes, combobox, and text. + * dwStyle DWORD style for edits, lists, and combos, and texts. + * hBmp HBITMAP for button gizmos, is applicable. + * iImage UINT index into hBmp for the button image, if applicable. + * uState UINT initial state of the control. + * + * Return Value: + * LPGIZMO If NULL returned then GizmoPAllocate could not allocate + * memory. If a non-NULL pointer is returned with + * *pfSuccess, then call GizmoPFree immediately. If you + * get a non-NULL pointer and *pfSuccess==TRUE then the + * function succeeded. + */ + +LPGIZMO GizmoPAllocate(LPINT pfSuccess, LPLPGIZMO ppFirst, HWND hWndParent + , UINT iType, UINT iGizmo, UINT uID, UINT dx, UINT dy, LPTSTR pszText + , HBITMAP hBmp, UINT iImage, UINT uState) + { + LPGIZMO pGizmo; + LPGIZMO pCur, pPrev; + LPTSTR pszClass; + HINSTANCE hInst; + UINT i; + DWORD dwStyle; + HWND hWndE; + + if (NULL==pfSuccess) + return NULL; + + //Make sure we know of this gizmo type. + if (GIZMOTYPE_MIN > iType || GIZMOTYPE_MAX < iType) + return NULL; + + *pfSuccess=FALSE; + + //Allocate the structure + pGizmo=(LPGIZMO)LocalAlloc(LPTR, CBGIZMO); + + if (NULL==pGizmo) + return NULL; + + + //Store the necessary information for this gizmo. + pGizmo->iType =iType; + pGizmo->uID =uID; + pGizmo->hBmp =hBmp; + pGizmo->iBmp =iImage; + pGizmo->uState =uState; + pGizmo->fNotify =TRUE; + + + /* + * Insert this structure into our gizmo list. Each time we scan + * we increment the index counter (starting at zero) comparing it + * to the desired index of insertion. We then know exactly where + * to insert this new gizmo. Note that we insert the new gizmo in + * the list appropriately for the given owner, so enumerations will + * come out ordered in the same way for that owner. + */ + + i=0; + pCur=*ppFirst; + pPrev=NULL; + + while (NULL!=pCur && i++ < iGizmo) + { + pPrev=pCur; + pCur =pCur->pNext; + } + + //Point to our neighbors + pGizmo->pPrev=pPrev; + pGizmo->pNext=pCur; + + + //Point out neighbors to us. + if (NULL==pPrev) + *ppFirst=pGizmo; + else + pPrev->pNext=pGizmo; + + if (NULL!=pCur) + pCur->pPrev=pGizmo; + + + //Our x-coordinate is the x of the previous gizmo plus its width. + if (NULL!=pPrev) + pGizmo->x=pGizmo->pPrev->x+pGizmo->pPrev->dx; + else + pGizmo->x=4; //First gizmo is at x=4 + + + //If we're a separator or image button, force standards on dx. + UIToolConfigureForDisplay(&tdd); + pGizmo->cxImage=tdd.cxImage; + pGizmo->cyImage=tdd.cyImage; + + if ((GIZMOTYPE_DRAWN & iType) && NULL==hBmp) + dx=tdd.cxButton; + + if (GIZMOTYPE_SEPARATOR==iType) + dx=6; + + /* + * Now create windows for edits, texts, lists, and comboboxes. + * First calculate the most often defaults used in the switch. + */ + pGizmo->dx=dx+6; + pGizmo->dy=min(dy, tdd.cyButton); + pGizmo->y=2; + pszClass=NULL; + + //If this is new gizmo is a window, create it. + switch (iType) + { + case GIZMOTYPE_TEXT: + pGizmo->dx=dx; + pGizmo->y=(tdd.cyBar-1-pGizmo->dy) >> 1; //Center vertically. + pszClass=szStatic; + dwStyle=SS_LEFT; + break; + + case GIZMOTYPE_EDIT: + pGizmo->y=(tdd.cyBar-1-pGizmo->dy) >> 1; //Center vertically. + pszClass=szEdit; + dwStyle=ES_LEFT | WS_BORDER | WS_TABSTOP; + break; + + case GIZMOTYPE_LISTBOX: + pGizmo->dy=dy; + pszClass=szCombobox; + dwStyle=CBS_DROPDOWNLIST | WS_TABSTOP; + break; + + case GIZMOTYPE_COMBOBOX: + pGizmo->dy=dy; + pszClass=szCombobox; + dwStyle=CBS_DROPDOWN | WS_TABSTOP; + break; + + case GIZMOTYPE_BUTTONNORMAL: + pGizmo->dy=dy; + pszClass=szButton; + dwStyle=BS_PUSHBUTTON | WS_TABSTOP; + break; + + case GIZMOTYPE_SEPARATOR: + pGizmo->dx=dx; + pGizmo->y=3; + break; + + case GIZMOTYPE_BUTTONATTRIBUTEIN: + case GIZMOTYPE_BUTTONATTRIBUTEEX: + case GIZMOTYPE_BUTTONCOMMAND: + pGizmo->dx=dx; + pGizmo->y=3; + break; + } + + + //If we matched a classname, create a window. + if (GIZMOTYPE_WINDOWS & iType) + { + if (!IsWindow(hWndParent)) + return pGizmo; + + hInst=(HINSTANCE) GetWindowLong(hWndParent, GWL_HINSTANCE); + + pGizmo->hWnd=CreateWindow(pszClass, pszText + , dwStyle | WS_CHILD | WS_VISIBLE, pGizmo->x, pGizmo->y + , dx, pGizmo->dy, hWndParent, (HMENU)uID, hInst, NULL); + + if (NULL==pGizmo->hWnd) + return pGizmo; + + /* + * Subclass comboboxes, listboxes, edits, and windowed buttons. + * We use iType to index the original proc array so we can use + * a single subclass procedure for all controls. If you mess + * with the gizmo type definitions, this is going to break. + */ + + if (GIZMOTYPE_WINDOWS & iType && GIZMOTYPE_TEXT!=iType) + { + //Give the window its type. + BITPOSITION(iType, i); + SetProp(pGizmo->hWnd, SZTYPEPROP, (HANDLE)i); + + if (NULL==pfnOrg[i]) + pfnOrg[i]=(WNDPROC)GetWindowLong(pGizmo->hWnd, GWL_WNDPROC); + + SetWindowLong(pGizmo->hWnd, GWL_WNDPROC, (LONG)GenericSubProc); + + //If we're a combobox, get the edit control and subclass it. + if (GIZMOTYPE_COMBOBOX==iType) + { + hWndE=GetDlgItem(pGizmo->hWnd, ID_COMBOEDIT); + SetProp(hWndE, SZTYPEPROP, (HANDLE)-1); //Special flag. + + if (NULL==pfnOrg[0]) + pfnOrg[0]=(WNDPROC)GetWindowLong(pGizmo->hWnd, GWL_WNDPROC); + + SetWindowLong(hWndE, GWL_WNDPROC, (LONG)GenericSubProc); + } + } + } + + + //Finally, move all our neighbors to the right over to accomodate us. + GizmosExpand(pGizmo); + + *pfSuccess=TRUE; + return pGizmo; + } + + + + + + +/* + * GizmoPFree + * + * Purpose: + * Reverses all initialization done by GizmoPAllocate, cleaning up + * any allocations including the application structure itself. + * + * Parameters: + * ppFirst LPLPGIZMO providing the first gizmo in this list. + * pGizmo LPGIZMO to the structure + * + * Return Value: + * LPGIZMO NULL if successful, pGizmo if not, meaning we couldn't + * free something. + */ + +LPGIZMO GizmoPFree(LPLPGIZMO ppFirst, LPGIZMO pGizmo) + { + int i; + + if (NULL==pGizmo) + return NULL; + + //Move other gizmos to fill in this gap. + GizmosCompact(pGizmo); + + //Unsubclass + if (GIZMOTYPE_WINDOWS & pGizmo->iType && GIZMOTYPE_TEXT!=pGizmo->iType) + { + i=(int)GetProp(pGizmo->hWnd, SZTYPEPROP); + RemoveProp(pGizmo->hWnd, SZTYPEPROP); + + SetWindowLong(pGizmo->hWnd, GWL_WNDPROC, (LONG)pfnOrg[i]); + } + + //If this was a window gizmo, destroy the window. + if (NULL!=pGizmo->hWnd && IsWindow(pGizmo->hWnd)) + DestroyWindow(pGizmo->hWnd); + + //Unlink ourselves. + if (NULL!=pGizmo->pNext) + pGizmo->pNext->pPrev=pGizmo->pPrev; + + if (NULL!=pGizmo->pPrev) + pGizmo->pPrev->pNext=pGizmo->pNext; + else + *ppFirst=pGizmo->pNext; + + return (LPGIZMO)LocalFree((HLOCAL)(UINT)(LONG)pGizmo); + } + + + + + + +/* + * GizmosExpand + * + * Purpose: + * Given a starting gizmo and a width, moves it and all gizmos to its + * right to the right by the width to make space for showing or creating + * a new gizmo. + * + * Parameters: + * pGizmo LPGIZMO specifying the gizmo that was inserted. + * + * Return Value: + * None + */ + +void GizmosExpand(LPGIZMO pGizmo) + { + int cx; + + cx=(int)pGizmo->dx; + + /* + * If we and the next control are buttons, use our width-1 to + * expand so we overlap borders with our neighboring button. + */ + + if (NULL!=pGizmo->pNext) + { + if ((GIZMOTYPE_BUTTONS & pGizmo->pNext->iType) + && (GIZMOTYPE_BUTTONS & pGizmo->iType)) + cx-=1; + } + + //Walk the gizmo list moving them right by our width. + pGizmo=pGizmo->pNext; + + while (NULL!=pGizmo) + { + pGizmo->x+=cx; + + //hWnd is NULL for buttons and separators. + if (NULL!=pGizmo->hWnd) + SetWindowPos(pGizmo->hWnd, NULL, pGizmo->x, pGizmo->y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + + pGizmo=pGizmo->pNext; + } + + return; + } + + + + + + + +/* + * GizmosCompact + * + * Purpose: + * Given a gizmo, moves all other gizmos to the right of it to the + * left by its width on the GizmoBar. Used when removing or hiding + * the gizmo. + * + * Parameters: + * pGizmo LPGIZMO that is going away, visibly or physically. + * + * Return Value: + * None + */ + +void GizmosCompact(LPGIZMO pGizmo) + { + UINT cx; + LPGIZMO pCur; + + //Move all the gizmos beyond us on the GizmoBar back by our width. + if (NULL!=pGizmo->pNext) + { + cx=pGizmo->pNext->x - pGizmo->x; + pCur=pGizmo->pNext; + + while (NULL!=pCur) + { + pCur->x-=cx; + + if (NULL!=pCur->hWnd) + { + SetWindowPos(pCur->hWnd, NULL, pCur->x, pCur->y + , 0, 0, SWP_NOZORDER | SWP_NOSIZE); + } + + pCur=pCur->pNext; + } + } + + return; + } + + + + + + +/* + * GizmoPFind + * + * Purpose: + * Given a GIZMO identifier, locates and returns a pointer to the structure + * for that position. + * + * Parameters: + * ppFirst LPLPGIZMO providing the first gizmo in this list. + * uID UINT identifier to find. + * + * Return Value: + * LPGIZMO A pointer to a GIZMO structure allocated through + * GizmoPAllocate, NULL if iGizmo is out of range. + */ + +LPGIZMO GizmoPFind(LPLPGIZMO ppFirst, UINT uID) + { + LPGIZMO pGizmo; + + pGizmo=*ppFirst; + + /* + * Yep, linear search, but a better search algorithm won't improve + * things appreciably. The better thing to optimize is what the + * caller passes as ppFirst. + */ + while (NULL!=pGizmo && uID!=pGizmo->uID) + pGizmo=pGizmo->pNext; + + return pGizmo; + } + + + + + + +/* + * GizmoFEnum + * + * Purpose: + * Enumerates the list of GIZMO structures, passing each one to + * an application-defined callback. + * + * Parameters: + * ppFirst LPLPGIZMO providing the first gizmo in this list. + * pfnEnum LPFNGIZMOENUM to call for each enumerated structure. + * dw DWORD extra data to pass to the enumeration function. + * + * Return Value: + * LPGIZMO NULL if the enumeration completed. Otherwise a pointer + * to the gizmo that enumeration stopped on. + */ + +LPGIZMO GizmoPEnum(LPLPGIZMO ppFirst, LPFNGIZMOENUM pfnEnum, DWORD dw) + { + LPGIZMO pGizmo; + UINT i=0; + + pGizmo=*ppFirst; + + while (NULL!=pGizmo) + { + if (!(*pfnEnum)(pGizmo, i++, dw)) + break; + + pGizmo=pGizmo->pNext; + } + + return pGizmo; + } + + + + +/* + * GizmoPStateSet + * + * Purpose: + * State maniuplation functions. Set and Clear also invalidate + * this gizmo's rectangle on the given window and forces a repaint. + * + * Parameters: + * hWnd HWND of the window to repaint. + * pGizmo LPGIZMO affected. + * dwNew DWORD new state flags. + * + * Return Value: + * UINT Previous state. + */ + +UINT GizmoPStateSet(HWND hWnd, LPGIZMO pGizmo, UINT uNew) + { + UINT uRet; + RECT rc; + + if (GIZMOTYPE_SEPARATOR==pGizmo->iType) + return pGizmo->uState; + + //Preserve the color conversion flags across this state change. + uRet=pGizmo->uState; + pGizmo->uState=(uNew & 0x00FF) | (uRet & 0xFF00); + + //Adjust the rectangle by one to avoid repainting borders. + SetRect(&rc, pGizmo->x+1, pGizmo->y+1, pGizmo->x+pGizmo->dx-1, pGizmo->y+pGizmo->dy-1); + InvalidateRect(hWnd, &rc, FALSE); + UpdateWindow(hWnd); + + return uRet; + } + + + + + + + + +/* + * GizmoPCheck + * + * Purpose: + * Handles checking a single button in a group of attribute buttons. + * If the gizmo belongs to a group of mutually exclusive buttons then + * the others surrounding it are unchecked appropriately. + * + * Parameters: + * hWnd HWND of the GizmoBar. + * pGizmo LPGIZMO of the gizmo affected. + * fCheck BOOL TRUE to check the button, FALSE to uncheck. + * + * Return Value: + * BOOL TRUE if the gizmo was previously checked, FALSE + * otherwise. + */ + +BOOL GizmoPCheck(HWND hWnd, LPGIZMO pGizmo, BOOL fCheck) + { + BOOL fPrevCheck; + LPGIZMO pCur; + + + //Ignore command buttons. + if (GIZMOTYPE_BUTTONCOMMAND==pGizmo->iType) + return FALSE; + + //Get the previous state + fPrevCheck=(BOOL)(BUTTONGROUP_DOWN & pGizmo->uState); + + + //Simply set the state for inclusive attribute buttons. + if (GIZMOTYPE_BUTTONATTRIBUTEIN==pGizmo->iType) + { + if (pGizmo->fDisabled) + { + GizmoPStateSet(hWnd, pGizmo + , fCheck ? ATTRIBUTEBUTTON_DOWNDISABLED : ATTRIBUTEBUTTON_DISABLED); + } + else + { + GizmoPStateSet(hWnd, pGizmo + , fCheck ? ATTRIBUTEBUTTON_DOWN : ATTRIBUTEBUTTON_UP); + } + } + + + if (GIZMOTYPE_BUTTONATTRIBUTEEX==pGizmo->iType) + { + //We cannot uncheck an exclusive attribute + if (!fCheck) + return fPrevCheck; + + /* + * For exclusive buttons we have to do more work. First, if we're + * already checked (incliding DOWN and MOUSEDOWN) then we set DOWN + * and exit. If we're not already checked, then we look for the + * gizmo around us, backwards and forwards, that is checked and + * uncheck him. + */ + + //Search backwards. + pCur=pGizmo->pPrev; + + while (NULL!=pCur) + { + //Stop at any non-exclusive attribute. + if (GIZMOTYPE_BUTTONATTRIBUTEEX!=pCur->iType) + { + pCur=NULL; + break; + } + + //If it's down, set it up and we've finished. + if (BUTTONGROUP_DOWN & pCur->uState) + break; + + pCur=pCur->pPrev; + } + + + //If we didn't find a previous one, pCur is NULL, so look ahead. + if (NULL==pCur) + { + pCur=pGizmo->pNext; + + while (NULL!=pCur) + { + //Stop at any non-exclusive attribute. + if (GIZMOTYPE_BUTTONATTRIBUTEEX!=pCur->iType) + { + pCur=NULL; + break; + } + + //If it's down, set it up and we've finished. + if (BUTTONGROUP_DOWN & pCur->uState) + break; + + pCur=pCur->pNext; + } + } + + //If pCur is non-NULL, the we found a neighbor, so uncheck him + if (NULL!=pCur) + { + GizmoPStateSet(hWnd, pCur + , (pGizmo->fDisabled) ? ATTRIBUTEBUTTON_DISABLED : ATTRIBUTEBUTTON_UP); + } + + //Always set ourselves down + GizmoPStateSet(hWnd, pGizmo + , (pGizmo->fDisabled) ? ATTRIBUTEBUTTON_DOWNDISABLED : ATTRIBUTEBUTTON_DOWN); + } + + return fPrevCheck; + } + + + + + + + +/* + * GenericSubProc + * + * Purpose: + * Subclasses window controls in Gizmos so we can trap the tab key and + * tab to the next control. We can have one shared generic subclass + * procedure because we save the type index for this control in the + * property "iType." This allows us to look up the original procedure + * in the pfnOrg array. + * + * Parameters: + * Standard + * + * Return Value: + * Standard + */ + +//LRESULT FAR PASCAL EXPORT GenericSubProc(HWND hWnd, UINT iMsg +LRESULT FAR PASCAL GenericSubProc(HWND hWnd, UINT iMsg + , WPARAM wParam, LPARAM lParam) + { + LONG lRet; + RECT rc; + RECT rcE; + HWND hWndE; + HBRUSH hBr; + HDC hDC; + UINT dx; + UINT iType, i; + + i=(int)GetProp(hWnd, SZTYPEPROP); + iType=POSITIONBIT(i); + + //Special: paint the gap in drop-down comboboxes. + if (GIZMOTYPE_COMBOBOX==iType && WM_PAINT==iMsg) + { + //Do default painting. + lRet=(*pfnOrg[i])(hWnd, iMsg, wParam, lParam); + + hWndE=GetDlgItem(hWnd, ID_COMBOEDIT); + + GetClientRect(hWnd, &rc); + GetClientRect(hWndE, &rcE); + + //The width of the button is the scroll bar width. + dx=GetSystemMetrics(SM_CXVSCROLL); + + //Calculate the rectangle + rc.right -=dx; + rc.left =rcE.right; + rc.bottom+=1; + + //Paint the gap + hDC=GetDC(hWnd); //Already did BeginPaint and EndPaint + + hBr=CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); + FillRect(hDC, &rc, hBr); + DeleteObject(hBr); + + ReleaseDC(hWnd, hDC); + return lRet; + } + + //Control tabbing to the next or previous control in the GizmoBar. + if (WM_KEYDOWN==iMsg && VK_TAB==wParam) + { + hWndE=hWnd; + + if (-1==i) + hWndE=GetParent(hWnd); + + hWndE=GetNextDlgTabItem(GetParent(hWndE), hWnd, (BOOL)(GetKeyState(VK_SHIFT))); + SetFocus(hWndE); + return 0L; + } + + if (-1==i) i=0; + + //Eat tab chars in edit controls to prevent beeping. + if (0==i && WM_CHAR==iMsg && VK_TAB==wParam) + return 0L; + + + //Do this or edit controls bomb big-time. + return CallWindowProc(pfnOrg[i], hWnd, iMsg, wParam, lParam); + } diff --git a/private/oleutest/letest/gizmobar/gizmo.h b/private/oleutest/letest/gizmobar/gizmo.h new file mode 100644 index 000000000..e99e06379 --- /dev/null +++ b/private/oleutest/letest/gizmobar/gizmo.h @@ -0,0 +1,103 @@ +/* + * GIZMO.H + * GizmoBar Version 1.00, Win32 version August 1993 + * + * Data structure and type definitions for the GIZMO data structure. Each + * gizmo on a gizmobar has one of these structures associated with it. + * + * Copyright (c)1993 Microsoft Corporation, All Rights Reserved + * + * Kraig Brockschmidt, Software Design Engineer + * Microsoft Systems Developer Relations + * + * Internet : kraigb@microsoft.com + * Compuserve: >INTERNET:kraigb@microsoft.com + */ + + +#ifndef _GIZMO_H_ +#define _GIZMO_H_ + +#ifdef __cplusplus +extern "C" + { +#endif + + +typedef struct tagGIZMO + { + struct tagGIZMO FAR *pPrev; + struct tagGIZMO FAR *pNext; + UINT iType; + HWND hWnd; //Texts, edits, lists, and combos only. + UINT uID; + UINT x, y; + UINT dx, dy; + UINT cxImage; //From UIToolConfigureForDisplay + UINT cyImage; + HBITMAP hBmp; //Buttons only. + UINT iBmp; + BOOL fNotify; //Indicates whether we send WM_COMMANDs + BOOL fHidden; //Independent of state + BOOL fDisabled; + UINT uState; + UINT uStateOrg; + DWORD dwData; //Application-supplied data. + } GIZMO, FAR * LPGIZMO; + +typedef LPGIZMO FAR *LPLPGIZMO; +#define CBGIZMO sizeof(GIZMO) + +//Property name we attach to controls in a gizmo to identify control type +#define SZTYPEPROP TEXT("iType") + +//Number of controls we subclass +#define CSUBGIZMOS 4 + +//ID of edit controls in comboboxes +#define ID_COMBOEDIT 1001 + + +/* + * Conversion of iType (a positioned bit) into its position. + * The BITPOSITION macro does not need to be fast because we only + * use it once when creating a gizmo. POSITIONBIT does, however, since + * we use it in subclass procedures. + */ +#define BITPOSITION(i, j) {int k=i; for (j=0; k>>=1; j++);} +#define POSITIONBIT(i) (1 << i) + +//Control classifications. GIZMOBAR.H must be included first. +#define GIZMOTYPE_WINDOWS (GIZMOTYPE_TEXT | GIZMOTYPE_EDIT | GIZMOTYPE_LISTBOX | GIZMOTYPE_COMBOBOX | GIZMOTYPE_BUTTONNORMAL) +#define GIZMOTYPE_BUTTONS (GIZMOTYPE_BUTTONATTRIBUTEIN | GIZMOTYPE_BUTTONATTRIBUTEEX | GIZMOTYPE_BUTTONCOMMAND | GIZMOTYPE_BUTTONNORMAL) +#define GIZMOTYPE_DRAWN (GIZMOTYPE_BUTTONATTRIBUTEIN | GIZMOTYPE_BUTTONATTRIBUTEEX | GIZMOTYPE_BUTTONCOMMAND) + + +//These must stay in sync with GIZMOBAR.H +#define GIZMOTYPE_MIN GIZMOTYPE_EDIT +#define GIZMOTYPE_MAX GIZMOTYPE_BUTTONCOMMAND + + +//Enumeration callback +typedef BOOL (FAR PASCAL *LPFNGIZMOENUM)(LPGIZMO, UINT, DWORD); + + +//GIZMO.C +LPGIZMO GizmoPAllocate(LPINT, LPLPGIZMO, HWND, UINT, UINT, UINT, UINT, UINT, LPTSTR, HBITMAP, UINT, UINT); +void GizmosExpand(LPGIZMO); +LPGIZMO GizmoPFree(LPLPGIZMO, LPGIZMO); +void GizmosCompact(LPGIZMO); +LPGIZMO GizmoPFind(LPLPGIZMO, UINT); +LPGIZMO GizmoPEnum(LPLPGIZMO, LPFNGIZMOENUM, DWORD); +UINT GizmoPStateSet(HWND, LPGIZMO, UINT); +BOOL GizmoPCheck(HWND, LPGIZMO, BOOL); + +//LRESULT FAR PASCAL EXPORT GenericSubProc(HWND, UINT, WPARAM, LPARAM); +LRESULT FAR PASCAL GenericSubProc(HWND, UINT, WPARAM, LPARAM); + + +#ifdef __cplusplus + } +#endif + +#endif //_GIZMO_H_ diff --git a/private/oleutest/letest/gizmobar/gizmobar.c b/private/oleutest/letest/gizmobar/gizmobar.c new file mode 100644 index 000000000..78b4fafd0 --- /dev/null +++ b/private/oleutest/letest/gizmobar/gizmobar.c @@ -0,0 +1,467 @@ +/* + * GIZMOBAR.C + * GizmoBar Version 1.00, Win32 version August 1993 + * + * Contains the main window procedure of the GizmoBar control + * that handles mouse logic and Windows messages. + * + * Copyright (c)1993 Microsoft Corporation, All Rights Reserved + * + * Kraig Brockschmidt, Software Design Engineer + * Microsoft Systems Developer Relations + * + * Internet : kraigb@microsoft.com + * Compuserve: >INTERNET:kraigb@microsoft.com + */ + + +#include <windows.h> +#include "gizmoint.h" + + + +/* + * GizmoBarWndProc + * + * Purpose: + * Window Procedure for the GizmoBar custom control. Handles all + * messages like WM_PAINT just as a normal application window would. + * Any message not processed here should go to DefWindowProc. + * + * Parameters: + * Standard + * + * Return Value: + * Standard + */ + +LRESULT FAR PASCAL GizmoBarWndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) + { + BOOL fSuccess; + BOOL fTemp; + LPCREATESTRUCT pCreate; + LPGIZMOBAR pGB; + LPGIZMO pGizmo; + RECT rc; + POINT pt; + short x, y; + COLORREF cr; + + COMMANDPARAMS(wID, wCode, hWndMsg); + + pGB=(LPGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE); + + //Pass control messages onto another function for processing. + if (iMsg >= WM_USER) + return GBMessageHandler(hWnd, iMsg, wParam, lParam, pGB); + + switch (iMsg) + { + case WM_NCCREATE: + pCreate=(LPCREATESTRUCT)lParam; + + pGB=GizmoBarPAllocate((LPINT)&fSuccess, hWnd, pCreate->hInstance + , pCreate->hwndParent, pCreate->style, 0 + , (UINT)pCreate->hMenu); + + if (!fSuccess) + { + GizmoBarPFree(pGB); + return -1L; + } + else + SetWindowLong(hWnd, GBWL_STRUCTURE, (LONG)pGB); + + return DefWindowProc(hWnd, iMsg, wParam, lParam); + + + case WM_DESTROY: + /* + * We want to clean up before DestroyWindow nukes all the + * children, so WM_DESTROY is a better to do it than + * WM_NCDESTROY. + */ + GizmoBarPFree(pGB); + break; + + + case WM_ERASEBKGND: + /* + * Eat this message to avoid erasing portions that + * we are going to repaint in WM_PAINT. Part of a + * change-state-and-repaint strategy is to rely on + * WM_PAINT to do anything visual, which includes + * erasing invalid portions. Letting WM_ERASEBKGND + * erase the background is redundant. + */ + return TRUE; + + #ifdef WIN32 + case WM_CTLCOLORBTN: + case WM_CTLCOLORSTATIC: + fTemp=TRUE; + #else + case WM_CTLCOLOR: + //Change the color of static text on the GizmoBar. + fTemp=(HIWORD(lParam)==CTLCOLOR_STATIC + || HIWORD(lParam)==CTLCOLOR_BTN); + #endif + + if (fTemp) + { + cr=GetSysColor(COLOR_BTNFACE); + SetTextColor((HDC)wParam, GetSysColor(COLOR_BTNTEXT)); + SetBkColor((HDC)wParam, cr); + + /* + * If the system colors have changed, then crFace will + * not be equal to COLOR_BTNFACE, so we reinitialize the + * background brush. This scheme handles system color + * changes appropriately without processing WM_WININICHANGE + * and without blindly creating a new brush on every + * WM_CTLCOLOR message. + */ + if (cr!=pGB->crFace) + { + pGB->crFace=cr; + + if (NULL!=pGB->hBrFace) + DeleteObject(pGB->hBrFace); + + pGB->hBrFace=CreateSolidBrush(pGB->crFace); + } + + return (LONG)(UINT)pGB->hBrFace; + } + + return DefWindowProc(hWnd, iMsg, wParam, lParam); + + + case WM_PAINT: + GizmoBarPaint(hWnd, pGB); + break; + + + case WM_SETFONT: + /* + * wParam has the new font that we now send to all other + * windows controls in us. We control repaints here to + * prevent a lot of repainting for each control. + */ + DefWindowProc(hWnd, WM_SETREDRAW, FALSE, 0L); + + if ((WPARAM)NULL!=wParam) + { + pGB->hFont=(HFONT)wParam; + GizmoPEnum(&pGB->pGizmos, FEnumChangeFont, (DWORD)(LPSTR)pGB); + + DefWindowProc(hWnd, WM_SETREDRAW, TRUE, 0L); + InvalidateRect(hWnd, NULL, FALSE); + UpdateWindow(hWnd); + } + + break; + + + case WM_GETFONT: + return (LRESULT)(UINT)pGB->hFont; + + + case WM_ENABLE: + /* + * wParam has the new enable flag that we use to enable + * or disable ALL controls in us at one time. We also turn + * the redraw off to prevent a lot of flicker. + */ + DefWindowProc(hWnd, WM_SETREDRAW, FALSE, 0L); + + pGB->fEnabled=(BOOL)wParam; + GizmoPEnum(&pGB->pGizmos, FEnumEnable, (DWORD)(LPSTR)pGB); + + DefWindowProc(hWnd, WM_SETREDRAW, TRUE, 0L); + InvalidateRect(hWnd, NULL, FALSE); + UpdateWindow(hWnd); + break; + + + case WM_CANCELMODE: + pGizmo=pGB->pGizmoTrack; + + pGB->fTracking=FALSE; + pGB->fMouseOut=FALSE; + + if (NULL!=pGizmo) + GizmoPStateSet(hWnd, pGizmo, COMMANDBUTTON_UP); + + ReleaseCapture(); + break; + + + case WM_LBUTTONDBLCLK: + case WM_LBUTTONDOWN: + //Get the mouse coordinates. + x=LOWORD(lParam); + y=HIWORD(lParam); + + + /* + * See if we hit a command or attribute gizmo or not. Anything + * else that is a control will get the message instead of + * us anyway, so we don't have to check. FEnumHitTest also + * validates drawn gizmos, enabled, and visible, so we don't. + */ + pGizmo=GizmoPEnum(&pGB->pGizmos, FEnumHitTest, lParam); + + if (NULL==pGizmo) + break; //Didn't hit one matching our needs. + + /* + * Inform the associate that a command was hit like a menu item. + */ + if (NULL!=pGB->hWndAssociate) + { + if (pGizmo->fNotify) + SendMenuSelect(pGB->hWndAssociate, pGizmo->uID, 0, 0); + } + + /* + * We hit a button. If it's a command or attribute, then change + * the state and start tracking. + */ + pGB->fTracking=TRUE; + pGB->pGizmoTrack=pGizmo; + pGB->fMouseOut=FALSE; + SetCapture(hWnd); + + pGizmo->uStateOrg=pGizmo->uState; + GizmoPStateSet(hWnd, pGizmo, ATTRIBUTEBUTTON_MOUSEDOWN); + + break; + + + case WM_MOUSEMOVE: + POINTFROMLPARAM(pt, lParam); + + if (!pGB->fTracking) + break; + + pGizmo=pGB->pGizmoTrack; + SetRect(&rc, pGizmo->x, pGizmo->y, pGizmo->x+pGizmo->dx, pGizmo->y+pGizmo->dy); + + fTemp=pGB->fMouseOut; + pGB->fMouseOut=!PtInRect(&rc, pt); + + //If the mouse went out, change state to the original. + if (!fTemp && pGB->fMouseOut) + { + GizmoPStateSet(hWnd, pGizmo, pGizmo->uStateOrg); + + if (NULL!=pGB->hWndAssociate) + { + //Notify that we left the button + if (pGizmo->fNotify) + SendMenuSelect(pGB->hWndAssociate, 0x0000, 0xFFFF, 0); + } + } + + if (fTemp && !pGB->fMouseOut) + { + GizmoPStateSet(hWnd, pGizmo, ATTRIBUTEBUTTON_MOUSEDOWN); + + if (NULL!=pGB->hWndAssociate) + { + //Notify that we pressed down again + if (pGizmo->fNotify) + SendMenuSelect(pGB->hWndAssociate, pGizmo->uID, 0x0000, 0); + } + } + + break; + + + case WM_LBUTTONUP: + if (!pGB->fTracking) + break; + + pGB->fTracking=FALSE; + pGizmo=pGB->pGizmoTrack; + ReleaseCapture(); + + + /* + * Repaint if we were actually below the mouse when this + * occurred. For command buttons, pop the button up. For + * attributes, either toggle the state (inclusive buttons) + * or check the selected one (exclusive buttons). + */ + + if (!pGB->fMouseOut) + { + //Command buttons always come up. + if (GIZMOTYPE_BUTTONCOMMAND==pGizmo->iType) + GizmoPStateSet(hWnd, pGizmo, COMMANDBUTTON_UP); + + //Attribute inclusive buttons toggle + if (GIZMOTYPE_BUTTONATTRIBUTEIN==pGizmo->iType) + GizmoPCheck(hWnd, pGizmo, !(BUTTONGROUP_DOWN & pGizmo->uStateOrg)); + + //Attribure exclusive buttons are always checked. + if (GIZMOTYPE_BUTTONATTRIBUTEEX==pGizmo->iType) + GizmoPCheck(hWnd, pGizmo, TRUE); + + //Only send messages if notify is ON. + if (NULL!=pGB->hWndAssociate && pGizmo->fNotify) + { + SendMenuSelect(pGB->hWndAssociate, 0, 0xFFFF, 0); + SendCommand(pGB->hWndAssociate, pGizmo->uID, BN_CLICKED, hWnd); + } + } + + break; + + + case WM_COMMAND: + //Pass control messages on if the gizmo's notify is ON. + if (NULL!=pGB->hWndAssociate) + { + pGizmo=PGizmoFromHwndID(hWnd, wID); + + if (NULL!=pGizmo) + { + if (pGizmo->fNotify) + SendMessage(pGB->hWndAssociate, iMsg, wParam, lParam); + } + } + break; + + default: + return DefWindowProc(hWnd, iMsg, wParam, lParam); + } + + return 0L; + } + + + + + +/* + * FEnumChangeFont + * + * Purpose: + * Enumeration callback for all the gizmos we know about in order to + * send a new font to them that's stored in LPGIZMOBAR in dw. + * + * Parameters: + * pGizmo LPGIZMO to draw. + * iGizmo UINT index on the GizmoBar of this gizmo. + * dw DWORD extra data passed to GizmoPEnum, in our case + * the GizmoBar's pGB. + * + * Return Value: + * BOOL TRUE to continue the enumeration, FALSE otherwise. + */ + +BOOL FAR PASCAL FEnumChangeFont(LPGIZMO pGizmo, UINT iGizmo, DWORD dw) + { + LPGIZMOBAR pGB=(LPGIZMOBAR)dw; + + //We only need to change fonts in windowed controls using WM_SETFONT + if (NULL!=pGizmo->hWnd) + SendMessage(pGizmo->hWnd, WM_SETFONT, (WPARAM)pGB->hFont, 1L); + + return TRUE; + } + + + + + + +/* + * FEnumEnable + * + * Purpose: + * Enumeration callback for all the gizmos we know about in order to + * enable or disable them from the WM_ENABLE message. + * + * Parameters: + * pGizmo LPGIZMO to draw. + * iGizmo UINT index on the GizmoBar of this gizmo. + * dw DWORD extra data passed to GizmoPEnum, in our case + * the GizmoBar's pGB. + * + * Return Value: + * BOOL TRUE to continue the enumeration, FALSE otherwise. + */ + +BOOL FAR PASCAL FEnumEnable(LPGIZMO pGizmo, UINT iGizmo, DWORD dw) + { + LPGIZMOBAR pGB=(LPGIZMOBAR)dw; + BOOL fEnable=pGB->fEnabled; + + //NOTE: This code is duplicated in GBGizmoEnable in API.C + if (NULL!=pGizmo->hWnd) + EnableWindow(pGizmo->hWnd, fEnable); + else + { + //If we're not down, command and attribute buttons act the same. + if (!(BUTTONGROUP_DOWN & pGizmo->uState)) + { + GizmoPStateSet(pGB->hWnd, pGizmo + , fEnable ? COMMANDBUTTON_UP : COMMANDBUTTON_DISABLED); + } + else + { + //Attribute buttons are a little more sensitive with DOWNDISABLED + GizmoPStateSet(pGB->hWnd, pGizmo + , fEnable ? ATTRIBUTEBUTTON_DOWN : ATTRIBUTEBUTTON_DOWNDISABLED); + } + } + + return TRUE; + } + + + + + + + +/* + * FEnumHitTest + * + * Purpose: + * Enumeration callback for all the gizmos we know about in order to + * hit-test them. + * + * Parameters: + * pGizmo LPGIZMO to draw. + * iGizmo UINT index on the GizmoBar of this gizmo. + * dw DWORD extra data passed to GizmoPEnum, in our case + * the hDC on which to draw. + * + * Return Value: + * BOOL TRUE to continue the enumeration, FALSE otherwise. + */ + +BOOL FAR PASCAL FEnumHitTest(LPGIZMO pGizmo, UINT iGizmo, DWORD dw) + { + RECT rc; + POINT pt; + + POINTFROMLPARAM(pt, dw); + + //Hit tests have to happen on visible, enabled, and drawn controls only. + if (GIZMOTYPE_DRAWN & pGizmo->iType + && !pGizmo->fHidden && !(BUTTONGROUP_DISABLED & pGizmo->uState)) + { + SetRect(&rc, pGizmo->x, pGizmo->y + , pGizmo->x+pGizmo->dx, pGizmo->y+pGizmo->dy); + + //Stop enumeration if we have a hit. + return !PtInRect(&rc, pt); + } + + return TRUE; + } diff --git a/private/oleutest/letest/gizmobar/gizmobar.h b/private/oleutest/letest/gizmobar/gizmobar.h new file mode 100644 index 000000000..f4888f925 --- /dev/null +++ b/private/oleutest/letest/gizmobar/gizmobar.h @@ -0,0 +1,178 @@ +/* + * GIZMOBAR.H + * GizmoBar Version 1.00, Win32 version August 1993 + * + * Public definitions for application that use the GizmoBar such as + * messages, prototypes for API functions, notification codes, and + * control styles. + * + * Copyright (c)1993 Microsoft Corporation, All Rights Reserved + * + * Kraig Brockschmidt, Software Design Engineer + * Microsoft Systems Developer Relations + * + * Internet : kraigb@microsoft.com + * Compuserve: >INTERNET:kraigb@microsoft.com + */ + + +#ifndef _GIZMOBAR_H_ +#define _GIZMOBAR_H_ + +#ifdef __cplusplus +extern "C" + { +#endif + + +//Classname +#define CLASS_GIZMOBAR TEXT("gizmobar") + + +//Message API Functions +HWND WINAPI GBHwndAssociateSet(HWND, HWND); +HWND WINAPI GBHwndAssociateGet(HWND); + +BOOL WINAPI GBGizmoAdd(HWND, UINT, UINT, UINT, UINT, UINT, LPTSTR, HBITMAP, UINT, UINT); +BOOL WINAPI GBGizmoRemove(HWND, UINT); + +LRESULT WINAPI GBGizmoSendMessage(HWND, UINT, UINT, WPARAM, LPARAM); + +BOOL WINAPI GBGizmoShow(HWND, UINT, BOOL); +BOOL WINAPI GBGizmoEnable(HWND, UINT, BOOL); +BOOL WINAPI GBGizmoCheck(HWND, UINT, BOOL); +UINT WINAPI GBGizmoFocusSet(HWND, UINT); +BOOL WINAPI GBGizmoExist(HWND, UINT); + +int WINAPI GBGizmoTypeGet(HWND, UINT); + +DWORD WINAPI GBGizmoDataSet(HWND, UINT, DWORD); +DWORD WINAPI GBGizmoDataGet(HWND, UINT); +BOOL WINAPI GBGizmoNotifySet(HWND, UINT, BOOL); +BOOL WINAPI GBGizmoNotifyGet(HWND, UINT); + +int WINAPI GBGizmoTextGet(HWND, UINT, LPTSTR, UINT); +void WINAPI GBGizmoTextSet(HWND, UINT, LPTSTR); +UINT WINAPI GBGizmoIntGet(HWND, UINT, BOOL FAR *, BOOL); +void WINAPI GBGizmoIntSet(HWND, UINT, UINT, BOOL); + + + +//Notification codes sent via WM_COMMAND from GBHwndAssociateSet +#define GBN_ASSOCIATEGAIN 1 +#define GBN_ASSOCIATELOSS 2 +#define GBN_GIZMOADDED 3 +#define GBN_GIZMOREMOVED 4 + +//Message equivalents for functions. +#define GBM_HWNDASSOCIATESET (WM_USER+0) +#define GBM_HWNDASSOCIATEGET (WM_USER+1) +#define GBM_GIZMOADD (WM_USER+2) +#define GBM_GIZMOREMOVE (WM_USER+3) +#define GBM_GIZMOSENDMESSAGE (WM_USER+4) +#define GBM_GIZMOSHOW (WM_USER+5) +#define GBM_GIZMOENABLE (WM_USER+6) +#define GBM_GIZMOCHECK (WM_USER+7) +#define GBM_GIZMOFOCUSSET (WM_USER+8) +#define GBM_GIZMOEXIST (WM_USER+9) +#define GBM_GIZMOTYPEGET (WM_USER+10) +#define GBM_GIZMODATASET (WM_USER+11) +#define GBM_GIZMODATAGET (WM_USER+12) +#define GBM_GIZMONOTIFYSET (WM_USER+13) +#define GBM_GIZMONOTIFYGET (WM_USER+14) +#define GBM_GIZMOTEXTGET (WM_USER+15) +#define GBM_GIZMOTEXTSET (WM_USER+16) +#define GBM_GIZMOINTGET (WM_USER+17) +#define GBM_GIZMOINTSET (WM_USER+18) + + + + +/* + * Structure passed in lParam of GBM_GIZMOADD that mirrors the parameters + * to GBGizmoAdd. + */ + +typedef struct + { + HWND hWndParent; //Parent window + UINT iType; //Type of gizmo + UINT iGizmo; //Position in which to create gizmo + UINT uID; //Identifier of gizmo (for WM_COMMAND messages) + UINT dx; //Dimensions of gizmo + UINT dy; + LPTSTR pszText; //Gizmo text + HBITMAP hBmp; //Source of gizmo button image. + UINT iImage; //Index of image from hBmp + UINT uState; //Initial state of the gizmo. + } CREATEGIZMO, FAR *LPCREATEGIZMO; + +#define CBCREATEGIZMO sizeof(CREATEGIZMO) + + +//For GBM_GIZMOSENDMESSAGE +typedef struct + { + UINT iMsg; + WPARAM wParam; + LPARAM lParam; + } GBMSG, FAR * LPGBMSG; + +#define CBGBMSG sizeof(GBMSG); + +//For GBM_GIZMOGETTEXT +typedef struct + { + LPTSTR psz; + UINT cch; + } GBGETTEXT, FAR * LPGBGETTEXT; + +#define CBGBGETTEXT sizeof(GBGETTEXT); + + +//For GBM_GIZMOGETINT +typedef struct + { + BOOL fSigned; + BOOL fSuccess; + } GBGETINT, FAR * LPGBGETINT; + +#define CBGBGETINT sizeof(GBGETINT); + + +//For GBM_GIZMOSETINT +typedef struct + { + UINT uValue; + BOOL fSigned; + } GBSETINT, FAR * LPGBSETINT; + +#define CBGBSETINT sizeof(GBSETINT); + + + +//Gizmo control types. DO NOT CHANGE THESE! +#define GIZMOTYPE_EDIT 0x0001 +#define GIZMOTYPE_LISTBOX 0x0002 +#define GIZMOTYPE_COMBOBOX 0x0004 +#define GIZMOTYPE_BUTTONNORMAL 0x0008 //Top of windowed gizmos. +#define GIZMOTYPE_TEXT 0x0010 +#define GIZMOTYPE_SEPARATOR 0x0020 +#define GIZMOTYPE_BUTTONATTRIBUTEIN 0x0040 +#define GIZMOTYPE_BUTTONATTRIBUTEEX 0x0080 +#define GIZMOTYPE_BUTTONCOMMAND 0x0100 + + +//Generic state flags for non-buttons based on BTTNCUR.H's button groups. +#define GIZMO_NORMAL (BUTTONGROUP_ACTIVE) +#define GIZMO_DISABLED (BUTTONGROUP_DISABLED) + + + +#ifdef __cplusplus + } //Match with extern "C" above. +#endif + + + +#endif //_GIZMOBAR_H_ diff --git a/private/oleutest/letest/gizmobar/gizmobar.rc b/private/oleutest/letest/gizmobar/gizmobar.rc new file mode 100644 index 000000000..e1550028e --- /dev/null +++ b/private/oleutest/letest/gizmobar/gizmobar.rc @@ -0,0 +1,20 @@ +/* + * GIZMOBAR.RC + * GizmoBar Version 1.00, Win32 version August 1993 + * + * Strings and other resources for the GizmoBar. + * + * Copyright (c)1993 Microsoft Corporation, All Rights Reserved + * + * Kraig Brockschmidt, Software Design Engineer + * Microsoft Systems Developer Relations + * + * Internet : kraigb@microsoft.com + * Compuserve: >INTERNET:kraigb@microsoft.com + */ + + +#include <windows.h> +#include "gizmoint.h" + +rcinclude gizmobar.rcv diff --git a/private/oleutest/letest/gizmobar/gizmobar.rcv b/private/oleutest/letest/gizmobar/gizmobar.rcv new file mode 100644 index 000000000..8958b7a2f --- /dev/null +++ b/private/oleutest/letest/gizmobar/gizmobar.rcv @@ -0,0 +1,53 @@ +/* + * GIZMOBAR.RCV + * GizmoBar Version 1.00, Win32 version August 1993 + * + * Version resource file for the GizmoBar Control DLL + * + * Copyright (c)1993 Microsoft Corporation, All Rights Reserved + * + * Kraig Brockschmidt, Software Design Engineer + * Microsoft Systems Developer Relations + * + * Internet : kraigb@microsoft.com + * Compuserve: >INTERNET:kraigb@microsoft.com + */ + +//Default is nodebug +#ifndef DEBUG +#define VER_DEBUG 0 +#else +#define VER_DEBUG VS_FF_DEBUG +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS VER_DEBUG + FILEOS VOS_DOS_WINDOWS16 + FILETYPE VFT_DLL + FILESUBTYPE VFT_UNKNOWN + + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "Microsoft Corporation\0", "\0" + VALUE "FileDescription", "Kraig Brockschmidt's GizmoBar", "\0" + VALUE "FileVersion", "1.00\0", "\0" + VALUE "InternalName", "GIZMOBAR.DLL", "\0" + VALUE "LegalCopyright", "Copyright \251 1993 Microsoft Corp.", "\0" + VALUE "OriginalFilename","GIZMOBAR.DLL", "\0" + VALUE "ProductName", "Kraig Brockschmidt's GizmoBar", "\0" + VALUE "ProductVersion", "1.00\0" + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04E4 + END + END + diff --git a/private/oleutest/letest/gizmobar/gizmoint.h b/private/oleutest/letest/gizmobar/gizmoint.h new file mode 100644 index 000000000..842b62a3e --- /dev/null +++ b/private/oleutest/letest/gizmobar/gizmoint.h @@ -0,0 +1,105 @@ +/* + * GIZMOINT.H + * GizmoBar Version 1.00, Win32 version August 1993 + * + * Internal definitions for the GizmoBar DLL + * + * Copyright (c)1993 Microsoft Corporation, All Rights Reserved + * + * Kraig Brockschmidt, Software Design Engineer + * Microsoft Systems Developer Relations + * + * Internet : kraigb@microsoft.com + * Compuserve: >INTERNET:kraigb@microsoft.com + */ + + +#ifndef _GIZMOINT_H_ +#define _GIZMOINT_H_ + +#include <bttncur.h> +#include <book1632.h> +#include "gizmo.h" +#include "gizmobar.h" + +#ifdef __cplusplus +extern "C" + { +#endif + + +/* + * The main gizmobar structure itself. There's only one of these, + * but it references the first GIZMO in the list. + */ + +typedef struct tagGIZMOBAR + { + LPGIZMO pGizmos; //List of gizmos we own. + HWND hWnd; //Window handle of ourselves. + HINSTANCE hInst; + HWND hWndAssociate; //Associate window handle who gets messages. + DWORD dwStyle; //Copy of GetWindowLong(hWnd, GWL_STYLE) + UINT uState; //State flags + UINT uID; //Control ID. + + HBRUSH hBrFace; //Static control background color + COLORREF crFace; //Color of hBrFace + HFONT hFont; //Font in use, defaults to system, WM_SETFONT + BOOL fEnabled; //Are we enabled? + + LPGIZMO pGizmoTrack; //Current pressed button. + BOOL fTracking; + BOOL fMouseOut; + } GIZMOBAR, FAR * LPGIZMOBAR; + +#define CBGIZMOBAR sizeof(GIZMOBAR) + + +//Extra bytes for the window if the size of a local handle. +#define CBWINDOWEXTRA sizeof(LPGIZMOBAR) + +#define GBWL_STRUCTURE 0 + + +//Structure for passing paint information to a gizmo enumeration callback. +typedef struct + { + HDC hDC; + BOOL fPaint; + } PAINTGIZMO, FAR * LPPAINTGIZMO; + + + +//Private functions specific to the control. + +//INIT.C +#ifdef WIN32 + extern BOOL WINAPI _CRT_INIT(HINSTANCE, DWORD, LPVOID); + extern _cexit(void); +#endif //WIN32 + +void FAR PASCAL WEP(int); +BOOL FRegisterControl(HINSTANCE); +LPGIZMOBAR GizmoBarPAllocate(LPINT, HWND, HINSTANCE, HWND, DWORD, UINT, UINT); +LPGIZMOBAR GizmoBarPFree(LPGIZMOBAR); + + +//PAINT.C +void GizmoBarPaint(HWND, LPGIZMOBAR); +BOOL FAR PASCAL FEnumPaintGizmos(LPGIZMO, UINT, DWORD); + + +//GIZMOBAR.C +LRESULT FAR PASCAL GizmoBarWndProc(HWND, UINT, WPARAM, LPARAM); +BOOL FAR PASCAL FEnumChangeFont(LPGIZMO, UINT, DWORD); +BOOL FAR PASCAL FEnumEnable(LPGIZMO, UINT, DWORD); +BOOL FAR PASCAL FEnumHitTest(LPGIZMO, UINT, DWORD); + + +//API.C Also see GIZMOBAR.H for others +LRESULT GBMessageHandler(HWND, UINT, WPARAM, LPARAM, LPGIZMOBAR); +LPGIZMO PGizmoFromHwndID(HWND, UINT); + + +#endif //_GIZMOINT_H_ diff --git a/private/oleutest/letest/gizmobar/init.c b/private/oleutest/letest/gizmobar/init.c new file mode 100644 index 000000000..736ef47b4 --- /dev/null +++ b/private/oleutest/letest/gizmobar/init.c @@ -0,0 +1,233 @@ +/* + * INIT.C + * GizmoBar Version 1.00, Win32 version August 1993 + * + * LibMain entry point and initialization code for the GizmoBar + * DLL that is likely to be used once or very infrequently. + * + * Copyright (c)1993 Microsoft Corporation, All Rights Reserved + * + * Kraig Brockschmidt, Software Design Engineer + * Microsoft Systems Developer Relations + * + * Internet : kraigb@microsoft.com + * Compuserve: >INTERNET:kraigb@microsoft.com + */ + + +#include <windows.h> +#include "gizmoint.h" + + +/* + * LibMain + * + * Purpose: + * Entry point conditionally compiled for Windows NT and Windows + * 3.1. Provides the proper structure for each environment + * and calls InternalLibMain for real initialization. + */ + +#ifdef WIN32 +BOOL _cdecl LibMain( + HINSTANCE hDll, + DWORD dwReason, + LPVOID lpvReserved) + { + if (DLL_PROCESS_ATTACH == dwReason) + { + return FRegisterControl(hDll); + } + else + { + return TRUE; + } + } + +#else +HANDLE FAR PASCAL LibMain(HANDLE hInstance, WORD wDataSeg + , WORD cbHeapSize, LPSTR lpCmdLine) + { + //Perform global initialization. + if (FRegisterControl(hInstance)) + { + if (0!=cbHeapSize) + UnlockData(0); + } + + return hInstance; + } +#endif + + + + +/* + * WEP + * + * Purpose: + * Required DLL Exit function. Does nothing. + * + * Parameters: + * bSystemExit BOOL indicating if the system is being shut + * down or the DLL has just been unloaded. + * + * Return Value: + * void + * + */ + +void FAR PASCAL WEP(int bSystemExit) + { + return; + } + + + + +/* + * FRegisterControl + * + * Purpose: + * Registers the GizmoBar control class, including CS_GLOBALCLASS + * to make the control available to all applications in the system. + * + * Parameters: + * hInst HINSTANCE of the DLL that will own this class. + * + * Return Value: + * BOOL TRUE if the class is registered, FALSE otherwise. + */ + +BOOL FRegisterControl(HINSTANCE hInst) + { + static BOOL fRegistered=FALSE; + WNDCLASS wc; + + if (!fRegistered) + { + wc.lpfnWndProc =GizmoBarWndProc; + wc.cbClsExtra =0; + wc.cbWndExtra =CBWINDOWEXTRA; + wc.hInstance =hInst; + wc.hIcon =NULL; + wc.hCursor =LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground =(HBRUSH)(COLOR_BTNFACE+1); + wc.lpszMenuName =NULL; + wc.lpszClassName =CLASS_GIZMOBAR; + wc.style =CS_DBLCLKS | CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW; + + fRegistered=RegisterClass(&wc); + } + + return fRegistered; + } + + + + + + +/* + * GizmoBarPAllocate + * + * Purpose: + * Allocates and initializes the control's primary data structure for + * each window that gets created. + * + * Parameters: + * pfSuccess LPINT indicating success of the function. + * hWnd HWND that is tied to this structure. + * hInst HINSTANCE of the DLL. + * hWndAssociate HWND to which we send messages. + * dwStyle DWORD initial style. + * uState UINT initial state. + * uID UINT identifier for this window. + * + * Return Value: + * LPGIZMOBAR If NULL returned then GizmoBarPAllocate could not allocate + * memory. If a non-NULL pointer is returned with + * *pfSuccess, then call GizmoBarPFree immediately. If you + * get a non-NULL pointer and *pfSuccess==TRUE then the + * function succeeded. + */ + +LPGIZMOBAR GizmoBarPAllocate(LPINT pfSuccess, HWND hWnd, HINSTANCE hInst + , HWND hWndAssociate, DWORD dwStyle, UINT uState, UINT uID) + { + LPGIZMOBAR pGB; + + if (NULL==pfSuccess) + return NULL; + + *pfSuccess=FALSE; + + //Allocate the structure + pGB=(LPGIZMOBAR)(void *)LocalAlloc(LPTR, CBGIZMOBAR); + + if (NULL==pGB) + return NULL; + + //Initialize LibMain parameter holders. + pGB->hWnd =hWnd; + pGB->hInst =hInst; + pGB->hWndAssociate=hWndAssociate; + pGB->dwStyle =dwStyle; + pGB->uState =uState; + pGB->uID =uID; + pGB->fEnabled =TRUE; + + pGB->crFace=GetSysColor(COLOR_BTNFACE); + pGB->hBrFace=CreateSolidBrush(pGB->crFace); + + if (NULL==pGB->hBrFace) + return pGB; + + pGB->hFont=GetStockObject(SYSTEM_FONT); + + *pfSuccess=TRUE; + return pGB; + } + + + + +/* + * GizmoBarPFree + * + * Purpose: + * Reverses all initialization done by GizmoBarPAllocate, cleaning up + * any allocations including the application structure itself. + * + * Parameters: + * pGB LPGIZMOBAR to the control's structure + * + * Return Value: + * LPGIZMOBAR NULL if successful, pGB if not, meaning we couldn't + * free some allocation. + */ + +LPGIZMOBAR GizmoBarPFree(LPGIZMOBAR pGB) + { + if (NULL==pGB) + return NULL; + + /* + * Free all the gizmos we own. When we call GizmoPFree we always + * free the first one in the list which updates pGB->pGizmos for + * us, so we just have to keep going until pGizmos is NULL, meaning + * we're at the end of the list. + */ + while (NULL!=pGB->pGizmos) + GizmoPFree(&pGB->pGizmos, pGB->pGizmos); + + if (NULL!=pGB->hBrFace) + DeleteObject(pGB->hBrFace); + + /* + * Notice that since we never create a font, we aren't responsible + * for our hFont member. + */ + + return (LPGIZMOBAR)(void *)LocalFree((HLOCAL)(void *)(LONG)pGB); + } diff --git a/private/oleutest/letest/gizmobar/paint.c b/private/oleutest/letest/gizmobar/paint.c new file mode 100644 index 000000000..14f6c5930 --- /dev/null +++ b/private/oleutest/letest/gizmobar/paint.c @@ -0,0 +1,132 @@ +/* + * PAINT.C + * GizmoBar Version 1.00, Win32 version August 1993 + * + * Contains any code related to GizmoBar visuals, primarily + * the WM_PAINT handler. + * + * Copyright (c)1993 Microsoft Corporation, All Rights Reserved + * + * Kraig Brockschmidt, Software Design Engineer + * Microsoft Systems Developer Relations + * + * Internet : kraigb@microsoft.com + * Compuserve: >INTERNET:kraigb@microsoft.com + */ + + +#include <windows.h> +#include "gizmoint.h" + + +//In GIZMO.C +extern TOOLDISPLAYDATA tdd; + + +/* + * GizmoBarPaint + * + * Purpose: + * Handles all WM_PAINT messages for the control and paints either the + * entire thing or just one GizmoBar button if pGB->pGizmoPaint is non-NULL. + * + * Parameters: + * hWnd HWND Handle to the control. + * pGB LPGIZMOBAR control data pointer. + * + * Return Value: + * None + */ + +void GizmoBarPaint(HWND hWnd, LPGIZMOBAR pGB) + { + PAINTSTRUCT ps; + RECT rc; + HDC hDC; + HBRUSH hBr=NULL; + HPEN hPen=NULL; + + + hDC=BeginPaint(hWnd, &ps); + GetClientRect(hWnd, &rc); + + /* + * The only part of the frame we need to draw is the bottom line, + * so we inflate the rectangle such that all other parts are outside + * the visible region. + */ + hBr =CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); + + if (NULL!=hBr) + SelectObject(hDC, hBr); + + hPen=CreatePen(PS_SOLID, 1, GetSysColor(COLOR_WINDOWFRAME)); + + if (NULL!=hPen) + SelectObject(hDC, hPen); + + Rectangle(hDC, rc.left-1, rc.top-1, rc.right+1, rc.bottom); + + + /* + * All that we have to do to draw the controls is start through the + * list, ignoring anything but buttons, and calling BTTNCUR's + * UIToolButtonDraw for buttons. Since we don't even have to track + * positions of things, we can just use an enum. + */ + GizmoPEnum(&pGB->pGizmos, FEnumPaintGizmos, (DWORD)(LPSTR)&ps); + + //Clean up + EndPaint(hWnd, &ps); + + if (NULL!=hBr) + DeleteObject(hBr); + + if (NULL!=hPen) + DeleteObject(hPen); + + return; + } + + + + + +/* + * FEnumPaintGizmos + * + * Purpose: + * Enumeration callback for all the gizmos we know about in order to + * draw them. + * + * Parameters: + * pGizmo LPGIZMO to draw. + * iGizmo UINT index on the GizmoBar of this gizmo. + * dw DWORD extra data passed to GizmoPEnum, in our case + * a pointer to the PAINTSTRUCT. + * + * Return Value: + * BOOL TRUE to continue the enumeration, FALSE otherwise. + */ + +BOOL FAR PASCAL FEnumPaintGizmos(LPGIZMO pGizmo, UINT iGizmo, DWORD dw) + { + LPPAINTSTRUCT pps=(LPPAINTSTRUCT)dw; + RECT rc, rcI; + + //Only draw those marked for repaint. + if ((GIZMOTYPE_DRAWN & pGizmo->iType)) + { + SetRect(&rc, pGizmo->x, pGizmo->y, pGizmo->x+pGizmo->dx, pGizmo->y+pGizmo->dy); + + //Only draw gizmos in the repaint area + if (IntersectRect(&rcI, &rc, &pps->rcPaint)) + { + UIToolButtonDrawTDD(pps->hdc, pGizmo->x, pGizmo->y + , pGizmo->dx, pGizmo->dy, pGizmo->hBmp, pGizmo->cxImage + , pGizmo->cyImage, pGizmo->iBmp, (UINT)pGizmo->uState, &tdd); + } + } + + return TRUE; + } |