Release 0.7

Thu Jan 13 11:45:13 1994  John Richardson <jrichard@cs.uml.edu>

	* [window/win.c]
	Added functions EnableWindow, IsWindowEnabled, and helper 
	WIN_SetSensitive.
	
	* [window/event.c]
	Added checks for WS_DISABLED windows in EVENT_key, EVENT_MotionNotify,
	EVENT_ButtonPress, EVENT_ButtonRelease, EVENT_ConfigureNotify,
	EVENT_FocusIn, EVENT_FocusOut, and EVENT_EnterNotify.  Key and 
	button presses beep for a disabled window.  
	If anyone finds better places for these checks, please tell me.

Jan 17, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [misc/message.c]
	Cleanup on buttons answer value returned.

	* [control/combo.c]
	Now use OBM_COMBO bitmap dropdown button.

Mon Jan 17 21:56:45 1994  Erik Bos (erik@trashcan.hacktic.nl)

	* [misc/comm/c]
	A few bugfixes.

Tue Jan 18 06:36:48 1994  julliard@di.epfl.ch (Alexandre Julliard)

	* [loader/cursor.c]
	Added X cursor for IDC_SIZENS and IDC_SIZEWE.

	* [include/options.h] [misc/main.c]  (New files)
	Rewrote main() function to get rid of Xt application context,
	and added command-line option parsing.

	* [objects/color.c]
	Use of a private map now configurable with command-line option.

	* [windows/defwnd.c]
	Added WM_SYSCOMMAND handling, and better WM_SETCURSOR handling.

	* [windows/event.c]
	Removed ConfigureNotify event handler (no longer needed).

	* [windows/message.c]
	Send WM_SETCURSOR message on mouse events.

	* [windows/nonclient.c]
	Use OEM bitmaps for the drawing of the non-client area.
	Added caption bar buttons handling, and moving and resizing of
	the window via the window frame (bypassing the window manager).

	* [windows/painting.c]
	Bug fix in BeginPaint().

	* [windows/win.c]
	Set the override_redirect flag for windows (to bypass window
	manager).

	* [windows/winpos.c]
	Implemented WindowFromPoint(), ChildWindowFromPoint(),
	BringWindowToTop(), Get/SetInternalWindowPos(),
	Get/SetWindowPlacement().

Mon Jan 17 20:48:24 1994  Bob Amstadt  (bob@pooh)

	* [memory/heap.c]
	Added support for multiple local heaps.
This commit is contained in:
Alexandre Julliard 1994-01-18 23:04:40 +00:00
parent cdd0923710
commit 86a8d0f942
47 changed files with 1438 additions and 3473 deletions

View File

@ -1,3 +1,73 @@
Thu Jan 13 11:45:13 1994 John Richardson <jrichard@cs.uml.edu>
* [window/win.c]
Added functions EnableWindow, IsWindowEnabled, and helper
WIN_SetSensitive.
* [window/event.c]
Added checks for WS_DISABLED windows in EVENT_key, EVENT_MotionNotify,
EVENT_ButtonPress, EVENT_ButtonRelease, EVENT_ConfigureNotify,
EVENT_FocusIn, EVENT_FocusOut, and EVENT_EnterNotify. Key and
button presses beep for a disabled window.
If anyone finds better places for these checks, please tell me.
Jan 17, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [misc/message.c]
Cleanup on buttons answer value returned.
* [control/combo.c]
Now use OBM_COMBO bitmap dropdown button.
Mon Jan 17 21:56:45 1994 Erik Bos (erik@trashcan.hacktic.nl)
* [misc/comm/c]
A few bugfixes.
Tue Jan 18 06:36:48 1994 julliard@di.epfl.ch (Alexandre Julliard)
* [loader/cursor.c]
Added X cursor for IDC_SIZENS and IDC_SIZEWE.
* [include/options.h] [misc/main.c] (New files)
Rewrote main() function to get rid of Xt application context,
and added command-line option parsing.
* [objects/color.c]
Use of a private map now configurable with command-line option.
* [windows/defwnd.c]
Added WM_SYSCOMMAND handling, and better WM_SETCURSOR handling.
* [windows/event.c]
Removed ConfigureNotify event handler (no longer needed).
* [windows/message.c]
Send WM_SETCURSOR message on mouse events.
* [windows/nonclient.c]
Use OEM bitmaps for the drawing of the non-client area.
Added caption bar buttons handling, and moving and resizing of
the window via the window frame (bypassing the window manager).
* [windows/painting.c]
Bug fix in BeginPaint().
* [windows/win.c]
Set the override_redirect flag for windows (to bypass window
manager).
* [windows/winpos.c]
Implemented WindowFromPoint(), ChildWindowFromPoint(),
BringWindowToTop(), Get/SetInternalWindowPos(),
Get/SetWindowPlacement().
Mon Jan 17 20:48:24 1994 Bob Amstadt (bob@pooh)
* [memory/heap.c]
Added support for multiple local heaps.
----------------------------------------------------------------------
Tue Jan 4 13:01:33 1994 David Metcalfe <david@prism.demon.co.uk>
* [window/caret.c]
@ -84,7 +154,6 @@ Tue Jan 11 05:27:45 1994 julliard@di.epfl.ch (Alexandre Julliard
Added sending of the WM_NCPAINT message in SetWindowPos().
Removed the Xt code.
----------------------------------------------------------------------
Sun Jan 2 12:38:53 1994 David Metcalfe <david@prism.demon.co.uk>
* [windows/class.c]

View File

@ -8,7 +8,7 @@ LDFLAGS=
######################################################################
# These definitions are for the top level
TARGET=wine
LIBS=-L. -L/usr/X386/lib -lXext -lXaw -lXt -lXmu -lX11 -lm
LIBS=-L/usr/X386/lib -lX11 -lm
OBJS=if1632/if1632.o controls/controls.o loader/loader.o \
memory/memory.o misc/misc.o objects/objects.o windows/windows.o debugger/debugger.o
SUBDIRS=if1632 controls loader memory misc objects windows debugger

6
README
View File

@ -41,6 +41,12 @@ For example: to run Windows' solitaire:
Have a nice game of solitaire, but be careful. Emulation isn't perfect.
So, occassionally it will crash.
WHAT'S NEW with version 0.7: (see ChangeLog for details)
- Eliminated Xt-dependent code. Thanks to Alexandre and Martin.
- Other bug fixes.
- IsWIndowEnabled() and EnableWindow() now implemented.
- New command line options.
WHAT'S NEW with version 0.6: (see ChangeLog for details)
- Working towards elimination of Xt-dependent code. Thanks to
Alexandre and Martin.

View File

@ -1,9 +1,7 @@
CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR)
OBJS = menu.o caption.o widgets.o button.o \
scroll.o listbox.o combo.o static.o \
SmeMenuButto.o WinLabel.o WinCommand.o \
WinMenuButto.o
scroll.o listbox.o combo.o static.o
default: controls.o

View File

@ -1,117 +0,0 @@
/*
* $XConsortium: SmeMenuButtP.h,v 1.6 89/12/11 15:20:15 kit Exp $
*
* Copyright 1989 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Chris D. Peterson, MIT X Consortium
*
* Modifications for Wine
*
* 8/23/93 David Metcalfe (david@prism.demon.co.uk)
* Added code to translate ampersand to underlined char
*/
/*
* SmeP.h - Private definitions for Sme object
*
*/
#ifndef _XawSmeMenuButtP_h
#define _XawSmeMenuButtP_h
/***********************************************************************
*
* Sme Object Private Data
*
***********************************************************************/
#include <X11/Xaw/SmeP.h>
#include "SmeMenuButto.h"
/************************************************************
*
* New fields for the Sme Object class record.
*
************************************************************/
typedef struct _SmeMenuButtonClassPart {
XtPointer extension;
} SmeMenuButtonClassPart;
/* Full class record declaration */
typedef struct _SmeMenuButtonClassRec {
RectObjClassPart rect_class;
SmeClassPart sme_class;
SmeMenuButtonClassPart sme_bsb_class;
} SmeMenuButtonClassRec;
extern SmeMenuButtonClassRec smeMenuButtonClassRec;
/* New fields for the Sme Object record */
typedef struct {
/* resources */
String label; /* The entry label. */
int vert_space; /* extra vert space to leave, as a percentage
of the font height of the label. */
Pixmap left_bitmap, right_bitmap; /* bitmaps to show. */
Dimension left_margin, right_margin; /* left and right margins. */
Pixel foreground; /* foreground color. */
XFontStruct * font; /* The font to show label in. */
XtJustify justify; /* Justification for the label. */
String menu_name; /* Menu to activate */
Boolean inactive; /* True if can't be selected */
/* private resources. */
Boolean set_values_area_cleared; /* Remember if we need to unhighlight. */
GC norm_gc; /* noral color gc. */
GC rev_gc; /* reverse color gc. */
GC norm_gray_gc; /* Normal color (grayed out) gc. */
GC invert_gc; /* gc for flipping colors. */
Dimension left_bitmap_width; /* size of each bitmap. */
Dimension left_bitmap_height;
Dimension right_bitmap_width;
Dimension right_bitmap_height;
int ul_pos; /* Offset in chars of underlined character */
/* in label */
} SmeMenuButtonPart;
/****************************************************************
*
* Full instance record declaration
*
****************************************************************/
typedef struct _SmeMenuButtonRec {
ObjectPart object;
RectObjPart rectangle;
SmePart sme;
SmeMenuButtonPart sme_bsb;
} SmeMenuButtonRec;
/************************************************************
*
* Private declarations.
*
************************************************************/
#endif /* _XawSmeMenuButtP_h */

View File

@ -1,758 +0,0 @@
/* $XConsortium: SmeMenuButton.c,v 1.16 91/03/15 15:59:41 gildea Exp $ */
/*
* Copyright 1989 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* SmeMenuButton.c - Source code file for BSB Menu Entry object.
*
* Date: September 26, 1989
*
* By: Chris D. Peterson
* MIT X Consortium
* kit@expo.lcs.mit.edu
*
* Modifications for Wine
*
* 8/23/93 David Metcalfe (david@prism.demon.co.uk)
* Added code to translate ampersand to underlined char
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xos.h>
#include <X11/Xmu/Drawing.h>
#include <X11/Xaw/XawInit.h>
#include <X11/Xaw/SimpleMenu.h>
#include "SmeMenuButtP.h"
#include <X11/Xaw/Cardinals.h>
#include <stdio.h>
#define ONE_HUNDRED 100
#define offset(field) XtOffsetOf(SmeMenuButtonRec, sme_bsb.field)
static XtResource resources[] = {
{XtNlabel, XtCLabel, XtRString, sizeof(String),
offset(label), XtRString, NULL},
{XtNvertSpace, XtCVertSpace, XtRInt, sizeof(int),
offset(vert_space), XtRImmediate, (XtPointer) 25},
{XtNleftBitmap, XtCLeftBitmap, XtRBitmap, sizeof(Pixmap),
offset(left_bitmap), XtRImmediate, (XtPointer)None},
{XtNjustify, XtCJustify, XtRJustify, sizeof(XtJustify),
offset(justify), XtRImmediate, (XtPointer) XtJustifyLeft},
{XtNrightBitmap, XtCRightBitmap, XtRBitmap, sizeof(Pixmap),
offset(right_bitmap), XtRImmediate, (XtPointer)None},
{XtNleftMargin, XtCHorizontalMargins, XtRDimension, sizeof(Dimension),
offset(left_margin), XtRImmediate, (XtPointer) 15},
{XtNrightMargin, XtCHorizontalMargins, XtRDimension, sizeof(Dimension),
offset(right_margin), XtRImmediate, (XtPointer) 5},
{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
offset(foreground), XtRString, XtDefaultForeground},
{XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
offset(font), XtRString, XtDefaultFont},
{XtNmenuName, XtCMenuName, XtRString, sizeof(String),
offset(menu_name), XtRString, (XtPointer) NULL},
{XtNinactive, XtCInactive, XtRBoolean, sizeof(Boolean),
offset(inactive), XtRImmediate, (XtPointer) FALSE },
};
#undef offset
/*
* Semi Public function definitions.
*/
static void Redisplay(), Destroy(), Initialize(), FlipColors();
static void ClassInitialize();
static void PopupMenu(), Unhighlight();
static Boolean SetValues();
static XtGeometryResult QueryGeometry();
/*
* Private Function Definitions.
*/
static void GetDefaultSize(), DrawBitmaps(), GetBitmapInfo();
static void CreateGCs(), DestroyGCs();
static void RemoveAmpersand();
#define superclass (&smeClassRec)
SmeMenuButtonClassRec smeMenuButtonClassRec = {
{
/* superclass */ (WidgetClass) superclass,
/* class_name */ "SmeMenuButton",
/* size */ sizeof(SmeMenuButtonRec),
/* class_initializer */ ClassInitialize,
/* class_part_initialize*/ NULL,
/* Class init'ed */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ NULL,
/* actions */ NULL,
/* num_actions */ ZERO,
/* resources */ resources,
/* resource_count */ XtNumber(resources),
/* xrm_class */ NULLQUARK,
/* compress_motion */ FALSE,
/* compress_exposure */ FALSE,
/* compress_enterleave*/ FALSE,
/* visible_interest */ FALSE,
/* destroy */ Destroy,
/* resize */ NULL,
/* expose */ Redisplay,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* set_values_almost */ XtInheritSetValuesAlmost,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* intrinsics version */ XtVersion,
/* callback offsets */ NULL,
/* tm_table */ NULL,
/* query_geometry */ QueryGeometry,
/* display_accelerator*/ NULL,
/* extension */ NULL
},{
/* Menu Entry Fields */
/* highlight */ FlipColors,
/* unhighlight */ Unhighlight,
/* notify */ XtInheritNotify,
/* extension */ NULL
}, {
/* BSB Menu entry Fields */
/* extension */ NULL
}
};
WidgetClass smeMenuButtonObjectClass = (WidgetClass) &smeMenuButtonClassRec;
/************************************************************
*
* Semi-Public Functions.
*
************************************************************/
/* Function Name: ClassInitialize
* Description: Initializes the SmeMenuButtonObject.
* Arguments: none.
* Returns: none.
*/
static void
ClassInitialize()
{
XawInitializeWidgetSet();
XtAddConverter( XtRString, XtRJustify, XmuCvtStringToJustify, NULL, 0 );
}
/* Function Name: Initialize
* Description: Initializes the simple menu widget
* Arguments: request - the widget requested by the argument list.
* new - the new widget with both resource and non
* resource values.
* Returns: none.
*/
/* ARGSUSED */
static void
Initialize(request, new)
Widget request, new;
{
SmeMenuButtonObject entry = (SmeMenuButtonObject) new;
if (entry->sme_bsb.label == NULL)
entry->sme_bsb.label = XtName(new);
else
entry->sme_bsb.label = XtNewString( entry->sme_bsb.label );
RemoveAmpersand(new);
GetDefaultSize(new, &(entry->rectangle.width), &(entry->rectangle.height));
CreateGCs(new);
entry->sme_bsb.left_bitmap_width = entry->sme_bsb.left_bitmap_height = 0;
entry->sme_bsb.right_bitmap_width = entry->sme_bsb.right_bitmap_height = 0;
GetBitmapInfo(new, TRUE); /* Left Bitmap Info */
GetBitmapInfo(new, FALSE); /* Right Bitmap Info */
}
/* Function Name: Destroy
* Description: Called at destroy time, cleans up.
* Arguments: w - the simple menu widget.
* Returns: none.
*/
static void
Destroy(w)
Widget w;
{
SmeMenuButtonObject entry = (SmeMenuButtonObject) w;
DestroyGCs(w);
if (entry->sme_bsb.label != XtName(w))
XtFree(entry->sme_bsb.label);
}
/* Function Name: Redisplay
* Description: Redisplays the contents of the widget.
* Arguments: w - the simple menu widget.
* event - the X event that caused this redisplay.
* region - the region the needs to be repainted.
* Returns: none.
*/
/* ARGSUSED */
static void
Redisplay(w, event, region)
Widget w;
XEvent * event;
Region region;
{
GC gc;
SmeMenuButtonObject entry = (SmeMenuButtonObject) w;
int font_ascent, font_descent, y_loc;
int ul_x_loc, ul_y_loc, ul_width;
entry->sme_bsb.set_values_area_cleared = FALSE;
font_ascent = entry->sme_bsb.font->max_bounds.ascent;
font_descent = entry->sme_bsb.font->max_bounds.descent;
y_loc = entry->rectangle.y;
if (XtIsSensitive(w) && XtIsSensitive( XtParent(w) ) ) {
if ( w == XawSimpleMenuGetActiveEntry(XtParent(w)) ) {
XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
entry->sme_bsb.norm_gc, 0, y_loc,
(unsigned int) entry->rectangle.width,
(unsigned int) entry->rectangle.height);
gc = entry->sme_bsb.rev_gc;
}
else
gc = entry->sme_bsb.norm_gc;
}
else
gc = entry->sme_bsb.norm_gray_gc;
if (entry->sme_bsb.label != NULL) {
int x_loc = entry->sme_bsb.left_margin;
int len = strlen(entry->sme_bsb.label);
char * label = entry->sme_bsb.label;
switch(entry->sme_bsb.justify) {
int width, t_width;
case XtJustifyCenter:
t_width = XTextWidth(entry->sme_bsb.font, label, len);
width = entry->rectangle.width - (entry->sme_bsb.left_margin +
entry->sme_bsb.right_margin);
x_loc += (width - t_width)/2;
break;
case XtJustifyRight:
t_width = XTextWidth(entry->sme_bsb.font, label, len);
x_loc = entry->rectangle.width - (entry->sme_bsb.right_margin +
t_width);
break;
case XtJustifyLeft:
default:
break;
}
y_loc += ((int)entry->rectangle.height -
(font_ascent + font_descent)) / 2 + font_ascent;
XDrawString(XtDisplayOfObject(w), XtWindowOfObject(w), gc,
x_loc, y_loc, label, len);
if (entry->sme_bsb.ul_pos != -1)
{
ul_x_loc = x_loc + XTextWidth(entry->sme_bsb.font,
entry->sme_bsb.label, entry->sme_bsb.ul_pos);
ul_y_loc = entry->rectangle.y + (entry->rectangle.height +
font_ascent + font_descent) / 2;
ul_width = XTextWidth(entry->sme_bsb.font,
entry->sme_bsb.label + entry->sme_bsb.ul_pos, 1);
XDrawLine(XtDisplayOfObject(w), XtWindowOfObject(w), gc,
ul_x_loc, ul_y_loc, ul_x_loc + ul_width - 1, ul_y_loc);
}
}
DrawBitmaps(w, gc);
}
/* Function Name: SetValues
* Description: Relayout the menu when one of the resources is changed.
* Arguments: current - current state of the widget.
* request - what was requested.
* new - what the widget will become.
* Returns: none
*/
/* ARGSUSED */
static Boolean
SetValues(current, request, new)
Widget current, request, new;
{
SmeMenuButtonObject entry = (SmeMenuButtonObject) new;
SmeMenuButtonObject old_entry = (SmeMenuButtonObject) current;
Boolean ret_val = FALSE;
if (old_entry->sme_bsb.label != entry->sme_bsb.label) {
if (old_entry->sme_bsb.label != XtName( new ) )
XtFree( (char *) old_entry->sme_bsb.label );
if (entry->sme_bsb.label != XtName(new) )
entry->sme_bsb.label = XtNewString( entry->sme_bsb.label );
RemoveAmpersand(new);
ret_val = True;
}
if (entry->rectangle.sensitive != old_entry->rectangle.sensitive )
ret_val = TRUE;
if (entry->sme_bsb.left_bitmap != old_entry->sme_bsb.left_bitmap) {
GetBitmapInfo(new, TRUE);
ret_val = TRUE;
}
if (entry->sme_bsb.right_bitmap != old_entry->sme_bsb.right_bitmap) {
GetBitmapInfo(new, FALSE);
ret_val = TRUE;
}
if ( (old_entry->sme_bsb.font != entry->sme_bsb.font) ||
(old_entry->sme_bsb.foreground != entry->sme_bsb.foreground) ) {
DestroyGCs(current);
CreateGCs(new);
ret_val = TRUE;
}
if (ret_val) {
GetDefaultSize(new,
&(entry->rectangle.width), &(entry->rectangle.height));
entry->sme_bsb.set_values_area_cleared = TRUE;
}
return(ret_val);
}
/* Function Name: QueryGeometry.
* Description: Returns the preferred geometry for this widget.
* Arguments: w - the menu entry object.
* itended, return_val - the intended and return geometry info.
* Returns: A Geometry Result.
*
* See the Intrinsics manual for details on what this function is for.
*
* I just return the height and width of the label plus the margins.
*/
static XtGeometryResult
QueryGeometry(w, intended, return_val)
Widget w;
XtWidgetGeometry *intended, *return_val;
{
SmeMenuButtonObject entry = (SmeMenuButtonObject) w;
Dimension width, height;
XtGeometryResult ret_val = XtGeometryYes;
XtGeometryMask mode = intended->request_mode;
GetDefaultSize(w, &width, &height );
if ( ((mode & CWWidth) && (intended->width != width)) ||
!(mode & CWWidth) ) {
return_val->request_mode |= CWWidth;
return_val->width = width;
ret_val = XtGeometryAlmost;
}
if ( ((mode & CWHeight) && (intended->height != height)) ||
!(mode & CWHeight) ) {
return_val->request_mode |= CWHeight;
return_val->height = height;
ret_val = XtGeometryAlmost;
}
if (ret_val == XtGeometryAlmost) {
mode = return_val->request_mode;
if ( ((mode & CWWidth) && (width == entry->rectangle.width)) &&
((mode & CWHeight) && (height == entry->rectangle.height)) )
return(XtGeometryNo);
}
return(ret_val);
}
/* Function Name: FlipColors
* Description: Invert the colors of the current entry.
* Arguments: w - the bsb menu entry widget.
* Returns: none.
*/
static void
FlipColors(w)
Widget w;
{
SmeMenuButtonObject entry = (SmeMenuButtonObject) w;
if (entry->sme_bsb.set_values_area_cleared || entry->sme_bsb.inactive)
return;
XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
entry->sme_bsb.invert_gc, 0, (int) entry->rectangle.y,
(unsigned int) entry->rectangle.width,
(unsigned int) entry->rectangle.height);
}
/************************************************************
*
* Private Functions.
*
************************************************************/
/* Function Name: GetDefaultSize
* Description: Calculates the Default (preferred) size of
* this menu entry.
* Arguments: w - the menu entry widget.
* width, height - default sizes (RETURNED).
* Returns: none.
*/
static void
GetDefaultSize(w, width, height)
Widget w;
Dimension * width, * height;
{
SmeMenuButtonObject entry = (SmeMenuButtonObject) w;
if (entry->sme_bsb.label == NULL)
*width = 0;
else
*width = XTextWidth(entry->sme_bsb.font, entry->sme_bsb.label,
strlen(entry->sme_bsb.label));
*width += entry->sme_bsb.left_margin + entry->sme_bsb.right_margin;
*height = (entry->sme_bsb.font->max_bounds.ascent +
entry->sme_bsb.font->max_bounds.descent);
*height = ((int)*height * ( ONE_HUNDRED +
entry->sme_bsb.vert_space )) / ONE_HUNDRED;
}
/* Function Name: DrawBitmaps
* Description: Draws left and right bitmaps.
* Arguments: w - the simple menu widget.
* gc - graphics context to use for drawing.
* Returns: none
*/
static void
DrawBitmaps(w, gc)
Widget w;
GC gc;
{
int x_loc, y_loc;
SmeMenuButtonObject entry = (SmeMenuButtonObject) w;
if ( (entry->sme_bsb.left_bitmap == None) &&
(entry->sme_bsb.right_bitmap == None) ) return;
/*
* Draw Left Bitmap.
*/
if (entry->sme_bsb.left_bitmap != None) {
x_loc = (int)(entry->sme_bsb.left_margin -
entry->sme_bsb.left_bitmap_width) / 2;
y_loc = entry->rectangle.y + (int)(entry->rectangle.height -
entry->sme_bsb.left_bitmap_height) / 2;
XCopyPlane(XtDisplayOfObject(w), entry->sme_bsb.left_bitmap,
XtWindowOfObject(w), gc, 0, 0,
entry->sme_bsb.left_bitmap_width,
entry->sme_bsb.left_bitmap_height, x_loc, y_loc, 1);
}
/*
* Draw Right Bitmap.
*/
if (entry->sme_bsb.right_bitmap != None) {
x_loc = entry->rectangle.width -
(int)(entry->sme_bsb.right_margin +
entry->sme_bsb.right_bitmap_width) / 2;
y_loc = entry->rectangle.y + (int)(entry->rectangle.height -
entry->sme_bsb.right_bitmap_height) / 2;
XCopyPlane(XtDisplayOfObject(w), entry->sme_bsb.right_bitmap,
XtWindowOfObject(w), gc, 0, 0,
entry->sme_bsb.right_bitmap_width,
entry->sme_bsb.right_bitmap_height, x_loc, y_loc, 1);
}
}
/* Function Name: GetBitmapInfo
* Description: Gets the bitmap information from either of the bitmaps.
* Arguments: w - the bsb menu entry widget.
* is_left - TRUE if we are testing left bitmap,
* FALSE if we are testing the right bitmap.
* Returns: none
*/
static void
GetBitmapInfo(w, is_left)
Widget w;
Boolean is_left;
{
SmeMenuButtonObject entry = (SmeMenuButtonObject) w;
unsigned int depth, bw;
Window root;
int x, y;
unsigned int width, height;
char buf[BUFSIZ];
if (is_left) {
if (entry->sme_bsb.left_bitmap != None) {
if (!XGetGeometry(XtDisplayOfObject(w),
entry->sme_bsb.left_bitmap, &root,
&x, &y, &width, &height, &bw, &depth)) {
sprintf(buf, "SmeMenuButton Object: %s %s \"%s\".", "Could not",
"get Left Bitmap geometry information for menu entry ",
XtName(w));
XtAppError(XtWidgetToApplicationContext(w), buf);
}
if (depth != 1) {
sprintf(buf, "SmeMenuButton Object: %s \"%s\"%s.",
"Left Bitmap of entry ",
XtName(w), " is not one bit deep.");
XtAppError(XtWidgetToApplicationContext(w), buf);
}
entry->sme_bsb.left_bitmap_width = (Dimension) width;
entry->sme_bsb.left_bitmap_height = (Dimension) height;
}
}
else if (entry->sme_bsb.right_bitmap != None) {
if (!XGetGeometry(XtDisplayOfObject(w),
entry->sme_bsb.right_bitmap, &root,
&x, &y, &width, &height, &bw, &depth)) {
sprintf(buf, "SmeMenuButton Object: %s %s \"%s\".", "Could not",
"get Right Bitmap geometry information for menu entry ",
XtName(w));
XtAppError(XtWidgetToApplicationContext(w), buf);
}
if (depth != 1) {
sprintf(buf, "SmeMenuButton Object: %s \"%s\"%s.",
"Right Bitmap of entry ", XtName(w),
" is not one bit deep.");
XtAppError(XtWidgetToApplicationContext(w), buf);
}
entry->sme_bsb.right_bitmap_width = (Dimension) width;
entry->sme_bsb.right_bitmap_height = (Dimension) height;
}
}
/* Function Name: CreateGCs
* Description: Creates all gc's for the simple menu widget.
* Arguments: w - the simple menu widget.
* Returns: none.
*/
static void
CreateGCs(w)
Widget w;
{
SmeMenuButtonObject entry = (SmeMenuButtonObject) w;
XGCValues values;
XtGCMask mask;
values.foreground = XtParent(w)->core.background_pixel;
values.background = entry->sme_bsb.foreground;
values.font = entry->sme_bsb.font->fid;
values.graphics_exposures = FALSE;
mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
entry->sme_bsb.rev_gc = XtGetGC(w, mask, &values);
values.foreground = entry->sme_bsb.foreground;
values.background = XtParent(w)->core.background_pixel;
entry->sme_bsb.norm_gc = XtGetGC(w, mask, &values);
values.fill_style = FillTiled;
values.tile = XmuCreateStippledPixmap(XtScreenOfObject(w),
entry->sme_bsb.foreground,
XtParent(w)->core.background_pixel,
XtParent(w)->core.depth);
values.graphics_exposures = FALSE;
mask |= GCTile | GCFillStyle;
entry->sme_bsb.norm_gray_gc = XtGetGC(w, mask, &values);
values.foreground ^= values.background;
values.background = 0;
values.function = GXxor;
mask = GCForeground | GCBackground | GCGraphicsExposures | GCFunction;
entry->sme_bsb.invert_gc = XtGetGC(w, mask, &values);
}
/* Function Name: DestroyGCs
* Description: Removes all gc's for the simple menu widget.
* Arguments: w - the simple menu widget.
* Returns: none.
*/
static void
DestroyGCs(w)
Widget w;
{
SmeMenuButtonObject entry = (SmeMenuButtonObject) w;
XtReleaseGC(w, entry->sme_bsb.norm_gc);
XtReleaseGC(w, entry->sme_bsb.norm_gray_gc);
XtReleaseGC(w, entry->sme_bsb.rev_gc);
XtReleaseGC(w, entry->sme_bsb.invert_gc);
}
static void
PopupMenu(w)
Widget w;
{
SmeMenuButtonObject mbw = (SmeMenuButtonObject) w;
Widget menu, temp;
Arg arglist[2];
Cardinal num_args;
int menu_x, menu_y, menu_width, menu_height, button_width;
Position button_x, button_y;
if (mbw->sme_bsb.menu_name == NULL || strlen(mbw->sme_bsb.menu_name) == 0)
return;
temp = w;
while(temp != NULL) {
menu = XtNameToWidget(temp, mbw->sme_bsb.menu_name);
if (menu == NULL)
temp = XtParent(temp);
else
break;
}
if (menu == NULL) {
char error_buf[BUFSIZ];
sprintf(error_buf, "MenuButton: %s %s.",
"Could not find menu widget named", mbw->sme_bsb.menu_name);
XtAppWarning(XtWidgetToApplicationContext(w), error_buf);
return;
}
if (!XtIsRealized(menu))
XtRealizeWidget(menu);
menu_width = menu->core.width + 2 * menu->core.border_width;
button_width = mbw->rectangle.width + 2 * mbw->rectangle.border_width;
menu_height = menu->core.height + 2 * menu->core.border_width;
XtTranslateCoords(w, 0, 0, &button_x, &button_y);
menu_x = button_x + button_width;
menu_y = button_y;
if (menu_x >= 0) {
int scr_width = WidthOfScreen(XtScreen(menu));
if (menu_x + menu_width > scr_width)
menu_x = scr_width - menu_width;
}
if (menu_x < 0)
menu_x = 0;
if (menu_y >= 0) {
int scr_height = HeightOfScreen(XtScreen(menu));
if (menu_y + menu_height > scr_height)
menu_y = scr_height - menu_height;
}
if (menu_y < 0)
menu_y = 0;
num_args = 0;
XtSetArg(arglist[num_args], XtNx, menu_x); num_args++;
XtSetArg(arglist[num_args], XtNy, menu_y); num_args++;
XtSetValues(menu, arglist, num_args);
XtPopupSpringLoaded(menu);
}
static void
Unhighlight(w)
Widget w;
{
SmeMenuButtonObject mbw = (SmeMenuButtonObject) w;
Display *display;
Screen *screen;
Window win, rootwin;
int rootwin_x, rootwin_y;
int win_x, win_y;
unsigned int mask;
Position left, right, top, bottom;
if (mbw->sme_bsb.inactive)
return;
display = XtDisplayOfObject(w);
screen = XtScreenOfObject(w);
XQueryPointer(display, RootWindowOfScreen(screen),
&rootwin, &win, &rootwin_x, &rootwin_y,
&win_x, &win_y, &mask);
XtTranslateCoords(w, 0, 0, &left, &top);
XtTranslateCoords(w, mbw->rectangle.width, mbw->rectangle.height,
&right, &bottom);
if (rootwin_x >= right && rootwin_y >= top && rootwin_y < bottom)
{
PopupMenu(w);
}
FlipColors(w);
}
static void
RemoveAmpersand(w)
Widget w;
{
SmeMenuButtonObject entry = (SmeMenuButtonObject) w;
entry->sme_bsb.ul_pos = strcspn(entry->sme_bsb.label, "&");
if (entry->sme_bsb.ul_pos == strlen(entry->sme_bsb.label))
{
entry->sme_bsb.ul_pos = -1;
return;
}
/* Remove ampersand from label */
strcpy(entry->sme_bsb.label + entry->sme_bsb.ul_pos,
entry->sme_bsb.label + entry->sme_bsb.ul_pos + 1);
}

