cmsops.c
/*--------------------------------------------------------------------
CMSOPS.C -- CMS Operations window
L. R. Erickson, Apr. 1994
-------------------------------------------------------------------*/
#include <windows.h>
#include <string.h>
#include "cms.h"
static cxOpsMinSize, cyOpsMinSize ;
static cxOpsCharSpace, cyOpsCharSpace, cyOpsLineSpace ;
struct
{
char *text ;
int xpos ;
int ypos ;
}
static Screen[] =
{
"HDR COMMENT", 1, 11, // Must be first.
"gdc-r", 2, 13,
"COM LINK", 1, 14,
"NET HDR FILE", 1, 15,
"COLLECTION SETTINGS", 2, 2,
"MODE", 1, 3,
"HSKP", 1, 4,
"TLM", 1, 5,
"SCAN SOURCE", 1, 6,
"FWD START", 1, 7,
"REV START", 1, 8,
"BB SETTING", 1, 9,
"SWITCHES", 2, 17,
"SCATTER", 1, 18,
"EXT AREA", 23, 18,
"JONES", 46, 18,
"DATA FILE", 28, 2,
"NEXT FILE", 27, 3,
"FRAMES/SNAP", 48, 3,
"SIZE (bytes)", 27, 4,
"SNAPS/FILE", 48, 4,
"POINTING MIRROR", 28, 6,
"X REL (mrad)", 27, 7,
"X ABS (mrad)", 27, 8,
"X CNTS", 27, 9,
"Y REL (mrad)", 48, 7,
"Y ABS (mrad)", 48, 8,
"Y CNTS", 48, 9,
"APERTURE", 28, 13,
"FILTER", 48, 13,
} ;
#define NUM_TXT_STRINGS (sizeof Screen / sizeof Screen[0])
#define SCREEN_WIDTH 68
#define SCREEN_HEIGHT 20
static int ScreenBoxes [7][12] =
{ // gdc-r box
1, 13, 0, 13, 0, 16, 24, 16, 24, 13, 7, 13,
// Collection Settings box
1, 2, 0, 2, 0, 10, 24, 10, 24, 2, 21, 2,
// Data File Box
26, 2, 25, 2, 25, 5, 67, 5, 67, 2, 37, 2,
// Pointing Mirror Box
26, 6, 25, 6, 25, 10, 67, 10, 67, 6, 44, 6,
// Aperture Box
26, 13, 25, 13, 25, 16, 45, 16, 45, 13, 38, 13,
// Filter Box
47, 13, 46, 13, 46, 16, 67, 16, 67, 13, 54, 13,
// Switches Box
1, 17, 0, 17, 0, 19, 67, 19, 67, 17, 10, 17,
} ;
struct
{
HWND hwnd ;
int CntrlClassIndex ;
long CntrlStyle ;
char *SetupText ;
int xpos ;
int ypos ;
int width ;
}
static OpsCntrl[] =
{
NULL, CC_BUTTONINDEX, BS_PUSHBUTTON, "AUTO COLLECT", 5, 0, 16,
NULL, CC_BUTTONINDEX, BS_PUSHBUTTON, "COLLECT DATA", 26, 0, 16,
NULL, CC_BUTTONINDEX, BS_PUSHBUTTON, "SET/RECALL POS", 47, 0, 16,
NULL, CC_EDITINDEX, ES_AUTOHSCROLL | WS_BORDER | ES_LEFT,
"", 15, 11, 53,
NULL, CC_COMBOBOXINDEX, CBS_DROPDOWN | WS_VSCROLL | WS_BORDER,
"", 26, 14, 19,
NULL, CC_COMBOBOXINDEX, CBS_DROPDOWN | WS_VSCROLL | WS_BORDER,
"", 47, 14, 20,
} ;
//************* Control ID's -- Want these up front and visible
// and in this file. ID must equal index into OpsCntrl[]
// for the control.
//****************************************************************
#define ID_AUTOCOLLECT 0
#define ID_GO 1
#define ID_RECALL 2
#define ID_COMMENT 3
#define ID_APLIST 4
#define ID_FILTLIST 5
#define NUM_OPS_CNTRLS (sizeof OpsCntrl / sizeof OpsCntrl[0])
#define NUM_APSTRINGS 19
static char *ApStrings[NUM_APSTRINGS] =
{
"1 0.00791",
"2 0.01112",
"3 0.01580",
"4 0.02240",
"5 0.03160",
"6 0.04470",
"7 0.06330",
"8 0.08950",
"9 0.12700",
"10 0.17900",
"11 0.25310",
"12 Vert Slit",
"13 Horz Slit",
"14 Open 0.52",
"15 Scene Sim",
"16 ND1",
"17 ND2",
"18 ND3",
"19 Closed"
} ;
#define NUM_FILTSTRINGS 19
static char *FiltStrings[NUM_FILTSTRINGS] =
{
"1 R6B",
"2 R8B",
"3 R96B",
"4 R12B",
"5 R15B",
"6 R17B",
"7 L",
"8 O",
"9 P",
"10 Q",
"11 R",
"12 S",
"13 SP50",
"14 W15166-9A",
"15 ND3",
"16 ND2",
"17 ND1",
"18 Open 0.625",
"19 Closed"
} ;
//*************** Start of CMSOpsWndProc ***************************
long FAR PASCAL _export CMSOpsWndProc (HWND hwnd, UINT message,
UINT wParam, LONG lParam)
{
static HWND hwndClient, hwndFrame ;
static HMENU hMenuOps, hMenuOpsWindow ;
PAINTSTRUCT ps ;
HDC hdc ;
CNTLPOS OpsCntlPos ;
int i ;
switch (message)
{
case WM_CREATE:
// Save window handles
hwndClient = GetParent (hwnd) ;
hwndFrame = GetParent (hwndClient) ;
hMenuOps = LoadMenu (globhCMSInst, "CMSOpsMenu") ;
hMenuOpsWindow = GetSubMenu (hMenuOps, OPS_MENU_POS) ;
// Set Min Window.
SetOpsWinMins () ;
// Start up controls
for (i = 0 ; i < NUM_OPS_CNTRLS ; i++)
{
SetOpsCntlPos (i, &OpsCntlPos) ;
OpsCntrl[i].hwnd = CreateWindow (
globCntrlClass[OpsCntrl[i].CntrlClassIndex],
OpsCntrl[i].SetupText,
WS_CHILD | WS_VISIBLE |
OpsCntrl[i].CntrlStyle,
OpsCntlPos.cxPos, OpsCntlPos.cyPos,
OpsCntlPos.cWidth, OpsCntlPos.cHeight,
hwnd, i, globhCMSInst, NULL) ;
}
// Load the list boxes.
LoadOpsLists () ;
// Start other windows
PostMessage (hwndFrame, WM_COMMAND, ID_MAKEDATAWIN, 0L) ;
return 0 ;
case WM_MDIACTIVATE:
// Set the Setup menu if gaining focus
if (wParam == TRUE)
SendMessage (hwndClient, WM_MDISETMENU, 0,
MAKELONG (hMenuOps, hMenuOpsWindow)) ;
DrawMenuBar (hwndFrame) ;
return 0 ;
case WM_DESTROY :
DestroyMenu (hMenuOps) ;
return 0 ;
case WM_SIZE :
SetOpsCharSpace (lParam) ;
// Reset control windows.
for (i = 0 ; i < NUM_OPS_CNTRLS ; i++)
{
SetOpsCntlPos (i, &OpsCntlPos) ;
MoveWindow (OpsCntrl[i].hwnd,
OpsCntlPos.cxPos, OpsCntlPos.cyPos,
OpsCntlPos.cWidth, OpsCntlPos.cHeight,
TRUE ) ;
}
break ;
case WM_PAINT :
hdc = BeginPaint (hwnd, &ps) ;
WriteOpsScreenText (hwnd, hdc) ;
EndPaint (hwnd, &ps) ;
return 0 ;
}
return DefMDIChildProc (hwnd, message, wParam, lParam) ;
}
//*************** End of CMSOpsWndProc ***************************
//*************** Start of SetOpsWinMins ***************************
void SetOpsWinMins (void)
{
cxOpsMinSize = SCREEN_WIDTH * globcxCharSpace ;
cyOpsMinSize = SCREEN_HEIGHT * globcyCharSpace ;
}
//*************** End of SetOpsWinMins ***************************
//****************** Start of SetOpsCharSpace ************************
void SetOpsCharSpace (LONG lParam)
{
if ((int) LOWORD (lParam) <= cxOpsMinSize)
cxOpsCharSpace = globcxCharSpace ;
else
cxOpsCharSpace = (int) (((LONG) globcxCharSpace
* (LONG) LOWORD (lParam)) / (LONG) cxOpsMinSize) ;
if ((int) HIWORD (lParam) <= cyOpsMinSize)
{
cyOpsCharSpace = globcyCharSpace ;
cyOpsLineSpace = (11 * globcyCharSpace) / 8 ;
}
else
{
cyOpsCharSpace = (int) (((LONG) globcyCharSpace
* (LONG) HIWORD (lParam)) / (LONG) cyOpsMinSize) ;
cyOpsLineSpace = (int) (((LONG) ((11 * globcyCharSpace) / 8)
* (LONG) HIWORD (lParam)) / (LONG) cyOpsMinSize) ;
}
}
//****************** End of SetOpsCharSpace ************************
//****************** Start of WriteOpsScreen ************************
void WriteOpsScreenText (HWND hwnd, HDC hdc)
{
int i,j ;
RECT TextRect ;
static POINT pts [6] ;
for (i = 0 ; i < NUM_TXT_STRINGS ; i++)
{
TextRect.left = Screen[i].xpos * cxOpsCharSpace ;
TextRect.top = Screen[i].ypos * cyOpsCharSpace ;
if (i == 0) TextRect.top = TextRect.top + (cyOpsCharSpace / 2) ;
TextRect.bottom = TextRect.top + cyOpsCharSpace ;
TextRect.right = TextRect.left + ((strlen (Screen[i].text) + 2)
* cxOpsCharSpace) ;
DrawText (hdc, (LPSTR) Screen[i].text, -1, &TextRect,
DT_NOCLIP | DT_SINGLELINE | DT_LEFT | DT_VCENTER) ;
}
for (i = 0 ; i < 7 ; i++)
{
for (j = 0 ; j < 6 ; j++)
{
pts[j].x = (ScreenBoxes[i][j * 2] * cxOpsCharSpace) +
(cxOpsCharSpace / 2) ;
pts[j].y = (ScreenBoxes[i][(j * 2) + 1] * cyOpsCharSpace) +
(cyOpsCharSpace / 2) ;
}
Polyline (hdc, pts, 6) ;
}
}
//****************** End of WriteOpsScreen ************************
//******************* Start of SetOpsCntlPos **********************
void SetOpsCntlPos (int i, CNTLPOS *CntlPos)
{
CntlPos->cxPos = SetOpsxCnts (i) ;
CntlPos->cyPos = SetOpsyCnts (i) ;
CntlPos->cWidth = SetOpsWidth (i) ;
CntlPos->cHeight = SetOpsHeight (i) ;
}
//******************* End of SetOpsCntlPos **********************
//******************* Start of SetOpsxCnts **********************
int SetOpsxCnts (int i)
{
int cxcnts ;
cxcnts = OpsCntrl[i].xpos * cxOpsCharSpace ;
return cxcnts ;
}
//******************* End of SetOpsxCnts **********************
//******************* Start of SetOpsWidth **********************
int SetOpsWidth (int i)
{
int width ;
width = OpsCntrl[i].width * cxOpsCharSpace ;
return width ;
}
//******************* End of SetOpsWidth **********************
//******************* Start of SetOpsHeight **********************
int SetOpsHeight (int i)
{
int height ;
switch (i)
{
case ID_COMMENT :
height = (7 * globcyCharSpace) / 4 ;
return height ;
case ID_AUTOCOLLECT :
case ID_GO :
case ID_RECALL :
height = (7 * globcyCharSpace) / 4 ;
return height ;
case ID_APLIST :
case ID_FILTLIST :
height = 10 * globcyCharSpace ;
return height ;
}
return height ;
}
//******************* End of SetOpsHeight **********************
//******************* Start of SetOpsyCnts **********************
int SetOpsyCnts (int i)
{
int cycnts ;
switch (i)
{
case ID_COMMENT :
case ID_APLIST :
case ID_FILTLIST :
cycnts = (OpsCntrl[i].ypos * cyOpsCharSpace)
+ (cyOpsCharSpace / 4) ;
return cycnts ;
case ID_AUTOCOLLECT :
case ID_GO :
case ID_RECALL :
cycnts = (OpsCntrl[i].ypos * globcyCharSpace)
+ (globcyCharSpace / 4) ;
return cycnts ;
}
return cycnts ;
}
//******************* End of SetOpsyCnts **********************
//******************* Start of LoadOpsLists **********************
void LoadOpsLists (void)
{
int i ;
for (i = 0 ; i < NUM_APSTRINGS ; i++)
SendMessage ( OpsCntrl[ID_APLIST].hwnd, CB_ADDSTRING, 0,
(LONG) (LPSTR) ApStrings[i]) ;
for (i = 0 ; i < NUM_FILTSTRINGS ; i++)
SendMessage ( OpsCntrl[ID_FILTLIST].hwnd, CB_ADDSTRING, 0,
(LONG) (LPSTR) FiltStrings[i]) ;
}
//******************* End of LoadOpsLists **********************