X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fframe-msw.c;h=36a6983437dc3114b0a57e3defc4270237600938;hb=09b372c3074a7cc339a61b2297583f2b9edefe86;hp=9ea792d894a5b91654f6bfe2631a33d4a05ac4bf;hpb=59eec5f21669e81977b5b1fe9bf717cab49cf7fb;p=chise%2Fxemacs-chise.git.1 diff --git a/src/frame-msw.c b/src/frame-msw.c index 9ea792d..36a6983 100644 --- a/src/frame-msw.c +++ b/src/frame-msw.c @@ -199,10 +199,9 @@ mswindows_init_frame_1 (struct frame *f, Lisp_Object props) hwnd = CreateWindowEx (exstyle, XEMACS_CLASS, - STRINGP(f->name) ? XSTRING_DATA(f->name) : - (STRINGP(name) ? - (const Extbyte*)XSTRING_DATA(name) : - (const Extbyte*)XEMACS_CLASS), + STRINGP (f->name) ? (LPCTSTR) XSTRING_DATA (f->name) : + (STRINGP (name) ? (LPCTSTR) XSTRING_DATA (name) : + XEMACS_CLASS), style, rect_default.left, rect_default.top, rect_default.width, rect_default.height, @@ -308,10 +307,15 @@ static void mswindows_set_frame_size (struct frame *f, int width, int height) { RECT rect; + int columns, rows; + rect.left = rect.top = 0; rect.right = width; rect.bottom = height; + pixel_to_char_size (f, rect.right, rect.bottom, &columns, &rows); + change_frame_size (f, rows, columns, 0); + AdjustWindowRectEx (&rect, GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE), GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL, @@ -643,13 +647,15 @@ mswindows_set_frame_properties (struct frame *f, Lisp_Object plist) } } -void mswindows_size_frame_internal (struct frame* f, XEMACS_RECT_WH* dest) +void +mswindows_size_frame_internal (struct frame* f, XEMACS_RECT_WH* dest) { 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); - char_to_real_pixel_size (f, dest->width, dest->height, &pixel_width, &pixel_height); + char_to_real_pixel_size (f, dest->width, dest->height, &pixel_width, + &pixel_height); if (dest->width < 0) pixel_width = FRAME_PIXWIDTH (f); @@ -807,15 +813,18 @@ msprinter_init_frame_1 (struct frame *f, Lisp_Object props) f->frame_data = xnew_and_zero (struct msprinter_frame); - /* Default margin size is 1" = 1440 twips */ - FRAME_MSPRINTER_TOP_MARGIN(f) = 1440; - FRAME_MSPRINTER_BOTTOM_MARGIN(f) = 1440; - FRAME_MSPRINTER_LEFT_MARGIN(f) = 1440; - FRAME_MSPRINTER_RIGHT_MARGIN(f) = 1440; + FRAME_MSPRINTER_TOP_MARGIN (f) = + mswindows_get_default_margin (Qtop_margin); + FRAME_MSPRINTER_BOTTOM_MARGIN (f) = + mswindows_get_default_margin (Qbottom_margin); + FRAME_MSPRINTER_LEFT_MARGIN (f) = + mswindows_get_default_margin (Qleft_margin); + FRAME_MSPRINTER_RIGHT_MARGIN (f) = + mswindows_get_default_margin (Qright_margin); /* Negative for "uinspecified" */ - FRAME_MSPRINTER_CHARWIDTH(f) = -1; - FRAME_MSPRINTER_CHARHEIGHT(f) = -1; + FRAME_MSPRINTER_CHARWIDTH (f) = -1; + FRAME_MSPRINTER_CHARHEIGHT (f) = -1; } static void @@ -823,36 +832,38 @@ msprinter_init_frame_3 (struct frame *f) { DOCINFO di; struct device *device = XDEVICE (FRAME_DEVICE (f)); - HDC hdc; int frame_left, frame_top, frame_width, frame_height; - + /* 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), - FRAME_MSPRINTER_LEFT_MARGIN(f), 1440) - - GetDeviceCaps (hdc, PHYSICALOFFSETX)); + HDC hdc = DEVICE_MSPRINTER_HDC (device); + int logpixelsx = GetDeviceCaps (hdc, LOGPIXELSX); + int logpixelsy = GetDeviceCaps (hdc, LOGPIXELSY); + int physicaloffsetx = GetDeviceCaps (hdc, PHYSICALOFFSETX); + int physicaloffsety = GetDeviceCaps (hdc, PHYSICALOFFSETY); + int physicalheight = GetDeviceCaps (hdc, PHYSICALHEIGHT); + int physicalwidth = GetDeviceCaps (hdc, PHYSICALWIDTH); + + /* Compute geometry properties. + Conversion is from TWIPS -> inches -> pixels. */ + frame_left = MulDiv (logpixelsx, FRAME_MSPRINTER_LEFT_MARGIN(f), 1440) + - physicaloffsetx; if (FRAME_MSPRINTER_CHARWIDTH(f) > 0) { char_to_real_pixel_size (f, FRAME_MSPRINTER_CHARWIDTH(f), 0, &frame_width, NULL); FRAME_MSPRINTER_RIGHT_MARGIN(f) = - MulDiv (GetDeviceCaps (hdc, PHYSICALWIDTH) - - (frame_left + frame_width), 1440, - GetDeviceCaps (hdc, LOGPIXELSX)); + MulDiv (physicalwidth - (frame_left + frame_width), 1440, + logpixelsx); } else - frame_width = (GetDeviceCaps (hdc, PHYSICALWIDTH) - - frame_left - - MulDiv (GetDeviceCaps (hdc, LOGPIXELSX), - FRAME_MSPRINTER_RIGHT_MARGIN(f), 1440)); + frame_width = physicalwidth - frame_left + - MulDiv (logpixelsx, FRAME_MSPRINTER_RIGHT_MARGIN(f), 1440) + - physicaloffsetx; - frame_top = (MulDiv (GetDeviceCaps (hdc, LOGPIXELSY), - FRAME_MSPRINTER_TOP_MARGIN(f), 1440) - - GetDeviceCaps (hdc, PHYSICALOFFSETY)); + frame_top = MulDiv (logpixelsy, FRAME_MSPRINTER_TOP_MARGIN(f), 1440) + - physicaloffsety; if (FRAME_MSPRINTER_CHARHEIGHT(f) > 0) { @@ -860,15 +871,13 @@ msprinter_init_frame_3 (struct frame *f) NULL, &frame_height); FRAME_MSPRINTER_BOTTOM_MARGIN(f) = - MulDiv (GetDeviceCaps (hdc, PHYSICALHEIGHT) - - (frame_top + frame_height), 1440, - GetDeviceCaps (hdc, LOGPIXELSY)); + MulDiv (physicalheight - (frame_top + frame_height), 1440, + logpixelsy); } else - frame_height = (GetDeviceCaps (hdc, PHYSICALHEIGHT) - - frame_top - - MulDiv (GetDeviceCaps (hdc, LOGPIXELSY), - FRAME_MSPRINTER_BOTTOM_MARGIN(f), 1440)); + frame_height = physicalheight - frame_top + - MulDiv (logpixelsy, FRAME_MSPRINTER_BOTTOM_MARGIN(f), 1440) + - physicaloffsety; /* Geometry sanity checks */ if (!frame_pixsize_valid_p (f, frame_width, frame_height)) @@ -1183,8 +1192,10 @@ set at any time, except as otherwise noted): top-margin typographical unit of measurement, right-margin equal to 1/1440 of an inch, or 1/20 of a bottom-margin point, and roughly equal to 7/400 of a - millimeter. If not specified, each margin - defaults to one inch (25.4 mm). + millimeter. If not specified, the left + and right margins default to 1 inch + (25.4 mm) and the top and bottom margins + to 0.5 inch (12.7 mm). MARGINS NOTE. right-margin and bottom-margin are overridden by the height and width properties. If you want to specify size @@ -1195,8 +1206,8 @@ set at any time, except as otherwise noted): want to specify right/bottom margins, set height/width in this plist to nil, as in this example: - (setq default-frame-plist '(height 55 'width 80) - default-msprinter-frame-plist '(height nil 'width nil)) + (setq default-frame-plist '(height 55 width 80) + default-msprinter-frame-plist '(height nil width nil)) See also `default-frame-plist', which specifies properties which apply to all frames, not just mswindows frames.