View File

@ -1,100 +0,0 @@
/*
* $XConsortium: SmeMenuButton.h,v 1.5 89/12/11 15:20:14 kit Exp $
*
* Copyright 1989 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* SmeMenuButton.h - Public Header file for SmeMenuButton object.
*
* This is the public header file for the Athena BSB Sme object.
* It is intended to be used with the simple menu widget. This object
* provides bitmap - string - bitmap style entries.
*
* Date: April 3, 1989
*
* By: Chris D. Peterson
* MIT X Consortium
* kit@expo.lcs.mit.edu
*
* Modifications for Wine
*
* 8/23/93 David Metcalfe (david@prism.demon.co.uk)
* Added code to translate ampersand to underlined char
*/
#ifndef _SmeMenuButto_h
#define _SmeMenuButto_h
#include <X11/Xmu/Converters.h>
#include <X11/Xaw/Sme.h>
/****************************************************************
*
* SmeMenuButton object
*
****************************************************************/
/* BSB Menu Entry Resources:
Name Class RepType Default Value
---- ----- ------- -------------
callback Callback Callback NULL
destroyCallback Callback Pointer NULL
font Font XFontStruct * XtDefaultFont
foreground Foreground Pixel XtDefaultForeground
height Height Dimension 0
label Label String Name of entry
leftBitmap LeftBitmap Pixmap None
leftMargin HorizontalMargins Dimension 4
rightBitmap RightBitmap Pixmap None
rightMargin HorizontalMargins Dimension 4
sensitive Sensitive Boolean True
vertSpace VertSpace int 25
width Width Dimension 0
x Position Position 0n
y Position Position 0
menuName MenuName String "menu"
inactive Inactive Boolean False
*/
typedef struct _SmeMenuButtonClassRec *SmeMenuButtonObjectClass;
typedef struct _SmeMenuButtonRec *SmeMenuButtonObject;
extern WidgetClass smeMenuButtonObjectClass;
#define XtNleftBitmap "leftBitmap"
#define XtNleftMargin "leftMargin"
#define XtNrightBitmap "rightBitmap"
#define XtNrightMargin "rightMargin"
#define XtNvertSpace "vertSpace"
#define XtNmenuName "menuName"
#define XtNinactive "inactive"
#define XtCLeftBitmap "LeftBitmap"
#define XtCHorizontalMargins "HorizontalMargins"
#define XtCRightBitmap "RightBitmap"
#define XtCVertSpace "VertSpace"
#define XtCMenuName "MenuName"
#define XtCInactive "Inactive"
#endif /* _SmeMenuButto_h */

View File

@ -1,567 +0,0 @@
/***********************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/*
* Modifications for Wine
*
* 8/27/93 David Metcalfe (david@prism.demon.co.uk)
* Converted to WinCommand
*/
/*
* WinCommand.c - WinCommand button widget
*/
#include <stdio.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xmu/Misc.h>
#include <X11/Xaw/XawInit.h>
#include "WinCommandP.h"
#include <X11/Xmu/Converters.h>
#define DEFAULT_HIGHLIGHT_THICKNESS 2
#define DEFAULT_SHAPE_HIGHLIGHT 32767
/****************************************************************
*
* Full class record constant
*
****************************************************************/
/* Private Data */
static char defaultTranslations[] =
"<EnterWindow>: highlight() \n\
<LeaveWindow>: reset() \n\
<Btn1Down>: set() \n\
<Btn1Up>: notify() unset() ";
#define offset(field) XtOffsetOf(WinCommandRec, field)
static XtResource resources[] = {
{XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
offset(wincommand.callbacks), XtRCallback, (XtPointer)NULL},
{XtNhighlightThickness, XtCThickness, XtRDimension, sizeof(Dimension),
offset(wincommand.highlight_thickness), XtRImmediate,
(XtPointer) DEFAULT_SHAPE_HIGHLIGHT},
{XtNshapeStyle, XtCShapeStyle, XtRShapeStyle, sizeof(int),
offset(wincommand.shape_style), XtRImmediate,
(XtPointer)XawShapeRectangle},
{XtNcornerRoundPercent, XtCCornerRoundPercent,
XtRDimension, sizeof(Dimension),
offset(wincommand.corner_round), XtRImmediate, (XtPointer) 25},
};
#undef offset
static Boolean SetValues();
static void Initialize(), Redisplay(), Set(), Reset(), Notify(), Unset();
static void Highlight(), Unhighlight(), Destroy(), PaintWinCommandWidget();
static void ClassInitialize();
static Boolean ShapeButton();
static void Realize(), Resize();
static XtActionsRec actionsList[] = {
{"set", Set},
{"notify", Notify},
{"highlight", Highlight},
{"reset", Reset},
{"unset", Unset},
{"unhighlight", Unhighlight}
};
#define SuperClass ((WinLabelWidgetClass)&winLabelClassRec)
WinCommandClassRec winCommandClassRec = {
{
(WidgetClass) SuperClass, /* superclass */
"WinCommand", /* class_name */
sizeof(WinCommandRec), /* size */
ClassInitialize, /* class_initialize */
NULL, /* class_part_initialize */
FALSE, /* class_inited */
Initialize, /* initialize */
NULL, /* initialize_hook */
Realize, /* realize */
actionsList, /* actions */
XtNumber(actionsList), /* num_actions */
resources, /* resources */
XtNumber(resources), /* resource_count */
NULLQUARK, /* xrm_class */
FALSE, /* compress_motion */
TRUE, /* compress_exposure */
TRUE, /* compress_enterleave */
FALSE, /* visible_interest */
Destroy, /* destroy */
Resize, /* resize */
Redisplay, /* expose */
SetValues, /* set_values */
NULL, /* set_values_hook */
XtInheritSetValuesAlmost, /* set_values_almost */
NULL, /* get_values_hook */
NULL, /* accept_focus */
XtVersion, /* version */
NULL, /* callback_private */
defaultTranslations, /* tm_table */
XtInheritQueryGeometry, /* query_geometry */
XtInheritDisplayAccelerator, /* display_accelerator */
NULL /* extension */
}, /* CoreClass fields initialization */
{
XtInheritChangeSensitive /* change_sensitive */
}, /* SimpleClass fields initialization */
{
0, /* field not used */
}, /* WinLabelClass fields initialization */
{
0, /* field not used */
}, /* WinCommandClass fields initialization */
};
/* for public consumption */
WidgetClass winCommandWidgetClass = (WidgetClass) &winCommandClassRec;
/****************************************************************
*
* Private Procedures
*
****************************************************************/
static GC
Get_GC(cbw, fg, bg)
WinCommandWidget cbw;
Pixel fg, bg;
{
XGCValues values;
values.foreground = fg;
values.background = bg;
values.font = cbw->winlabel.font->fid;
values.cap_style = CapProjecting;
if (cbw->wincommand.highlight_thickness > 1 )
values.line_width = cbw->wincommand.highlight_thickness;
else
values.line_width = 0;
return XtGetGC((Widget)cbw,
(GCForeground|GCBackground|GCFont|GCLineWidth|GCCapStyle),
&values);
}
/* ARGSUSED */
static void
Initialize(request, new, args, num_args)
Widget request, new;
ArgList args; /* unused */
Cardinal *num_args; /* unused */
{
WinCommandWidget cbw = (WinCommandWidget) new;
int shape_event_base, shape_error_base;
if (cbw->wincommand.shape_style != XawShapeRectangle
&& !XShapeQueryExtension(XtDisplay(new), &shape_event_base,
&shape_error_base))
cbw->wincommand.shape_style = XawShapeRectangle;
if (cbw->wincommand.highlight_thickness == DEFAULT_SHAPE_HIGHLIGHT) {
if (cbw->wincommand.shape_style != XawShapeRectangle)
cbw->wincommand.highlight_thickness = 0;
else
cbw->wincommand.highlight_thickness = DEFAULT_HIGHLIGHT_THICKNESS;
}
cbw->wincommand.normal_GC = Get_GC(cbw, cbw->winlabel.foreground,
cbw->core.background_pixel);
cbw->wincommand.inverse_GC = Get_GC(cbw, cbw->core.background_pixel,
cbw->winlabel.foreground);
XtReleaseGC(new, cbw->winlabel.normal_GC);
cbw->winlabel.normal_GC = cbw->wincommand.normal_GC;
cbw->wincommand.set = FALSE;
cbw->wincommand.highlighted = HighlightNone;
}
static Region
HighlightRegion(cbw)
WinCommandWidget cbw;
{
static Region outerRegion = NULL, innerRegion, emptyRegion;
XRectangle rect;
if (cbw->wincommand.highlight_thickness == 0 ||
cbw->wincommand.highlight_thickness >
(Dimension) ((Dimension) Min(cbw->core.width, cbw->core.height)/2))
return(NULL);
if (outerRegion == NULL) {
/* save time by allocating scratch regions only once. */
outerRegion = XCreateRegion();
innerRegion = XCreateRegion();
emptyRegion = XCreateRegion();
}
rect.x = rect.y = 0;
rect.width = cbw->core.width;
rect.height = cbw->core.height;
XUnionRectWithRegion( &rect, emptyRegion, outerRegion );
rect.x = rect.y = cbw->wincommand.highlight_thickness;
rect.width -= cbw->wincommand.highlight_thickness * 2;
rect.height -= cbw->wincommand.highlight_thickness * 2;
XUnionRectWithRegion( &rect, emptyRegion, innerRegion );
XSubtractRegion( outerRegion, innerRegion, outerRegion );
return outerRegion;
}
/***************************
*
* Action Procedures
*
***************************/
/* ARGSUSED */
static void
Set(w,event,params,num_params)
Widget w;
XEvent *event;
String *params; /* unused */
Cardinal *num_params; /* unused */
{
WinCommandWidget cbw = (WinCommandWidget)w;
if (cbw->wincommand.set)
return;
cbw->wincommand.set= TRUE;
if (XtIsRealized(w))
PaintWinCommandWidget(w, (Region) NULL, TRUE);
}
/* ARGSUSED */
static void
Unset(w,event,params,num_params)
Widget w;
XEvent *event;
String *params; /* unused */
Cardinal *num_params;
{
WinCommandWidget cbw = (WinCommandWidget)w;
if (!cbw->wincommand.set)
return;
cbw->wincommand.set = FALSE;
if (XtIsRealized(w)) {
XClearWindow(XtDisplay(w), XtWindow(w));
PaintWinCommandWidget(w, (Region) NULL, TRUE);
}
}
/* ARGSUSED */
static void
Reset(w,event,params,num_params)
Widget w;
XEvent *event;
String *params; /* unused */
Cardinal *num_params; /* unused */
{
WinCommandWidget cbw = (WinCommandWidget)w;
if (cbw->wincommand.set) {
cbw->wincommand.highlighted = HighlightNone;
Unset(w, event, params, num_params);
}
else
Unhighlight(w, event, params, num_params);
}
/* ARGSUSED */
static void
Highlight(w,event,params,num_params)
Widget w;
XEvent *event;
String *params;
Cardinal *num_params;
{
WinCommandWidget cbw = (WinCommandWidget)w;
if ( *num_params == (Cardinal) 0)
cbw->wincommand.highlighted = HighlightWhenUnset;
else {
if ( *num_params != (Cardinal) 1)
XtWarning("Too many parameters passed to highlight action table.");
switch (params[0][0]) {
case 'A':
case 'a':
cbw->wincommand.highlighted = HighlightAlways;
break;
default:
cbw->wincommand.highlighted = HighlightWhenUnset;
break;
}
}
if (XtIsRealized(w))
PaintWinCommandWidget(w, HighlightRegion(cbw), TRUE);
}
/* ARGSUSED */
static void
Unhighlight(w,event,params,num_params)
Widget w;
XEvent *event;
String *params; /* unused */
Cardinal *num_params; /* unused */
{
WinCommandWidget cbw = (WinCommandWidget)w;
cbw->wincommand.highlighted = HighlightNone;
if (XtIsRealized(w))
PaintWinCommandWidget(w, HighlightRegion(cbw), TRUE);
}
/* ARGSUSED */
static void
Notify(w,event,params,num_params)
Widget w;
XEvent *event;
String *params; /* unused */
Cardinal *num_params; /* unused */
{
WinCommandWidget cbw = (WinCommandWidget)w;
/* check to be sure state is still Set so that user can cancel
the action (e.g. by moving outside the window, in the default
bindings.
*/
if (cbw->wincommand.set)
XtCallCallbackList(w, cbw->wincommand.callbacks, NULL);
}
/*
* Repaint the widget window
*/
/************************
*
* REDISPLAY (DRAW)
*
************************/
/* ARGSUSED */
static void
Redisplay(w, event, region)
Widget w;
XEvent *event;
Region region;
{
PaintWinCommandWidget(w, region, FALSE);
}
/* Function Name: PaintWinCommandWidget
* Description: Paints the wincommand widget.
* Arguments: w - the wincommand widget.
* region - region to paint (passed to the superclass).
* change - did it change either set or highlight state?
* Returns: none
*/
static void
PaintWinCommandWidget(w, region, change)
Widget w;
Region region;
Boolean change;
{
WinCommandWidget cbw = (WinCommandWidget) w;
Boolean very_thick;
GC norm_gc, rev_gc;
very_thick = cbw->wincommand.highlight_thickness >
(Dimension)((Dimension) Min(cbw->core.width,
cbw->core.height)/2);
if (cbw->wincommand.set) {
cbw->winlabel.normal_GC = cbw->wincommand.inverse_GC;
XFillRectangle(XtDisplay(w), XtWindow(w), cbw->wincommand.normal_GC,
0, 0, cbw->core.width, cbw->core.height);
region = NULL; /* Force label to repaint text. */
}
else
cbw->winlabel.normal_GC = cbw->wincommand.normal_GC;
if (cbw->wincommand.highlight_thickness <= 0)
{
(*SuperClass->core_class.expose) (w, (XEvent *) NULL, region);
return;
}
/*
* If we are set then use the same colors as if we are not highlighted.
*/
if (cbw->wincommand.set == (cbw->wincommand.highlighted == HighlightNone)) {
norm_gc = cbw->wincommand.inverse_GC;
rev_gc = cbw->wincommand.normal_GC;
}
else {
norm_gc = cbw->wincommand.normal_GC;
rev_gc = cbw->wincommand.inverse_GC;
}
if ( !( (!change && (cbw->wincommand.highlighted == HighlightNone)) ||
((cbw->wincommand.highlighted == HighlightWhenUnset) &&
(cbw->wincommand.set))) ) {
if (very_thick) {
cbw->winlabel.normal_GC = norm_gc; /* Give the label the right GC. */
XFillRectangle(XtDisplay(w),XtWindow(w), rev_gc,
0, 0, cbw->core.width, cbw->core.height);
}
else {
/* wide lines are centered on the path, so indent it */
int offset = cbw->wincommand.highlight_thickness/2;
XDrawRectangle(XtDisplay(w),XtWindow(w), rev_gc, offset, offset,
cbw->core.width - cbw->wincommand.highlight_thickness,
cbw->core.height - cbw->wincommand.highlight_thickness);
}
}
(*SuperClass->core_class.expose) (w, (XEvent *) NULL, region);
}
static void
Destroy(w)
Widget w;
{
WinCommandWidget cbw = (WinCommandWidget) w;
/* so WinLabel can release it */
if (cbw->winlabel.normal_GC == cbw->wincommand.normal_GC)
XtReleaseGC( w, cbw->wincommand.inverse_GC );
else
XtReleaseGC( w, cbw->wincommand.normal_GC );
}
/*
* Set specified arguments into widget
*/
/* ARGSUSED */
static Boolean
SetValues (current, request, new)
Widget current, request, new;
{
WinCommandWidget oldcbw = (WinCommandWidget) current;
WinCommandWidget cbw = (WinCommandWidget) new;
Boolean redisplay = False;
if ( oldcbw->core.sensitive != cbw->core.sensitive && !cbw->core.sensitive) {
/* about to become insensitive */
cbw->wincommand.set = FALSE;
cbw->wincommand.highlighted = HighlightNone;
redisplay = TRUE;
}
if ( (oldcbw->winlabel.foreground != cbw->winlabel.foreground) ||
(oldcbw->core.background_pixel != cbw->core.background_pixel) ||
(oldcbw->wincommand.highlight_thickness !=
cbw->wincommand.highlight_thickness) ||
(oldcbw->winlabel.font != cbw->winlabel.font) )
{
if (oldcbw->winlabel.normal_GC == oldcbw->wincommand.normal_GC)
/* WinLabel has release one of these */
XtReleaseGC(new, cbw->wincommand.inverse_GC);
else
XtReleaseGC(new, cbw->wincommand.normal_GC);
cbw->wincommand.normal_GC = Get_GC(cbw, cbw->winlabel.foreground,
cbw->core.background_pixel);
cbw->wincommand.inverse_GC = Get_GC(cbw, cbw->core.background_pixel,
cbw->winlabel.foreground);
XtReleaseGC(new, cbw->winlabel.normal_GC);
cbw->winlabel.normal_GC = (cbw->wincommand.set
? cbw->wincommand.inverse_GC
: cbw->wincommand.normal_GC);
redisplay = True;
}
if ( XtIsRealized(new)
&& oldcbw->wincommand.shape_style != cbw->wincommand.shape_style
&& !ShapeButton(cbw, TRUE))
{
cbw->wincommand.shape_style = oldcbw->wincommand.shape_style;
}
return (redisplay);
}
static void ClassInitialize()
{
XawInitializeWidgetSet();
XtSetTypeConverter( XtRString, XtRShapeStyle, XmuCvtStringToShapeStyle,
NULL, 0, XtCacheNone, NULL );
}
static Boolean
ShapeButton(cbw, checkRectangular)
WinCommandWidget cbw;
Boolean checkRectangular;
{
Dimension corner_size;
if ( (cbw->wincommand.shape_style == XawShapeRoundedRectangle) ) {
corner_size = (cbw->core.width < cbw->core.height) ? cbw->core.width
: cbw->core.height;
corner_size = (int) (corner_size * cbw->wincommand.corner_round) / 100;
}
if (checkRectangular || cbw->wincommand.shape_style != XawShapeRectangle) {
if (!XmuReshapeWidget((Widget) cbw, cbw->wincommand.shape_style,
corner_size, corner_size)) {
cbw->wincommand.shape_style = XawShapeRectangle;
return(False);
}
}
return(TRUE);
}
static void Realize(w, valueMask, attributes)
Widget w;
Mask *valueMask;
XSetWindowAttributes *attributes;
{
(*winCommandWidgetClass->core_class.superclass->core_class.realize)
(w, valueMask, attributes);
ShapeButton( (WinCommandWidget) w, FALSE);
}
static void Resize(w)
Widget w;
{
if (XtIsRealized(w))
ShapeButton( (WinCommandWidget) w, FALSE);
(*winCommandWidgetClass->core_class.superclass->core_class.resize)(w);
}

