guimdi.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 526 行 · 第 1/2 页
C
526 行
static void ChangeMenuTitle( gui_window *root, int index )
{
char name[MAX_LENGTH];
char label[MAX_LENGTH];
MakeLabel( index, name, label );
GUISetMenuText( root, GUI_MDI_FIRST_WINDOW + index, label, FALSE );
MakeHintText( index, name );
}
void ChangeTitle( gui_window *wnd )
{
int index;
index = GetIndex( wnd );
if( index != -1 ) {
ChangeMenuTitle( GUIGetRootWindow(), index );
}
if( index == CurrMDIWindow ) {
GUIXChangeTitle( wnd );
}
}
void BroughtToFront( gui_window *wnd )
{
gui_window *root;
int index;
root = GUIGetRootWindow();
index = GetIndex( wnd );
if( ( CurrMDIWindow != -1 ) && ( root != NULL ) ) {
GUICheckMenuItem( root, CurrMDIWindow + GUI_MDI_FIRST_WINDOW, FALSE, FALSE );
}
CurrMDIWindow = index;
if( ( CurrMDIWindow != -1 ) && ( root != NULL ) ) {
GUICheckMenuItem( root, CurrMDIWindow + GUI_MDI_FIRST_WINDOW, TRUE, FALSE );
}
}
gui_window *FindNextMDIMenuWindowNotInArray( gui_window *wnd, gui_window *avoid )
{
gui_window *start, *next, *parent;
bool done;
done = FALSE;
start = next = wnd;
parent = GUIGetParentWindow( wnd );
while( !done ) {
next = GUIGetNextWindow( next );
if( next == NULL ) {
next = GUIGetFirstSibling( start );
}
if( parent != GUIGetParentWindow( next ) ) {
continue;
}
if( next == start ) {
break;
}
if( ( next != avoid ) && GetIndex( next ) == -1 ) {
done = TRUE;
}
}
if( done ) {
return( next );
} else {
return( NULL );
}
}
/*
* MDIDelete -- make adjustments need to reflect the fact the wnd was deleted
*/
void MDIDelete( gui_window *wnd )
{
gui_window *root;
int index, offset;
int i, num_menu_windows;
if( wnd == Root ) {
Root = NULL;
}
if( Root == NULL ) {
return;
}
root = GUIGetRootWindow();
// This check will make sure that windows that are not children of
// the root window are ignored
if( GUIGetParentWindow( wnd ) != root ) {
return;
}
index = GetIndex( wnd );
if( NumMDIWindows == ( MAX_NUM_MDI_WINDOWS + 1 ) ) {
GUIDeleteMenuItem( root, GUI_MDI_MORE_WINDOWS, FALSE );
}
NumMDIWindows--;
if( index != -1 ) {
if( index == NumMDIWindows ) {
GUIDeleteMenuItem( root, index + GUI_MDI_FIRST_WINDOW, FALSE );
MDIWindows[index] = NULL;
} else {
// delete all MDI menu items from this index on
num_menu_windows = min( NumMDIWindows, MAX_NUM_MDI_WINDOWS-1 );
for( i = index; i < num_menu_windows; i++ ) {
GUIDeleteMenuItem( root, i + GUI_MDI_FIRST_WINDOW, FALSE );
MDIWindows[i] = MDIWindows[i+1];
}
GUIDeleteMenuItem( root, num_menu_windows + GUI_MDI_FIRST_WINDOW, FALSE );
MDIWindows[num_menu_windows] = NULL;
// re-add all menu items from index on
offset = GUIGetMenuPopupCount ( root, GUIMDIMenuID );
if( NumMDIWindows > MAX_NUM_MDI_WINDOWS ) {
offset--;
}
for( i = index; i < num_menu_windows; i++ ) {
InsertMenuForWindow( root, i, offset + i - index );
if( CurrMDIWindow == i ) {
CurrMDIWindow--;
if( CurrMDIWindow < 0 ) {
CurrMDIWindow = -1;
} else {
GUICheckMenuItem( root, CurrMDIWindow + GUI_MDI_FIRST_WINDOW, TRUE, FALSE );
}
}
}
// Fill in the last spot in the MDIWindows array and insert it
// after the 8th element
if( NumMDIWindows >= MAX_NUM_MDI_WINDOWS ) {
MDIWindows[MAX_NUM_MDI_WINDOWS-1] =
FindNextMDIMenuWindowNotInArray( MDIWindows[MAX_NUM_MDI_WINDOWS-2], wnd );
if( MDIWindows[MAX_NUM_MDI_WINDOWS-1] != NULL ) {
offset = GUIGetMenuPopupCount( root, GUIMDIMenuID ) - 1;
if( NumMDIWindows > MAX_NUM_MDI_WINDOWS ) {
offset--;
}
InsertMenuForWindow( root, MAX_NUM_MDI_WINDOWS-1, offset );
}
}
}
}
if( NumMDIWindows <= 0 ) {
EnableMDIMenus( root, FALSE );
CurrMDIWindow = -1;
}
}
/*
* DlgInit -- callback function for GUIEnumChildWindows to fill list box
* with names of MDI windows
*/
static void DlgInit( gui_window *wnd, void *param )
{
char buffer[MAX_LENGTH];
dlg_init *info;
info = (dlg_init *)param;
TotalWindows++;
ChildWindows[TotalWindows-1] = wnd;
if( GUIGetWindowText( wnd, buffer, MAX_LENGTH - 1 ) != 0 ) {
GUIAddText( info->dlg_wnd, info->list_ctrl, buffer );
} else {
GUIAddText( info->dlg_wnd, info->list_ctrl, "" );
}
if( wnd == GUICurrWnd ) {
GUISetCurrSelect( info->dlg_wnd, info->list_ctrl, TotalWindows - 1 );
}
}
/*
* DlgCount -- callback function for GUIEnumChildWindows to count the number
* of MDI child windows
*/
static void DlgCount( gui_window *wnd, void *param )
{
param = param;
wnd = wnd;
TotalWindows++;
}
static void IconCount( gui_window *wnd, void *param )
{
param = param;
if( GUIIsMinimized( wnd ) ) {
TotalWindows++;
}
}
/*
* GUIGetNumChildWindows -- return the number of MDI child windows
*/
int GUIGetNumChildWindows( void )
{
TotalWindows = 0;
GUIEnumChildWindows( GUIGetRootWindow(), &DlgCount, NULL );
return( TotalWindows );
}
int GUIGetNumIconicWindows( void )
{
TotalWindows = 0;
GUIEnumChildWindows( GUIGetRootWindow(), &IconCount, NULL );
return( TotalWindows );
}
/*
* PickInit -- callback procedure to GUIDlgPick function
*/
static void PickInit( gui_window *wnd, int list_ctrl )
{
gui_window *root;
int num_windows;
dlg_init info;
root = GUIGetRootWindow();
num_windows = GUIGetNumChildWindows();
ChildWindows = (gui_window **)GUIMemAlloc( sizeof( gui_window *) * num_windows );
info.dlg_wnd = wnd;
info.list_ctrl = list_ctrl;
TotalWindows = 0;
GUIEnumChildWindows( root, &DlgInit, &info );
}
void GUIMDIMoreWindows( void )
{
int chosen;
gui_window *wnd;
chosen = GUIDlgPick( LIT( Select_Window ), &PickInit );
if( ( chosen >= 0 ) && ( chosen < TotalWindows ) ) {
wnd = ChildWindows[ chosen ];
if( GUIIsMinimized( wnd ) ) {
GUIRestoreWindow( wnd );
}
GUIBringToFront( wnd );
}
GUIMemFree( ChildWindows );
ChildWindows = NULL;
TotalWindows = 0;
}
gui_window *GUIMDIGetWindow( int id )
{
int index;
index = id - GUI_MDI_FIRST_WINDOW;
if( index < MAX_NUM_MDI_WINDOWS ) {
return( MDIWindows[index] );
} else {
return( NULL );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?