home *** CD-ROM | disk | FTP | other *** search
- //lRegen_FileHeading
- //lRegen_FileHeading
-
- /********************************************************************
- *
- * Source File: aligner.c
- * Author:
- * Module:
- * Program Desc:
- * Date: Mon Feb 19 13:11:40 1996
- * Language: ANSI C
- *
- ********************************************************************/
-
- #include ".\idoiface.h"
-
-
- //lRegen_Variables
- #include <pvido.h>
-
-
- static BOOL bVisible = FALSE;
- static HWND hAlignPalette;
-
- HWND GetAlignPaletteWnd()
- {
- return hAlignPalette;
- }
-
- void ResizeEntities(BOOL bWidth, BOOL bHeight);
- void RepositionEntities(BOOL bLeft, BOOL bTop, BOOL bRight, BOOL bBottom);
-
-
- //lRegen_Variables
-
- VIEW hViewaligner;
- HWND hWndaligner;
- LRESULT CALLBACK EXPORT fnalignerWndProc(HWND, UINT, WPARAM, LPARAM);
-
- int fnaligner(HWND hParentWnd, UINT iData, void FAR *lpData)
- {
- //lRegen_BeginFunction
- //lRegen_BeginFunction
-
- //lRegen_InitDlg
- if(bVisible)
- {
- DestroyWindow(hAlignPalette);
- return 0;
- }
- //lRegen_InitDlg
-
- if(NULL == (hViewaligner = vwCreateView(hInstance,
- MAKEINTRESOURCE(aligner),
- hParentWnd,
- (VIEWPROC)fnalignerWndProc,
- NULL)))
- {
- //lRegen_Create
- //lRegen_Create
- return FALSE;
- }
- //lRegen_InitView
- //lRegen_InitView
- if((hWndaligner = vwShowView(hViewaligner)) == (HWND)-1)
- {
- MessageBox(NULL, "Unable to display view", "System Error",
- MB_SYSTEMMODAL | MB_ICONHAND | MB_OK);
- return FALSE;
- }
-
- //lRegen_TermView
- //lRegen_TermView
- return(TRUE);
- }
-
- LRESULT CALLBACK EXPORT fnalignerWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
- {
- GETVIEW;
- WORD CtlId;
- WORD Notify;
- HWND CtlWnd;
-
- //lRegen_WindowProcVariables
- //lRegen_WindowProcVariables
-
- switch(uMessage)
- {
- //lRegen_WndProc
- //lRegen_WndProc
-
- case WM_INITDIALOG :
- //lRegen_InitDialogBegin
- bVisible = TRUE;
- hAlignPalette = hWnd;
- //lRegen_InitDialogBegin
- //Regen_WM_InitDialog
- //Regen_WM_InitDialog
- return TRUE;
-
- case WM_COMMAND :
- #ifdef WIN32
- CtlId = LOWORD(wParam);
- Notify = HIWORD(wParam);
- CtlWnd = (HWND)lParam;
- #else
- CtlId = wParam;
- Notify = HIWORD(lParam);
- CtlWnd = (HWND)LOWORD(lParam);
- #endif
- switch(CtlId)
- {
- case ID_HORZ :
- //Regen_ID_HORZ
- ResizeEntities(TRUE, FALSE);
- //Regen_ID_HORZ
- break;
-
- case ID_VERT :
- //Regen_ID_VERT
- ResizeEntities(FALSE, TRUE);
- //Regen_ID_VERT
- break;
-
- case ID_BOTH :
- //Regen_ID_BOTH
- ResizeEntities(TRUE, TRUE);
- //Regen_ID_BOTH
- break;
-
- case IDC_LEFT :
- //Regen_IDC_LEFT
- RepositionEntities(TRUE, FALSE, FALSE, FALSE);
- //Regen_IDC_LEFT
- break;
-
- case IDC_TOP :
- //Regen_IDC_TOP
- RepositionEntities(FALSE, TRUE, FALSE, FALSE);
- //Regen_IDC_TOP
- break;
-
- case IDC_RIGHT :
- //Regen_IDC_RIGHT
- RepositionEntities(FALSE, FALSE, TRUE, FALSE);
- //Regen_IDC_RIGHT
- break;
-
- case IDC_BOTTOM :
- //Regen_IDC_BOTTOM
- RepositionEntities(FALSE, FALSE, FALSE, TRUE);
- //Regen_IDC_BOTTOM
- break;
-
- //lRegen_CustomCommand
- //lRegen_CustomCommand
- }
- break;
-
- case WM_DESTROY :
- //Regen_WM_Destroy
- bVisible = FALSE;
- hAlignPalette = 0;
- //Regen_WM_Destroy
- break;
- }
- return DefViewProc(hWnd, uMessage, wParam, lParam);
- }
-
- //Regen_CustomCode
- void ResizeEntities(BOOL bWidth, BOOL bHeight)
- {
- RECT rect;
- int width, height;
- HWND hido;
- ENTITY entity;
-
-
- if(hido = GetActiveIDO())
- {
- if(idoGetCurrentEntity(hido, &entity))
- {
- idoEntityGetRect(&entity, &rect);
- width = rect.right - rect.left;
- height = rect.bottom - rect.top;
-
- idoIterateSelectedEntityFirst(hido);
- while(idoIterateSelectedEntityNext(hido, &entity))
- {
- idoEntityGetRect(&entity, &rect);
- if(bWidth)
- rect.right = rect.left + width;
- if(bHeight)
- rect.bottom = rect.top + height;
- idoEntitySetRect(&entity, &rect);
- }
-
- InvalidateRect(hido, NULL, TRUE);
- UpdateWindow(hido);
- }
- }
- }
-
- void RepositionEntities(BOOL bLeft, BOOL bTop, BOOL bRight, BOOL bBottom)
- {
- RECT rect;
- RECT anchor;
- int width, height;
- HWND hido;
- ENTITY entity;
-
-
-
- if(hido = GetActiveIDO())
- {
- if(idoGetCurrentEntity(hido, &entity))
- {
- idoEntityGetRect(&entity, &rect);
- anchor = rect;
-
- idoIterateSelectedEntityFirst(hido);
- while(idoIterateSelectedEntityNext(hido, &entity))
- {
- idoEntityGetRect(&entity, &rect);
- width = rect.right - rect.left;
- height = rect.bottom - rect.top;
-
- if(bLeft)
- {
- rect.left = anchor.left;
- rect.right = rect.left + width;
- }
- if(bTop)
- {
- rect.top = anchor.top;
- rect.bottom = rect.top + height;
- }
- if(bRight)
- {
- rect.right = anchor.right;
- rect.left = rect.right - width;
- }
- if(bBottom)
- {
- rect.bottom = anchor.bottom;
- rect.top = rect.bottom - height;
- }
-
- idoEntitySetRect(&entity, &rect);
- }
-
- InvalidateRect(hido, NULL, TRUE);
- UpdateWindow(hido);
- }
- }
- }
-
- //Regen_CustomCode
-