View File

@ -1,100 +0,0 @@
/***********************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/*
* Modifications for Wine
*
* 8/27/93 David Metcalfe (david@prism.demon.co.uk)
* Converted to WinCommand
*/
#ifndef _WinCommand_h
#define _WinCommand_h
#include "WinLabel.h"
/* Command widget resources:
Name Class RepType Default Value
---- ----- ------- -------------
accelerators Accelerators AcceleratorTable NULL
ancestorSensitive AncestorSensitive Boolean True
background Background Pixel XtDefaultBackground
backgroundPixmap Pixmap Pixmap XtUnspecifiedPixmap
bitmap Pixmap Pixmap None
borderColor BorderColor Pixel XtDefaultForeground
borderPixmap Pixmap Pixmap XtUnspecifiedPixmap
borderWidth BorderWidth Dimension 1
callback Callback XtCallbackList NULL
colormap Colormap Colormap parent's colormap
cornerRoundPercent CornerRoundPercent Dimension 25
cursor Cursor Cursor None
cursorName Cursor String NULL
depth Depth int parent's depth
destroyCallback Callback XtCallbackList NULL
encoding Encoding UnsignedChar XawTextEncoding8bit
font Font XFontStruct* XtDefaultFont
foreground Foreground Pixel XtDefaultForeground
height Height Dimension text height
highlightThickness Thickness Dimension 0 if shaped, else 2
insensitiveBorder Insensitive Pixmap Gray
internalHeight Height Dimension 2
internalWidth Width Dimension 4
justify Justify XtJustify XtJustifyCenter
label Label String NULL
leftBitmap LeftBitmap Pixmap None
mappedWhenManaged MappedWhenManaged Boolean True
pointerColor Foreground Pixel XtDefaultForeground
pointerColorBackground Background Pixel XtDefaultBackground
resize Resize Boolean True
screen Screen Screen parent's Screen
sensitive Sensitive Boolean True
shapeStyle ShapeStyle ShapeStyle Rectangle
translations Translations TranslationTable see doc or source
width Width Dimension text width
x Position Position 0
y Position Position 0
*/
#define XtNhighlightThickness "highlightThickness"
#define XtNshapeStyle "shapeStyle"
#define XtCShapeStyle "ShapeStyle"
#define XtRShapeStyle "ShapeStyle"
#define XtNcornerRoundPercent "cornerRoundPercent"
#define XtCCornerRoundPercent "CornerRoundPercent"
#define XawShapeRectangle XmuShapeRectangle
#define XawShapeOval XmuShapeOval
#define XawShapeEllipse XmuShapeEllipse
#define XawShapeRoundedRectangle XmuShapeRoundedRectangle
extern WidgetClass winCommandWidgetClass;
typedef struct _WinCommandClassRec *WinCommandWidgetClass;
typedef struct _WinCommandRec *WinCommandWidget;
#endif /* _WinCommand_h */
/* DON'T ADD STUFF AFTER THIS */

View File

@ -1,118 +0,0 @@
/***********************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/*
* Modifications for Wine
*
* 8/27/93 David Metcalfe (david@prism.demon.co.uk)
* Convrted to WinCommand
*/
/*
* WinCommandP.h - Private definitions for WinCommand widget
*
*/
#ifndef _WinCommandP_h
#define _WinCommandP_h
#include "WinCommand.h"
#include "WinLabelP.h"
/***********************************************************************
*
* WinCommand Widget Private Data
*
***********************************************************************/
typedef enum {
HighlightNone, /* Do not highlight. */
HighlightWhenUnset, /* Highlight only when unset, this is
to preserve current command widget
functionality. */
HighlightAlways /* Always highlight, lets the toggle widget
and other subclasses do the right thing. */
} XtCommandHighlight;
/************************************
*
* Class structure
*
***********************************/
/* New fields for the WinCommand widget class record */
typedef struct _WinCommandClass
{
int makes_compiler_happy; /* not used */
} WinCommandClassPart;
/* Full class record declaration */
typedef struct _WinCommandClassRec {
CoreClassPart core_class;
SimpleClassPart simple_class;
WinLabelClassPart winlabel_class;
WinCommandClassPart wincommand_class;
} WinCommandClassRec;
extern WinCommandClassRec winCommandClassRec;
/***************************************
*
* Instance (widget) structure
*
**************************************/
/* New fields for the WinCommand widget record */
typedef struct {
/* resources */
Dimension highlight_thickness;
XtCallbackList callbacks;
/* private state */
Pixmap gray_pixmap;
GC normal_GC;
GC inverse_GC;
Boolean set;
XtCommandHighlight highlighted;
/* more resources */
int shape_style;
Dimension corner_round;
} WinCommandPart;
/* XtEventsPtr eventTable;*/
/* Full widget declaration */
typedef struct _WinCommandRec {
CorePart core;
SimplePart simple;
WinLabelPart winlabel;
WinCommandPart wincommand;
} WinCommandRec;
#endif /* _WinCommandP_h */

View File

@ -1,691 +0,0 @@
/***********************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/*
* Modifications for Wine
*
* 8/23/93 David Metcalfe (david@prism.demon.co.uk)
* Added code to translate ampersand to underlined char
*
* 8/27/93 David Metcalfe (david@prism.demon.co.uk)
* Converted to WinLabel
*/
/*
* WinLabel.c - WinLabel widget
*
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xos.h>
#include <X11/Xaw/XawInit.h>
#include "WinLabelP.h"
#include <X11/Xmu/Converters.h>
#include <X11/Xmu/Drawing.h>
#include <stdio.h>
#include <ctype.h>
#define streq(a,b) (strcmp( (a), (b) ) == 0)
#define MULTI_LINE_LABEL 32767
#ifdef CRAY
#define WORD64
#endif
/****************************************************************
*
* Full class record constant
*
****************************************************************/
/* Private Data */
#define offset(field) XtOffsetOf(WinLabelRec, field)
static XtResource resources[] = {
{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
offset(winlabel.foreground), XtRString, XtDefaultForeground},
{XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
offset(winlabel.font),XtRString, XtDefaultFont},
{XtNlabel, XtCLabel, XtRString, sizeof(String),
offset(winlabel.label), XtRString, NULL},
{XtNencoding, XtCEncoding, XtRUnsignedChar, sizeof(unsigned char),
offset(winlabel.encoding), XtRImmediate,
(XtPointer)XawTextEncoding8bit},
{XtNjustify, XtCJustify, XtRJustify, sizeof(XtJustify),
offset(winlabel.justify), XtRImmediate, (XtPointer)XtJustifyCenter},
{XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension),
offset(winlabel.internal_width), XtRImmediate, (XtPointer)4},
{XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension),
offset(winlabel.internal_height), XtRImmediate, (XtPointer)4},
{XtNleftBitmap, XtCLeftBitmap, XtRBitmap, sizeof(Pixmap),
offset(winlabel.left_bitmap), XtRImmediate, (XtPointer) None},
{XtNbitmap, XtCPixmap, XtRBitmap, sizeof(Pixmap),
offset(winlabel.pixmap), XtRImmediate, (XtPointer)None},
{XtNresize, XtCResize, XtRBoolean, sizeof(Boolean),
offset(winlabel.resize), XtRImmediate, (XtPointer)True},
};
#undef offset
static void Initialize();
static void Resize();
static void Redisplay();
static Boolean SetValues();
static void ClassInitialize();
static void Destroy();
static XtGeometryResult QueryGeometry();
WinLabelClassRec winLabelClassRec = {
{
/* core_class fields */
#define superclass (&simpleClassRec)
/* superclass */ (WidgetClass) superclass,
/* class_name */ "WinLabel",
/* widget_size */ sizeof(WinLabelRec),
/* class_initialize */ ClassInitialize,
/* class_part_initialize */ NULL,
/* class_inited */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ XtInheritRealize,
/* actions */ NULL,
/* num_actions */ 0,
/* resources */ resources,
/* num_resources */ XtNumber(resources),
/* xrm_class */ NULLQUARK,
/* compress_motion */ TRUE,
/* compress_exposure */ TRUE,
/* compress_enterleave */ TRUE,
/* visible_interest */ FALSE,
/* destroy */ Destroy,
/* resize */ Resize,
/* expose */ Redisplay,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* set_values_almost */ XtInheritSetValuesAlmost,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* tm_table */ NULL,
/* query_geometry */ QueryGeometry,
/* display_accelerator */ XtInheritDisplayAccelerator,
/* extension */ NULL
},
/* Simple class fields initialization */
{
/* change_sensitive */ XtInheritChangeSensitive
}
};
WidgetClass winLabelWidgetClass = (WidgetClass)&winLabelClassRec;
/****************************************************************
*
* Private Procedures
*
****************************************************************/
static void ClassInitialize()
{
XawInitializeWidgetSet();
XtAddConverter( XtRString, XtRJustify, XmuCvtStringToJustify, NULL, 0 );
}
#ifndef WORD64
#define TXT16 XChar2b
#else
#define TXT16 char
static XChar2b *buf2b;
static int buf2blen = 0;
_WinLabelWidth16(fs, str, n)
XFontStruct *fs;
char *str;
int n;
{
int i;
XChar2b *ptr;
if (n > buf2blen) {
buf2b = (XChar2b *)XtRealloc((char *)buf2b, n * sizeof(XChar2b));
buf2blen = n;
}
for (ptr = buf2b, i = n; --i >= 0; ptr++) {
ptr->byte1 = *str++;
ptr->byte2 = *str++;
}
return XTextWidth16(fs, buf2b, n);
}
_WinLabelDraw16(dpy, d, gc, x, y, str, n)
Display *dpy;
Drawable d;
GC gc;
int x, y;
char *str;
int n;
{
int i;
XChar2b *ptr;
if (n > buf2blen) {
buf2b = (XChar2b *)XtRealloc((char *)buf2b, n * sizeof(XChar2b));
buf2blen = n;
}
for (ptr = buf2b, i = n; --i >= 0; ptr++) {
ptr->byte1 = *str++;
ptr->byte2 = *str++;
}
XDrawString16(dpy, d, gc, x, y, buf2b, n);
}
#define XTextWidth16 _WinLabelWidth16
#define XDrawString16 _WinLabelDraw16
#endif /* WORD64 */
/*
* Calculate width and height of displayed text in pixels
*/
static void SetTextWidthAndHeight(lw)
WinLabelWidget lw;
{
register XFontStruct *fs = lw->winlabel.font;
char *nl;
if (lw->winlabel.pixmap != None) {
Window root;
int x, y;
unsigned int width, height, bw, depth;
if (XGetGeometry(XtDisplay(lw), lw->winlabel.pixmap, &root, &x, &y,
&width, &height, &bw, &depth)) {
lw->winlabel.label_height = height;
lw->winlabel.label_width = width;
lw->winlabel.label_len = depth;
return;
}
}
lw->winlabel.label_height = fs->max_bounds.ascent + fs->max_bounds.descent;
if (lw->winlabel.label == NULL) {
lw->winlabel.label_len = 0;
lw->winlabel.label_width = 0;
}
else if ((nl = index(lw->winlabel.label, '\n')) != NULL) {
char *label;
lw->winlabel.label_len = MULTI_LINE_LABEL;
lw->winlabel.label_width = 0;
for (label = lw->winlabel.label; nl != NULL; nl = index(label, '\n')) {
int width;
if (lw->winlabel.encoding)
width = XTextWidth16(fs, (TXT16*)label, (int)(nl - label)/2);
else
width = XTextWidth(fs, label, (int)(nl - label));
if (width > (int)lw->winlabel.label_width)
lw->winlabel.label_width = width;
label = nl + 1;
if (*label)
lw->winlabel.label_height +=
fs->max_bounds.ascent + fs->max_bounds.descent;
}
if (*label) {
int width = XTextWidth(fs, label, strlen(label));
if (lw->winlabel.encoding)
width = XTextWidth16(fs, (TXT16*)label, (int)strlen(label)/2);
else
width = XTextWidth(fs, label, strlen(label));
if (width > (int) lw->winlabel.label_width)
lw->winlabel.label_width = width;
}
} else {
lw->winlabel.label_len = strlen(lw->winlabel.label);
if (lw->winlabel.encoding)
lw->winlabel.label_width =
XTextWidth16(fs, (TXT16*)lw->winlabel.label,
(int) lw->winlabel.label_len/2);
else
lw->winlabel.label_width =
XTextWidth(fs, lw->winlabel.label,
(int) lw->winlabel.label_len);
}
}
static void GetnormalGC(lw)
WinLabelWidget lw;
{
XGCValues values;
values.foreground = lw->winlabel.foreground;
values.background = lw->core.background_pixel;
values.font = lw->winlabel.font->fid;
values.graphics_exposures = False;
lw->winlabel.normal_GC = XtGetGC(
(Widget)lw,
(unsigned) GCForeground | GCBackground | GCFont | GCGraphicsExposures,
&values);
}
static void GetgrayGC(lw)
WinLabelWidget lw;
{
XGCValues values;
values.foreground = lw->winlabel.foreground;
values.background = lw->core.background_pixel;
values.font = lw->winlabel.font->fid;
values.fill_style = FillTiled;
values.tile = XmuCreateStippledPixmap(XtScreen((Widget)lw),
lw->winlabel.foreground,
lw->core.background_pixel,
lw->core.depth);
values.graphics_exposures = False;
lw->winlabel.stipple = values.tile;
lw->winlabel.gray_GC = XtGetGC((Widget)lw,
(unsigned) GCForeground | GCBackground |
GCFont | GCTile | GCFillStyle |
GCGraphicsExposures,
&values);
}
static void compute_bitmap_offsets (lw)
WinLabelWidget lw;
{
/*
* label will be displayed at (internal_width, internal_height + lbm_y)
*/
if (lw->winlabel.lbm_height != 0) {
lw->winlabel.lbm_y = (((int) lw->core.height) -
((int) lw->winlabel.internal_height * 2) -
((int) lw->winlabel.lbm_height)) / 2;
} else {
lw->winlabel.lbm_y = 0;
}
}
static void set_bitmap_info (lw)
WinLabelWidget lw;
{
Window root;
int x, y;
unsigned int bw, depth;
if (!(lw->winlabel.left_bitmap &&
XGetGeometry (XtDisplay(lw), lw->winlabel.left_bitmap, &root, &x, &y,
&lw->winlabel.lbm_width, &lw->winlabel.lbm_height,
&bw, &depth))) {
lw->winlabel.lbm_width = lw->winlabel.lbm_height = 0;
}
compute_bitmap_offsets (lw);
}
static void
RemoveAmpersand(w)
Widget w;
{
WinLabelWidget lw = (WinLabelWidget) w;
lw->winlabel.ul_pos = strcspn(lw->winlabel.label, "&");
if (lw->winlabel.ul_pos == strlen(lw->winlabel.label))
{
lw->winlabel.ul_pos = -1;
return;
}
/* Remove ampersand from label */
strcpy(lw->winlabel.label + lw->winlabel.ul_pos,
lw->winlabel.label + lw->winlabel.ul_pos + 1);
}
/* ARGSUSED */
static void Initialize(request, new)
Widget request, new;
{
WinLabelWidget lw = (WinLabelWidget) new;
if (lw->winlabel.label == NULL)
lw->winlabel.label = XtNewString(lw->core.name);
else {
lw->winlabel.label = XtNewString(lw->winlabel.label);
}
RemoveAmpersand(new);
GetnormalGC(lw);
GetgrayGC(lw);
SetTextWidthAndHeight(lw);
if (lw->core.height == 0)
lw->core.height = lw->winlabel.label_height +
2*lw->winlabel.internal_height;
set_bitmap_info (lw); /* need core.height */
if (lw->core.width == 0) /* need winlabel.lbm_width */
lw->core.width = (lw->winlabel.label_width +
2 * lw->winlabel.internal_width
+ LEFT_OFFSET(lw));
lw->winlabel.label_x = lw->winlabel.label_y = 0;
(*XtClass(new)->core_class.resize) ((Widget)lw);
} /* Initialize */
/*
* Repaint the widget window
*/
/* ARGSUSED */
static void Redisplay(w, event, region)
Widget w;
XEvent *event;
Region region;
{
WinLabelWidget lw = (WinLabelWidget) w;
GC gc;
int ul_x_loc, ul_y_loc, ul_width;
if (region != NULL) {
int x = lw->winlabel.label_x;
unsigned int width = lw->winlabel.label_width;
if (lw->winlabel.lbm_width) {
if (lw->winlabel.label_x > (x = lw->winlabel.internal_width))
width += lw->winlabel.label_x - x;
}
if (XRectInRegion(region, x, lw->winlabel.label_y,
width, lw->winlabel.label_height) == RectangleOut)
return;
}
gc = XtIsSensitive((Widget)lw) ? lw->winlabel.normal_GC
: lw->winlabel.gray_GC;
#ifdef notdef
if (region != NULL) XSetRegion(XtDisplay(w), gc, region);
#endif /*notdef*/
if (lw->winlabel.pixmap == None) {
int len = lw->winlabel.label_len;
char *label = lw->winlabel.label;
Position y = lw->winlabel.label_y +
lw->winlabel.font->max_bounds.ascent;
/* display left bitmap */
if (lw->winlabel.left_bitmap && lw->winlabel.lbm_width != 0) {
XCopyPlane (XtDisplay(w), lw->winlabel.left_bitmap, XtWindow(w), gc,
0, 0, lw->winlabel.lbm_width, lw->winlabel.lbm_height,
(int) lw->winlabel.internal_width,
(int) lw->winlabel.internal_height +
lw->winlabel.lbm_y,
(unsigned long) 1L);
}
if (len == MULTI_LINE_LABEL) {
char *nl;
while ((nl = index(label, '\n')) != NULL) {
if (lw->winlabel.encoding)
XDrawString16(XtDisplay(w), XtWindow(w), gc,
lw->winlabel.label_x, y,
(TXT16*)label, (int)(nl - label)/2);
else
XDrawString(XtDisplay(w), XtWindow(w), gc,
lw->winlabel.label_x, y, label,
(int)(nl - label));
y += lw->winlabel.font->max_bounds.ascent +
lw->winlabel.font->max_bounds.descent;
label = nl + 1;
}
len = strlen(label);
}
if (len) {
if (lw->winlabel.encoding)
XDrawString16(XtDisplay(w), XtWindow(w), gc,
lw->winlabel.label_x, y, (TXT16*)label, len/2);
else
XDrawString(XtDisplay(w), XtWindow(w), gc,
lw->winlabel.label_x, y, label, len);
if (lw->winlabel.ul_pos != -1)
{
/* Don't bother with two byte chars at present */
if (!lw->winlabel.encoding)
{
ul_x_loc = lw->winlabel.label_x +
XTextWidth(lw->winlabel.font,
lw->winlabel.label, lw->winlabel.ul_pos);
ul_y_loc = lw->winlabel.label_height +
lw->winlabel.internal_height + 1;
ul_width = XTextWidth(lw->winlabel.font,
lw->winlabel.label + lw->winlabel.ul_pos, 1);
XDrawLine(XtDisplayOfObject(w), XtWindowOfObject(w), gc,
ul_x_loc, ul_y_loc, ul_x_loc + ul_width - 1, ul_y_loc);
}
}
}
} else if (lw->winlabel.label_len == 1) { /* depth */
XCopyPlane(XtDisplay(w), lw->winlabel.pixmap, XtWindow(w), gc,
0, 0, lw->winlabel.label_width, lw->winlabel.label_height,
lw->winlabel.label_x, lw->winlabel.label_y, 1L);
} else {
XCopyArea(XtDisplay(w), lw->winlabel.pixmap, XtWindow(w), gc,
0, 0, lw->winlabel.label_width, lw->winlabel.label_height,
lw->winlabel.label_x, lw->winlabel.label_y);
}
#ifdef notdef
if (region != NULL) XSetClipMask(XtDisplay(w), gc, (Pixmap)None);
#endif /* notdef */
}
static void _Reposition(lw, width, height, dx, dy)
register WinLabelWidget lw;
Dimension width, height;
Position *dx, *dy;
{
Position newPos;
Position leftedge = lw->winlabel.internal_width + LEFT_OFFSET(lw);
switch (lw->winlabel.justify) {
case XtJustifyLeft :
newPos = leftedge;
break;
case XtJustifyRight :
newPos = width -
(lw->winlabel.label_width + lw->winlabel.internal_width);
break;
case XtJustifyCenter :
default:
newPos = (int)(width - lw->winlabel.label_width) / 2;
break;
}
if (newPos < (Position)leftedge)
newPos = leftedge;
*dx = newPos - lw->winlabel.label_x;
lw->winlabel.label_x = newPos;
*dy = (newPos = (int)(height - lw->winlabel.label_height) / 2)
- lw->winlabel.label_y;
lw->winlabel.label_y = newPos;
return;
}
static void Resize(w)
Widget w;
{
WinLabelWidget lw = (WinLabelWidget)w;
Position dx, dy;
_Reposition(lw, w->core.width, w->core.height, &dx, &dy);
compute_bitmap_offsets (lw);
}
/*
* Set specified arguments into widget
*/
#define PIXMAP 0
#define WIDTH 1
#define HEIGHT 2
#define NUM_CHECKS 3
static Boolean SetValues(current, request, new, args, num_args)
Widget current, request, new;
ArgList args;
Cardinal *num_args;
{
WinLabelWidget curlw = (WinLabelWidget) current;
WinLabelWidget reqlw = (WinLabelWidget) request;
WinLabelWidget newlw = (WinLabelWidget) new;
int i;
Boolean was_resized = False, redisplay = False, checks[NUM_CHECKS];
for (i = 0; i < NUM_CHECKS; i++)
checks[i] = FALSE;
for (i = 0; i < *num_args; i++) {
if (streq(XtNbitmap, args[i].name))
checks[PIXMAP] = TRUE;
if (streq(XtNwidth, args[i].name))
checks[WIDTH] = TRUE;
if (streq(XtNheight, args[i].name))
checks[HEIGHT] = TRUE;
}
if (newlw->winlabel.label == NULL) {
newlw->winlabel.label = newlw->core.name;
}
/*
* resize on bitmap change
*/
if (curlw->winlabel.left_bitmap != newlw->winlabel.left_bitmap) {
was_resized = True;
}
if (curlw->winlabel.encoding != newlw->winlabel.encoding)
was_resized = True;
if (curlw->winlabel.label != newlw->winlabel.label) {
if (curlw->winlabel.label != curlw->core.name)
XtFree( (char *)curlw->winlabel.label );
if (newlw->winlabel.label != newlw->core.name) {
newlw->winlabel.label = XtNewString( newlw->winlabel.label );
}
RemoveAmpersand(new);
was_resized = True;
}
if (was_resized || (curlw->winlabel.font != newlw->winlabel.font) ||
(curlw->winlabel.justify != newlw->winlabel.justify)
|| checks[PIXMAP]) {
SetTextWidthAndHeight(newlw);
was_resized = True;
}
/* recalculate the window size if something has changed. */
if (newlw->winlabel.resize && was_resized) {
if ((curlw->core.height == reqlw->core.height) && !checks[HEIGHT])
newlw->core.height = (newlw->winlabel.label_height +
2 * newlw->winlabel.internal_height);
set_bitmap_info (newlw);
if ((curlw->core.width == reqlw->core.width) && !checks[WIDTH])
newlw->core.width = (newlw->winlabel.label_width +
LEFT_OFFSET(newlw) +
2 * newlw->winlabel.internal_width);
}
if (curlw->winlabel.foreground != newlw->winlabel.foreground
|| curlw->core.background_pixel != newlw->core.background_pixel
|| curlw->winlabel.font->fid != newlw->winlabel.font->fid) {
XtReleaseGC(new, curlw->winlabel.normal_GC);
XtReleaseGC(new, curlw->winlabel.gray_GC);
XmuReleaseStippledPixmap( XtScreen(current), curlw->winlabel.stipple );
GetnormalGC(newlw);
GetgrayGC(newlw);
redisplay = True;
}
if ((curlw->winlabel.internal_width != newlw->winlabel.internal_width)
|| (curlw->winlabel.internal_height != newlw->winlabel.internal_height)
|| was_resized) {
/* Resize() will be called if geometry changes succeed */
Position dx, dy;
_Reposition(newlw, curlw->core.width, curlw->core.height, &dx, &dy);
}
return was_resized || redisplay ||
XtIsSensitive(current) != XtIsSensitive(new);
}
static void Destroy(w)
Widget w;
{
WinLabelWidget lw = (WinLabelWidget)w;
XtFree( lw->winlabel.label );
XtReleaseGC( w, lw->winlabel.normal_GC );
XtReleaseGC( w, lw->winlabel.gray_GC);
XmuReleaseStippledPixmap( XtScreen(w), lw->winlabel.stipple );
}
static XtGeometryResult QueryGeometry(w, intended, preferred)
Widget w;
XtWidgetGeometry *intended, *preferred;
{
register WinLabelWidget lw = (WinLabelWidget)w;
preferred->request_mode = CWWidth | CWHeight;
preferred->width = (lw->winlabel.label_width +
2 * lw->winlabel.internal_width +
LEFT_OFFSET(lw));
preferred->height = lw->winlabel.label_height +
2*lw->winlabel.internal_height;
if ( ((intended->request_mode & (CWWidth | CWHeight))
== (CWWidth | CWHeight)) &&
intended->width == preferred->width &&
intended->height == preferred->height)
return XtGeometryYes;
else if (preferred->width == w->core.width &&
preferred->height == w->core.height)
return XtGeometryNo;
else
return XtGeometryAlmost;
}

View File

@ -1,106 +0,0 @@
/***********************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/*
* Modifications for Wine
*
* 8/23/93 David Metcalfe (david@prism.demon.co.uk)
* Added code to translate ampersand to underlined char
*
* 8/27/93 David Metcalfe (david@prism.demon.co.uk)
* Converted to WinLabel
*/
#ifndef _WinLabel_h
#define _WinLabel_h
/***********************************************************************
*
* WinLabel Widget
*
***********************************************************************/
#include <X11/Xaw/Simple.h>
/* Resources:
Name Class RepType Default Value
---- ----- ------- -------------
background Background Pixel XtDefaultBackground
bitmap Pixmap Pixmap None
border BorderColor Pixel XtDefaultForeground
borderWidth BorderWidth Dimension 1
cursor Cursor Cursor None
cursorName Cursor String NULL
destroyCallback Callback XtCallbackList NULL
encoding Encoding unsigned char XawTextEncoding8bit
font Font XFontStruct* XtDefaultFont
foreground Foreground Pixel XtDefaultForeground
height Height Dimension text height
insensitiveBorder Insensitive Pixmap Gray
internalHeight Height Dimension 2
internalWidth Width Dimension 4
justify Justify XtJustify XtJustifyCenter
label Label String NULL
leftBitmap LeftBitmap Pixmap None
mappedWhenManaged MappedWhenManaged Boolean True
pointerColor Foreground Pixel XtDefaultForeground
pointerColorBackground Background Pixel XtDefaultBackground
resize Resize Boolean True
sensitive Sensitive Boolean True
width Width Dimension text width
x Position Position 0
y Position Position 0
*/
#define XawTextEncoding8bit 0
#define XawTextEncodingChar2b 1
#define XtNleftBitmap "leftBitmap"
#define XtCLeftBitmap "LeftBitmap"
#define XtNencoding "encoding"
#define XtCEncoding "Encoding"
#ifndef _XtStringDefs_h_
#define XtNbitmap "bitmap"
#define XtNforeground "foreground"
#define XtNlabel "label"
#define XtNfont "font"
#define XtNinternalWidth "internalWidth"
#define XtNinternalHeight "internalHeight"
#define XtNresize "resize"
#define XtCResize "Resize"
#define XtCBitmap "Bitmap"
#endif
/* Class record constants */
extern WidgetClass winLabelWidgetClass;
typedef struct _WinLabelClassRec *WinLabelWidgetClass;
typedef struct _WinLabelRec *WinLabelWidget;
#endif /* _WinLabel_h */
/* DON'T ADD STUFF AFTER THIS #endif */

View File

@ -1,114 +0,0 @@
/***********************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/*
* Modifications for Wine
*
* 8/23/93 David Metcalfe (david@prism.demon.co.uk)
* Added code to translate ampersand to underlined char
*
* 8/27/93 David Metcalfe (david@prism.demon.co.uk)
* Converted to WinLabel
*/
/*
* WinLabelP.h - Private definitions for WinLabel widget
*
*/
#ifndef _WinLabelP_h
#define _WinLabelP_h
/***********************************************************************
*
* WinLabel Widget Private Data
*
***********************************************************************/
#include "WinLabel.h"
#include <X11/Xaw/SimpleP.h>
/* New fields for the WinLabel widget class record */
typedef struct {int foo;} WinLabelClassPart;
/* Full class record declaration */
typedef struct _WinLabelClassRec {
CoreClassPart core_class;
SimpleClassPart simple_class;
WinLabelClassPart winlabel_class;
} WinLabelClassRec;
extern WinLabelClassRec winLabelClassRec;
/* New fields for the WinLabel widget record */
typedef struct {
/* resources */
Pixel foreground;
XFontStruct *font;
char *label;
XtJustify justify;
Dimension internal_width;
Dimension internal_height;
Pixmap pixmap;
Boolean resize;
unsigned char encoding;
Pixmap left_bitmap;
/* private state */
GC normal_GC;
GC gray_GC;
Pixmap stipple;
Position label_x;
Position label_y;
Dimension label_width;
Dimension label_height;
Dimension label_len;
int lbm_y; /* where in label */
unsigned int lbm_width, lbm_height; /* size of pixmap */
int ul_pos; /* Offset in chars of underlined character */
/* in label */
} WinLabelPart;
/****************************************************************
*
* Full instance record declaration
*
****************************************************************/
typedef struct _WinLabelRec {
CorePart core;
SimplePart simple;
WinLabelPart winlabel;
} WinLabelRec;
#define LEFT_OFFSET(lw) ((lw)->winlabel.left_bitmap \
? (lw)->winlabel.lbm_width + \
(lw)->winlabel.internal_width \
: 0)
#endif /* _WinLabelP_h */

View File

@ -1,100 +0,0 @@
/*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Modifications for Wine
*
* 8/27/93 David Metcalfe (david@prism.demon.co.uk)
* Converted to WinMenuButton
*/
/***********************************************************************
*
* WinMenuButton Widget
*
***********************************************************************/
/*
* WinMenuButtP.h - Private Header file for WinMenuButton widget.
*
* This is the private header file for the WinMenuButton widget.
* It is intended to provide an easy method of activating pulldown menus.
*
* Date: May 2, 1989
*
* By: Chris D. Peterson
* MIT X Consortium
* kit@expo.lcs.mit.edu
*/
#ifndef _WinMenuButtonP_h
#define _WinMenuButtonP_h
#include "WinMenuButto.h"
#include "WinCommandP.h"
/************************************
*
* Class structure
*
***********************************/
/* New fields for the WinMenuButton widget class record */
typedef struct _WinMenuButtonClass
{
int makes_compiler_happy; /* not used */
} WinMenuButtonClassPart;
/* Full class record declaration */
typedef struct _WinMenuButtonClassRec {
CoreClassPart core_class;
SimpleClassPart simple_class;
WinLabelClassPart winLabel_class;
WinCommandClassPart winCommand_class;
WinMenuButtonClassPart winMenuButton_class;
} WinMenuButtonClassRec;
extern WinMenuButtonClassRec winMenuButtonClassRec;
/***************************************
*
* Instance (widget) structure
*
**************************************/
/* New fields for the WinMenuButton widget record */
typedef struct {
/* resources */
String menu_name;
} WinMenuButtonPart;
/* Full widget declaration */
typedef struct _WinMenuButtonRec {
CorePart core;
SimplePart simple;
WinLabelPart winlabel;
WinCommandPart wincommand;
WinMenuButtonPart winmenu_button;
} WinMenuButtonRec;
#endif /* _WinMenuButtonP_h */

View File

@ -1,215 +0,0 @@
/*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/*
* Modifications for Wine
*
* 8/27/93 David Metcalfe (david@prism.demon.co.uk)
* Converted to WinMenuButton
*/
/***********************************************************************
*
* WinMenuButton Widget
*
***********************************************************************/
/*
* WinMenuButto.c - Source code for WinMenuButton widget.
*
* This is the source code for the WinMenuButton widget.
* It is intended to provide an easy method of activating pulldown menus.
*
* Date: May 2, 1989
*
* By: Chris D. Peterson
* MIT X Consortium
* kit@expo.lcs.mit.edu
*/
#include <stdio.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/XawInit.h>
#include "WinMenuButtP.h"
static void ClassInitialize();
static void PopupMenu();
#define superclass ((WinCommandWidgetClass)&winCommandClassRec)
static char defaultTranslations[] =
"<EnterWindow>: highlight() \n\
<LeaveWindow>: reset() \n\
<BtnDown>: reset() PopupMenu() ";
/****************************************************************
*
* Full class record constant
*
****************************************************************/
/* Private Data */
#define offset(field) XtOffsetOf(WinMenuButtonRec, field)
static XtResource resources[] = {
{
XtNmenuName, XtCMenuName, XtRString, sizeof(String),
offset(winmenu_button.menu_name), XtRString, (XtPointer)"menu"},
};
#undef offset
static XtActionsRec actionsList[] =
{
{"PopupMenu", PopupMenu}
};
WinMenuButtonClassRec winMenuButtonClassRec = {
{
(WidgetClass) superclass, /* superclass */
"WinMenuButton", /* class_name */
sizeof(WinMenuButtonRec), /* size */
ClassInitialize, /* class_initialize */
NULL, /* class_part_initialize */
FALSE, /* class_inited */
NULL, /* initialize */
NULL, /* initialize_hook */
XtInheritRealize, /* realize */
actionsList, /* actions */
XtNumber(actionsList), /* num_actions */
resources, /* resources */
XtNumber(resources), /* resource_count */
NULLQUARK, /* xrm_class */
FALSE, /* compress_motion */
TRUE, /* compress_exposure */
TRUE, /* compress_enterleave */
FALSE, /* visible_interest */
NULL, /* destroy */
XtInheritResize, /* resize */
XtInheritExpose, /* expose */
NULL, /* set_values */
NULL, /* set_values_hook */
XtInheritSetValuesAlmost, /* set_values_almost */
NULL, /* get_values_hook */
NULL, /* accept_focus */
XtVersion, /* version */
NULL, /* callback_private */
defaultTranslations, /* tm_table */
XtInheritQueryGeometry, /* query_geometry */
XtInheritDisplayAccelerator, /* display_accelerator */
NULL /* extension */
}, /* CoreClass fields initialization */
{
XtInheritChangeSensitive /* change_sensitive */
}, /* SimpleClass fields initialization */
{
0, /* field not used */
}, /* WinLabelClass fields initialization */
{
0, /* field not used */
}, /* WinCommandClass fields initialization */
{
0, /* field not used */
}, /* WinMenuButtonClass fields initialization */
};
/* for public consumption */
WidgetClass winMenuButtonWidgetClass = (WidgetClass) &winMenuButtonClassRec;
/****************************************************************
*
* Private Procedures
*
****************************************************************/
static void ClassInitialize()
{
XawInitializeWidgetSet();
XtRegisterGrabAction(PopupMenu, True, ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync);
}
/* ARGSUSED */
static void
PopupMenu(w, event, params, num_params)
Widget w;
XEvent * event;
String * params;
Cardinal * num_params;
{
WinMenuButtonWidget mbw = (WinMenuButtonWidget) w;
Widget menu, temp;
Arg arglist[2];
Cardinal num_args;
int menu_x, menu_y, menu_width, menu_height, button_height;
Position button_x, button_y;
temp = w;
while(temp != NULL) {
menu = XtNameToWidget(temp, mbw->winmenu_button.menu_name);
if (menu == NULL)
temp = XtParent(temp);
else
break;
}
if (menu == NULL) {
char error_buf[BUFSIZ];
sprintf(error_buf, "MenuButton: %s %s.",
"Could not find menu widget named", mbw->winmenu_button.menu_name);
XtAppWarning(XtWidgetToApplicationContext(w), error_buf);
return;
}
if (!XtIsRealized(menu))
XtRealizeWidget(menu);
menu_width = menu->core.width + 2 * menu->core.border_width;
button_height = w->core.height + 2 * w->core.border_width;
menu_height = menu->core.height + 2 * menu->core.border_width;
XtTranslateCoords(w, 0, 0, &button_x, &button_y);
menu_x = button_x;
menu_y = button_y + button_height;
if (menu_x >= 0) {
int scr_width = WidthOfScreen(XtScreen(menu));
if (menu_x + menu_width > scr_width)
menu_x = scr_width - menu_width;
}
if (menu_x < 0)
menu_x = 0;
if (menu_y >= 0) {
int scr_height = HeightOfScreen(XtScreen(menu));
if (menu_y + menu_height > scr_height)
menu_y = scr_height - menu_height;
}
if (menu_y < 0)
menu_y = 0;
num_args = 0;
XtSetArg(arglist[num_args], XtNx, menu_x); num_args++;
XtSetArg(arglist[num_args], XtNy, menu_y); num_args++;
XtSetValues(menu, arglist, num_args);
XtPopupSpringLoaded(menu);
}

View File

@ -1,91 +0,0 @@
/*
* Copyright 1989 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Modifications for Wine
*
* 8/23/93 David Metcalfe (david@prism.demon.co.uk)
* Converted to WinMenuButton
*/
/***********************************************************************
*
* WinMenuButton Widget
*
***********************************************************************/
/*
* WinMenuButton.h - Public Header file for WinMenuButton widget.
*
* This is the public header file for the WinMenuButton widget.
* It is intended to provide an easy method of activating pulldown menus.
*
* Date: May 2, 1989
*
* By: Chris D. Peterson
* MIT X Consortium
* kit@expo.lcs.mit.edu
*/
#ifndef _WinMenuButton_h
#define _WinMenuButton_h
#include "WinCommand.h"
/* Resources:
Name Class RepType Default Value
---- ----- ------- -------------
background Background Pixel XtDefaultBackground
bitmap Pixmap Pixmap None
border BorderColor Pixel XtDefaultForeground
borderWidth BorderWidth Dimension 1
callback Callback Pointer NULL
cursor Cursor Cursor None
destroyCallback Callback Pointer NULL
font Font XFontStruct* XtDefaultFont
foreground Foreground Pixel XtDefaultForeground
height Height Dimension text height
highlightThickness Thickness Dimension 2
insensitiveBorder Insensitive Pixmap Gray
internalHeight Height Dimension 2
internalWidth Width Dimension 4
justify Justify XtJustify XtJustifyCenter
label Label String NULL
mappedWhenManaged MappedWhenManaged Boolean True
menuName MenuName String "menu"
resize Resize Boolean True
sensitive Sensitive Boolean True
width Width Dimension text width
x Position Position 0
y Position Position 0
*/
#define XtNmenuName "menuName"
#define XtCMenuName "MenuName"
extern WidgetClass winMenuButtonWidgetClass;
typedef struct _WinMenuButtonClassRec *WinMenuButtonWidgetClass;
typedef struct _WinMenuButtonRec *WinMenuButtonWidget;
#endif /* _WinMenuButton_h -- DON'T ADD STUFF AFTER THIS */

View File

