You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
6.3 KiB
1 lines
6.3 KiB
// ===========================================================================
// UAMDLOGUtils.c © 1997-2001 Microsoft Corp. All rights reserved.
// ===========================================================================
// General dialog utilities used by the Microsoft User Authentication Method.
//
// ===========================================================================
#include <Carbon/Carbon.h>
#include <ctype.h>
#include "UAMUtils.h"
#include "UAMDLOGUtils.h"
#include "UAMDebug.h"
// ---------------------------------------------------------------------------
// ¥ UAM_MakeEditItemFocus()
// ---------------------------------------------------------------------------
void UAM_MakeEditItemFocus(DialogRef inDialog, SInt16 inEditItem)
{
OSErr theError;
ControlRef theControl = NULL;
theError = GetDialogItemAsControl(inDialog, inEditItem, &theControl);
if (theError == noErr)
{
SetKeyboardFocus(GetDialogWindow(inDialog), theControl, kControlEditTextPart);
}
}
// ---------------------------------------------------------------------------
// ¥ UAM_GetDialogItemRect()
// ---------------------------------------------------------------------------
Rect UAM_GetDialogItemRect(DialogRef inDialog, SInt16 inItem)
{
SInt16 itype;
Rect irect;
Handle ihan;
GetDialogItem(inDialog, inItem, &itype, &ihan, &irect);
return(irect);
}
// ---------------------------------------------------------------------------
// ¥ UAM_ToggleControl()
// ---------------------------------------------------------------------------
void UAM_ToggleDialogControl(DialogRef inDialog, SInt16 inItem)
{
OSErr theError;
ControlRef theControl = NULL;
theError = GetDialogItemAsControl(inDialog, inItem, &theControl);
if (theError == noErr)
{
SetControlValue(
theControl,
(SInt16)GetControlValue(theControl) == 0);
}
}
// ---------------------------------------------------------------------------
// ¥ UAM_GetDialogEditText()
// ---------------------------------------------------------------------------
void UAM_GetDialogEditText(DialogRef inDialog, short item, Str255 theText)
{
OSErr theError;
Size theActualLength;
ControlRef theControl = NULL;
theError = GetDialogItemAsControl(inDialog, item, &theControl);
if (theError == noErr)
{
GetControlData(
theControl,
kControlNoPart,
kControlEditTextTextTag,
sizeof(Str255),
(char*)&theText[1],
&theActualLength);
theText[0] = (UInt8)theActualLength;
}
}
// ---------------------------------------------------------------------------
// ¥ UAM_SetDialogEditText()
// ---------------------------------------------------------------------------
void UAM_SetDialogEditText(DialogRef inDialog, short item, Str255 theText)
{
OSErr theError;
ControlRef theControl = NULL;
theError = GetDialogItemAsControl(inDialog, item, &theControl);
if (theError == noErr)
{
SetControlData(
theControl,
kControlEditTextPart,
kControlStaticTextTextTag,
theText[0],
(void*)&theText[1]);
}
}
// ---------------------------------------------------------------------------
// ¥ UAM_HiliteDialogControlItem()
// ---------------------------------------------------------------------------
void UAM_HiliteDialogControlItem(DialogRef inDialog, SInt16 inItem, SInt16 inValue)
{
OSErr theError;
ControlRef theControl = NULL;
theError = GetDialogItemAsControl(inDialog, inItem, &theControl);
if (theError == noErr)
{
HiliteControl(theControl, inValue);
}
}
// ---------------------------------------------------------------------------
// ¥ UAM_IsDialogControlActive()
// ---------------------------------------------------------------------------
Boolean UAM_IsDialogControlActive(DialogRef inDialog, SInt16 inItem)
{
OSErr theError;
ControlRef theControl = NULL;
theError = GetDialogItemAsControl(inDialog, inItem, &theControl);
if (theError == noErr)
{
return(IsControlActive(theControl));
}
return(FALSE);
}
// ---------------------------------------------------------------------------
// ¥ UAM_GetDialogControlValue()
// ---------------------------------------------------------------------------
SInt16 UAM_GetDialogControlValue(DialogRef inDialog, SInt16 inItem)
{
OSErr theError;
ControlRef theControl = NULL;
theError = GetDialogItemAsControl(inDialog, inItem, &theControl);
if (theError == noErr)
{
return(GetControlValue(theControl));
}
return(0);
}
// ---------------------------------------------------------------------------
// ¥ UAM_SetDialogControlValue()
// ---------------------------------------------------------------------------
void UAM_SetDialogControlValue(DialogRef inDialog, SInt16 inItem, SInt16 inValue)
{
OSErr theError;
ControlRef theControl = NULL;
theError = GetDialogItemAsControl(inDialog, inItem, &theControl);
if (theError == noErr)
{
SetControlValue(theControl, inValue);
}
}
// ---------------------------------------------------------------------------
// ¥ UAM_FrameDialogItem()
// ---------------------------------------------------------------------------
pascal void UAM_FrameDialogItem(DialogRef inDialog, SInt16 inItem)
{
GrafPtr savePort;
Rect r;
GetPort(&savePort);
SetPortDialogPort(inDialog);
r = UAM_GetDialogItemRect(inDialog, inItem);
if ((r.bottom - r.top <= 1) || (r.right - r.left <= 1))
{
if (r.bottom - r.top <= 1) {
MoveTo(r.left, r.top);
LineTo(r.right, r.top);
} else {
MoveTo(r.left, r.top);
LineTo(r.left, r.bottom);
}
}
else
FrameRect(&r);
SetPort(savePort);
}
// ---------------------------------------------------------------------------
// ¥ UAM_SetupDialogUserItem()
// ---------------------------------------------------------------------------
void UAM_SetupDialogUserItem(DialogRef inDialog, SInt16 inItem, UserItemUPP inUserProc, SInt16 inType)
{
short itype;
Handle ihan;
Rect irect;
GetDialogItem(inDialog, inItem, &itype, &ihan, &irect);
SetDialogItem(inDialog, inItem, inType, (Handle)inUserProc, &irect);
}
|