#define POPUP_WIDTH 30
#define POPUP_HEIGHT 10
-/* Default popup size, in characters */
+/* Default regular frame size, in characters */
#define DEFAULT_FRAME_WIDTH 80
#define DEFAULT_FRAME_HEIGHT 35
/*----- DISPLAY FRAME -----*/
/*---------------------------------------------------------------------*/
+HWND
+mswindows_get_selected_frame_hwnd (void)
+{
+ Lisp_Object frame, device;
+
+ device = Ffind_device (Qnil, Qmswindows);
+ if (NILP (device))
+ return NULL;
+ frame = DEVICE_SELECTED_FRAME (XDEVICE (device));
+ if (NILP (frame))
+ return NULL;
+
+ return FRAME_MSWINDOWS_HANDLE (XFRAME (frame));
+}
+
static void
mswindows_init_frame_1 (struct frame *f, Lisp_Object props)
{
abs (XINT (height));
/* Misc frame stuff */
- FRAME_MSWINDOWS_DATA(f)->button2_need_lbutton = 0;
- FRAME_MSWINDOWS_DATA(f)->button2_need_rbutton = 0;
- FRAME_MSWINDOWS_DATA(f)->button2_is_down = 0;
- FRAME_MSWINDOWS_DATA(f)->ignore_next_lbutton_up = 0;
- FRAME_MSWINDOWS_DATA(f)->ignore_next_rbutton_up = 0;
- FRAME_MSWINDOWS_DATA(f)->sizing = 0;
FRAME_MSWINDOWS_MENU_HASH_TABLE(f) = Qnil;
#ifdef HAVE_TOOLBARS
FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE(f) =
make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
#endif
/* hashtable of instantiated glyphs on the frame. */
- FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f) =
+ FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f) =
+ make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL);
+ FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f) =
+ make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL);
+ FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f) =
make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL);
/* Will initialize these in WM_SIZE handler. We cannot do it now,
because we do not know what is CW_USEDEFAULT height and width */
SetWindowLong (hwnd, XWL_FRAMEOBJ, (LONG)LISP_TO_VOID(frame_obj));
FRAME_MSWINDOWS_DC(f) = GetDC (hwnd);
- FRAME_MSWINDOWS_CDC(f) = CreateCompatibleDC (FRAME_MSWINDOWS_CDC(f));
SetTextAlign (FRAME_MSWINDOWS_DC(f), TA_BASELINE | TA_LEFT | TA_NOUPDATECP);
}
#ifdef HAVE_TOOLBARS
mark_object (FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f));
#endif
- mark_object (FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f));
+ mark_object (FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f));
+ mark_object (FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f));
+ mark_object (FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f));
}
static void
{
if (f->frame_data)
{
- DeleteDC(FRAME_MSWINDOWS_CDC(f));
ReleaseDC(FRAME_MSWINDOWS_HANDLE(f), FRAME_MSWINDOWS_DC(f));
DestroyWindow(FRAME_MSWINDOWS_HANDLE(f));
xfree (f->frame_data);
void mswindows_size_frame_internal (struct frame* f, XEMACS_RECT_WH* dest)
{
- RECT rect;
+ RECT rect, ws_rect;
int pixel_width, pixel_height;
int size_p = (dest->width >=0 || dest->height >=0);
int move_p = (dest->top >=0 || dest->left >=0);
- struct device* d = XDEVICE (FRAME_DEVICE (f));
char_to_real_pixel_size (f, dest->width, dest->height, &pixel_width, &pixel_height);
if (dest->width < 0)
GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL,
GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
- /* resize and move the window so that it fits on the screen. This is
+ /* resize and move the window so that it fits in the workspace. This is
not restrictive since this will happen later anyway in WM_SIZE. We
have to do this after adjusting the rect to account for menubar
etc. */
+ mswindows_get_workspace_coords (&ws_rect);
pixel_width = rect.right - rect.left;
pixel_height = rect.bottom - rect.top;
- if (pixel_width > DEVICE_MSWINDOWS_HORZRES(d))
+ if (pixel_width > ws_rect.right - ws_rect.left)
{
- pixel_width = DEVICE_MSWINDOWS_HORZRES(d);
+ pixel_width = ws_rect.right - ws_rect.left;
size_p=1;
}
- if (pixel_height > DEVICE_MSWINDOWS_VERTRES(d))
+ if (pixel_height > ws_rect.bottom - ws_rect.top)
{
- pixel_height = DEVICE_MSWINDOWS_VERTRES(d);
+ pixel_height = ws_rect.bottom - ws_rect.top;
size_p=1;
}
- /* adjust position so window is on screen */
- if (dest->left + pixel_width > DEVICE_MSWINDOWS_HORZRES(d))
+ /* adjust position so window is in workspace */
+ if (dest->left + pixel_width > ws_rect.right)
+ {
+ dest->left = ws_rect.right - pixel_width;
+ move_p=1;
+ }
+ if (dest->left < ws_rect.left)
+ {
+ dest->left = ws_rect.left;
+ move_p=1;
+ }
+
+ if (dest->top + pixel_height > ws_rect.bottom)
{
- dest->left = DEVICE_MSWINDOWS_HORZRES(d) - pixel_width;
+ dest->top = ws_rect.bottom - pixel_height;
move_p=1;
}
- if (dest->top + pixel_height > DEVICE_MSWINDOWS_VERTRES(d))
+ if (dest->top < ws_rect.top)
{
- dest->top = DEVICE_MSWINDOWS_VERTRES(d) - pixel_height;
+ dest->top = ws_rect.top;
move_p=1;
}
/*----- PRINTER FRAME -----*/
/*---------------------------------------------------------------------*/
+/*
+ * With some drvier/os combination (I discovered this with HP drviers
+ * under W2K), DC geometry is reset upon StartDoc and EndPage
+ * calls. This is called every time one of these calls is made.
+ */
+static void
+apply_dc_geometry (struct frame* f)
+{
+ HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)));
+ SetTextAlign (hdc, TA_BASELINE | TA_LEFT | TA_NOUPDATECP);
+ SetViewportOrgEx (hdc, FRAME_MSPRINTER_PIXLEFT(f),
+ FRAME_MSPRINTER_PIXTOP(f), NULL);
+}
+
void
msprinter_start_page (struct frame *f)
{
{
FRAME_MSPRINTER_PAGE_STARTED (f) = 1;
StartPage (DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f))));
+ apply_dc_geometry (f);
}
}
/* Negative for "uinspecified" */
FRAME_MSPRINTER_CHARWIDTH(f) = -1;
FRAME_MSPRINTER_CHARHEIGHT(f) = -1;
-
- /* nil is for "system default" for these properties. */
- FRAME_MSPRINTER_ORIENTATION(f) = Qnil;
- FRAME_MSPRINTER_DUPLEX(f) = Qnil;
}
static void
{
DOCINFO di;
struct device *device = XDEVICE (FRAME_DEVICE (f));
- HDC hdc = DEVICE_MSPRINTER_HDC (device);
+ HDC hdc;
int frame_left, frame_top, frame_width, frame_height;
- /* Change printer parameters */
- {
- DEVMODE* devmode = msprinter_get_devmode_copy (device);
- devmode->dmFields = 0;
-
- if (!NILP (FRAME_MSPRINTER_ORIENTATION(f)))
- {
- devmode->dmFields = DM_ORIENTATION;
- if (EQ (FRAME_MSPRINTER_ORIENTATION(f), Qportrait))
- devmode->dmOrientation = DMORIENT_PORTRAIT;
- else if (EQ (FRAME_MSPRINTER_ORIENTATION(f), Qlandscape))
- devmode->dmOrientation = DMORIENT_LANDSCAPE;
- else
- abort();
- }
-
- if (!NILP (FRAME_MSPRINTER_DUPLEX(f)))
- {
- devmode->dmFields = DM_DUPLEX;
- if (EQ (FRAME_MSPRINTER_DUPLEX(f), Qnone))
- devmode->dmDuplex = DMDUP_SIMPLEX;
- if (EQ (FRAME_MSPRINTER_DUPLEX(f), Qvertical))
- devmode->dmDuplex = DMDUP_VERTICAL;
- if (EQ (FRAME_MSPRINTER_DUPLEX(f), Qhorizontal))
- devmode->dmDuplex = DMDUP_HORIZONTAL;
- else
- abort();
- }
-
- msprinter_apply_devmode (device, devmode);
- }
+ /* DC might be recreated in msprinter_apply_devmode,
+ so do not initialize until now */
+ hdc = DEVICE_MSPRINTER_HDC (device);
/* Compute geometry properties */
frame_left = (MulDiv (GetDeviceCaps (hdc, LOGPIXELSX),
change_frame_size (f, rows, columns, 0);
}
- /* Apply DC geometry */
- SetTextAlign (hdc, TA_BASELINE | TA_LEFT | TA_NOUPDATECP);
- SetViewportOrgEx (hdc, frame_left, frame_top, NULL);
- SetWindowOrgEx (hdc, 0, 0, NULL);
+ FRAME_MSPRINTER_PIXLEFT(f) = frame_left;
+ FRAME_MSPRINTER_PIXTOP(f) = frame_top;
/* Start print job */
di.cbSize = sizeof (di);
if (StartDoc (hdc, &di) <= 0)
error ("Cannot start print job");
+ apply_dc_geometry (f);
+
/* Finish frame setup */
- FRAME_MSPRINTER_CDC(f) = CreateCompatibleDC (hdc);
FRAME_MSPRINTER_JOB_STARTED (f) = 1;
FRAME_VISIBLE_P(f) = 0;
}
static void
msprinter_mark_frame (struct frame *f)
{
- /* NOTE: These need not be marked as long as we allow only c-defined
- symbols for their values. Although, marking these is safer than
- expensive. [I know a proof to the theorem postulating that a
- gator is longer than greener. Ask me. -- kkm] */
- mark_object (FRAME_MSPRINTER_ORIENTATION (f));
- mark_object (FRAME_MSPRINTER_DUPLEX (f));
}
static void
EndPage (hdc);
if (FRAME_MSPRINTER_JOB_STARTED (f))
EndDoc (hdc);
- if (FRAME_MSPRINTER_CDC(f))
- DeleteDC (FRAME_MSPRINTER_CDC(f));
xfree (f->frame_data);
}
return make_int (FRAME_MSPRINTER_RIGHT_MARGIN(f));
else if (EQ (Qbottom_margin, property))
return make_int (FRAME_MSPRINTER_BOTTOM_MARGIN(f));
- else if (EQ (Qorientation, property))
- return FRAME_MSPRINTER_ORIENTATION(f);
- else if (EQ (Qduplex, property))
- return FRAME_MSPRINTER_DUPLEX(f);
else
return Qunbound;
}
msprinter_internal_frame_property_p (struct frame *f, Lisp_Object property)
{
return (EQ (Qleft_margin, property) || EQ (Qtop_margin, property) ||
- EQ (Qright_margin, property) || EQ (Qbottom_margin, property) ||
- EQ (Qorientation, property) || EQ (Qduplex, property));
+ EQ (Qright_margin, property) || EQ (Qbottom_margin, property));
}
static Lisp_Object
msprinter_frame_properties (struct frame *f)
{
Lisp_Object props = Qnil;
- props = cons3 (Qorientation, FRAME_MSPRINTER_ORIENTATION(f), props);
- props = cons3 (Qduplex, FRAME_MSPRINTER_DUPLEX(f), props);
props = cons3 (Qbottom_margin,
make_int (FRAME_MSPRINTER_BOTTOM_MARGIN(f)), props);
props = cons3 (Qright_margin,
CHECK_NATNUM (val);
FRAME_MSPRINTER_BOTTOM_MARGIN(f) = XINT (val);
}
- else if (EQ (prop, Qorientation))
- {
- maybe_error_if_job_active (f);
- CHECK_SYMBOL (val);
- if (!NILP(val) &&
- !EQ (val, Qportrait) &&
- !EQ (val, Qlandscape))
- signal_simple_error ("Page orientation can only be "
- "'portrait or 'landscape", val);
- FRAME_MSPRINTER_ORIENTATION(f) = val;
- }
- else if (EQ (prop, Qduplex))
- {
- maybe_error_if_job_active (f);
- CHECK_SYMBOL (val);
- if (!NILP(val) &&
- !EQ (val, Qnone) &&
- !EQ (val, Qvertical) &&
- !EQ (val, Qhorizontal))
- signal_simple_error ("Duplex can only be 'none, "
- "'vertical or 'horizontal", val);
- FRAME_MSPRINTER_DUPLEX(f) = val;
- }
}
}
}
{
FRAME_MSPRINTER_PAGE_STARTED (f) = 0;
EndPage (DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f))));
+ apply_dc_geometry (f);
}
}
(setq default-frame-plist '(height 55 'width 80)
default-msprinter-frame-plist '(height nil 'width nil))
-
- orientation Printer page orientation. Can be 'nil,
- indicating system default, 'portrait
- or 'landscape.
-
- duplex Duplex printing mode, subject to printer
- support. Can be 'nil for the device default,
- 'none for simplex printing, 'vertical or
- 'horizontal for duplex page bound along
- the corresponding page direction.
-
See also `default-frame-plist', which specifies properties which apply
to all frames, not just mswindows frames.
*/ );