@ -21,6 +21,8 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993";
#include <dirent.h>
#include <sys/stat.h>
HBITMAP hComboBit = 0;
LPHEADCOMBO ComboGetStorageHeader(HWND hwnd);
int CreateComboStruct(HWND hwnd);
@ -37,12 +39,21 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
int AltState;
WND *wndPtr;
LPHEADCOMBO lphc;
LPDRAWITEMSTRUCT lpdis;
HDC hMemDC;
BITMAP bm;
char str[128];
PAINTSTRUCT paintstruct;
static RECT rectsel;
switch(message)
{
case WM_CREATE:
ShowScrollBar(hwnd, SB_BOTH, FALSE);
GetClientRect(hwnd, &rect);
width = rect.right - rect.left;
height = rect.bottom - rect.top;
/* SetWindowPos(hwnd, 0, 0, 0, width, 16,
SWP_NOMOVE | SWP_NOZORDER); */
CreateComboStruct(hwnd);
wndPtr = WIN_FindWndPtr(hwnd);
lphc = ComboGetStorageHeader(hwnd);
@ -50,10 +61,10 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
#ifdef DEBUG_COMBO
printf("Combo WM_CREATE %lX !\n", lphc);
#endif
width = wndPtr->rectClient.right - wndPtr->rectClient.left;
height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
if (hComboBit == (HBITMAP)NULL)
hComboBit = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_COMBO));
lphc->hWndDrop = CreateWindow("BUTTON", "",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_OWNERDRAW,
width - 16, 0, 16, 16, hwnd, 1, wndPtr->hInstance, 0L);
lphc->hWndEdit = CreateWindow("STATIC", "",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT,
@ -189,6 +200,24 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
break;
case WM_CTLCOLOR:
return(SendMessage(GetParent(hwnd), WM_CTLCOLOR, wParam, lParam));
case WM_DRAWITEM:
#ifdef DEBUG_SCROLL
printf("ComboBox WM_DRAWITEM w=%04X l=%08X\n", wParam, lParam);
#endif
lpdis = (LPDRAWITEMSTRUCT)lParam;
if (lpdis->CtlType == ODT_BUTTON && lpdis->itemAction == ODA_DRAWENTIRE) {
hMemDC = CreateCompatibleDC(lpdis->hDC);
GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm);
SelectObject(hMemDC, hComboBit);
BitBlt(lpdis->hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
}
if (lpdis->CtlType == ODT_BUTTON && lpdis->itemAction == ODA_SELECT) {
CopyRect(&rect, &lpdis->rcItem);
InflateRect(&rect, -1, -1);
DrawReliefRect(lpdis->hDC, rect, 1, 1);
}
break;
case WM_PAINT:
BeginPaint( hwnd, &paintstruct );
EndPaint( hwnd, &paintstruct );

View File

@ -9,11 +9,6 @@ static char Copyright2[] = "Copyright Martin Ayotte, 1993";
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/SmeBSB.h>
#include <X11/Xaw/SmeLine.h>
#include <X11/Xaw/SimpleMenu.h>
#include "WinMenuButto.h"
#include "SmeMenuButto.h"
#include "windows.h"
#include "menu.h"
#include "heap.h"

View File

@ -205,7 +205,9 @@ LONG ScrollBarWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
if (lpdis->CtlID == 1) {
GetObject(hUpArrow, sizeof(BITMAP), (LPSTR)&bm);
SelectObject(hMemDC, hUpArrow);
BitBlt(lpdis->hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
/* BitBlt(lpdis->hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); */
StretchBlt(lpdis->hDC, 0, 0, lpdis->rcItem.right, lpdis->rcItem.right,
hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
}
if (lpdis->CtlID == 2) {
GetObject(hDnArrow, sizeof(BITMAP), (LPSTR)&bm);

View File

@ -43,9 +43,8 @@ length 490
33 pascal TextOut(word s_word s_word ptr word) TextOut(1 2 3 4 5)
34 pascal BitBlt( word s_word s_word s_word s_word word s_word s_word long)
BitBlt(1 2 3 4 5 6 7 8 9)
35 pascal StrechBlt( word s_word s_word s_word s_word word s_word s_word s_word s_word long)
StrechBlt(1 2 3 4 5 6 7 8 9 10 11)
35 pascal StretchBlt( word s_word s_word s_word s_word word s_word s_word s_word s_word long)
StretchBlt(1 2 3 4 5 6 7 8 9 10 11)
36 pascal Polygon (word ptr word) Polygon (1 2 3)
37 pascal Polyline (word ptr word) Polyline (1 2 3)
39 pascal RestoreDC(word s_word) RestoreDC(1 2)

View File

@ -23,9 +23,12 @@ length 540
23 pascal GetFocus() GetFocus()
28 pascal ClientToScreen(word ptr) ClientToScreen(1 2)
29 pascal ScreenToClient(word ptr) ScreenToClient(1 2)
30 pascal WindowFromPoint(long) WindowFromPoint(1)
31 pascal IsIconic(word) IsIconic(1)
32 pascal GetWindowRect(word ptr) GetWindowRect(1 2)
33 pascal GetClientRect(word ptr) GetClientRect(1 2)
34 pascal EnableWindow(word word) EnableWindow(1 2)
35 pascal IsWindowEnabled(word) IsWindowEnabled(1)
36 pascal GetWindowText(word ptr word) GetWindowText(1 2 3)
37 pascal SetWindowText(word ptr) SetWindowText(1 2)
38 pascal GetWindowTextLength(word) GetWindowTextLength(1)
@ -36,6 +39,7 @@ length 540
42 pascal ShowWindow(word word) ShowWindow(1 2)
43 pascal CloseWindow(word) CloseWindow(1)
44 pascal OpenIcon(word) OpenIcon(1)
45 pascal BringWindowToTop(word) BringWindowToTop(1)
46 pascal GetParent(word) GetParent(1)
47 pascal IsWindow(word) IsWindow(1)
48 pascal IsChild(word word) IsChild(1 2)
@ -140,6 +144,7 @@ length 540
182 pascal KillSystemTimer(word word) KillSystemTimer(1 2)
183 pascal GetCaretPos(ptr) GetCaretPos(1)
190 pascal GetUpdateRect(word ptr word) GetUpdateRect(1 2 3)
191 pascal ChildWindowFromPoint(word long) ChildWindowFromPoint(1 2)
200 pascal OpenComm(ptr word word) OpenComm(1 2 3)
201 pascal SetCommState(ptr) SetCommState(1)
202 pascal GetCommState(word ptr) GetCommState(1 2)
@ -194,6 +199,8 @@ length 540
334 pascal GetQueueStatus(word) GetQueueStatus(1)
335 pascal GetInputState() GetInputState()
359 pascal GetDCEx(word word long) GetDCEx(1 2 3)
370 pascal GetWindowPlacement(word ptr) GetWindowPlacement(1 2)
371 pascal SetWindowPlacement(word ptr) SetWindowPlacement(1 2)
373 pascal SubtractRect(ptr ptr ptr) SubtractRect(1 2 3)
403 pascal UnregisterClass(ptr word) UnregisterClass(1 2)
404 pascal GetClassInfo(word ptr ptr) GetClassInfo(1 2 3)
@ -226,6 +233,9 @@ length 540
454 pascal AdjustWindowRectEx(ptr long word long) AdjustWindowRectEx(1 2 3 4)
457 pascal DestroyIcon(word) DestroyIcon(1)
458 pascal DestroyCursor(word) DestroyCursor(1)
460 pascal GetInternalWindowPos(word ptr ptr) GetInternalWindowPos(1 2 3)
461 pascal SetInternalWindowPos(word word ptr ptr) SetInternalWindowPos(1 2 3 4)
466 pascal DrawFocusRect(word ptr) DrawFocusRect(1 2)
471 pascal lstrcmpi(ptr ptr) lstrcmpi(1 2)
472 pascal AnsiNext(ptr) AnsiNext(1 )
473 pascal AnsiPrev(ptr ptr) AnsiPrev(1 2)

20
include/options.h Normal file
View File

@ -0,0 +1,20 @@
/*
* Command-line options.
*
* Copyright 1994 Alexandre Julliard
*/
#ifndef OPTIONS_H
#define OPTIONS_H
struct options
{
char * spyFilename;
int usePrivateMap;
int synchronous;
short cmdShow;
};
extern struct options Options;
#endif

View File

@ -69,4 +69,10 @@ static __inline__ int Is16bitAddress(void *address)
return ((int) address >= (((FIRST_SELECTOR << 3) | 0x0007) << 16));
}
extern SEGDESC Segments[];
#endif /* SEGMEM_H */

View File

@ -26,6 +26,9 @@ typedef struct tagWND
HANDLE hInstance; /* Window hInstance (from CreateWindow) */
RECT rectClient; /* Client area rel. to parent client area */
RECT rectWindow; /* Whole window rel. to parent client area */
RECT rectNormal; /* Window rect. when in normal state */
POINT ptIconPos; /* Icon position */
POINT ptMaxPos; /* Maximized window position */
HANDLE hmemTaskQ; /* Task queue global memory handle */
HRGN hrgnUpdate; /* Update region */
HWND hwndLastActive; /* Last active popup hwnd */
@ -54,6 +57,10 @@ typedef struct tagWND
#define WIN_OWN_DC 0x08 /* Win class has style CS_OWNDC */
#define WIN_CLASS_DC 0x10 /* Win class has style CS_CLASSDC */
#define WIN_DOUBLE_CLICKS 0x20 /* Win class has style CS_DBLCLKS */
#define WIN_RESTORE_MAX 0x40 /* Maximize when restoring */
/* First top-level window */
extern HWND firstWindow;
/* Window functions */
WND *WIN_FindWndPtr( HWND hwnd );

View File

@ -111,6 +111,19 @@ typedef int *LPCATCHBUF;
#endif
*/
typedef struct { short x, y; } POINT;
typedef POINT *PPOINT;
typedef POINT *NPPOINT;
typedef POINT *LPPOINT;
typedef struct
{
short cx;
short cy;
} SIZE, *LPSIZE;
#define MAKEPOINT(l) (*((POINT *)&(l)))
#define MAKELPARAM(low, high) ((LONG)(((WORD)(low)) | \
(((DWORD)((WORD)(high))) << 16)))
@ -221,6 +234,21 @@ typedef struct
UINT flags;
} WINDOWPOS;
/* SetWindowPlacement() struct */
typedef struct
{
UINT length;
UINT flags;
UINT showCmd;
POINT ptMinPosition __attribute__ ((packed));
POINT ptMaxPosition __attribute__ ((packed));
RECT rcNormalPosition __attribute__ ((packed));
} WINDOWPLACEMENT, *LPWINDOWPLACEMENT;
/* WINDOWPLACEMENT flags */
#define WPF_SETMINPOSITION 0x0001
#define WPF_RESTORETOMAXIMIZED 0x0002
/* WM_NCCALCSIZE parameter structure */
typedef struct
{
@ -324,19 +352,6 @@ typedef struct
#define IDNO 7
typedef struct { short x, y; } POINT;
typedef POINT *PPOINT;
typedef POINT *NPPOINT;
typedef POINT *LPPOINT;
typedef struct
{
short cx;
short cy;
} SIZE, *LPSIZE;
#define MAKEPOINT(l) (*((POINT *)&(l)))
typedef struct tagMSG
{
HWND hwnd;
@ -2002,6 +2017,7 @@ Fa(ATOM,FindAtom,LPCSTR,a)
Fa(ATOM,GlobalAddAtom,LPCSTR,a)
Fa(ATOM,GlobalDeleteAtom,ATOM,a)
Fa(ATOM,GlobalFindAtom,LPCSTR,a)
Fa(BOOL,BringWindowToTop,HWND,a)
Fa(BOOL,DeleteDC,HDC,a)
Fa(BOOL,DeleteMetaFile,HANDLE,a)
Fa(BOOL,DeleteObject,HANDLE,a)
@ -2156,7 +2172,6 @@ Fa(int,ShowCursor,BOOL,a)
Fa(int,UpdateColors,HDC,a)
Fa(int,WaitSoundState,int,a)
Fa(short,GetTextCharacterExtra,HDC,a)
Fa(void,BringWindowToTop,HWND,a)
Fa(void,ClipCursor,LPRECT,a)
Fa(void,CloseWindow,HWND,a)
Fa(void,DrawMenuBar,HWND,a)
@ -2179,6 +2194,8 @@ Fa(void,ShowCaret,HWND,a)
Fa(void,SwapRecording,WORD,a)
Fb(BOOL,ExitWindows,DWORD,dwReserved,WORD,wReturnCode)
Fb(BOOL,GetBitmapDimensionEx,HBITMAP,a,LPSIZE,b)
Fb(BOOL,GetWindowPlacement,HWND,a,LPWINDOWPLACEMENT,b)
Fb(BOOL,SetWindowPlacement,HWND,a,LPWINDOWPLACEMENT,b)
Fb(BOOL,ShowWindow,HWND,a,int,b)
Fb(HDC,BeginPaint,HWND,a,LPPAINTSTRUCT,b)
Fb(LPSTR,lstrcat,LPSTR,a,LPCSTR,b )
@ -2270,6 +2287,12 @@ Fb(WORD,IsDlgButtonChecked,HWND,a,WORD,b)
Fb(WORD,LocalShrink,HANDLE,a,WORD,b)
Fb(WORD,MapVirtualKey,WORD,a,WORD,b)
Fb(WORD,SetSystemPaletteUse,HDC,a,WORD,b)
Fb(WORD,SetBkMode,HDC,a,WORD,b)
Fb(WORD,SetMapMode,HDC,a,WORD,b)
Fb(WORD,SetPolyFillMode,HDC,a,WORD,b)
Fb(WORD,SetRelAbs,HDC,a,WORD,b)
Fb(WORD,SetROP2,HDC,a,WORD,b)
Fb(WORD,SetStretchBltMode,HDC,a,WORD,b)
Fb(WORD,SetTaskQueue,HANDLE,a,HANDLE,b)
Fb(WORD,SetTextAlign,HDC,a,WORD,b)
Fb(WORD,SizeofResource,HANDLE,a,HANDLE,b)
@ -2317,6 +2340,7 @@ Fb(void,Throw,LPCATCHBUF,a,int,b)
Fb(void,ValidateRect,HWND,a,LPRECT,b)
Fb(void,ValidateRgn,HWND,a,HRGN,b)
Fc(BOOL,LineTo,HDC,a,short,b,short,c)
Fc(WORD,GetInternalWindowPos,HWND,a,LPRECT,b,LPPOINT,c)
Fc(LONG,_llseek,int,a,long,b,int,c)
Fc(WORD,_lread,int,a,LPSTR,b,int,c)
Fc(WORD,_lwrite,int,a,LPSTR,b,int,c)
@ -2378,12 +2402,6 @@ Fc(WORD,GetProfileInt,LPSTR,a,LPSTR,b,int,c)
Fc(WORD,GlobalGetAtomName,ATOM,a,LPSTR,b,short,c)
Fc(WORD,SetClassWord,HWND,a,short,b,WORD,c)
Fc(WORD,SetWindowWord,HWND,a,short,b,WORD,c)
Fb(WORD,SetBkMode,HDC,a,WORD,b)
Fb(WORD,SetMapMode,HDC,a,WORD,b)
Fb(WORD,SetPolyFillMode,HDC,a,WORD,b)
Fb(WORD,SetRelAbs,HDC,a,WORD,b)
Fb(WORD,SetROP2,HDC,a,WORD,b)
Fb(WORD,SetStretchBltMode,HDC,a,WORD,b)
Fc(int,FrameRect,HDC,a,LPRECT,b,HBRUSH,c)
Fc(int,GetClassName,HWND,a,LPSTR,b,short,c)
Fc(int,GetClipboardFormatName,WORD,a,LPSTR,b,int,c)
@ -2479,6 +2497,7 @@ Fd(void,FillWindow,HWND,a,HWND,b,HDC,c,HBRUSH,d)
Fd(void,GetScrollRange,HWND,a,int,b,LPINT,c,LPINT,d)
Fd(void,MapWindowPoints,HWND,a,HWND,b,LPPOINT,c,WORD,d)
Fd(void,PlayMetaFileRecord,HDC,a,LPHANDLETABLE,b,LPMETARECORD,c,WORD,d)
Fd(void,SetInternalWindowPos,HWND,a,WORD,b,LPRECT,c,LPPOINT,d)
Fd(void,SetDlgItemInt,HWND,a,WORD,b,WORD,c,BOOL,d)
Fe(BOOL,Rectangle,HDC,a,int,xLeft,int,yTop,int,xRight,int,yBottom)
Fe(int,DrawText,HDC,a,LPSTR,str,int,c,LPRECT,d,WORD,flag)

View File

@ -77,6 +77,14 @@ HCURSOR LoadCursor(HANDLE instance, LPSTR cursor_name)
lpcur->xcursor = XCreateFontCursor(XT_display, XC_watch);
GlobalUnlock(hCursor);
return hCursor;
case IDC_SIZENS:
lpcur->xcursor = XCreateFontCursor(XT_display, XC_sb_v_double_arrow);
GlobalUnlock(hCursor);
return hCursor;
case IDC_SIZEWE:
lpcur->xcursor = XCreateFontCursor(XT_display, XC_sb_h_double_arrow);
GlobalUnlock(hCursor);
return hCursor;
default:
break;
}

View File

@ -62,6 +62,35 @@ extern int Argc;
* FindUnusedSelector
*/
int
FindUnusedSelectors(int n_selectors)
{
int i;
int n_found;
n_found = 0;
for (i = LastUsedSelector + 1; i != LastUsedSelector; i++)
{
if (i >= MAX_SELECTORS)
{
n_found = 0;
i = FIRST_SELECTOR;
}
if (!SelectorMap[i] && ++n_found == n_selectors)
break;
}
if (i == LastUsedSelector)
return 0;
LastUsedSelector = i;
return i - n_selectors + 1;
}
/**********************************************************************
* FindUnusedSelector
*/
int
FindUnusedSelector(void)
{
int i;
@ -728,6 +757,7 @@ CreateSelectors(struct w_files * wpnt)
int i;
int status;
int old_length, file_image_length;
int saved_old_length;
/*
* Allocate memory for the table to keep track of all selectors.
@ -828,14 +858,18 @@ CreateSelectors(struct w_files * wpnt)
if (i + 1 == ne_header->auto_data_seg)
{
auto_data_sel = s->selector;
HEAP_LocalInit(s->base_addr + old_length,
ne_header->local_heap_length);
saved_old_length = old_length;
}
}
s = selectors;
for (i = 0; i < ne_header->n_segment_tab; i++, s++)
{
Segments[s->selector >> 3].owner = auto_data_sel;
if (s->selector == auto_data_sel)
HEAP_LocalInit(auto_data_sel, s->base_addr + saved_old_length,
ne_header->local_heap_length);
}
if(!EnvironmentSelector) {
EnvironmentSelector = CreateEnvironment();

View File

@ -6,8 +6,16 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include "prototypes.h"
#include "segmem.h"
#include "heap.h"
#include "regfunc.h"
MDESC *LOCAL_FreeList;
typedef struct heap_local_heap_s
{
struct heap_local_heap_s *next;
MDESC *free_list;
unsigned short selector;
} LHEAP;
LHEAP *LocalHeaps = NULL;
/**********************************************************************
* HEAP_Init
@ -273,13 +281,50 @@ HEAP_Free(MDESC **free_list, void *block)
return 0;
}
/**********************************************************************
* HEAP_LocalFindHeap
*/
MDESC **
HEAP_LocalFindHeap(unsigned short owner)
{
LHEAP *lh;
#ifdef DEBUG_HEAP
printf("HEAP_LocalFindHeap: owner %04x\n", owner);
#endif
for (lh = LocalHeaps; lh != NULL; lh = lh->next)
{
if (lh->selector == owner)
return &lh->free_list;
}
return NULL;
}
#define LOCALHEAP() HEAP_LocalFindHeap(Segments[Stack16Frame[11] >> 3].owner)
/**********************************************************************
* HEAP_LocalInit
*/
void
HEAP_LocalInit(void *start, int length)
HEAP_LocalInit(unsigned short owner, void *start, int length)
{
HEAP_Init(&LOCAL_FreeList, start, length);
LHEAP *lh;
#ifdef DEBUG_HEAP
printf("HEAP_LocalInit: owner %04x, start %08x, length %04x\n",
owner, start, length);
#endif
lh = (LHEAP *) malloc(sizeof(*lh));
if (lh == NULL)
return;
lh->selector = owner;
lh->next = LocalHeaps;
HEAP_Init(&lh->free_list, start, length);
LocalHeaps = lh;
}
/**********************************************************************
@ -292,9 +337,10 @@ LocalAlloc(int flags, int bytes)
#ifdef DEBUG_HEAP
printf("LocalAlloc: flags %x, bytes %d\n", flags, bytes);
printf(" called from segment %04x\n", Stack16Frame[11]);
#endif
m = HEAP_Alloc(&LOCAL_FreeList, flags, bytes);
m = HEAP_Alloc(LOCALHEAP(), flags, bytes);
#ifdef DEBUG_HEAP
printf("LocalAlloc: returning %x\n", (int) m);
@ -312,7 +358,7 @@ LocalCompact(int min_free)
int max_block;
max_block = 0;
for (m = LOCAL_FreeList; m != NULL; m = m->next)
for (m = *LOCALHEAP(); m != NULL; m = m->next)
if (m->length > max_block)
max_block = m->length;
@ -327,7 +373,7 @@ LocalFlags(unsigned int handle)
{
MDESC *m;
m = (MDESC *) (((int) LOCAL_FreeList & 0xffff0000) |
m = (MDESC *) (((int) *LOCALHEAP() & 0xffff0000) |
(handle & 0xffff)) - 1;
if (m->next != m || m->prev != m)
return 0;
@ -343,8 +389,8 @@ LocalFree(unsigned int handle)
{
unsigned int addr;
addr = ((int) LOCAL_FreeList & 0xffff0000) | (handle & 0xffff);
if (HEAP_Free(&LOCAL_FreeList, (void *) addr) < 0)
addr = ((int) *LOCALHEAP() & 0xffff0000) | (handle & 0xffff);
if (HEAP_Free(LOCALHEAP(), (void *) addr) < 0)
return handle;
else
return 0;
@ -356,7 +402,7 @@ LocalFree(unsigned int handle)
unsigned int
LocalInit(unsigned int segment, unsigned int start, unsigned int end)
{
HEAP_Init(&LOCAL_FreeList,
HEAP_Init(LOCALHEAP(),
(void *) ((segment << 16) | start), end - start + 1);
return segment;
@ -370,7 +416,7 @@ LocalLock(unsigned int handle)
{
MDESC *m;
m = (MDESC *) (((int) LOCAL_FreeList & 0xffff0000) |
m = (MDESC *) (((int) *LOCALHEAP() & 0xffff0000) |
(handle & 0xffff)) - 1;
if (m->next != m || m->prev != m)
return 0;
@ -387,8 +433,8 @@ LocalReAlloc(unsigned int handle, int flags, int bytes)
{
void *m;
m = HEAP_ReAlloc(&LOCAL_FreeList, (void *)
(((int) LOCAL_FreeList & 0xffff0000) | (handle & 0xffff)),
m = HEAP_ReAlloc(LOCALHEAP(), (void *)
(((int) *LOCALHEAP() & 0xffff0000) | (handle & 0xffff)),
bytes, flags);
return m;
@ -402,7 +448,7 @@ LocalSize(unsigned int handle)
{
MDESC *m;
m = (MDESC *) (((int) LOCAL_FreeList & 0xffff0000) |
m = (MDESC *) (((int) *LOCALHEAP() & 0xffff0000) |
(handle & 0xffff)) - 1;
if (m->next != m || m->prev != m)
return 0;
@ -418,7 +464,7 @@ LocalUnlock(unsigned int handle)
{
MDESC *m;
m = (MDESC *) (((int) LOCAL_FreeList & 0xffff0000) |
m = (MDESC *) (((int) *LOCALHEAP() & 0xffff0000) |
(handle & 0xffff)) - 1;
if (m->next != m || m->prev != m)
return 1;

View File

@ -1,6 +1,6 @@
CFLAGS=$(COPTS) $(DEBUGOPTS) -I../include
OBJS=kernel.o user.o xt.o rect.o file.o sound.o emulate.o \
OBJS=main.o kernel.o user.o rect.o file.o sound.o emulate.o \
keyboard.o profile.o lstr.o exec.o message.o int1a.o int21.o \
dos_fs.o comm.o spy.o

View File

@ -25,6 +25,8 @@ struct DosDeviceStruct {
char *devicename; /* /dev/cua1 */
int fd;
int suspended;
int unget;
int unget_byte;
};
struct DosDeviceStruct COM[MAX_PORTS];
@ -83,15 +85,6 @@ void Comm_Init(void)
}
atexit(Comm_DeInit);
#ifdef DEBUG_COMM
for (x=0; x!=MAX_PORTS; x++) {
if (COM[x].devicename)
fprintf(stderr, "comm: COM%d = %s\n", x, COM[x].devicename);
if (LPT[x].devicename)
fprintf(stderr, "comm: LPT%d = %s\n", x, LPT[x].devicename);
}
#endif
}
void Comm_DeInit(void)
@ -103,13 +96,11 @@ void Comm_DeInit(void)
if (COM[x].devicename) {
if (COM[x].fd)
close(COM[x].fd);
fprintf(stderr, "comm: COM%d = %s\n",x,COM[x].devicename);
free(COM[x].devicename);
}
if (LPT[x].devicename) {
if (LPT[x].fd)
close(LPT[x].fd);
fprintf(stderr, "comm: LPT%d = %s\n",x,LPT[x].devicename);
free(LPT[x].devicename);
}
}
@ -799,7 +790,6 @@ int UngetCommChar(int fd, char chUnget)
#ifdef DEBUG_COMM
fprintf(stderr,"UngetCommChar: fd %d (char %d)\n", fd, chUnget);
#endif
fprintf(stderr,"NOT implemented!\n");
if ((ptr = GetDeviceStruct(fd)) == NULL) {
commerror = IE_BADID;
@ -811,16 +801,22 @@ fprintf(stderr,"UngetCommChar: fd %d (char %d)\n", fd, chUnget);
return -1;
}
ptr->unget = 1;
ptr->unget_byte = chUnget;
commerror = 0;
return 0;
}
int ReadComm(int fd, LPSTR lpvBuf, int cbRead)
{
int status, length;
struct DosDeviceStruct *ptr;
#ifdef DEBUG_COMM
fprintf(stderr,"ReadComm: fd %d, ptr %d, length %d\n", fd, lpvBuf, cbRead);
#endif
if ((ptr = GetDeviceStruct(fd)) == NULL) {
commerror = IE_BADID;
return -1;
@ -831,18 +827,29 @@ fprintf(stderr,"ReadComm: fd %d, ptr %d, length %d\n", fd, lpvBuf, cbRead);
return -1;
}
if (read(fd, (void *) lpvBuf, cbRead) == -1) {
if (ptr->unget) {
*lpvBuf = ptr->unget_byte;
lpvBuf++;
ptr->unget = 0;
length = 1;
} else
length = 0;
status = read(fd, (void *) lpvBuf, cbRead);
if (status == -1) {
commerror = WinError();
return -1;
return -1 - length;
} else {
commerror = 0;
return 0;
return length + status;
}
}
int WriteComm(int fd, LPSTR lpvBuf, int cbWrite)
{
int x;
int x, length;
struct DosDeviceStruct *ptr;
#ifdef DEBUG_COMM
@ -859,14 +866,18 @@ fprintf(stderr,"WriteComm: fd %d, ptr %d, length %d\n", fd, lpvBuf, cbWrite);
return -1;
}
#ifdef DEBUG_COMM
for (x=0; x != cbWrite ; x++)
fprintf(stderr,"%c", *(lpvBuf + x) );
#endif
if (write(fd, (void *) lpvBuf, cbWrite) == -1) {
length = write(fd, (void *) lpvBuf, cbWrite);
if (length == -1) {
commerror = WinError();
return -1;
} else {
commerror = 0;
return 0;
return length;
}
}

View File

@ -338,8 +338,9 @@ char *GetDirectUnixFileName(char *dosfilename)
{
/* a:\windows\system.ini => /dos/windows/system.ini */
static char temp[256];
int drive;
char x, temp[256];
char x;
if (dosfilename[1] == ':')
{

View File

@ -73,7 +73,7 @@ BOOL WinHelp(HWND hWnd, LPSTR lpHelpFile, WORD wCommand, DWORD dwData)
case 0:
printf("New process started !\n");
ArgV[0] = "wine";
ArgV[1] = "/C:/windows/winhelp.exe";
ArgV[1] = "winhelp.exe";
ArgV[2] = lpHelpFile;
switch (wCommand) {
case HELP_CONTEXT:
@ -99,5 +99,3 @@ BOOL WinHelp(HWND hWnd, LPSTR lpHelpFile, WORD wCommand, DWORD dwData)
}
return(TRUE);
}

View File

@ -5,6 +5,7 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <stdlib.h>
#include "prototypes.h"
#include "regfunc.h"
#include "options.h"
extern unsigned short WIN_StackSize;
@ -48,7 +49,7 @@ KERNEL_InitTask()
_BX = 0x81;
_AX = 1;
_CX = WIN_StackSize;
_DX = 1;
_DX = Options.cmdShow;
_SI = 0;
ReturnFromRegisterFunc();
/* Function does not return */

120
misc/main.c Normal file
View File

@ -0,0 +1,120 @@
/*
* Main function.
*
* Copyright 1994 Alexandre Julliard
*/
static char Copyright[] = "Copyright Alexandre Julliard, 1994";
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include "windows.h"
#include "options.h"
Display * XT_display; /* To be removed */
Screen * XT_screen; /* To be removed */
Display * display;
Screen * screen;
struct options Options =
{ /* default options */
NULL, /* spyFilename */
FALSE, /* usePrivateMap */
FALSE, /* synchronous */
SW_SHOWNORMAL /* cmdShow */
};
static XrmOptionDescRec optionsTable[] =
{
{ "-display", ".display", XrmoptionSepArg, (caddr_t)NULL },
{ "-iconic", ".iconic", XrmoptionNoArg, (caddr_t)"on" },
{ "-privatemap", ".privatemap", XrmoptionNoArg, (caddr_t)"on" },
{ "-synchronous", ".synchronous", XrmoptionNoArg, (caddr_t)"on" },
{ "-spy", ".spy", XrmoptionSepArg, (caddr_t)NULL }
};
#define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
/***********************************************************************
* MAIN_Usage
*/
static void MAIN_Usage( char *name )
{
fprintf( stderr,"Usage: %s [-display name] [-iconic] [-privatemap]\n"
" [-synchronous] [-spy file] program [arguments]\n",
name );
exit(1);
}
/***********************************************************************
* MAIN_ParseOptions
*
* Parse command line options and open display.
*/
static void MAIN_ParseOptions( int *argc, char *argv[] )
{
char *dummy, *display_name;
XrmValue value;
XrmDatabase db = NULL;
XrmParseCommand( &db, optionsTable, NB_OPTIONS, "wine", argc, argv );
if (*argc < 2) MAIN_Usage( argv[0] );
if (XrmGetResource( db, "wine.display", "Wine.display", &dummy, &value ))
display_name = value.addr;
else display_name = NULL;
if (!(display = XOpenDisplay( display_name )))
{
fprintf( stderr, "%s: Can't open display: %s\n",
argv[0], display_name ? display_name : "" );
exit(1);
}
if (XrmGetResource(db,"wine.iconic","Wine.iconic",&dummy,&value))
Options.cmdShow = SW_SHOWMINIMIZED;
if (XrmGetResource(db,"wine.privatemap","Wine.privatemap",&dummy,&value))
Options.usePrivateMap = TRUE;
if (XrmGetResource(db,"wine.synchronous","Wine.synchronous",&dummy,&value))
Options.synchronous = TRUE;
if (XrmGetResource(db,"wine.spy","Wine.spy",&dummy,&value))
Options.spyFilename = value.addr;
}
/***********************************************************************
* main
*/
int main( int argc, char *argv[] )
{
XrmInitialize();
MAIN_ParseOptions( &argc, argv );
screen = DefaultScreenOfDisplay( display );
XT_display = display;
XT_screen = screen;
if (Options.synchronous) XSynchronize( display, True );
DOS_InitFS();
Comm_Init();
return _WinMain( argc, argv );
}
/***********************************************************************
* MessageBeep (USER.104)
*/
void MessageBeep( WORD i )
{
XBell( display, 100 );
}

View File

@ -108,6 +108,9 @@ LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam)
int x;
switch(message) {
case WM_CREATE:
#ifdef DEBUG_MSGBOX
printf("MessageBox WM_CREATE !\n");
#endif
wndPtr = WIN_FindWndPtr(hWnd);
createStruct = (CREATESTRUCT *)lParam;
lpmbInit = (LPMSGBOX)createStruct->lpCreateParams;
@ -122,55 +125,55 @@ LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam)
lpmb->hWndYes = CreateWindow("BUTTON", "&Ok",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 30, rect.bottom - 25,
60, 18, hWnd, 1, wndPtr->hInstance, 0L);
60, 18, hWnd, IDOK, wndPtr->hInstance, 0L);
break;
case MB_OKCANCEL :
lpmb->hWndYes = CreateWindow("BUTTON", "&Ok",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 65, rect.bottom - 25,
60, 18, hWnd, 1, wndPtr->hInstance, 0L);
60, 18, hWnd, IDOK, wndPtr->hInstance, 0L);
lpmb->hWndCancel = CreateWindow("BUTTON", "&Cancel",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 + 5, rect.bottom - 25,
60, 18, hWnd, 2, wndPtr->hInstance, 0L);
60, 18, hWnd, IDCANCEL, wndPtr->hInstance, 0L);
break;
case MB_ABORTRETRYIGNORE :
lpmb->hWndYes = CreateWindow("BUTTON", "&Retry",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 100, rect.bottom - 25,
60, 18, hWnd, 1, wndPtr->hInstance, 0L);
60, 18, hWnd, IDRETRY, wndPtr->hInstance, 0L);
lpmb->hWndNo = CreateWindow("BUTTON", "&Ignore",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 30, rect.bottom - 25,
60, 18, hWnd, 2, wndPtr->hInstance, 0L);
60, 18, hWnd, IDIGNORE, wndPtr->hInstance, 0L);
lpmb->hWndCancel = CreateWindow("BUTTON", "&Abort",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 + 40, rect.bottom - 25,
60, 18, hWnd, 3, wndPtr->hInstance, 0L);
60, 18, hWnd, IDABORT, wndPtr->hInstance, 0L);
break;
case MB_YESNO :
lpmb->hWndYes = CreateWindow("BUTTON", "&Yes",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 65, rect.bottom - 25,
60, 18, hWnd, 1, wndPtr->hInstance, 0L);
60, 18, hWnd, IDYES, wndPtr->hInstance, 0L);
lpmb->hWndNo = CreateWindow("BUTTON", "&No",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 + 5, rect.bottom - 25,
60, 18, hWnd, 2, wndPtr->hInstance, 0L);
60, 18, hWnd, IDNO, wndPtr->hInstance, 0L);
break;
case MB_YESNOCANCEL :
lpmb->hWndYes = CreateWindow("BUTTON", "&Yes",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 100, rect.bottom - 25,
60, 18, hWnd, 1, wndPtr->hInstance, 0L);
60, 18, hWnd, IDYES, wndPtr->hInstance, 0L);
lpmb->hWndNo = CreateWindow("BUTTON", "&No",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 - 30, rect.bottom - 25,
60, 18, hWnd, 2, wndPtr->hInstance, 0L);
60, 18, hWnd, IDNO, wndPtr->hInstance, 0L);
lpmb->hWndCancel = CreateWindow("BUTTON", "&Cancel",
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
rect.right / 2 + 40, rect.bottom - 25,
60, 18, hWnd, 3, wndPtr->hInstance, 0L);
60, 18, hWnd, IDCANCEL, wndPtr->hInstance, 0L);
break;
}
switch(lpmb->wType & MB_ICONMASK) {
@ -199,6 +202,9 @@ LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam)
}
break;
case WM_PAINT:
#ifdef DEBUG_MSGBOX
printf("MessageBox WM_PAINT !\n");
#endif
lpmb = MsgBoxGetStorageHeader(hWnd);
CopyRect(&rect, &lpmb->rectStr);
hDC = BeginPaint(hWnd, &ps);
@ -224,65 +230,12 @@ LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam)
break;
case WM_COMMAND:
lpmb = MsgBoxGetStorageHeader(hWnd);
switch(wParam) {
case 1:
lpmb->wRetVal = IDOK;
break;
case 2:
wndPtr = WIN_FindWndPtr(hWnd);
hDC = GetDC(hWnd);
/*
for (x = 1; x < 50; x++) {
hBitMap = LoadBitmap(wndPtr->hInstance, MAKEINTRESOURCE(x));
GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
hMemDC = CreateCompatibleDC(hDC);
SelectObject(hMemDC, hBitMap);
printf(" bm.bmWidth=%d bm.bmHeight=%d\n",
bm.bmWidth, bm.bmHeight);
BitBlt(hDC, x * 20, 30, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
}
*/
hBitMap = LoadBitmap((HINSTANCE)NULL, "WINELOGO");
GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
printf("bm.bmWidth=%d bm.bmHeight=%d\n",
bm.bmWidth, bm.bmHeight);
hMemDC = CreateCompatibleDC(hDC);
SelectObject(hMemDC, hBitMap);
BitBlt(hDC, 100, 30, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
ReleaseDC(hWnd, hDC);
lpmb->wRetVal = IDCANCEL;
/*
SetWindowPos(lpmb->hWndNo, (HWND)NULL, 20, 20, 0, 0,
SWP_NOSIZE | SWP_NOZORDER);
*/
return 0;
break;
case 3:
hDC = GetDC(hWnd);
hInst2 = LoadImage("ev3lite.exe");
printf("hInst2=%04X\n", hInst2);
hIcon = LoadIcon(hInst2, "EV3LITE");
DrawIcon(hDC, 20, 20, hIcon);
DestroyIcon(hIcon);
hInst2 = LoadImage("moricons.dll");
printf("hInst2=%04X\n", hInst2);
hIcon = LoadIcon(hInst2, MAKEINTRESOURCE(1));
/* hIcon = LoadIcon(hInst2, "WINEICON"); */
DrawIcon(hDC, 60, 20, hIcon);
DestroyIcon(hIcon);
hIcon = LoadIcon((HINSTANCE)NULL, IDI_EXCLAMATION);
DrawIcon(hDC, 1000, 20, hIcon);
DestroyIcon(hIcon);
ReleaseDC(hWnd, hDC);
lpmb->wRetVal = IDIGNORE;
return(0);
break;
default:
return(0);
}
CloseWindow(hWnd);
if (wParam < IDOK || wParam > IDNO) return(0);
lpmb->wRetVal = wParam;
#ifdef DEBUG_MSGBOX
printf("MessageBox sending WM_CLOSE !\n");
#endif
PostMessage(hWnd, WM_CLOSE, 0, 0L);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam );
@ -292,3 +245,52 @@ return(0);
/*************************************************************************
* "About Wine..." Dialog Box
*/
BOOL FAR PASCAL AboutWine_Proc(HWND hDlg, WORD msg, WORD wParam, LONG lParam)
{
HDC hDC;
HDC hMemDC;
PAINTSTRUCT ps;
int OldBackMode;
HFONT hOldFont;
RECT rect;
BITMAP bm;
char C[80];
int X;
static HBITMAP hBitMap;
switch (msg) {
case WM_INITDIALOG:
strcpy(C, "WINELOGO");
hBitMap = LoadBitmap((HINSTANCE)NULL, (LPSTR)C);
return TRUE;
case WM_PAINT:
hDC = BeginPaint(hDlg, &ps);
GetClientRect(hDlg, &rect);
FillRect(hDC, &rect, GetStockObject(GRAY_BRUSH));
InflateRect(&rect, -3, -3);
FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH));
InflateRect(&rect, -10, -10);
hMemDC = CreateCompatibleDC(hDC);
SelectObject(hMemDC, hBitMap);
GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
BitBlt(hDC, rect.left, rect.top, bm.bmWidth, bm.bmHeight,
hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
EndPaint(hDlg, &ps);
return TRUE;
case WM_COMMAND:
switch (wParam)
{
case IDOK:
CloseDLG: EndDialog(hDlg, TRUE);
return TRUE;
default:
return TRUE;
}
}
return FALSE;
}

View File

@ -5,9 +5,12 @@
#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include "wineopts.h"
#include "windows.h"
#include "wine.h"
#include "options.h"
#ifndef NOSPY
@ -244,9 +247,14 @@ void SpyInit(void)
if (SpyFp == NULL)
return;
GetPrivateProfileString("spy", "file", "", filename, sizeof(filename),
WINE_INI);
if (Options.spyFilename == NULL)
{
GetPrivateProfileString("spy", "file", "", filename, sizeof(filename),
WINE_INI);
}
else
strncpy(filename, Options.spyFilename, 100);
if (strcasecmp(filename, "CON") == 0)
SpyFp = stdout;

View File

@ -1,74 +0,0 @@
/*
* X toolkit functions
*
* Copyright 1993 Alexandre Julliard
*/
static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include <sys/param.h>
#include <sys/times.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Core.h>
#include <X11/Shell.h>
#include "windows.h"
#ifdef __NetBSD__
#define HZ 100
#endif
Display * XT_display;
Screen * XT_screen;
Display * display;
Screen * screen;
XtAppContext XT_app_context;
static Widget topLevelWidget;
/***********************************************************************
* main
*/
void main(int argc, char **argv)
{
topLevelWidget = XtVaAppInitialize(&XT_app_context,
"XWine", /* Application class */
NULL, 0, /* Option list */
&argc, argv, /* Command line args */
NULL, /* Fallback resources */
NULL );
XT_display = XtDisplay( topLevelWidget );
XT_screen = XtScreen( topLevelWidget );
display = XtDisplay( topLevelWidget );
screen = XtScreen( topLevelWidget );
DOS_InitFS();
Comm_Init();
_WinMain( argc, argv );
}
/********************************************************************
*
* Miscellaneous partially implemented functions.
*
*/
void MessageBeep( WORD i )
{
XBell(XT_display, 100);
}
/***********************************************************************
* GetTickCount (USER.13)
*/
DWORD GetTickCount()
{
struct tms dummy;
return (times(&dummy) * 1000) / HZ;
}

View File

@ -113,9 +113,9 @@ BOOL BitBlt( HDC hdcDest, short xDest, short yDest, short width, short height,
/***********************************************************************
* StrechBlt (GDI.35)
* StretchBlt (GDI.35)
*/
BOOL StrechBlt( HDC hdcDest, short xDest, short yDest, short widthDest, short heightDest,
BOOL StretchBlt( HDC hdcDest, short xDest, short yDest, short widthDest, short heightDest,
HDC hdcSrc, short xSrc, short ySrc, short widthSrc, short heightSrc, DWORD rop )
{
int xs1, xs2, ys1, ys2;
@ -124,7 +124,7 @@ BOOL StrechBlt( HDC hdcDest, short xDest, short yDest, short widthDest, short he
/*#ifdef DEBUG_GDI */
printf( "StrechBlt: %d %d,%d %dx%d %d %d,%d %dx%d %08x\n",
printf( "StretchBlt: %d %d,%d %dx%d %d %d,%d %dx%d %08x\n",
hdcDest, xDest, yDest, widthDest, heightDest, hdcSrc, xSrc,
ySrc, widthSrc, heightSrc, rop );
/*#endif */

View File

@ -10,17 +10,12 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include <X11/Xlib.h>
#include "windows.h"
#include "options.h"
extern Display * XT_display;
extern Screen * XT_screen;
extern Display * display;
extern Screen * screen;
/*
* We try to use a private color map if possible, because Windows programs
* assume that palette(0) == Black and palette(max-1) == White.
*/
#undef USE_PRIVATE_MAP
Colormap COLOR_WinColormap = 0;
@ -55,10 +50,10 @@ static int COLOR_FillDefaultMap()
for (i = 0; i < NB_SYS_COLORS; i++)
{
if (XParseColor( XT_display, DefaultColormapOfScreen( XT_screen ),
if (XParseColor( display, DefaultColormapOfScreen( screen ),
SysColors[i], &color ))
{
if (XAllocColor( XT_display, DefaultColormapOfScreen( XT_screen ),
if (XAllocColor( display, DefaultColormapOfScreen( screen ),
&color ))
total++;
}
@ -72,8 +67,6 @@ static int COLOR_FillDefaultMap()
*
* Fill the private colormap.
*/
#ifdef USE_PRIVATE_MAP
static BOOL COLOR_BuildMap( Colormap map, int depth, int size )
{
XColor color;
@ -99,7 +92,7 @@ static BOOL COLOR_BuildMap( Colormap map, int depth, int size )
color.red = r;
color.green = g;
color.blue = b;
XStoreColor( XT_display, map, &color );
XStoreColor( display, map, &color );
}
}
@ -107,46 +100,47 @@ static BOOL COLOR_BuildMap( Colormap map, int depth, int size )
for (i = 0; i < NB_SYS_COLORS; i++)
{
if (!XParseColor( XT_display, map, SysColors[i], &color ))
if (!XParseColor( display, map, SysColors[i], &color ))
color.red = color.green = color.blue = color.flags = 0;
if (i < NB_SYS_COLORS/2) color.pixel = i;
else color.pixel = (1 << depth) - NB_SYS_COLORS + i;
if (color.pixel < size) XStoreColor( XT_display, map, &color );
if (color.pixel < size) XStoreColor( display, map, &color );
}
return TRUE;
}
#endif /* USE_PRIVATE_MAP */
/***********************************************************************
* COLOR_Init
*/
BOOL COLOR_Init()
{
Visual * visual = DefaultVisual( XT_display, DefaultScreen(XT_display) );
Visual * visual = DefaultVisual( display, DefaultScreen(display) );
switch(visual->class)
{
case GrayScale:
case PseudoColor:
case DirectColor:
#ifdef USE_PRIVATE_MAP
COLOR_WinColormap = XCreateColormap( XT_display,
DefaultRootWindow(XT_display),
visual, AllocAll );
if (COLOR_WinColormap)
COLOR_BuildMap(COLOR_WinColormap,
DefaultDepth(XT_display, DefaultScreen(XT_display)),
visual->map_entries );
else COLOR_FillDefaultMap();
break;
#endif /* USE_PRIVATE_MAP */
case StaticGray:
case StaticColor:
case TrueColor:
case GrayScale:
case PseudoColor:
case DirectColor:
if (Options.usePrivateMap)
{
COLOR_WinColormap = XCreateColormap( display,
DefaultRootWindow(display),
visual, AllocAll );
if (COLOR_WinColormap)
{
COLOR_BuildMap(COLOR_WinColormap,
DefaultDepth(display, DefaultScreen(display)),
visual->map_entries );
break;
}
}
/* Fall through */
case StaticGray:
case StaticColor:
case TrueColor:
COLOR_FillDefaultMap();
COLOR_WinColormap = DefaultColormapOfScreen( XT_screen );
COLOR_WinColormap = DefaultColormapOfScreen( screen );
break;
}
return TRUE;

View File

@ -12,12 +12,15 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include "class.h"
#include "user.h"
extern Display * display;
extern LONG NC_HandleNCPaint( HWND hwnd, HRGN hrgn );
extern LONG NC_HandleNCCalcSize( HWND hwnd, NCCALCSIZE_PARAMS *params );
extern LONG NC_HandleNCHitTest( HWND hwnd, POINT pt );
extern LONG NC_HandleNCMouseMsg(HWND hwnd, WORD msg, WORD wParam, LONG lParam);
extern LONG NC_HandleNCLButtonDown( HWND hwnd, WORD wParam, LONG lParam );
extern LONG NC_HandleNCLButtonUp( HWND hwnd, WORD wParam, LONG lParam );
extern LONG NC_HandleNCLButtonDblClk( HWND hwnd, WORD wParam, LONG lParam );
extern LONG NC_HandleNCMouseMove( HWND hwnd, WORD wParam, POINT pt );
extern LONG NC_HandleSysCommand( HWND hwnd, WORD wParam, POINT pt );
extern LONG NC_HandleSetCursor( HWND hwnd, WORD wParam, LONG lParam );
/***********************************************************************
@ -28,7 +31,6 @@ LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam )
CLASS * classPtr;
LPSTR textPtr;
int len;
int tempwidth, tempheight;
WND * wndPtr = WIN_FindWndPtr( hwnd );
#ifdef DEBUG_MESSAGE
@ -63,10 +65,16 @@ LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam )
return NC_HandleNCHitTest( hwnd, MAKEPOINT(lParam) );
case WM_NCLBUTTONDOWN:
return NC_HandleNCLButtonDown( hwnd, wParam, lParam );
case WM_NCLBUTTONUP:
return NC_HandleNCLButtonUp( hwnd, wParam, lParam );
case WM_NCLBUTTONDBLCLK:
return NC_HandleNCLButtonDblClk( hwnd, wParam, lParam );
case WM_NCMOUSEMOVE:
return NC_HandleNCMouseMsg( hwnd, msg, wParam, lParam );
return NC_HandleNCMouseMove( hwnd, wParam, MAKEPOINT(lParam) );
case WM_NCDESTROY:
{
@ -170,32 +178,18 @@ LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam )
strlen((LPSTR)lParam) + 1);
textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
strcpy(textPtr, (LPSTR)lParam);
XStoreName( display, wndPtr->window, textPtr );
return (0L);
}
case WM_SETCURSOR:
if (wndPtr->hCursor != (HCURSOR)NULL)
SetCursor(wndPtr->hCursor);
return 0L;
if (wndPtr->dwStyle & WS_CHILD)
if (SendMessage(wndPtr->hwndParent, WM_SETCURSOR, wParam, lParam))
return TRUE;
return NC_HandleSetCursor( hwnd, wParam, lParam );
case WM_SYSCOMMAND:
switch (wParam)
{
case SC_CLOSE:
ShowWindow(hwnd, SW_MINIMIZE);
printf("defdwndproc WM_SYSCOMMAND SC_CLOSE !\n");
return SendMessage( hwnd, WM_CLOSE, 0, 0 );
case SC_RESTORE:
ShowWindow(hwnd, SW_RESTORE);
break;
case SC_MINIMIZE:
ShowWindow(hwnd, SW_MINIMIZE);
printf("defdwndproc WM_SYSCOMMAND SC_MINIMIZE !\n");
break;
case SC_MAXIMIZE:
ShowWindow(hwnd, SW_MAXIMIZE);
break;
}
break;
return NC_HandleSysCommand( hwnd, wParam, MAKEPOINT(lParam) );
case WM_SYSKEYDOWN:
if (wParam == VK_MENU) {
printf("VK_MENU Pressed // hMenu=%04X !\n", GetMenu(hwnd));

View File

@ -117,7 +117,6 @@ static void EVENT_EnterNotify( HWND hwnd, XCrossingEvent *event );
static void EVENT_FocusIn( HWND hwnd, XFocusChangeEvent *event );
static void EVENT_FocusOut( HWND hwnd, XFocusChangeEvent *event );
static void EVENT_Expose( HWND hwnd, XExposeEvent *event );
static void EVENT_ConfigureNotify( HWND hwnd, XConfigureEvent *event );
/***********************************************************************
@ -172,10 +171,6 @@ void EVENT_ProcessEvent( XEvent *event )
EVENT_Expose( hwnd, (XExposeEvent*)event );
break;
case ConfigureNotify:
EVENT_ConfigureNotify( hwnd, (XConfigureEvent*)event );
break;
#ifdef DEBUG_EVENT
default:
printf( "Unprocessed event %s for hwnd %d\n",
@ -257,6 +252,12 @@ static void EVENT_key( HWND hwnd, XKeyEvent *event )
keysym, count, Str[0], Str);
#endif
if (wndPtr->dwStyle & WS_DISABLED) {
if (event->type == KeyPress) XBell(display, 0);
return;
}
xkey = LOWORD(keysym);
key_type = HIBYTE(xkey);
key = LOBYTE(xkey);
@ -358,6 +359,14 @@ static void EVENT_key( HWND hwnd, XKeyEvent *event )
*/
static void EVENT_MotionNotify( HWND hwnd, XMotionEvent *event )
{
WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return;
if (wndPtr->dwStyle & WS_DISABLED) {
return;
}
hardware_event( hwnd, WM_MOUSEMOVE,
EVENT_XStateToKeyState( event->state ), 0L,
event->x_root & 0xffff, event->y_root & 0xffff,
@ -373,6 +382,18 @@ static void EVENT_ButtonPress( HWND hwnd, XButtonEvent *event )
static WORD messages[NB_BUTTONS] =
{ WM_LBUTTONDOWN, WM_MBUTTONDOWN, WM_RBUTTONDOWN };
int buttonNum = event->button - 1;
WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) {
printf("couldn't find window\n");
return;
}
if (wndPtr->dwStyle & WS_DISABLED) {
XBell(display, 0);
return;
}
if (buttonNum >= NB_BUTTONS) return;
winHasCursor = event->window;
@ -391,6 +412,13 @@ static void EVENT_ButtonRelease( HWND hwnd, XButtonEvent *event )
static const WORD messages[NB_BUTTONS] =
{ WM_LBUTTONUP, WM_MBUTTONUP, WM_RBUTTONUP };
int buttonNum = event->button - 1;
WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return;
if (wndPtr->dwStyle & WS_DISABLED) {
return;
}
if (buttonNum >= NB_BUTTONS) return;
winHasCursor = event->window;
@ -401,42 +429,20 @@ static void EVENT_ButtonRelease( HWND hwnd, XButtonEvent *event )
}
/***********************************************************************
* EVENT_ConfigureNotify
*/
static void EVENT_ConfigureNotify( HWND hwnd, XConfigureEvent *event )
{
HANDLE handle;
NCCALCSIZE_PARAMS *params;
WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return;
wndPtr->rectWindow.left = event->x;
wndPtr->rectWindow.top = event->y;
wndPtr->rectWindow.right = event->x + event->width;
wndPtr->rectWindow.bottom = event->y + event->height;
/* Send WM_NCCALCSIZE message */
handle = GlobalAlloc( GMEM_MOVEABLE, sizeof(*params) );
params = (NCCALCSIZE_PARAMS *)GlobalLock( handle );
params->rgrc[0] = wndPtr->rectWindow;
params->lppos = NULL; /* Should be WINDOWPOS struct */
SendMessage( hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)params );
wndPtr->rectClient = params->rgrc[0];
PostMessage( hwnd, WM_MOVE, 0,
MAKELONG( wndPtr->rectClient.left, wndPtr->rectClient.top ));
PostMessage( hwnd, WM_SIZE, SIZE_RESTORED,
MAKELONG( wndPtr->rectClient.right-wndPtr->rectClient.left,
wndPtr->rectClient.bottom-wndPtr->rectClient.top) );
GlobalUnlock( handle );
GlobalFree( handle );
}
/**********************************************************************
* EVENT_FocusIn
*/
static void EVENT_FocusIn( HWND hwnd, XFocusChangeEvent *event )
{
WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return;
if (wndPtr->dwStyle & WS_DISABLED) {
return;
}
PostMessage( hwnd, WM_SETFOCUS, hwnd, 0 );
hWndFocus = hwnd;
}
@ -447,6 +453,14 @@ static void EVENT_FocusIn( HWND hwnd, XFocusChangeEvent *event )
*/
static void EVENT_FocusOut( HWND hwnd, XFocusChangeEvent *event )
{
WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return;
if (wndPtr->dwStyle & WS_DISABLED) {
return;
}
if (hWndFocus)
{
PostMessage( hwnd, WM_KILLFOCUS, hwnd, 0 );
@ -460,9 +474,20 @@ static void EVENT_FocusOut( HWND hwnd, XFocusChangeEvent *event )
*/
static void EVENT_EnterNotify( HWND hwnd, XCrossingEvent *event )
{
WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return;
if (wndPtr->dwStyle & WS_DISABLED) {
return;
}
if (captureWnd != 0) return;
winHasCursor = event->window;
PostMessage( hwnd, WM_SETCURSOR, hwnd, 0 );
/* Simulate a mouse motion to set the correct cursor */
hardware_event( hwnd, WM_MOUSEMOVE,
EVENT_XStateToKeyState( event->state ), 0L,
event->x_root & 0xffff, event->y_root & 0xffff,
event->time, 0 );
}

View File

@ -382,7 +382,7 @@ BOOL FillRgn( HDC hdc, HRGN hrgn, HBRUSH hbrush )
/***********************************************************************
* DrawFocusRect (GDI.466)
* DrawFocusRect (USER.466)
*/
void DrawFocusRect( HDC hdc, LPRECT rc )
{

View File

@ -196,10 +196,11 @@ static void MSG_RemoveMsg( MESSAGEQUEUE * msgQueue, int pos )
*
* Translate an mouse hardware event into a real mouse message.
* Actions performed:
* - Translate button down messages in double-clicks.
* - Translate button-down messages in double-clicks.
* - Send the WM_NCHITTEST message to find where the cursor is.
* - Translate the message into a non-client message, or translate
* the coordinates to client coordinates.
* - Send the WM_SETCURSOR message.
*/
static void MSG_TranslateMouseMsg( MSG *msg )
{
@ -209,6 +210,8 @@ static void MSG_TranslateMouseMsg( MSG *msg )
LONG hittest_result = SendMessage( msg->hwnd, WM_NCHITTEST, 0,
MAKELONG( msg->pt.x, msg->pt.y ) );
SendMessage( msg->hwnd, WM_SETCURSOR, msg->hwnd,
MAKELONG( hittest_result, msg->message ));
if ((msg->message == WM_LBUTTONDOWN) ||
(msg->message == WM_RBUTTONDOWN) ||
@ -697,3 +700,13 @@ WORD RegisterWindowMessage( LPCSTR str )
return GlobalAddAtom( str );
}
/***********************************************************************
* GetTickCount (USER.13)
*/
DWORD GetTickCount()
{
struct timeval t;
gettimeofday( &t, NULL );
return (t.tv_sec * 1000) + (t.tv_usec / 1000);
}

View File

@ -10,6 +10,35 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1994";
#include "sysmetrics.h"
static HBITMAP hbitmapClose = 0;
static HBITMAP hbitmapMinimize = 0;
static HBITMAP hbitmapMinimizeD = 0;
static HBITMAP hbitmapMaximize = 0;
static HBITMAP hbitmapMaximizeD = 0;
static HBITMAP hbitmapRestore = 0;
static HBITMAP hbitmapRestoreD = 0;
/* Hit test code returned when the mouse is captured. */
/* Used to direct NC mouse messages to the correct part of the window. */
static WORD captureHitTest = HTCLIENT;
/* Point where the current capture started. Used for SC_SIZE and SC_MOVE. */
static POINT capturePoint;
/* Current window rectangle when a move or resize is in progress. */
static RECT sizingRect;
/* Some useful macros */
#define HAS_DLGFRAME(style,exStyle) \
(((style) & WS_DLGFRAME) && \
(((exStyle) & WS_EX_DLGMODALFRAME) || !((style) & WS_BORDER)))
#define HAS_THICKFRAME(style) \
(((style) & WS_THICKFRAME) && \
!(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
#define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0))
/***********************************************************************
* NC_AdjustRect
*
@ -18,14 +47,15 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1994";
*/
static void NC_AdjustRect( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
{
if ((style & WS_DLGFRAME) &&
((exStyle & WS_EX_DLGMODALFRAME) || !(style & WS_BORDER)))
if (HAS_DLGFRAME( style, exStyle ))
InflateRect( rect, SYSMETRICS_CXDLGFRAME, SYSMETRICS_CYDLGFRAME );
else if (style & WS_THICKFRAME)
InflateRect( rect, SYSMETRICS_CXFRAME, SYSMETRICS_CYFRAME );
if (style & WS_BORDER)
InflateRect( rect, SYSMETRICS_CXBORDER, SYSMETRICS_CYBORDER );
else
{
if (HAS_THICKFRAME(style))
InflateRect( rect, SYSMETRICS_CXFRAME, SYSMETRICS_CYFRAME );
if (style & WS_BORDER)
InflateRect( rect, SYSMETRICS_CXBORDER, SYSMETRICS_CYBORDER );
}
if ((style & WS_CAPTION) == WS_CAPTION)
rect->top -= SYSMETRICS_CYCAPTION - 1;
@ -74,14 +104,12 @@ void AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle )
LONG NC_HandleNCCalcSize( HWND hwnd, NCCALCSIZE_PARAMS *params )
{
RECT tmpRect = { 0, 0, 0, 0 };
BOOL hasMenu;
WND *wndPtr = WIN_FindWndPtr( hwnd );
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return 0;
hasMenu = (!(wndPtr->dwStyle & WS_CHILD)) && (wndPtr->wIDmenu != 0);
NC_AdjustRect( &tmpRect, wndPtr->dwStyle, hasMenu, wndPtr->dwExStyle );
NC_AdjustRect( &tmpRect, wndPtr->dwStyle,
HAS_MENU(wndPtr), wndPtr->dwExStyle );
params->rgrc[0].left -= tmpRect.left;
params->rgrc[0].top -= tmpRect.top;
@ -92,21 +120,45 @@ LONG NC_HandleNCCalcSize( HWND hwnd, NCCALCSIZE_PARAMS *params )
/***********************************************************************
* NC_HandleNCHitTest
* NC_GetInsideRect
*
* Handle a WM_NCHITTEST message. Called from DefWindowProc().
* Get the 'inside' rectangle of a window, i.e. the whole window rectangle
* but without the borders (if any).
* The rectangle is in window coordinates (for drawing with GetWindowDC()).
*/
LONG NC_HandleNCHitTest( HWND hwnd, POINT pt )
static void NC_GetInsideRect( HWND hwnd, RECT *rect )
{
WND * wndPtr = WIN_FindWndPtr( hwnd );
rect->top = rect->left = 0;
rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
/* Remove frame from rectangle */
if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
InflateRect( rect, -SYSMETRICS_CXDLGFRAME, -SYSMETRICS_CYDLGFRAME);
else
{
if (HAS_THICKFRAME( wndPtr->dwStyle ))
InflateRect( rect, -SYSMETRICS_CXFRAME, -SYSMETRICS_CYFRAME );
if (wndPtr->dwStyle & WS_BORDER)
InflateRect( rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER );
}
}
/***********************************************************************
* NC_InternalNCHitTest
*
* Perform the hit test calculation, but whithout testing the capture
* window.
*/
static LONG NC_InternalNCHitTest( HWND hwnd, POINT pt )
{
RECT rect;
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return HTERROR;
#ifdef DEBUG_NONCLIENT
printf( "NC_HandleNCHitTest: hwnd=%x pt=%d,%d\n", hwnd, pt.x, pt.y );
#endif
if (hwnd == GetCapture()) return HTCLIENT;
GetWindowRect( hwnd, &rect );
if (!PtInRect( &rect, pt )) return HTNOWHERE;
ScreenToClient( hwnd, &pt );
@ -135,7 +187,7 @@ LONG NC_HandleNCHitTest( HWND hwnd, POINT pt )
}
/* Check menu */
if ((!(wndPtr->dwStyle & WS_CHILD)) && (wndPtr->wIDmenu != 0))
if (HAS_MENU(wndPtr))
{
rect.top -= SYSMETRICS_CYMENU + 1;
if (PtInRect( &rect, pt )) return HTMENU;
@ -163,9 +215,7 @@ LONG NC_HandleNCHitTest( HWND hwnd, POINT pt )
}
/* Check non-sizing border */
if (!(wndPtr->dwStyle & WS_THICKFRAME) ||
((wndPtr->dwStyle & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME))
return HTBORDER;
if (!HAS_THICKFRAME( wndPtr->dwStyle )) return HTBORDER;
/* Check top sizing border */
if (pt.y < rect.top)
@ -204,6 +254,86 @@ LONG NC_HandleNCHitTest( HWND hwnd, POINT pt )
}
/***********************************************************************
* NC_HandleNCHitTest
*
* Handle a WM_NCHITTEST message. Called from DefWindowProc().
*/
LONG NC_HandleNCHitTest( HWND hwnd, POINT pt )
{
#ifdef DEBUG_NONCLIENT
printf( "NC_HandleNCHitTest: hwnd=%x pt=%d,%d\n", hwnd, pt.x, pt.y );
#endif
if (hwnd == GetCapture()) return captureHitTest;
return NC_InternalNCHitTest( hwnd, pt );
}
/***********************************************************************
* NC_DrawSysButton
*/
static void NC_DrawSysButton( HWND hwnd, HDC hdc )
{
RECT rect;
BOOL down;
HDC hdcMem = CreateCompatibleDC( hdc );
if (hdcMem)
{
NC_GetInsideRect( hwnd, &rect );
down = ((GetCapture() == hwnd) && (captureHitTest == HTSYSMENU));
SelectObject( hdcMem, hbitmapClose );
BitBlt( hdc, rect.left-1, rect.top-1, SYSMETRICS_CXSIZE+1,
SYSMETRICS_CYSIZE+1, hdcMem, 0, 0, down ? NOTSRCCOPY : SRCCOPY);
DeleteDC( hdcMem );
}
}
/***********************************************************************
* NC_DrawMaxButton
*/
static void NC_DrawMaxButton( HWND hwnd, HDC hdc )
{
RECT rect;
BOOL down;
HDC hdcMem = CreateCompatibleDC( hdc );
if (hdcMem)
{
NC_GetInsideRect( hwnd, &rect );
down = ((GetCapture() == hwnd) && (captureHitTest == HTMAXBUTTON));
if (IsZoomed(hwnd))
SelectObject( hdcMem, down ? hbitmapRestoreD : hbitmapRestore );
else SelectObject( hdcMem, down ? hbitmapMaximizeD : hbitmapMaximize );
BitBlt( hdc, rect.right - SYSMETRICS_CXSIZE - 1, rect.top - 1,
SYSMETRICS_CXSIZE+2, SYSMETRICS_CYSIZE+2, hdcMem, 0, 0, SRCCOPY);
DeleteDC( hdcMem );
}
}
/***********************************************************************
* NC_DrawMinButton
*/
static void NC_DrawMinButton( HWND hwnd, HDC hdc )
{
RECT rect;
WND *wndPtr = WIN_FindWndPtr( hwnd );
HDC hdcMem = CreateCompatibleDC( hdc );
if (hdcMem)
{
NC_GetInsideRect( hwnd, &rect );
if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
rect.right -= SYSMETRICS_CXSIZE + 1;
if ((GetCapture() == hwnd) && (captureHitTest == HTMINBUTTON))
SelectObject( hdcMem, hbitmapMinimizeD );
else SelectObject( hdcMem, hbitmapMinimize );
BitBlt( hdc, rect.right - SYSMETRICS_CXSIZE - 1, rect.top - 1,
SYSMETRICS_CXSIZE+2, SYSMETRICS_CYSIZE+2, hdcMem, 0, 0, SRCCOPY);
DeleteDC( hdcMem );
}
}
/***********************************************************************
* NC_DrawFrame
*
@ -277,6 +407,36 @@ static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame )
}
/***********************************************************************
* NC_DrawMovingFrame
*
* Draw the frame used when moving or resizing window.
*/
static void NC_DrawMovingFrame( HWND hwnd, RECT *rect )
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
HDC hdc = GetDC( 0 );
if (HAS_THICKFRAME( wndPtr->dwStyle ))
{
SelectObject( hdc, GetStockObject( GRAY_BRUSH ) );
PatBlt( hdc, rect->left, rect->top,
rect->right - rect->left - SYSMETRICS_CXFRAME,
SYSMETRICS_CYFRAME, PATINVERT );
PatBlt( hdc, rect->left, rect->top + SYSMETRICS_CYFRAME,
SYSMETRICS_CXFRAME,
rect->bottom - rect->top - SYSMETRICS_CYFRAME, PATINVERT );
PatBlt( hdc, rect->left + SYSMETRICS_CXFRAME, rect->bottom,
rect->right - rect->left - SYSMETRICS_CXFRAME,
-SYSMETRICS_CYFRAME, PATINVERT );
PatBlt( hdc, rect->right, rect->top, -SYSMETRICS_CXFRAME,
rect->bottom - rect->top - SYSMETRICS_CYFRAME, PATINVERT );
}
else DrawFocusRect( hdc, rect );
ReleaseDC( 0, hdc );
}
/***********************************************************************
* NC_DrawCaption
*
@ -285,58 +445,55 @@ static void NC_DrawFrame( HDC hdc, RECT *rect, BOOL dlgFrame )
*/
static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd, DWORD style )
{
RECT r;
HBRUSH hbrushCaption, hbrushButtons;
RECT r = *rect;
HBRUSH hbrushCaption;
char buffer[256];
hbrushButtons = CreateSolidBrush( GetSysColor( COLOR_BTNFACE ) );
if (!hbitmapClose)
{
if (!(hbitmapClose = LoadBitmap( 0, MAKEINTRESOURCE(OBM_CLOSE) )))
return;
hbitmapMinimize = LoadBitmap( 0, MAKEINTRESOURCE(OBM_REDUCE) );
hbitmapMinimizeD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_REDUCED) );
hbitmapMaximize = LoadBitmap( 0, MAKEINTRESOURCE(OBM_ZOOM) );
hbitmapMaximizeD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_ZOOMD) );
hbitmapRestore = LoadBitmap( 0, MAKEINTRESOURCE(OBM_RESTORE) );
hbitmapRestoreD = LoadBitmap( 0, MAKEINTRESOURCE(OBM_RESTORED) );
}
hbrushCaption = CreateSolidBrush( GetSysColor( COLOR_ACTIVECAPTION ) );
MoveTo( hdc, rect->left, rect->bottom );
LineTo( hdc, rect->right-1, rect->bottom );
MoveTo( hdc, r.left, r.bottom );
LineTo( hdc, r.right-1, r.bottom );
/* We should probably use OEM bitmaps (OBM_*) here */
if (style & WS_SYSMENU)
{
r = *rect;
r.right = r.left + SYSMETRICS_CYSIZE;
FillRect( hdc, &r, hbrushButtons );
MoveTo( hdc, r.right, r.top );
LineTo( hdc, r.right, r.bottom );
rect->left += SYSMETRICS_CXSIZE + 1;
NC_DrawSysButton( hwnd, hdc );
r.left += SYSMETRICS_CXSIZE + 1;
MoveTo( hdc, r.left - 1, r.top );
LineTo( hdc, r.left - 1, r.bottom );
}
if (style & WS_MAXIMIZEBOX)
{
r = *rect;
r.left = r.right - SYSMETRICS_CXSIZE;
FillRect( hdc, &r, hbrushButtons );
MoveTo( hdc, r.left-1, r.top );
LineTo( hdc, r.left-1, r.bottom );
DrawReliefRect( hdc, r, 2, 0 );
rect->right -= SYSMETRICS_CXSIZE + 1;
NC_DrawMaxButton( hwnd, hdc );
r.right -= SYSMETRICS_CXSIZE + 1;
}
if (style & WS_MINIMIZEBOX)
{
r = *rect;
r.left = r.right - SYSMETRICS_CXSIZE;
FillRect( hdc, &r, hbrushButtons );
MoveTo( hdc, r.left-1, r.top );
LineTo( hdc, r.left-1, r.bottom );
DrawReliefRect( hdc, r, 2, 0 );
rect->right -= SYSMETRICS_CXSIZE + 1;
NC_DrawMinButton( hwnd, hdc );
r.right -= SYSMETRICS_CXSIZE + 1;
}
FillRect( hdc, rect, hbrushCaption );
FillRect( hdc, &r, hbrushCaption );
if (GetWindowText( hwnd, buffer, 256 ))
{
SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
SetBkMode( hdc, TRANSPARENT );
DrawText( hdc, buffer, -1, rect,
DrawText( hdc, buffer, -1, &r,
DT_SINGLELINE | DT_CENTER | DT_VCENTER );
}
DeleteObject( hbrushButtons );
DeleteObject( hbrushCaption );
}
@ -443,19 +600,359 @@ LONG NC_HandleNCPaint( HWND hwnd, HRGN hrgn )
/***********************************************************************
* NC_HandleNCMouseMsg
* NC_HandleNCLButtonDown
*
* Handle a non-client mouse message. Called from DefWindowProc().
* Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
*/
LONG NC_HandleNCMouseMsg( HWND hwnd, WORD msg, WORD wParam, LONG lParam )
LONG NC_HandleNCLButtonDown( HWND hwnd, WORD wParam, LONG lParam )
{
switch(wParam) /* Hit test code */
HDC hdc = GetWindowDC( hwnd );
switch(wParam) /* Hit test */
{
case HTCAPTION:
if (GetCapture() != hwnd)
SendMessage( hwnd, WM_SYSCOMMAND, SC_MOVE, lParam );
break;
case HTSYSMENU:
if (msg == WM_NCLBUTTONDBLCLK)
return SendMessage( hwnd, WM_SYSCOMMAND, SC_CLOSE, lParam );
captureHitTest = wParam;
SetCapture( hwnd );
NC_DrawSysButton( hwnd, hdc );
break;
case HTMENU:
break;
case HTHSCROLL:
if (GetCapture() != hwnd)
SendMessage( hwnd, WM_SYSCOMMAND, SC_HSCROLL, lParam );
break;
case HTVSCROLL:
if (GetCapture() != hwnd)
SendMessage( hwnd, WM_SYSCOMMAND, SC_VSCROLL, lParam );
break;
case HTMINBUTTON:
captureHitTest = wParam;
SetCapture( hwnd );
NC_DrawMinButton( hwnd, hdc );
break;
case HTMAXBUTTON:
captureHitTest = wParam;
SetCapture( hwnd );
NC_DrawMaxButton( hwnd, hdc );
break;
case HTLEFT:
case HTRIGHT:
case HTTOP:
case HTTOPLEFT:
case HTTOPRIGHT:
case HTBOTTOM:
case HTBOTTOMLEFT:
case HTBOTTOMRIGHT:
if (GetCapture() != hwnd)
SendMessage( hwnd, WM_SYSCOMMAND,
SC_SIZE + wParam - HTLEFT + 1, lParam );
break;
case HTBORDER:
break;
}
ReleaseDC( hwnd, hdc );
return 0;
}
/***********************************************************************
* NC_HandleNCLButtonUp
*
* Handle a WM_NCLBUTTONUP message. Called from DefWindowProc().
*/
LONG NC_HandleNCLButtonUp( HWND hwnd, WORD wParam, LONG lParam )
{
HDC hdc;
WORD hittest;
if (hwnd != GetCapture()) return 0;
ReleaseCapture();
captureHitTest = HTCLIENT;
hdc = GetWindowDC( hwnd );
hittest = NC_InternalNCHitTest( hwnd, MAKEPOINT(lParam) );
switch(wParam) /* Hit test */
{
case HTCAPTION: /* End of window moving */
NC_DrawMovingFrame( hwnd, &sizingRect );
SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top, 0, 0,
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER );
break;
case HTSYSMENU:
NC_DrawSysButton( hwnd, hdc );
break;
case HTMENU:
case HTHSCROLL:
case HTVSCROLL:
break;
case HTMINBUTTON:
NC_DrawMinButton( hwnd, hdc );
if (hittest == HTMINBUTTON)
SendMessage( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, lParam );
break;
case HTMAXBUTTON:
NC_DrawMaxButton( hwnd, hdc );
if (hittest == HTMAXBUTTON)
{
if (IsZoomed(hwnd))
SendMessage( hwnd, WM_SYSCOMMAND, SC_RESTORE, lParam );
else SendMessage( hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, lParam );
}
break;
case HTLEFT:
case HTRIGHT:
case HTTOP:
case HTTOPLEFT:
case HTTOPRIGHT:
case HTBOTTOM:
case HTBOTTOMLEFT:
case HTBOTTOMRIGHT: /* End of window resizing */
NC_DrawMovingFrame( hwnd, &sizingRect );
SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top,
sizingRect.right - sizingRect.left,
sizingRect.bottom - sizingRect.top,
SWP_NOACTIVATE | SWP_NOZORDER );
break;
case HTBORDER:
break;
}
ReleaseDC( hwnd, hdc );
return 0;
}
/***********************************************************************
* NC_HandleNCLButtonDblClk
*
* Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
*/
LONG NC_HandleNCLButtonDblClk( HWND hwnd, WORD wParam, LONG lParam )
{
switch(wParam) /* Hit test */
{
case HTCAPTION:
SendMessage( hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, lParam );
break;
case HTSYSMENU:
SendMessage( hwnd, WM_SYSCOMMAND, SC_CLOSE, lParam );
break;
}
return 0;
}
/***********************************************************************
* NC_HandleNCMouseMove
*
* Handle a WM_NCMOUSEMOVE message. Called from DefWindowProc().
*/
LONG NC_HandleNCMouseMove( HWND hwnd, WORD wParam, POINT pt )
{
RECT newRect;
if (hwnd != GetCapture()) return 0;
newRect = sizingRect;
switch(wParam) /* Hit test */
{
case HTCAPTION:
OffsetRect( &newRect, pt.x - capturePoint.x, pt.y - capturePoint.y);
break;
case HTLEFT:
newRect.left += pt.x - capturePoint.x;
break;
case HTRIGHT:
newRect.right += pt.x - capturePoint.x;
break;
case HTTOP:
newRect.top += pt.y - capturePoint.y;
break;
case HTTOPLEFT:
newRect.left += pt.x - capturePoint.x;
newRect.top += pt.y - capturePoint.y;
break;
case HTTOPRIGHT:
newRect.right += pt.x - capturePoint.x;
newRect.top += pt.y - capturePoint.y;
break;
case HTBOTTOM:
newRect.bottom += pt.y - capturePoint.y;
break;
case HTBOTTOMLEFT:
newRect.left += pt.x - capturePoint.x;
newRect.bottom += pt.y - capturePoint.y;
break;
case HTBOTTOMRIGHT:
newRect.right += pt.x - capturePoint.x;
newRect.bottom += pt.y - capturePoint.y;
break;
default:
return 0; /* Nothing to do */
}
NC_DrawMovingFrame( hwnd, &sizingRect );
NC_DrawMovingFrame( hwnd, &newRect );
capturePoint = pt;
sizingRect = newRect;
return 0;
}
/***********************************************************************
* NC_HandleSysCommand
*
* Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
*/
LONG NC_HandleSysCommand( HWND hwnd, WORD wParam, POINT pt )
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
#ifdef DEBUG_NONCLIENT
printf( "Handling WM_SYSCOMMAND %x %d,%d\n", wParam, pt.x, pt.y );
#endif
switch (wParam & 0xfff0)
{
case SC_SIZE:
if (!HAS_THICKFRAME(wndPtr->dwStyle)) break;
if (IsZoomed(hwnd) || IsIconic(hwnd)) break;
if (wParam & 0x0f) captureHitTest = (wParam & 0x0f) + HTLEFT - 1;
else captureHitTest = HTBORDER;
capturePoint = pt;
SetCapture( hwnd );
GetWindowRect( hwnd, &sizingRect );
NC_DrawMovingFrame( hwnd, &sizingRect );
break;
case SC_MOVE:
if (!(wndPtr->dwStyle & WS_CAPTION)) break;
if (IsZoomed(hwnd) || IsIconic(hwnd)) break;
captureHitTest = HTCAPTION;
capturePoint = pt;
SetCapture( hwnd );
GetWindowRect( hwnd, &sizingRect );
NC_DrawMovingFrame( hwnd, &sizingRect );
break;
case SC_MINIMIZE:
ShowWindow( hwnd, SW_MINIMIZE );
break;
case SC_MAXIMIZE:
ShowWindow( hwnd, SW_MAXIMIZE );
break;
case SC_RESTORE:
ShowWindow( hwnd, SW_RESTORE );
break;
case SC_NEXTWINDOW:
case SC_PREVWINDOW:
break;
case SC_CLOSE:
return SendMessage( hwnd, WM_CLOSE, 0, 0 );
case SC_VSCROLL:
case SC_HSCROLL:
case SC_MOUSEMENU:
case SC_KEYMENU:
case SC_ARRANGE:
break;
case SC_TASKLIST:
case SC_SCREENSAVE:
case SC_HOTKEY:
break;
}
return 0;
}
/***********************************************************************
* NC_HandleSetCursor
*
* Handle a WM_SETCURSOR message. Called from DefWindowProc().
*/
LONG NC_HandleSetCursor( HWND hwnd, WORD wParam, LONG lParam )
{
if (hwnd != wParam) return 0; /* Don't set the cursor for child windows */
switch(LOWORD(lParam))
{
case HTERROR:
{
WORD msg = HIWORD( lParam );
if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
(msg == WM_RBUTTONDOWN))
MessageBeep(0);
}
break;
case HTCLIENT:
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (wndPtr && wndPtr->hCursor)
{
SetCursor( wndPtr->hCursor );
return TRUE;
}
}
break;
case HTLEFT:
case HTRIGHT:
SetCursor( LoadCursor( 0, IDC_SIZEWE ) );
return TRUE;
case HTTOP:
case HTBOTTOM:
SetCursor( LoadCursor( 0, IDC_SIZENS ) );
return TRUE;
case HTTOPLEFT:
case HTBOTTOMRIGHT:
SetCursor( LoadCursor( 0, IDC_SIZENWSE ) );
return TRUE;
case HTTOPRIGHT:
case HTBOTTOMLEFT:
SetCursor( LoadCursor( 0, IDC_SIZENESW ) );
return TRUE;
}
/* Default cursor: arrow */
SetCursor( LoadCursor( 0, IDC_ARROW ) );
return TRUE;
}

View File

@ -33,13 +33,14 @@ HDC BeginPaint( HWND hwnd, LPPAINTSTRUCT lps )
if (wndPtr->hrgnUpdate)
{
DeleteObject( wndPtr->hrgnUpdate );
wndPtr->hrgnUpdate = 0;
MSG_DecPaintCount( wndPtr->hmemTaskQ );
}
wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
SendMessage( hwnd, WM_NCPAINT, hrgnUpdate, 0 );
if (hrgnUpdate) DeleteObject( hrgnUpdate );
if (!(wndPtr->flags & WIN_ERASE_UPDATERGN)) lps->fErase = TRUE;
else lps->fErase = !SendMessage( hwnd, WM_ERASEBKGND, lps->hdc, 0 );

View File

@ -22,7 +22,7 @@ extern Colormap COLOR_WinColormap;
extern void EVENT_RegisterWindow( Window w, HWND hwnd ); /* event.c */
static HWND firstWindow = 0;
HWND firstWindow = 0;
/***********************************************************************
* WIN_FindWndPtr
@ -240,6 +240,11 @@ HWND CreateWindowEx( DWORD exStyle, LPSTR className, LPSTR windowName,
wndPtr->rectWindow.right = x + width;
wndPtr->rectWindow.bottom = y + height;
wndPtr->rectClient = wndPtr->rectWindow;
wndPtr->rectNormal = wndPtr->rectWindow;
wndPtr->ptIconPos.x = -1;
wndPtr->ptIconPos.y = -1;
wndPtr->ptMaxPos.x = -1;
wndPtr->ptMaxPos.y = -1;
wndPtr->hmemTaskQ = GetTaskQueue(0);
wndPtr->hrgnUpdate = 0;
wndPtr->hwndLastActive = 0;
@ -281,10 +286,9 @@ HWND CreateWindowEx( DWORD exStyle, LPSTR className, LPSTR windowName,
/* Create the X window */
win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
PointerMotionMask | ButtonPressMask |
ButtonReleaseMask | StructureNotifyMask |
FocusChangeMask | EnterWindowMask;
win_attr.override_redirect = /*True*/ False;
PointerMotionMask | ButtonPressMask |
ButtonReleaseMask | FocusChangeMask | EnterWindowMask;
win_attr.override_redirect = True;
win_attr.colormap = COLOR_WinColormap;
if (style & WS_CHILD)
{
@ -360,12 +364,14 @@ HWND CreateWindowEx( DWORD exStyle, LPSTR className, LPSTR windowName,
/* Create scrollbars */
#if 0
if (windowName != NULL) SetWindowText(hwnd, windowName);
if ((style & WS_CAPTION) == WS_CAPTION) {
wndPtr->hWndCaption = CreateWindow("CAPTION", "",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
0, -20, width, 20, hwnd, 1, instance, 0L);
}
#endif
if (((style & WS_CHILD) != WS_CHILD) && (wndPtr->wIDmenu != 0)) {
lpbar = (LPPOPUPMENU) GlobalLock(wndPtr->wIDmenu);
if (lpbar != NULL) {
@ -434,6 +440,7 @@ BOOL DestroyWindow( HWND hwnd )
/* Destroy the window */
wndPtr->dwMagic = 0; /* Mark it as invalid */
XDestroyWindow( display, wndPtr->window );
if (wndPtr->flags & WIN_OWN_DC) DCE_FreeDCE( wndPtr->hdce );
classPtr->cWindows--;
@ -555,6 +562,86 @@ WORD SetWindowWord( HWND hwnd, short offset, WORD newval )
}
/*******************************************************************
* WIN_SetSensitive
*
* sets hWnd and all children to the same sensitivity
*
* sets hWnd sensitive and then calls SetSensitive on hWnd's child
* and all of hWnd's child's Next windows
*/
static BOOL WIN_SetSensitive(HWND hWnd, BOOL fEnable)
{
WND *wndPtr;
HWND hwnd;
printf("in SetSenitive\n");
if (!hWnd) return 0;
if (!(wndPtr = WIN_FindWndPtr(hWnd))) return 0;
if (fEnable) {
wndPtr->dwStyle &= ~WS_DISABLED;
} else {
wndPtr->dwStyle |= WS_DISABLED;
}
hwnd=wndPtr->hwndChild;
while (hwnd) { /* mk next child sens */
WIN_SetSensitive(hwnd, fEnable);
if ( !(wndPtr=WIN_FindWndPtr(hwnd)) ) return 0;
hwnd=wndPtr->hwndNext;
}
return 1;
}
/*******************************************************************
* EnableWindow (USER.34)
*
*
*/
BOOL EnableWindow(HWND hWnd, BOOL fEnable)
{
WND *wndPtr;
int eprev;
if (hWnd == 0) return 0;
wndPtr = WIN_FindWndPtr(hWnd);
if (wndPtr == 0) return 0;
eprev = ! (wndPtr->dwStyle & WS_DISABLED);
if (fEnable != eprev) { /* change req */
printf("changing window\n");
WIN_SetSensitive(hWnd, fEnable);
SendMessage(hWnd, WM_ENABLE, (WORD)fEnable, 0);
}
return !eprev;
}
/***********************************************************************
* IsWindowEnabled (USER.35)
*/
BOOL IsWindowEnabled(HWND hWnd)
{
WND * wndPtr;
if (hWnd == 0) return 0;
wndPtr = WIN_FindWndPtr(hWnd);
if (wndPtr == 0) return 0;
return !(wndPtr->dwStyle & WS_DISABLED);
}
/**********************************************************************
* GetWindowLong (USER.135)
*/

View File

@ -59,6 +59,44 @@ void ScreenToClient( HWND hwnd, LPPOINT lppnt )
}
/*******************************************************************
* WindowFromPoint (USER.30)
*/
HWND WindowFromPoint( POINT pt )
{
RECT rect;
HWND hwnd = firstWindow;
while (hwnd)
{
GetWindowRect( hwnd, &rect );
if (PtInRect( &rect, pt )) return hwnd;
hwnd = GetWindow( hwnd, GW_HWNDNEXT );
}
return 0;
}
/*******************************************************************
* ChildWindowFromPoint (USER.191)
*/
HWND ChildWindowFromPoint( HWND hwndParent, POINT pt )
{
RECT rect;
HWND hwnd;
GetWindowRect( hwndParent, &rect );
if (!PtInRect( &rect, pt )) return 0;
hwnd = GetTopWindow( hwndParent );
while (hwnd)
{
GetWindowRect( hwnd, &rect );
if (PtInRect( &rect, pt )) return hwnd;
hwnd = GetWindow( hwnd, GW_HWNDNEXT );
}
return 0;
}
/*******************************************************************
* MapWindowPoints (USER.258)
*/
@ -118,6 +156,15 @@ BOOL IsZoomed(HWND hWnd)
}
/***********************************************************************
* BringWindowToTop (USER.45)
*/
BOOL BringWindowToTop( HWND hwnd )
{
return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
}
/***********************************************************************
* MoveWindow (USER.56)
*/
@ -195,6 +242,75 @@ BOOL ShowWindow( HWND hwnd, int cmd )
}
/***********************************************************************
* GetInternalWindowPos (USER.460)
*/
WORD GetInternalWindowPos( HWND hwnd, LPRECT rectWnd, LPPOINT ptIcon )
{
WINDOWPLACEMENT wndpl;
if (!GetWindowPlacement( hwnd, &wndpl )) return 0;
if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
if (ptIcon) *ptIcon = wndpl.ptMinPosition;
return wndpl.showCmd;
}
/***********************************************************************
* SetInternalWindowPos (USER.461)
*/
void SetInternalWindowPos( HWND hwnd, WORD showCmd, LPRECT rect, LPPOINT pt )
{
WINDOWPLACEMENT wndpl;
WND *wndPtr = WIN_FindWndPtr( hwnd );
wndpl.length = sizeof(wndpl);
wndpl.flags = (pt != NULL) ? WPF_SETMINPOSITION : 0;
wndpl.showCmd = showCmd;
if (pt) wndpl.ptMinPosition = *pt;
wndpl.rcNormalPosition = (rect != NULL) ? *rect : wndPtr->rectNormal;
wndpl.ptMaxPosition = wndPtr->ptMaxPos;
SetWindowPlacement( hwnd, &wndpl );
}
/***********************************************************************
* GetWindowPlacement (USER.370)
*/
BOOL GetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *wndpl )
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return FALSE;
wndpl->length = sizeof(*wndpl);
wndpl->flags = 0;
wndpl->showCmd = IsZoomed(hwnd) ? SW_SHOWMAXIMIZED :
(IsIconic(hwnd) ? SW_SHOWMINIMIZED : SW_SHOWNORMAL);
wndpl->ptMinPosition = wndPtr->ptIconPos;
wndpl->ptMaxPosition = wndPtr->ptMaxPos;
wndpl->rcNormalPosition = wndPtr->rectNormal;
return TRUE;
}
/***********************************************************************
* SetWindowPlacement (USER.371)
*/
BOOL SetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *wndpl )
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return FALSE;
if (wndpl->flags & WPF_SETMINPOSITION)
wndPtr->ptIconPos = wndpl->ptMinPosition;
if ((wndpl->flags & WPF_RESTORETOMAXIMIZED) &&
(wndpl->showCmd == SW_SHOWMINIMIZED)) wndPtr->flags |= WIN_RESTORE_MAX;
wndPtr->ptMaxPos = wndpl->ptMaxPosition;
wndPtr->rectNormal = wndpl->rcNormalPosition;
ShowWindow( hwnd, wndpl->showCmd );
return TRUE;
}
/***********************************************************************
* SetWindowPos (USER.232)
*/