📄 wdefcntl.c
字号:
}
BOOL WdeControlNotify ( WdeControlObject *obj, NOTE_ID *id, void *p2 )
{
HWND handle;
BOOL new_parent;
BOOL parent_changed;
new_parent = FALSE;
parent_changed = FALSE;
switch ( *id ) {
case MOVE_START:
HideSelectBoxes();
break;
case MOVE_END:
ShowSelectBoxes();
break;
case PRIMARY_OBJECT:
if ( obj->tag != (HWND) NULL ) {
WdeTagPressed ( WdeGetTagInfo ( obj->tag ) );
}
/* make sure the current object is first in the parent list */
/* I know, a child object has implementation knowlegde of its
* parent. C'est la vie.
*/
if ( !WdeControlFirstChild ( obj, NULL, NULL ) ) {
WdeWriteTrail("WdeControlNotify: FIRST_CHILD falied!");
return ( FALSE );
}
if (!Forward ( obj->parent, BECOME_FIRST_CHILD, NULL, NULL) ) {
WdeWriteTrail("WdeControlNotify: BECOME_FIRST_CHILD falied!");
return ( FALSE );
}
if ( obj->parent == obj->base_obj ) {
WdeSetControlObjectMenu ( FALSE, FALSE, FALSE, obj->mode );
} else {
WdeSetControlObjectMenu
( TRUE, WdeIsDialogRestorable ( obj->parent ),
( obj->res_info && obj->res_info->hash_table ),
obj->mode );
}
WdeWriteControlToInfo ( obj );
return ( TRUE );
case NEW_PARENT:
if ( !p2 ) {
obj->parent = NULL;
obj->parent_handle = NULL;
return ( Notify ( obj->o_item, *id, obj->parent ) );
}
if ( obj->parent != p2 ) {
new_parent = TRUE;
}
if (!Forward ( p2, GET_WINDOW_HANDLE, &handle, NULL)) {
WdeWriteTrail("WdeControlNotify: GET_WINDOW_HANDLE failed!");
return ( FALSE );
}
if ( obj->parent_handle != handle ) {
parent_changed = TRUE;
}
if ( new_parent ) {
obj->parent = p2;
obj->parent_handle = handle;
if (!Forward ( obj->parent, GET_FONT, &(obj->font), NULL)) {
WdeWriteTrail("WdeControlNotify: GET_FONT failed!");
return ( FALSE );
}
parent_changed = TRUE;
}
if ( parent_changed ) {
if (obj->window_handle != NULL) {
if ( !WdeControlDestroyWindow ( obj, NULL, NULL ) ) {
WdeWriteTrail("WdeControlNotify: "
"DESTROY_WINDOW failed!");
return ( FALSE );
}
if (!Forward ( (OBJPTR)obj->object_handle,
CREATE_WINDOW, NULL, NULL)) {
WdeWriteTrail("WdeControlNotify: "
"CREATE_WINDOW failed!");
return ( FALSE );
}
}
}
return ( Notify ( obj->o_item, *id, obj->parent ) );
case SET_LOCATION:
if ( obj->clear_interior ) {
WdeSetClearObjectPos ( obj );
}
return ( WdeChangeControlSize ( obj, FALSE, FALSE ) );
}
return ( FALSE );
}
/* NOTE: This function assumes that there was no change of parent */
static BOOL WdeOffsetDialogUnits ( WdeControlObject *obj, WdeResizeRatio *r )
{
RECT parent_pos;
RECT new_pos;
RECT nc_size;
RECT win_pos;
DialogSizeInfo dsize;
Location( obj->object_handle, &new_pos );
if ( obj->parent != obj->base_obj ) {
Location( obj->parent, &parent_pos );
if ( !Forward ( obj->parent, GET_NC_SIZE, &nc_size, NULL) ) {
WdeWriteTrail("WdeOffsetDialogUnits: GET_NC_SIZE failed!");
return ( FALSE );
}
win_pos.left = new_pos.left - parent_pos.left - nc_size.left;
win_pos.top = new_pos.top - parent_pos.top - nc_size.top;
} else {
win_pos.left = new_pos.left;
win_pos.top = new_pos.top;
}
win_pos.right = win_pos.left + ( new_pos.right - new_pos.left );
win_pos.bottom = win_pos.top + ( new_pos.bottom - new_pos.top );
if ( WdeScreenToDialog ( obj, r, &win_pos, &dsize ) ) {
SETCTL_SIZEX( obj->control_info, dsize.x );
SETCTL_SIZEY( obj->control_info, dsize.y );
return ( TRUE );
}
return ( FALSE );
}
BOOL WdeUpdateCDialogUnits( OBJPTR obj, RECT *new, WdeResizeRatio *r )
{
WdeControlObject *cobj;
DialogSizeInfo dsize;
cobj = (WdeControlObject * )obj;
/* save the old dialog units */
dsize = GETCTL_SIZE( cobj->control_info );
if( !WdeScreenToDialog( cobj, r, new, GETCTL_PSIZE(cobj->control_info) ) ) {
/* restore the old dialog units */
SETCTL_SIZE( cobj->control_info, dsize );
return ( FALSE );
}
return ( TRUE );
}
BOOL WdeControlResize ( WdeControlObject *obj, RECT *new_pos, BOOL *flag )
{
RECT object_rect;
RECT nc_size;
RECT parent_rect;
RECT rect;
POINT origin;
POINT pnt;
BOOL error;
WdeResizeRatio resizer;
int min_width;
int min_height;
if( *flag && ( obj->mode != WdeSelect ) ) {
return( FALSE );
}
if ( obj->parent == NULL ) {
WdeWriteTrail("WdeDialogResize: obj has no parent!");
return ( FALSE );
}
if ( !Forward ( obj->parent, GET_RESIZER, &resizer, NULL) ) {
WdeWriteTrail("WdeDialogResize: GET_RESIZER failed!");
return ( FALSE );
}
min_width = MulDiv ( WDE_CONTROL_MIN_WIDTH, resizer.xmap, 4 );
min_height = MulDiv ( WDE_CONTROL_MIN_HEIGHT, resizer.ymap, 8 );
if ( (new_pos->right - new_pos->left) < min_width ) {
new_pos->right = new_pos->left + min_height;
}
if ( (new_pos->bottom - new_pos->top) < min_height ) {
new_pos->bottom = new_pos->top + min_height;
}
Location ( obj->object_handle, &object_rect );
if ( !Resize(obj->o_item, new_pos, *flag) ) {
WdeWriteTrail("WdeControlResize: O_ITEM RESIZE failed!");
return ( FALSE );
}
if ( !*flag ) {
error = FALSE;
if (obj->parent != obj->base_obj ) {
Location( obj->parent, &parent_rect );
if (!Forward ( obj->parent, GET_NC_SIZE, &nc_size, NULL )) {
WdeWriteTrail("WdeDialogAddSubObject: Couldn't get nc size!");
error = TRUE;
}
parent_rect.left += nc_size.left;
parent_rect.right -= nc_size.right;
parent_rect.top += nc_size.top;
parent_rect.bottom -= nc_size.bottom;
pnt.x = new_pos->left;
pnt.y = new_pos->top;
if ( (pnt.x < parent_rect.left) || (pnt.y < parent_rect.top) ) {
WdeWriteTrail("WdeControlResize: "
"control not contained by dialog top left!");
//error = TRUE;
error = FALSE; // experiment -- don't cause a failure
}
}
if ( error ) {
if (!Resize(obj->o_item, &object_rect, FALSE)) {
WdeWriteTrail("WdeControlResize: O_ITEM RESIZE undo failed!");
}
return ( FALSE );
}
}
rect = *new_pos;
GetOffset( &origin );
OffsetRect ( &rect, -origin.x, -origin.y );
WdeMapWindowRect ( obj->res_info->edit_win, obj->parent_handle,
&rect );
if ( obj->clear_interior ) {
WdeSetClearObjectPos ( obj );
}
if ( obj->window_handle != NULL ) {
SetWindowPos ( obj->window_handle,
(HWND) NULL,
rect.left, rect.top,
(rect.right - rect.left),
(rect.bottom - rect.top),
SWP_NOZORDER | SWP_NOREDRAW );
}
if ( *flag ) {
WdeControlModified ( obj );
if (obj->parent == obj->base_obj ) {
rect = *new_pos;
}
WdeUpdateCDialogUnits ( obj, &rect, &resizer );
if ( !WdeChangeControlSize ( obj, FALSE, FALSE ) ) {
WdeWriteTrail("WdeControlResize: WdeChangeControlSize failed!");
return ( FALSE );
}
if( obj->parent == obj->base_obj ) {
WdeCheckBaseScrollbars( FALSE );
}
}
return ( TRUE );
}
BOOL WdeControlMove ( WdeControlObject *obj, POINT *off, BOOL *forms_called )
{
RECT parent_rect;
RECT object_rect;
RECT old_pos;
RECT nc_size;
POINT origin;
POINT pnt;
POINT offset;
Bool ok;
OBJPTR clone;
OBJPTR old_parent;
WdeResizeRatio resizer;
if ( *forms_called &&
( clone = WdeCloneObject ( obj->object_handle, off ) ) ) {
offset.x = 0;
offset.y = 0;
} else {
offset.x = off->x;
offset.y = off->y;
}
ok = TRUE;
old_parent = obj->parent;
Location( obj->object_handle, &old_pos );
/* update the location of the object */
if (!Move( obj->o_item, &offset, *forms_called)) {
return ( FALSE );
}
Location( obj->object_handle, &object_rect );
if ( !*forms_called ) {
Location( obj->parent, &parent_rect );
if (obj->parent != obj->base_obj ) {
if ( !Forward ( obj->parent, GET_NC_SIZE, &nc_size, NULL ) ) {
WdeWriteTrail("WdeDialogAddSubObject: Couldn't get nc size!");
ok = FALSE;
}
if ( ok ) {
parent_rect.left += nc_size.left;
parent_rect.right -= nc_size.right;
parent_rect.top += nc_size.top;
parent_rect.bottom -= nc_size.bottom;
pnt.x = object_rect.left;
pnt.y = object_rect.top;
if ( (pnt.x<parent_rect.left) || (pnt.y<parent_rect.top) ) {
WdeWriteTrail("WdeControlMove: control "
"not contained by dialog top left!");
ok = FALSE;
}
}
}
}
GetOffset(&origin);
if ( ok && *forms_called ) {
if ( old_parent == obj->parent ) {
WdeOffsetDialogUnits ( obj, NULL );
} else {
if ( !Forward ( obj->parent, GET_RESIZER, &resizer, NULL) ) {
WdeWriteTrail("WdeDialogResize: GET_RESIZER failed!");
ok = FALSE;
}
if ( ok ) {
if (obj->parent != obj->base_obj ) {
OffsetRect ( &object_rect, -origin.x, -origin.y );
WdeMapWindowRect ( obj->res_info->edit_win,
obj->parent_handle, &object_rect );
}
SETCTL_SIZEX( obj->control_info, ( uint_16 )
MulDiv ( object_rect.left, 4, resizer.xmap ) );
SETCTL_SIZEY( obj->control_info, ( uint_16 )
MulDiv ( object_rect.top, 8, resizer.ymap ) );
}
if( obj->symbol ) {
WdeAddSymbolToObjectHashTable( obj->res_info, obj->symbol,
GETCTL_ID(obj->control_info) );
}
}
if ( ok && !WdeChangeControlSize ( obj, FALSE, TRUE ) ) {
WdeWriteTrail("WdeControlMove: WdeChangeControlSize failed!");
ok = FALSE;
}
if ( ok ) {
Location( obj->object_handle, &object_rect );
}
}
if ( ok ) {
OffsetRect ( &object_rect, -origin.x, -origin.y );
pnt.x = object_rect.left;
pnt.y = object_rect.top;
MapWindowPoints( obj->res_info->edit_win, obj->parent_handle,
&pnt, 1 );
WdeSetClearObjectPos( obj );
if( !SetWindowPos( obj->window_handle, (HWND)NULL,
pnt.x, pnt.y, 0, 0,
SWP_NOZORDER | SWP_NOSIZE ) ) {
ok = FALSE;
}
}
if( !ok ) {
if( *forms_called ) {
RemoveObject( obj->parent, obj->object_handle );
}
if ( !Resize ( obj->o_item, &old_pos, FALSE ) ) {
WdeWriteTrail("WdeControlMove: O_ITEM RESIZE undo failed!");
}
} else if ( ok && *forms_called ) {
WdeControlModified ( obj );
if( ( old_parent == obj->base_obj ) ||
( obj->parent == obj->base_obj ) ) {
WdeCheckBaseScrollbars( FALSE );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -