📄 wdefbutt.c
字号:
SETCTL_EXTRABYTES( WdeDefaultButton, 0 );
SETCTL_SIZEX( WdeDefaultButton, 0 );
SETCTL_SIZEY( WdeDefaultButton, 0 );
SETCTL_SIZEW( WdeDefaultButton, 0 );
SETCTL_SIZEH( WdeDefaultButton, 0 );
SETCTL_TEXT( WdeDefaultButton, NULL );
SETCTL_CLASSID( WdeDefaultButton, ResNumToControlClass( CLASS_BUTTON ) );
WdeButtonDispatch = MakeProcInstance((FARPROC)WdeButtonDispatcher,
WdeGetAppInstance());
return( TRUE );
}
void WdeButtonFini ( void )
{
WdeFreeDialogBoxControl ( &WdeDefaultButton );
FreeProcInstance ( WdeButtonDispatch );
}
BOOL WdeButtonDestroy ( WdeButtonObject *obj, BOOL *flag, void *p2 )
{
/* touch unused vars to get rid of warning */
_wde_touch(p2);
if ( !Forward ( obj->control, DESTROY, flag, NULL ) ) {
WdeWriteTrail("WdeButtonDestroy: Control DESTROY failed");
return ( FALSE );
}
WdeMemFree( obj );
return ( TRUE );
}
static BOOL WdeValidateGroupBoxMove( WdeButtonObject *obj, POINT *pnt)
{
RECT obj_rect;
RECT text_rect;
SIZE size;
OBJPTR parent;
WdeResizeRatio resizer;
WdeDialogBoxControl *info;
WdeOrderMode mode;
if( Forward( (OBJPTR)obj, GET_ORDER_MODE, &mode, NULL ) &&
( mode != WdeSelect ) ) {
return( FALSE );
}
Location ( (OBJPTR)obj, &obj_rect );
GetObjectParent ( (OBJPTR)obj, &parent );
if( Forward( obj->control, GET_OBJECT_INFO, &info, NULL ) &&
parent && Forward( parent, GET_RESIZER, &resizer, NULL ) ) {
if( WdeGetNameOrOrdSize( parent, GETCTL_TEXT(info), &size ) ) {
text_rect.left = obj_rect.left + 8;
text_rect.top = obj_rect.top + (resizer.xmap*3)/4;
text_rect.right = text_rect.left + size.cx;
text_rect.bottom = text_rect.top + size.cy;
} else {
SetRectEmpty ( &text_rect );
}
} else {
SetRectEmpty ( &text_rect );
}
if ( PtInRect ( &text_rect, *pnt ) ) {
return ( TRUE );
}
obj_rect.left += WDE_GBOX_BORDER_SIZE;
obj_rect.right -= WDE_GBOX_BORDER_SIZE;
obj_rect.top += WDE_GBOX_BORDER_SIZE;
obj_rect.bottom -= WDE_GBOX_BORDER_SIZE;
if ( PtInRect( &obj_rect, *pnt ) ) {
return ( FALSE );
}
return ( TRUE );
}
BOOL WdeButtonValidateAction ( WdeButtonObject *obj, ACTION *act, void *p2 )
{
int i;
if ( ( *act == MOVE ) && ( obj->object_id == GBUTTON_OBJ ) ) {
return ( WdeValidateGroupBoxMove ( obj, p2 ) );
}
for ( i = 0; i < MAX_ACTIONS; i++ ) {
if( WdeButtonActions[i].id == *act ) {
return ( TRUE );
}
}
return ( ValidateAction( (OBJPTR) obj->control, *act, p2 ) );
}
BOOL WdeButtonCopyObject ( WdeButtonObject *obj, WdeButtonObject **new,
WdeButtonObject *handle )
{
if (new == NULL) {
WdeWriteTrail("WdeButtonCopyObject: Invalid new object!");
return ( FALSE );
}
*new = (WdeButtonObject *) WdeMemAlloc ( sizeof(WdeButtonObject) );
if ( *new == NULL ) {
WdeWriteTrail("WdeButtonCopyObject: Object malloc failed");
return ( FALSE );
}
(*new)->dispatcher = obj->dispatcher;
(*new)->object_id = obj->object_id;
if ( handle == NULL ) {
(*new)->object_handle = *new;
} else {
(*new)->object_handle = handle;
}
if (!CopyObject(obj->control, &((*new)->control), (*new)->object_handle)) {
WdeWriteTrail("WdeButtonCopyObject: Control not created!");
WdeMemFree ( (*new) );
return ( FALSE );
}
return ( TRUE );
}
BOOL WdeButtonIdentify ( WdeButtonObject *obj, OBJ_ID *id, void *p2 )
{
/* touch unused vars to get rid of warning */
_wde_touch(p2);
*id = obj->object_id;
return ( TRUE );
}
BOOL WdeButtonGetWndProc( WdeButtonObject *obj, WNDPROC *proc, void *p2 )
{
/* touch unused vars to get rid of warning */
_wde_touch(obj);
_wde_touch(p2);
*proc = WdeButtonSuperClassProc;
return ( TRUE );
}
BOOL WdeButtonGetWindowClass ( WdeButtonObject *obj, char **class, void *p2 )
{
/* touch unused vars to get rid of warning */
_wde_touch(obj);
_wde_touch(p2);
//*class = "wdebutton";
*class = "button";
return ( TRUE );
}
BOOL WdeButtonDefine ( WdeButtonObject *obj, POINT *pnt, void *p2 )
{
WdeDefineObjectInfo o_info;
/* touch unused vars to get rid of warning */
_wde_touch(pnt);
_wde_touch(p2);
o_info.obj = obj->object_handle;
o_info.obj_id = obj->object_id;
o_info.mask = WS_VISIBLE | WS_DISABLED | WS_TABSTOP | WS_GROUP;
o_info.set_func = (WdeSetProc)WdeButtonSetDefineInfo;
o_info.get_func = (WdeGetProc)WdeButtonGetDefineInfo;
o_info.hook_func = NULL;
o_info.win = NULL;
return ( WdeControlDefine ( &o_info ) );
}
void WdeButtonSetDefineInfo ( WdeDefineObjectInfo *o_info, HWND hDlg )
{
BOOL check_lefttext;
OBJ_ID id;
DialogStyle mask;
id = o_info->obj_id;
mask = GETCTL_STYLE(o_info->info.c.info) & (0x0000ffff ^ ( BS_LEFTTEXT ) );
check_lefttext = FALSE;
if ( id == PBUTTON_OBJ ) {
#if __NT__XX
EnableWindow ( GetDlgItem(hDlg, IDB_BS_BITMAP), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_ICON), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_TEXT), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_TOP), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_BOTTOM), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_CENTER), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_LEFT), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_RIGHT), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_VCENTER), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_MULTILINE), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_NOTIFY), TRUE );
mask = GETCTL_STYLE(o_info->info.c.info) & 0x0000000f;
if ( mask == BS_OWNERDRAW ) {
CheckDlgButton ( hDlg, IDB_BS_OWNERDRAW, 1);
} else {
if ( mask == BS_PUSHBUTTON ) {
CheckDlgButton ( hDlg, IDB_BS_PUSHBUTTON, 1);
} else if ( mask == BS_DEFPUSHBUTTON ) {
CheckDlgButton ( hDlg, IDB_BS_DEFPUSHBUTTON, 1);
} else {
WdeWriteTrail("WdeButtonSetDefineInfo: Bad Push mask!");
}
// set any new styles
mask = GETCTL_STYLE(o_info->info.c.info) & 0x00000f00;
if ( (mask & BS_CENTER) == BS_CENTER ) {
CheckDlgButton ( hDlg, IDB_BS_CENTER, 1 );
} else if ( mask & BS_RIGHT ) {
CheckDlgButton ( hDlg, IDB_BS_RIGHT, 1 );
} else if ( mask & BS_LEFT ) {
CheckDlgButton ( hDlg, IDB_BS_LEFT, 1 );
} else {
CheckDlgButton ( hDlg, IDB_BS_CENTER, 1 );
}
if ( (mask & BS_VCENTER) == BS_VCENTER ) {
CheckDlgButton ( hDlg, IDB_BS_VCENTER, 1 );
} else if ( mask & BS_TOP ) {
CheckDlgButton ( hDlg, IDB_BS_TOP, 1 );
} else if ( mask & BS_BOTTOM ) {
CheckDlgButton ( hDlg, IDB_BS_BOTTOM, 1 );
} else {
CheckDlgButton ( hDlg, IDB_BS_VCENTER, 1 );
}
if ( GETCTL_STYLE(o_info->info.c.info) & BS_BITMAP ) {
CheckDlgButton ( hDlg, IDB_BS_BITMAP, 1 );
}
if ( GETCTL_STYLE(o_info->info.c.info) & BS_ICON ) {
CheckDlgButton ( hDlg, IDB_BS_ICON, 1 );
}
if ( GETCTL_STYLE(o_info->info.c.info) & BS_TEXT ) {
CheckDlgButton ( hDlg, IDB_BS_TEXT, 1 );
}
if ( GETCTL_STYLE(o_info->info.c.info) & BS_MULTILINE ) {
CheckDlgButton ( hDlg, IDB_BS_MULTILINE, 1 );
}
if ( GETCTL_STYLE(o_info->info.c.info) & BS_NOTIFY ) {
CheckDlgButton ( hDlg, IDB_BS_NOTIFY, 1 );
}
}
#else
EnableWindow ( GetDlgItem(hDlg, IDB_BS_BITMAP), FALSE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_ICON), FALSE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_TEXT), FALSE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_TOP), FALSE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_BOTTOM), FALSE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_CENTER), FALSE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_LEFT), FALSE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_RIGHT), FALSE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_VCENTER), FALSE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_MULTILINE), FALSE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_NOTIFY), FALSE );
if ( mask == BS_PUSHBUTTON ) {
CheckDlgButton ( hDlg, IDB_BS_PUSHBUTTON, 1);
} else if ( mask == BS_DEFPUSHBUTTON ) {
CheckDlgButton ( hDlg, IDB_BS_DEFPUSHBUTTON, 1);
} else if ( mask == BS_OWNERDRAW ) {
CheckDlgButton ( hDlg, IDB_BS_OWNERDRAW, 1);
} else {
WdeWriteTrail("WdeButtonSetDefineInfo: Bad Push mask!");
}
#endif
} else if ( id == CBUTTON_OBJ ) {
check_lefttext = TRUE;
#if __NT__XX
EnableWindow ( GetDlgItem(hDlg, IDB_BS_NOTIFY), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_PUSHLIKE), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_LEFTTEXT), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_LEFT), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_RIGHT), TRUE );
EnableWindow ( GetDlgItem(hDlg, IDB_BS_CENTER), TRUE );
mask = GETCTL_STYLE(o_info->info.c.info) & 0x0000000f;
if ( mask == BS_3STATE ) {
CheckDlgButton ( hDlg, IDB_BS_3STATE, 1);
} else if ( mask == BS_AUTOCHECKBOX ) {
CheckDlgButton ( hDlg, IDB_BS_AUTOCHECKBOX, 1);
} else if ( mask == BS_AUTO3STATE ) {
CheckDlgButton ( hDlg, IDB_BS_3STATE, 1);
CheckDlgButton ( hDlg, IDB_BS_AUTOCHECKBOX, 1);
}
// set the new styles
mask = GETCTL_STYLE(o_info->info.c.info) & 0x00000f00;
if ( (mask & BS_CENTER) == BS_CENTER ) {
CheckDlgButton ( hDlg, IDB_BS_CENTER, 1);
}
else if ( mask & BS_RIGHT ) {
CheckDlgButton ( hDlg, IDB_BS_RIGHT, 1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -