]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/MAI/bios_emulator/scitech/src/common/center.c
* Patch by Thomas Frieden, 13 Nov 2002:
[karo-tx-uboot.git] / board / MAI / bios_emulator / scitech / src / common / center.c
1 /****************************************************************************
2 *
3 *                  Display Doctor Windows Interface Code
4 *
5 *  ======================================================================
6 *  |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
7 *  |                                                                    |
8 *  |This copyrighted computer code is a proprietary trade secret of     |
9 *  |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
10 *  |USA (www.scitechsoft.com).  ANY UNAUTHORIZED POSSESSION, USE,       |
11 *  |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS     |
12 *  |STRICTLY PROHIBITED BY LAW.  Unless you have current, express       |
13 *  |written authorization from SciTech to possess or use this code, you |
14 *  |may be subject to civil and/or criminal penalties.                  |
15 *  |                                                                    |
16 *  |If you received this code in error or you would like to report      |
17 *  |improper use, please immediately contact SciTech Software, Inc. at  |
18 *  |530-894-8400.                                                       |
19 *  |                                                                    |
20 *  |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
21 *  ======================================================================
22 *
23 * Language:     C++ 3.0
24 * Environment:  Win16
25 *
26 * Description:  Dialog driven configuration program for UniVBE and
27 *               WinDirect Professional products.
28 *
29 ****************************************************************************/
30
31 #include "center.h"
32
33 /*------------------------------ Implementation ---------------------------*/
34
35 void _EXPORT CenterWindow(HWND hWndCenter, HWND parent, BOOL repaint)
36 /****************************************************************************
37 *
38 * Function:     CenterWindow
39 * Parameters:   hWndCenter  - Window to center
40 *               parent      - Handle for parent window
41 *               repaint     - true if window should be re-painted
42 *
43 * Description:  Centers the specified window within the bounds of the
44 *               specified parent window. If the parent window is NULL, then
45 *               we center it using the Desktop window.
46 *
47 ****************************************************************************/
48 {
49     HWND    hWndParent = (parent ? parent : GetDesktopWindow());
50     RECT    RectParent;
51     RECT    RectCenter;
52     int     CenterX,CenterY,Height,Width;
53
54     GetWindowRect(hWndParent, &RectParent);
55     GetWindowRect(hWndCenter, &RectCenter);
56
57     Width = (RectCenter.right - RectCenter.left);
58     Height = (RectCenter.bottom - RectCenter.top);
59     CenterX = ((RectParent.right - RectParent.left) - Width) / 2;
60     CenterY = ((RectParent.bottom - RectParent.top) - Height) / 2;
61
62     if ((CenterX < 0) || (CenterY < 0)) {
63         /* The Center Window is smaller than the parent window. */
64         if (hWndParent != GetDesktopWindow()) {
65             /* If the parent window is not the desktop use the desktop size. */
66             CenterX = (GetSystemMetrics(SM_CXSCREEN) - Width) / 2;
67             CenterY = (GetSystemMetrics(SM_CYSCREEN) - Height) / 2;
68             }
69         CenterX = (CenterX < 0) ? 0: CenterX;
70         CenterY = (CenterY < 0) ? 0: CenterY;
71         }
72     else {
73         CenterX += RectParent.left;
74         CenterY += RectParent.top;
75         }
76
77     /* Copy the values into RectCenter */
78     RectCenter.left = CenterX;
79     RectCenter.right = CenterX + Width;
80     RectCenter.top = CenterY;
81     RectCenter.bottom = CenterY + Height;
82
83     /* Move the window to the new location */
84     MoveWindow(hWndCenter, RectCenter.left, RectCenter.top,
85             (RectCenter.right - RectCenter.left),
86             (RectCenter.bottom - RectCenter.top), repaint);
87 }
88
89 void _EXPORT CenterLogo(HWND hWndLogo, HWND hWndParent, int CenterY)
90 /****************************************************************************
91 *
92 * Function:     CenterLogo
93 * Parameters:   hWndLogo    - Window to center
94 *               hWndParent  - Handle for parent window
95 *               CenterY     - Top coordinate for logo
96 *
97 * Description:  Centers the specified window within the bounds of the
98 *               specified parent window in the horizontal direction only.
99 *
100 ****************************************************************************/
101 {
102     RECT    RectParent;
103     RECT    RectCenter;
104     int     CenterX,Height,Width;
105
106     GetWindowRect(hWndParent, &RectParent);
107     GetWindowRect(hWndLogo, &RectCenter);
108     Width = (RectCenter.right - RectCenter.left);
109     Height = (RectCenter.bottom - RectCenter.top);
110     CenterX = ((RectParent.right - RectParent.left) - Width) / 2;
111
112     /* Copy the values into RectCenter */
113     RectCenter.left = CenterX;
114     RectCenter.right = CenterX + Width;
115     RectCenter.top = CenterY;
116     RectCenter.bottom = CenterY + Height;
117
118     /* Move the window to the new location */
119     MoveWindow(hWndLogo, RectCenter.left, RectCenter.top,
120             (RectCenter.right - RectCenter.left),
121             (RectCenter.bottom - RectCenter.top), false);
122 }
123