ReactOS  0.4.15-dev-5492-g47f3a4e
print.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <wingdi.h>
#include <winuser.h>
#include <richedit.h>
#include <commctrl.h>
#include <commdlg.h>
#include "wordpad.h"
Include dependency graph for print.c:

Go to the source code of this file.

Classes

struct  _previewinfo
 

Typedefs

typedef struct _previewinfo previewinfo
 
typedef struct _previewinfoppreviewinfo
 

Functions

static LPWSTR get_print_file_filter (HWND hMainWnd)
 
void registry_set_pagemargins (HKEY hKey)
 
void registry_read_pagemargins (HKEY hKey)
 
void registry_set_previewpages (HKEY hKey)
 
void registry_read_previewpages (HKEY hKey)
 
static void AddTextButton (HWND hRebarWnd, UINT string, UINT command, UINT id)
 
static HDC make_dc (void)
 
static LONG twips_to_centmm (int twips)
 
static LONG centmm_to_twips (int mm)
 
static LONG twips_to_pixels (int twips, int dpi)
 
static LONG devunits_to_twips (int units, int dpi)
 
static RECT get_print_rect (HDC hdc)
 
void target_device (HWND hMainWnd, DWORD wordWrap)
 
static LPWSTR dialog_print_to_file (HWND hMainWnd)
 
static void char_from_pagenum (HWND hEditorWnd, FORMATRANGE *fr, int page)
 
static HWND get_ruler_wnd (HWND hMainWnd)
 
void redraw_ruler (HWND hRulerWnd)
 
static void update_ruler (HWND hRulerWnd)
 
static void add_ruler_units (HDC hdcRuler, RECT *drawRect, BOOL NewMetrics, LONG EditLeftmost)
 
static void paint_ruler (HWND hWnd, LONG EditLeftmost, BOOL NewMetrics)
 
LRESULT CALLBACK ruler_proc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static void print (LPPRINTDLGW pd, LPWSTR wszFileName)
 
void dialog_printsetup (HWND hMainWnd)
 
void get_default_printer_opts (void)
 
void print_quick (HWND hMainWnd, LPWSTR wszFileName)
 
void dialog_print (HWND hMainWnd, LPWSTR wszFileName)
 
static void preview_bar_show (HWND hMainWnd, BOOL show)
 
static void update_preview_scrollbars (HWND hwndPreview, RECT *window)
 
static void update_preview_sizes (HWND hwndPreview, BOOL zoomLevelUpdated)
 
static void draw_margin_lines (HDC hdc, int x, int y, float ratio)
 
static BOOL is_last_preview_page (int page)
 
void init_preview (HWND hMainWnd, LPWSTR wszFileName)
 
void close_preview (HWND hMainWnd)
 
BOOL preview_isactive (void)
 
static void draw_preview (HWND hEditorWnd, FORMATRANGE *lpFr, RECT *paper, int page)
 
static void update_preview_buttons (HWND hMainWnd)
 
static LRESULT print_preview (HWND hwndPreview)
 
static void update_preview_statusbar (HWND hMainWnd)
 
static void update_preview (HWND hMainWnd)
 
static void toggle_num_pages (HWND hMainWnd)
 
static int preview_page_hittest (POINT pt)
 
LRESULT CALLBACK preview_proc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
LRESULT preview_command (HWND hWnd, WPARAM wParam)
 

Variables

static HGLOBAL devMode
 
static HGLOBAL devNames
 
static RECT margins
 
static previewinfo preview
 
const WCHAR wszPreviewWndClass []
 
static const WCHAR var_pagemargin [] = {'P','a','g','e','M','a','r','g','i','n',0}
 
static const WCHAR var_previewpages [] = {'P','r','e','v','i','e','w','P','a','g','e','s',0}
 
static const int min_spacing = 10
 

Typedef Documentation

◆ ppreviewinfo

◆ previewinfo

Function Documentation

◆ add_ruler_units()

static void add_ruler_units ( HDC  hdcRuler,
RECT drawRect,
BOOL  NewMetrics,
LONG  EditLeftmost 
)
static

Definition at line 302 of file print.c.

303 {
304  static HDC hdc;
305 
306  if(NewMetrics)
307  {
308  static HBITMAP hBitmap;
309  int i, x, y, RulerTextEnd;
310  int CmPixels;
311  int QuarterCmPixels;
312  HFONT hFont;
313  WCHAR FontName[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f',0};
314 
315  if(hdc)
316  {
317  DeleteDC(hdc);
319  }
320 
321  hdc = CreateCompatibleDC(0);
322 
324  QuarterCmPixels = (int)((float)CmPixels / 4.0);
325 
326  hBitmap = CreateCompatibleBitmap(hdc, drawRect->right, drawRect->bottom);
328  FillRect(hdc, drawRect, GetStockObject(WHITE_BRUSH));
329 
330  hFont = CreateFontW(10, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FontName);
331 
335  y = (int)(((float)drawRect->bottom - (float)drawRect->top) / 2.0) + 1;
336  RulerTextEnd = drawRect->right - EditLeftmost + 1;
337  for(i = 1, x = EditLeftmost; x < (drawRect->right - EditLeftmost + 1); i ++)
338  {
339  WCHAR str[3];
340  WCHAR format[] = {'%','d',0};
341  int x2 = x;
342 
343  x2 += QuarterCmPixels;
344  if(x2 > RulerTextEnd)
345  break;
346 
347  MoveToEx(hdc, x2, y, NULL);
348  LineTo(hdc, x2, y+2);
349 
350  x2 += QuarterCmPixels;
351  if(x2 > RulerTextEnd)
352  break;
353 
354  MoveToEx(hdc, x2, y - 3, NULL);
355  LineTo(hdc, x2, y + 3);
356 
357  x2 += QuarterCmPixels;
358  if(x2 > RulerTextEnd)
359  break;
360 
361  MoveToEx(hdc, x2, y, NULL);
362  LineTo(hdc, x2, y+2);
363 
364  x += CmPixels;
365  if(x > RulerTextEnd)
366  break;
367 
368  wsprintfW(str, format, i);
369  TextOutW(hdc, x, 5, str, lstrlenW(str));
370  }
372  }
373 
374  BitBlt(hdcRuler, 0, 0, drawRect->right, drawRect->bottom, hdc, 0, 0, SRCAND);
375 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define LOGPIXELSX
Definition: wingdi.h:718
HFONT WINAPI CreateFontW(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCWSTR)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define WHITE_BRUSH
Definition: wingdi.h:902
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
UINT WINAPI SetTextAlign(_In_ HDC, _In_ UINT)
Definition: text.c:883
LONG right
Definition: windef.h:308
#define lstrlenW
Definition: compat.h:750
HFONT hFont
Definition: main.c:53
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
#define TRANSPARENT
Definition: wingdi.h:950
const WCHAR * str
static LONG centmm_to_twips(int mm)
Definition: print.c:171
__wchar_t WCHAR
Definition: xmlstorage.h:180
static LONG twips_to_pixels(int twips, int dpi)
Definition: print.c:176
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOL WINAPI DeleteDC(_In_ HDC)
#define SRCAND
Definition: wingdi.h:330
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LONG bottom
Definition: windef.h:309
static HBITMAP
Definition: button.c:44
#define TA_CENTER
Definition: wingdi.h:931
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
static HBITMAP hBitmap
Definition: timezone.c:26
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by paint_ruler().

◆ AddTextButton()

static void AddTextButton ( HWND  hRebarWnd,
UINT  string,
UINT  command,
UINT  id 
)
static

Definition at line 121 of file print.c.

122 {
123  REBARBANDINFOW rb;
126  HWND hButton;
127 
129  hButton = CreateWindowW(WC_BUTTONW, text,
130  WS_VISIBLE | WS_CHILD, 5, 5, 100, 15,
131  hRebarWnd, ULongToHandle(command), hInstance, NULL);
132 
136  rb.hwndChild = hButton;
137  rb.cyChild = rb.cyMinChild = 22;
138  rb.cx = rb.cxMinChild = 90;
139  rb.cxIdeal = 100;
140  rb.wID = id;
141 
142  SendMessageW(hRebarWnd, RB_INSERTBANDW, -1, (LPARAM)&rb);
143 }
#define ULongToHandle(h)
Definition: basetsd.h:81
#define RBBIM_CHILD
Definition: commctrl.h:1506
const WCHAR * text
Definition: package.c:1799
#define RBBIM_ID
Definition: commctrl.h:1510
#define MAX_STRING_LEN
Definition: precomp.h:36
#define WS_CHILD
Definition: pedump.c:617
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4306
#define REBARBANDINFOW_V6_SIZE
Definition: commctrl.h:1542
#define RBBIM_STYLE
Definition: commctrl.h:1502
#define RBBIM_SIZE
Definition: commctrl.h:1508
HINSTANCE hInstance
Definition: charmap.c:19
LONG_PTR LPARAM
Definition: windef.h:208
#define RB_INSERTBANDW
Definition: commctrl.h:1583
#define RBBS_VARIABLEHEIGHT
Definition: commctrl.h:1495
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define RBBIM_CHILDSIZE
Definition: commctrl.h:1507
#define WC_BUTTONW
Definition: commctrl.h:4623
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define NULL
Definition: types.h:112
#define RBBS_NOGRIPPER
Definition: commctrl.h:1497
GLenum GLuint id
Definition: glext.h:5579
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define WS_VISIBLE
Definition: pedump.c:620
#define RBBIM_IDEALSIZE
Definition: commctrl.h:1511

Referenced by preview_bar_show().

◆ centmm_to_twips()

static LONG centmm_to_twips ( int  mm)
static

Definition at line 171 of file print.c.

172 {
174 }
#define CENTMM_PER_INCH
Definition: wordpad.h:25
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
#define TWIPS_PER_INCH
Definition: wordpad.h:24

Referenced by add_ruler_units(), dialog_printsetup(), and get_print_rect().

◆ char_from_pagenum()

static void char_from_pagenum ( HWND  hEditorWnd,
FORMATRANGE fr,
int  page 
)
static

Definition at line 269 of file print.c.

270 {
271  int i;
272 
273  fr->chrg.cpMin = 0;
274 
275  for(i = 1; i < page; i++)
276  {
277  int bottom = fr->rc.bottom;
279  fr->rc.bottom = bottom;
280  }
281 }
#define EM_FORMATRANGE
Definition: richedit.h:90
static HWND hEditorWnd
Definition: wordpad.c:61
#define FALSE
Definition: types.h:117
LONG_PTR LPARAM
Definition: windef.h:208
GLint GLint bottom
Definition: glext.h:7726
Definition: module.h:566
CHARRANGE chrg
Definition: richedit.h:611
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LONG bottom
Definition: windef.h:309
LONG cpMin
Definition: richedit.h:500

Referenced by print().

◆ close_preview()

void close_preview ( HWND  hMainWnd)

Definition at line 751 of file print.c.

752 {
753  HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW);
754  preview.window.right = 0;
755  preview.window.bottom = 0;
756  preview.page = 0;
759  preview.pageCapacity = 0;
760  if (preview.zoomlevel > 0)
762  if(preview.hdc) {
765  DeleteObject(oldbm);
766  preview.hdc = NULL;
767  }
768  if(preview.hdc2) {
771  DeleteObject(oldbm);
772  preview.hdc2 = NULL;
773  }
774 
776  DestroyWindow(hwndPreview);
777 }
HDC hdc2
Definition: print.c:41
static void preview_bar_show(HWND hMainWnd, BOOL show)
Definition: print.c:578
int * pageEnds
Definition: print.c:38
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
int zoomlevel
Definition: print.c:48
LONG right
Definition: windef.h:308
BOOL WINAPI DestroyWindow(_In_ HWND)
#define FALSE
Definition: types.h:117
int pages_shown
Definition: print.c:36
#define GetProcessHeap()
Definition: compat.h:736
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
int page
Definition: print.c:35
HWND hMainWnd
Definition: magnifier.c:32
HDC hdc
Definition: print.c:40
int saved_pages_shown
Definition: print.c:37
#define IDC_PREVIEW
Definition: wordpad.h:171
RECT window
Definition: print.c:42
BOOL WINAPI DeleteDC(_In_ HDC)
static previewinfo preview
Definition: print.c:56
#define NULL
Definition: types.h:112
int pageCapacity
Definition: print.c:38
LONG bottom
Definition: windef.h:309
static HBITMAP
Definition: button.c:44
#define OBJ_BITMAP
Definition: objidl.idl:1415
#define HeapFree(x, y, z)
Definition: compat.h:735
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:428

Referenced by preview_exit().

◆ devunits_to_twips()

static LONG devunits_to_twips ( int  units,
int  dpi 
)
static

Definition at line 181 of file print.c.

182 {
183  return MulDiv(units, TWIPS_PER_INCH, dpi);
184 }
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
#define dpi
Definition: sysparams.c:22
#define TWIPS_PER_INCH
Definition: wordpad.h:24
GLfloat units
Definition: glext.h:11727

Referenced by get_print_rect().

◆ dialog_print()

void dialog_print ( HWND  hMainWnd,
LPWSTR  wszFileName 
)

Definition at line 549 of file print.c.

550 {
551  PRINTDLGW pd;
553  int from = 0;
554  int to = 0;
555 
556  ZeroMemory(&pd, sizeof(pd));
557  pd.lStructSize = sizeof(pd);
558  pd.hwndOwner = hMainWnd;
560  pd.nMinPage = 1;
561  pd.nMaxPage = -1;
562  pd.hDevMode = devMode;
563  pd.hDevNames = devNames;
564 
566  if(from == to)
567  pd.Flags |= PD_NOSELECTION;
568 
569  if(PrintDlgW(&pd))
570  {
571  devMode = pd.hDevMode;
572  devNames = pd.hDevNames;
573  print(&pd, wszFileName);
575  }
576 }
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:71
#define PD_NOSELECTION
Definition: commdlg.h:149
HWND hwndOwner
Definition: commdlg.h:487
static HGLOBAL devMode
Definition: print.c:52
HGLOBAL hDevNames
Definition: commdlg.h:489
#define ZeroMemory
Definition: winbase.h:1670
static HWND hEditorWnd
Definition: wordpad.c:61
UINT_PTR WPARAM
Definition: windef.h:207
DWORD Flags
Definition: commdlg.h:491
#define EM_GETSEL
Definition: winuser.h:1987
#define PD_USEDEVMODECOPIESANDCOLLATE
Definition: commdlg.h:166
WORD nMinPage
Definition: commdlg.h:494
BOOL WINAPI PrintDlgW(LPPRINTDLGW lppd)
Definition: printdlg.c:2403
HGLOBAL hDevMode
Definition: commdlg.h:488
LONG_PTR LPARAM
Definition: windef.h:208
#define PD_RETURNDC
Definition: commdlg.h:155
DWORD lStructSize
Definition: commdlg.h:486
static HGLOBAL devNames
Definition: print.c:53
static void update_ruler(HWND hRulerWnd)
Definition: print.c:296
#define IDC_EDITOR
Definition: wordpad.h:156
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HWND hMainWnd
Definition: magnifier.c:32
WORD nMaxPage
Definition: commdlg.h:495
static void print(LPPRINTDLGW pd, LPWSTR wszFileName)
Definition: print.c:438
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
CardRegion * from
Definition: spigame.cpp:19
static HWND get_ruler_wnd(HWND hMainWnd)
Definition: print.c:283

Referenced by OnCommand(), and preview_command().

◆ dialog_print_to_file()

static LPWSTR dialog_print_to_file ( HWND  hMainWnd)
static

Definition at line 243 of file print.c.

244 {
246  static WCHAR file[MAX_PATH] = {'O','U','T','P','U','T','.','P','R','N',0};
247  static const WCHAR defExt[] = {'P','R','N',0};
248  static LPWSTR file_filter;
249 
250  if(!file_filter)
251  file_filter = get_print_file_filter(hMainWnd);
252 
253  ZeroMemory(&ofn, sizeof(ofn));
254 
255  ofn.lStructSize = sizeof(ofn);
258  ofn.lpstrFilter = file_filter;
259  ofn.lpstrFile = file;
261  ofn.lpstrDefExt = defExt;
262 
263  if(GetSaveFileNameW(&ofn))
264  return file;
265  else
266  return FALSE;
267 }
#define OFN_EXPLORER
Definition: commdlg.h:104
HWND hwndOwner
Definition: commdlg.h:330
OPENFILENAME ofn
Definition: main.cpp:37
#define ZeroMemory
Definition: winbase.h:1670
LPCSTR lpstrDefExt
Definition: commdlg.h:345
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4742
DWORD nMaxFile
Definition: commdlg.h:337
#define FALSE
Definition: types.h:117
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
DWORD lStructSize
Definition: commdlg.h:329
const char file[]
Definition: icontest.c:11
HWND hMainWnd
Definition: magnifier.c:32
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
static LPWSTR get_print_file_filter(HWND hMainWnd)
Definition: print.c:63
LPSTR lpstrFile
Definition: commdlg.h:336
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
LPCSTR lpstrFilter
Definition: commdlg.h:332
WCHAR * LPWSTR
Definition: xmlstorage.h:184
DWORD Flags
Definition: commdlg.h:342
Definition: fci.c:126

Referenced by print().

◆ dialog_printsetup()

void dialog_printsetup ( HWND  hMainWnd)

Definition at line 498 of file print.c.

499 {
500  PAGESETUPDLGW ps;
501 
502  ZeroMemory(&ps, sizeof(ps));
503  ps.lStructSize = sizeof(ps);
504  ps.hwndOwner = hMainWnd;
508  ps.hDevMode = devMode;
509  ps.hDevNames = devNames;
510 
511  if(PageSetupDlgW(&ps))
512  {
515  devMode = ps.hDevMode;
516  devNames = ps.hDevNames;
518  }
519 }
static LONG twips_to_centmm(int twips)
Definition: print.c:166
#define PSD_INHUNDREDTHSOFMILLIMETERS
Definition: commdlg.h:175
static HGLOBAL devMode
Definition: print.c:52
#define PSD_MARGINS
Definition: commdlg.h:173
LONG top
Definition: windef.h:307
#define ZeroMemory
Definition: winbase.h:1670
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
RECT rtMargin
Definition: commdlg.h:456
HGLOBAL hDevNames
Definition: commdlg.h:452
DWORD lStructSize
Definition: commdlg.h:449
static HGLOBAL devNames
Definition: print.c:53
static LONG centmm_to_twips(int mm)
Definition: print.c:171
BOOL WINAPI PageSetupDlgW(LPPAGESETUPDLGW setupdlg)
Definition: printdlg.c:3938
static void update_ruler(HWND hRulerWnd)
Definition: print.c:296
HWND hwndOwner
Definition: commdlg.h:450
HWND hMainWnd
Definition: magnifier.c:32
HGLOBAL hDevMode
Definition: commdlg.h:451
static RECT margins
Definition: print.c:55
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
DWORD Flags
Definition: commdlg.h:453
LONG bottom
Definition: windef.h:309
static HWND get_ruler_wnd(HWND hMainWnd)
Definition: print.c:283

Referenced by OnCommand().

◆ draw_margin_lines()

static void draw_margin_lines ( HDC  hdc,
int  x,
int  y,
float  ratio 
)
static

Definition at line 694 of file print.c.

695 {
696  HPEN hPen, oldPen;
697  SIZE dpi;
698  RECT page_margin = preview.rcPage;
699 
702 
705 
706  page_margin.left = (int)((float)twips_to_pixels(page_margin.left, dpi.cx) * ratio);
707  page_margin.top = (int)((float)twips_to_pixels(page_margin.top, dpi.cy) * ratio);
708  page_margin.bottom = (int)((float)twips_to_pixels(page_margin.bottom, dpi.cy) * ratio);
709  page_margin.right = (int)((float)twips_to_pixels(page_margin.right, dpi.cx) * ratio);
710 
711  OffsetRect(&page_margin, x, y);
712 
713  hPen = CreatePen(PS_DOT, 1, RGB(0,0,0));
714  oldPen = SelectObject(hdc, hPen);
715 
716  MoveToEx(hdc, x, page_margin.top, NULL);
717  LineTo(hdc, x + preview.bmScaledSize.cx, page_margin.top);
718  MoveToEx(hdc, x, page_margin.bottom, NULL);
719  LineTo(hdc, x + preview.bmScaledSize.cx, page_margin.bottom);
720 
721  MoveToEx(hdc, page_margin.left, y, NULL);
722  LineTo(hdc, page_margin.left, y + preview.bmScaledSize.cy);
723  MoveToEx(hdc, page_margin.right, y, NULL);
724  LineTo(hdc, page_margin.right, y + preview.bmScaledSize.cy);
725 
726  SelectObject(hdc, oldPen);
727  DeleteObject(hPen);
728 }
#define LOGPIXELSX
Definition: wingdi.h:718
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define RGB(r, g, b)
Definition: precomp.h:62
RECT rcPage
Definition: print.c:43
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
LONG cx
Definition: windef.h:334
#define dpi
Definition: sysparams.c:22
static LONG twips_to_pixels(int twips, int dpi)
Definition: print.c:176
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
static RECT margins
Definition: print.c:55
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
static previewinfo preview
Definition: print.c:56
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define PS_DOT
Definition: wingdi.h:588
LONG bottom
Definition: windef.h:309
#define LOGPIXELSY
Definition: wingdi.h:719
LONG cy
Definition: windef.h:335
SIZE bmScaledSize
Definition: print.c:45
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by print_preview().

◆ draw_preview()

static void draw_preview ( HWND  hEditorWnd,
FORMATRANGE lpFr,
RECT paper,
int  page 
)
static

Definition at line 784 of file print.c.

785 {
786  int bottom;
787 
788  if (!preview.pageEnds)
789  {
790  preview.pageCapacity = 32;
792  sizeof(int) * preview.pageCapacity);
793  if (!preview.pageEnds) return;
794  } else if (page >= preview.pageCapacity) {
795  int *new_buffer;
796  new_buffer = HeapReAlloc(GetProcessHeap(), 0, preview.pageEnds,
797  sizeof(int) * preview.pageCapacity * 2);
798  if (!new_buffer) return;
799  preview.pageCapacity *= 2;
800  preview.pageEnds = new_buffer;
801  }
802 
803  FillRect(lpFr->hdc, paper, GetStockObject(WHITE_BRUSH));
804  if (page > 1 && is_last_preview_page(page - 1)) return;
805  lpFr->chrg.cpMin = page <= 1 ? 0 : preview.pageEnds[page-2];
806  bottom = lpFr->rc.bottom;
808 
809  /* EM_FORMATRANGE sets fr.rc.bottom to indicate the area printed in,
810  * but we want to keep the original for drawing margins */
811  lpFr->rc.bottom = bottom;
813 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define TRUE
Definition: types.h:120
int * pageEnds
Definition: print.c:38
#define EM_FORMATRANGE
Definition: richedit.h:90
#define WHITE_BRUSH
Definition: wingdi.h:902
static HWND hEditorWnd
Definition: wordpad.c:61
static BOOL is_last_preview_page(int page)
Definition: print.c:730
#define FALSE
Definition: types.h:117
LONG_PTR LPARAM
Definition: windef.h:208
GLint GLint bottom
Definition: glext.h:7726
Definition: module.h:566
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
CHARRANGE chrg
Definition: richedit.h:611
static previewinfo preview
Definition: print.c:56
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HeapReAlloc
Definition: compat.h:734
int pageCapacity
Definition: print.c:38
LONG bottom
Definition: windef.h:309
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
LONG cpMin
Definition: richedit.h:500

Referenced by update_preview().

◆ get_default_printer_opts()

void get_default_printer_opts ( void  )

Definition at line 521 of file print.c.

522 {
523  PRINTDLGW pd;
524  ZeroMemory(&pd, sizeof(pd));
525 
526  ZeroMemory(&pd, sizeof(pd));
527  pd.lStructSize = sizeof(pd);
529  pd.hDevMode = devMode;
530 
531  PrintDlgW(&pd);
532 
533  devMode = pd.hDevMode;
534  devNames = pd.hDevNames;
535 }
static HGLOBAL devMode
Definition: print.c:52
HGLOBAL hDevNames
Definition: commdlg.h:489
#define ZeroMemory
Definition: winbase.h:1670
DWORD Flags
Definition: commdlg.h:491
BOOL WINAPI PrintDlgW(LPPRINTDLGW lppd)
Definition: printdlg.c:2403
HGLOBAL hDevMode
Definition: commdlg.h:488
#define PD_RETURNDC
Definition: commdlg.h:155
DWORD lStructSize
Definition: commdlg.h:486
static HGLOBAL devNames
Definition: print.c:53
#define PD_RETURNDEFAULT
Definition: commdlg.h:157

Referenced by WinMain().

◆ get_print_file_filter()

static LPWSTR get_print_file_filter ( HWND  hMainWnd)
static

Definition at line 63 of file print.c.

64 {
65  static WCHAR wszPrintFilter[MAX_STRING_LEN*2+6+4+1];
66  const WCHAR files_prn[] = {'*','.','P','R','N',0};
67  const WCHAR files_all[] = {'*','.','*','\0'};
68  LPWSTR p;
70 
71  p = wszPrintFilter;
73  p += lstrlenW(p) + 1;
74  lstrcpyW(p, files_prn);
75  p += lstrlenW(p) + 1;
77  p += lstrlenW(p) + 1;
78  lstrcpyW(p, files_all);
79  p += lstrlenW(p) + 1;
80  *p = 0;
81 
82  return wszPrintFilter;
83 }
#define STRING_PRINTER_FILES_PRN
Definition: wordpad.h:208
#define MAX_STRING_LEN
Definition: precomp.h:36
#define lstrlenW
Definition: compat.h:750
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE hInstance
Definition: charmap.c:19
#define STRING_ALL_FILES
Definition: notepad_res.h:80
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define lstrcpyW
Definition: compat.h:749
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by dialog_print_to_file().

◆ get_print_rect()

static RECT get_print_rect ( HDC  hdc)
static

Definition at line 187 of file print.c.

188 {
189  RECT rc;
190  int width, height;
191 
192  if(hdc)
193  {
194  int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
195  int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
198  } else
199  {
200  width = centmm_to_twips(18500);
201  height = centmm_to_twips(27000);
202  }
203 
205 
206  return rc;
207 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define LOGPIXELSX
Definition: wingdi.h:718
static LONG devunits_to_twips(int units, int dpi)
Definition: print.c:181
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define PHYSICALHEIGHT
Definition: wingdi.h:736
static LONG centmm_to_twips(int mm)
Definition: print.c:171
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
static RECT margins
Definition: print.c:55
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define PHYSICALWIDTH
Definition: wingdi.h:735
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
LONG bottom
Definition: windef.h:309
#define LOGPIXELSY
Definition: wingdi.h:719

Referenced by paint_ruler(), preview_proc(), print(), and target_device().

◆ get_ruler_wnd()

static HWND get_ruler_wnd ( HWND  hMainWnd)
static

Definition at line 283 of file print.c.

284 {
286 }
#define IDC_RULER
Definition: wordpad.h:170
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HWND hMainWnd
Definition: magnifier.c:32
#define IDC_REBAR
Definition: wordpad.h:159

Referenced by dialog_print(), and dialog_printsetup().

◆ init_preview()

void init_preview ( HWND  hMainWnd,
LPWSTR  wszFileName 
)

Definition at line 735 of file print.c.

736 {
738  preview.page = 1;
739  preview.hdc = 0;
740  preview.hdc2 = 0;
742  preview.zoomratio = 0;
743  preview.zoomlevel = 0;
745 
748  0, 0, 200, 10, hMainWnd, (HMENU)IDC_PREVIEW, hInstance, NULL);
749 }
HDC hdc2
Definition: print.c:41
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:71
static void preview_bar_show(HWND hMainWnd, BOOL show)
Definition: print.c:578
#define TRUE
Definition: types.h:120
int zoomlevel
Definition: print.c:48
#define WS_CHILD
Definition: pedump.c:617
HINSTANCE hInstance
Definition: charmap.c:19
float zoomratio
Definition: print.c:47
const WCHAR wszPreviewWndClass[]
Definition: wordpad.c:57
int page
Definition: print.c:35
#define WS_HSCROLL
Definition: pedump.c:628
HWND hMainWnd
Definition: magnifier.c:32
LPWSTR wszFileName
Definition: print.c:49
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
HDC hdc
Definition: print.c:40
#define IDC_PREVIEW
Definition: wordpad.h:171
static previewinfo preview
Definition: print.c:56
#define NULL
Definition: types.h:112
#define WS_VSCROLL
Definition: pedump.c:627
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define WS_VISIBLE
Definition: pedump.c:620
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by OnCommand().

◆ is_last_preview_page()

static BOOL is_last_preview_page ( int  page)
static

Definition at line 730 of file print.c.

731 {
732  return preview.pageEnds[page - 1] >= preview.textlength;
733 }
int * pageEnds
Definition: print.c:38
int textlength
Definition: print.c:39
Definition: module.h:566
static previewinfo preview
Definition: print.c:56

Referenced by draw_preview(), preview_page_hittest(), print_preview(), update_preview_buttons(), and update_preview_statusbar().

◆ make_dc()

static HDC make_dc ( void  )
static

Definition at line 145 of file print.c.

146 {
147  if(devNames && devMode)
148  {
151  HDC ret;
152 
153  ret = CreateDCW((LPWSTR)dn + dn->wDriverOffset,
154  (LPWSTR)dn + dn->wDeviceOffset, 0, dm);
155 
156  GlobalUnlock(dn);
157  GlobalUnlock(dm);
158 
159  return ret;
160  } else
161  {
162  return 0;
163  }
164 }
static HGLOBAL devMode
Definition: print.c:52
static HDC
Definition: imagelist.c:92
WORD wDeviceOffset
Definition: commdlg.h:298
WORD wDriverOffset
Definition: commdlg.h:297
static HGLOBAL devNames
Definition: print.c:53
int ret
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HDC WINAPI CreateDCW(_In_opt_ LPCWSTR pszDriver, _In_opt_ LPCWSTR pszDevice, _In_opt_ LPCWSTR psz, _In_opt_ const DEVMODEW *pdmInit)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by paint_ruler(), preview_proc(), print_quick(), target_device(), and update_preview().

◆ paint_ruler()

static void paint_ruler ( HWND  hWnd,
LONG  EditLeftmost,
BOOL  NewMetrics 
)
static

Definition at line 377 of file print.c.

378 {
379  PAINTSTRUCT ps;
380  HDC hdc = BeginPaint(hWnd, &ps);
381  HDC hdcPrint = make_dc();
382  RECT printRect = get_print_rect(hdcPrint);
383  RECT drawRect;
384 
385  GetClientRect(hWnd, &drawRect);
386  FillRect(hdc, &drawRect, GetSysColorBrush(COLOR_MENU));
387 
388  InflateRect(&drawRect, 0, -3);
389  drawRect.left = EditLeftmost;
390  drawRect.right = twips_to_pixels(printRect.right - margins.left, GetDeviceCaps(hdc, LOGPIXELSX));
391  FillRect(hdc, &drawRect, GetStockObject(WHITE_BRUSH));
392 
393  drawRect.top--;
394  drawRect.bottom++;
395  DrawEdge(hdc, &drawRect, EDGE_SUNKEN, BF_RECT);
396 
397  drawRect.left = drawRect.right - 1;
399  DrawEdge(hdc, &drawRect, EDGE_ETCHED, BF_RECT);
400 
401  drawRect.left = 0;
402  drawRect.top = 0;
403  add_ruler_units(hdc, &drawRect, NewMetrics, EditLeftmost);
404 
406  DeleteDC(hdcPrint);
407  EndPaint(hWnd, &ps);
408 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define LOGPIXELSX
Definition: wingdi.h:718
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
static RECT get_print_rect(HDC hdc)
Definition: print.c:187
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define WHITE_BRUSH
Definition: wingdi.h:902
LONG left
Definition: windef.h:306
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
LONG right
Definition: windef.h:308
#define BF_RECT
Definition: winuser.h:462
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
static void add_ruler_units(HDC hdcRuler, RECT *drawRect, BOOL NewMetrics, LONG EditLeftmost)
Definition: print.c:302
#define COLOR_MENU
Definition: winuser.h:911
#define BLACK_BRUSH
Definition: wingdi.h:896
static LONG twips_to_pixels(int twips, int dpi)
Definition: print.c:176
#define EDGE_ETCHED
Definition: winuser.h:452
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
static RECT margins
Definition: print.c:55
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI DeleteDC(_In_ HDC)
LONG bottom
Definition: windef.h:309
#define EDGE_SUNKEN
Definition: winuser.h:451
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
static HDC make_dc(void)
Definition: print.c:145

Referenced by ruler_proc().

◆ preview_bar_show()

static void preview_bar_show ( HWND  hMainWnd,
BOOL  show 
)
static

Definition at line 578 of file print.c.

579 {
580  HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR);
581  int i;
582 
583  if(show)
584  {
585  REBARBANDINFOW rb;
586  HWND hStatic;
587  UINT num_pages_string = preview.pages_shown > 1 ? STRING_PREVIEW_ONEPAGE :
589 
593  AddTextButton(hReBar, num_pages_string, ID_PREVIEW_NUMPAGES, BANDID_PREVIEW_BTN4);
597 
598  hStatic = CreateWindowW(WC_STATICW, NULL,
599  WS_VISIBLE | WS_CHILD, 0, 0, 0, 0,
600  hReBar, NULL, NULL, NULL);
601 
605  rb.hwndChild = hStatic;
606  rb.cyChild = rb.cyMinChild = 22;
607  rb.cx = rb.cxMinChild = 90;
608  rb.cxIdeal = 100;
610 
611  SendMessageW(hReBar, RB_INSERTBANDW, -1, (LPARAM)&rb);
612  } else
613  {
614  for(i = 0; i <= PREVIEW_BUTTONS; i++)
616  }
617 }
#define RBBIM_CHILD
Definition: commctrl.h:1506
#define BANDID_PREVIEW_BTN7
Definition: wordpad.h:107
#define STRING_PREVIEW_PREVPAGE
Definition: wordpad.h:220
#define BANDID_PREVIEW_BTN3
Definition: wordpad.h:103
#define RBBIM_ID
Definition: commctrl.h:1510
#define WS_CHILD
Definition: pedump.c:617
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4306
#define BANDID_PREVIEW_BTN1
Definition: wordpad.h:101
#define REBARBANDINFOW_V6_SIZE
Definition: commctrl.h:1542
#define STRING_PREVIEW_ONEPAGE
Definition: wordpad.h:222
#define RBBIM_STYLE
Definition: commctrl.h:1502
#define RBBIM_SIZE
Definition: commctrl.h:1508
static void AddTextButton(HWND hRebarWnd, UINT string, UINT command, UINT id)
Definition: print.c:121
#define BANDID_PREVIEW_BUFFER
Definition: wordpad.h:108
#define ID_FILE_EXIT
Definition: resource.h:46
LONG_PTR LPARAM
Definition: windef.h:208
#define RB_INSERTBANDW
Definition: commctrl.h:1583
#define ID_PREVIEW_NUMPAGES
Definition: wordpad.h:50
#define RBBS_VARIABLEHEIGHT
Definition: commctrl.h:1495
#define BANDID_PREVIEW_BTN4
Definition: wordpad.h:104
int pages_shown
Definition: print.c:36
#define STRING_PREVIEW_CLOSE
Definition: wordpad.h:225
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define BANDID_PREVIEW_BTN5
Definition: wordpad.h:105
#define RBBIM_CHILDSIZE
Definition: commctrl.h:1507
#define STRING_PREVIEW_ZOOMIN
Definition: wordpad.h:223
HWND hMainWnd
Definition: magnifier.c:32
#define STRING_PREVIEW_NEXTPAGE
Definition: wordpad.h:219
#define STRING_PREVIEW_PRINT
Definition: wordpad.h:218
#define STRING_PREVIEW_ZOOMOUT
Definition: wordpad.h:224
#define BANDID_PREVIEW_BTN6
Definition: wordpad.h:106
#define ID_PRINT
Definition: wordpad.h:39
#define PREVIEW_BUTTONS
Definition: wordpad.h:89
#define ID_PREVIEW_ZOOMOUT
Definition: wordpad.h:52
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static previewinfo preview
Definition: print.c:56
#define STRING_PREVIEW_TWOPAGES
Definition: wordpad.h:221
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define ID_PREVIEW_ZOOMIN
Definition: wordpad.h:51
#define RB_IDTOINDEX
Definition: commctrl.h:1588
#define ID_PREVIEW_NEXTPAGE
Definition: wordpad.h:48
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define WC_STATICW
Definition: commctrl.h:4680
#define ID_PREVIEW_PREVPAGE
Definition: wordpad.h:49
#define RBBS_NOGRIPPER
Definition: commctrl.h:1497
#define RB_DELETEBAND
Definition: commctrl.h:1576
#define BANDID_PREVIEW_BTN2
Definition: wordpad.h:102
#define WS_VISIBLE
Definition: pedump.c:620
#define IDC_REBAR
Definition: wordpad.h:159
#define RBBIM_IDEALSIZE
Definition: commctrl.h:1511

Referenced by close_preview(), and init_preview().

◆ preview_command()

LRESULT preview_command ( HWND  hWnd,
WPARAM  wParam 
)

Definition at line 1203 of file print.c.

1204 {
1205  switch(LOWORD(wParam))
1206  {
1207  case ID_FILE_EXIT:
1208  PostMessageW(hWnd, WM_CLOSE, 0, 0);
1209  break;
1210 
1211  case ID_PREVIEW_NEXTPAGE:
1212  case ID_PREVIEW_PREVPAGE:
1213  {
1215  preview.page++;
1216  else
1217  preview.page--;
1218 
1220  }
1221  break;
1222 
1223  case ID_PREVIEW_NUMPAGES:
1225  break;
1226 
1227  case ID_PREVIEW_ZOOMIN:
1228  if (preview.zoomlevel < 2)
1229  {
1230  if (preview.zoomlevel == 0)
1232  preview.zoomlevel++;
1233  preview.zoomratio = 0;
1234  if (preview.pages_shown > 1)
1235  {
1236  /* Forced switch to one page when zooming in. */
1238  } else {
1239  HWND hwndPreview = GetDlgItem(hWnd, IDC_PREVIEW);
1240  update_preview_sizes(hwndPreview, TRUE);
1241  InvalidateRect(hwndPreview, NULL, FALSE);
1243  }
1244  }
1245  break;
1246 
1247  case ID_PREVIEW_ZOOMOUT:
1248  if (preview.zoomlevel > 0)
1249  {
1250  HWND hwndPreview = GetDlgItem(hWnd, IDC_PREVIEW);
1251  preview.zoomlevel--;
1252  preview.zoomratio = 0;
1253  if (preview.zoomlevel == 0 && preview.saved_pages_shown > 1) {
1255  } else {
1256  update_preview_sizes(hwndPreview, TRUE);
1257  InvalidateRect(hwndPreview, NULL, FALSE);
1259  }
1260  }
1261  break;
1262 
1263  case ID_PRINT:
1265  SendMessageW(hWnd, WM_CLOSE, 0, 0);
1266  break;
1267  }
1268 
1269  return 0;
1270 }
void dialog_print(HWND hMainWnd, LPWSTR wszFileName)
Definition: print.c:549
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
int zoomlevel
Definition: print.c:48
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
float zoomratio
Definition: print.c:47
#define ID_FILE_EXIT
Definition: resource.h:46
#define ID_PREVIEW_NUMPAGES
Definition: wordpad.h:50
static void update_preview(HWND hMainWnd)
Definition: print.c:920
int pages_shown
Definition: print.c:36
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
int page
Definition: print.c:35
#define WM_CLOSE
Definition: winuser.h:1611
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
LPWSTR wszFileName
Definition: print.c:49
int saved_pages_shown
Definition: print.c:37
#define IDC_PREVIEW
Definition: wordpad.h:171
static void toggle_num_pages(HWND hMainWnd)
Definition: print.c:972
#define ID_PRINT
Definition: wordpad.h:39
#define ID_PREVIEW_ZOOMOUT
Definition: wordpad.h:52
static previewinfo preview
Definition: print.c:56
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define ID_PREVIEW_ZOOMIN
Definition: wordpad.h:51
#define ID_PREVIEW_NEXTPAGE
Definition: wordpad.h:48
#define NULL
Definition: types.h:112
#define ID_PREVIEW_PREVPAGE
Definition: wordpad.h:49
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static void update_preview_buttons(HWND hMainWnd)
Definition: print.c:815
static void update_preview_sizes(HWND hwndPreview, BOOL zoomLevelUpdated)
Definition: print.c:649
#define LOWORD(l)
Definition: pedump.c:82

Referenced by WndProc().

◆ preview_isactive()

BOOL preview_isactive ( void  )

Definition at line 779 of file print.c.

780 {
781  return preview.page != 0;
782 }
int page
Definition: print.c:35
static previewinfo preview
Definition: print.c:56

Referenced by OnSize(), and WndProc().

◆ preview_page_hittest()

static int preview_page_hittest ( POINT  pt)
static

Definition at line 995 of file print.c.

996 {
997  RECT rc;
998  rc.left = preview.spacing.cx;
999  rc.right = rc.left + preview.bmScaledSize.cx;
1000  rc.top = preview.spacing.cy;
1001  rc.bottom = rc.top + preview.bmScaledSize.cy;
1002  if (PtInRect(&rc, pt))
1003  return 1;
1004 
1005  if (preview.pages_shown <= 1)
1006  return 0;
1007 
1010  if (PtInRect(&rc, pt))
1011  return is_last_preview_page(preview.page) ? 1 : 2;
1012 
1013  return 0;
1014 }
#define pt(x, y)
Definition: drawing.c:79
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
static BOOL is_last_preview_page(int page)
Definition: print.c:730
LONG cx
Definition: windef.h:334
int pages_shown
Definition: print.c:36
int page
Definition: print.c:35
SIZE spacing
Definition: print.c:46
static previewinfo preview
Definition: print.c:56
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
LONG bottom
Definition: windef.h:309
LONG cy
Definition: windef.h:335
SIZE bmScaledSize
Definition: print.c:45

Referenced by preview_proc().

◆ preview_proc()

LRESULT CALLBACK preview_proc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1016 of file print.c.

1017 {
1018  switch(msg)
1019  {
1020  case WM_CREATE:
1021  {
1024  FORMATRANGE fr;
1025  GETTEXTLENGTHEX gt = {GTL_DEFAULT, 1200};
1026  HDC hdc = GetDC(hWnd);
1027  HDC hdcTarget = make_dc();
1028 
1033  fr.rcPage = preview.rcPage;
1034 
1037 
1039 
1040  fr.hdc = CreateCompatibleDC(hdc);
1041  fr.hdcTarget = hdcTarget;
1042  fr.chrg.cpMin = 0;
1044  DeleteDC(fr.hdc);
1046  ReleaseDC(hWnd, hdc);
1047 
1050  break;
1051  }
1052 
1053  case WM_PAINT:
1054  return print_preview(hWnd);
1055 
1056  case WM_SIZE:
1057  {
1060  break;
1061  }
1062 
1063  case WM_VSCROLL:
1064  case WM_HSCROLL:
1065  {
1066  SCROLLINFO si;
1067  RECT rc;
1068  int nBar = (msg == WM_VSCROLL) ? SB_VERT : SB_HORZ;
1069  int origPos;
1070 
1071  GetClientRect(hWnd, &rc);
1072  si.cbSize = sizeof(si);
1073  si.fMask = SIF_ALL;
1074  GetScrollInfo(hWnd, nBar, &si);
1075  origPos = si.nPos;
1076  switch(LOWORD(wParam))
1077  {
1078  case SB_TOP: /* == SB_LEFT */
1079  si.nPos = si.nMin;
1080  break;
1081  case SB_BOTTOM: /* == SB_RIGHT */
1082  si.nPos = si.nMax;
1083  break;
1084  case SB_LINEUP: /* == SB_LINELEFT */
1085  si.nPos -= si.nPage / 10;
1086  break;
1087  case SB_LINEDOWN: /* == SB_LINERIGHT */
1088  si.nPos += si.nPage / 10;
1089  break;
1090  case SB_PAGEUP: /* == SB_PAGELEFT */
1091  si.nPos -= si.nPage;
1092  break;
1093  case SB_PAGEDOWN: /* SB_PAGERIGHT */
1094  si.nPos += si.nPage;
1095  break;
1096  case SB_THUMBTRACK:
1097  si.nPos = si.nTrackPos;
1098  break;
1099  }
1100  si.fMask = SIF_POS;
1101  SetScrollInfo(hWnd, nBar, &si, TRUE);
1102  GetScrollInfo(hWnd, nBar, &si);
1103  if (si.nPos != origPos)
1104  {
1105  int amount = origPos - si.nPos;
1106  if (msg == WM_VSCROLL)
1107  ScrollWindow(hWnd, 0, amount, NULL, NULL);
1108  else
1109  ScrollWindow(hWnd, amount, 0, NULL, NULL);
1110  }
1111  return 0;
1112  }
1113 
1114  case WM_SETCURSOR:
1115  {
1116  POINT pt;
1117  RECT rc;
1118  int bHittest = 0;
1119  DWORD messagePos = GetMessagePos();
1120  pt.x = (short)LOWORD(messagePos);
1121  pt.y = (short)HIWORD(messagePos);
1122  ScreenToClient(hWnd, &pt);
1123 
1124  GetClientRect(hWnd, &rc);
1125  if (PtInRect(&rc, pt))
1126  {
1127  pt.x += GetScrollPos(hWnd, SB_HORZ);
1128  pt.y += GetScrollPos(hWnd, SB_VERT);
1129  bHittest = preview_page_hittest(pt);
1130  }
1131 
1132  if (bHittest)
1135  else
1137 
1138  return TRUE;
1139  }
1140 
1141  case WM_LBUTTONDOWN:
1142  {
1143  int page;
1144  POINT pt;
1147  if ((page = preview_page_hittest(pt)) > 0)
1148  {
1150 
1151  /* Convert point from client coordinate to unzoomed page
1152  * coordinate. */
1153  pt.x -= preview.spacing.cx;
1154  if (page > 1)
1156  pt.y -= preview.spacing.cy;
1157  pt.x /= preview.zoomratio;
1158  pt.y /= preview.zoomratio;
1159 
1160  if (preview.zoomlevel == 0)
1162  preview.zoomlevel = (preview.zoomlevel + 1) % 3;
1163  preview.zoomratio = 0;
1164  if (preview.zoomlevel == 0 && preview.saved_pages_shown > 1)
1165  {
1167  } else if (preview.pages_shown > 1) {
1168  if (page >= 2) preview.page++;
1170  } else {
1174  }
1175 
1176  if (preview.zoomlevel > 0) {
1177  SCROLLINFO si;
1178  /* Convert the coordinate back to client coordinate. */
1179  pt.x *= preview.zoomratio;
1180  pt.y *= preview.zoomratio;
1181  pt.x += preview.spacing.cx;
1182  pt.y += preview.spacing.cy;
1183  /* Scroll to center view at that point on the page */
1184  si.cbSize = sizeof(si);
1185  si.fMask = SIF_PAGE;
1186  GetScrollInfo(hWnd, SB_HORZ, &si);
1187  pt.x -= si.nPage / 2;
1189  GetScrollInfo(hWnd, SB_VERT, &si);
1190  pt.y -= si.nPage / 2;
1192  }
1193  }
1194  }
1195 
1196  default:
1197  return DefWindowProcW(hWnd, msg, wParam, lParam);
1198  }
1199 
1200  return 0;
1201 }
#define GTL_DEFAULT
Definition: richedit.h:1054
#define SB_PAGEDOWN
Definition: winuser.h:569
#define IDC_ZOOM
Definition: resource.h:16
#define SB_PAGEUP
Definition: winuser.h:568
#define LOGPIXELSX
Definition: wingdi.h:718
#define WM_LBUTTONDOWN
Definition: winuser.h:1766
static RECT get_print_rect(HDC hdc)
Definition: print.c:187
HDC WINAPI GetDC(_In_opt_ HWND)
#define SB_VERT
Definition: winuser.h:553
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
SIZE bmSize
Definition: print.c:44
RECT rcPage
Definition: print.c:43
RECT rcPage
Definition: richedit.h:610
#define SB_HORZ
Definition: winuser.h:552
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
LONG cpMax
Definition: richedit.h:501
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int zoomlevel
Definition: print.c:48
static HWND hEditorWnd
Definition: wordpad.c:61
UINT_PTR WPARAM
Definition: windef.h:207
DWORD WINAPI GetMessagePos(void)
Definition: message.c:1351
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define SIF_PAGE
Definition: winuser.h:1223
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI ScrollWindow(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT)
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define FALSE
Definition: types.h:117
float zoomratio
Definition: print.c:47
#define WM_SETCURSOR
Definition: winuser.h:1626
int textlength
Definition: print.c:39
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
LONG cx
Definition: windef.h:334
Definition: module.h:566
static void update_preview(HWND hMainWnd)
Definition: print.c:920
HDC hdcTarget
Definition: richedit.h:608
int pages_shown
Definition: print.c:36
#define IDC_EDITOR
Definition: wordpad.h:156
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
int page
Definition: print.c:35
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SB_THUMBTRACK
Definition: winuser.h:573
#define WM_SIZE
Definition: winuser.h:1601
int WINAPI GetScrollPos(_In_ HWND, _In_ int)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
static LONG twips_to_pixels(int twips, int dpi)
Definition: print.c:176
unsigned long DWORD
Definition: ntddk_ex.h:95
SIZE spacing
Definition: print.c:46
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define WM_PAINT
Definition: winuser.h:1610
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
HWND hMainWnd
Definition: magnifier.c:32
HDC hdc
Definition: main.c:9
CHARRANGE chrg
Definition: richedit.h:611
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
int saved_pages_shown
Definition: print.c:37
static RECT margins
Definition: print.c:55
HDC hdcTarget
Definition: PatBlt.c:12
static void toggle_num_pages(HWND hMainWnd)
Definition: print.c:972
#define SIF_POS
Definition: winuser.h:1224
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)
#define SB_TOP
Definition: winuser.h:578
BOOL WINAPI DeleteDC(_In_ HDC)
static previewinfo preview
Definition: print.c:56
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_LINEDOWN
Definition: winuser.h:565
#define NULL
Definition: types.h:112
#define WM_HSCROLL
Definition: winuser.h:1733
#define SB_LINEUP
Definition: winuser.h:564
#define SB_BOTTOM
Definition: winuser.h:577
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WM_CREATE
Definition: winuser.h:1598
static int preview_page_hittest(POINT pt)
Definition: print.c:995
#define HIWORD(l)
Definition: typedefs.h:247
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
static void update_preview_buttons(HWND hMainWnd)
Definition: print.c:815
LONG bottom
Definition: windef.h:309
#define LOGPIXELSY
Definition: wingdi.h:719
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define EM_GETTEXTLENGTHEX
Definition: richedit.h:129
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
static HDC make_dc(void)
Definition: print.c:145
static void update_preview_sizes(HWND hwndPreview, BOOL zoomLevelUpdated)
Definition: print.c:649
static LRESULT print_preview(HWND hwndPreview)
Definition: print.c:829
LONG cy
Definition: windef.h:335
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
SIZE bmScaledSize
Definition: print.c:45
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
LONG cpMin
Definition: richedit.h:500
#define WM_VSCROLL
Definition: winuser.h:1734
#define SIF_ALL
Definition: winuser.h:1222

Referenced by WinMain().

◆ print()

static void print ( LPPRINTDLGW  pd,
LPWSTR  wszFileName 
)
static

Definition at line 438 of file print.c.

439 {
440  FORMATRANGE fr;
441  DOCINFOW di;
443  int printedPages = 0;
444 
445  fr.hdc = pd->hDC;
446  fr.hdcTarget = pd->hDC;
447 
448  fr.rc = get_print_rect(fr.hdc);
449  SetRect(&fr.rcPage, 0, 0, fr.rc.right + margins.right, fr.rc.bottom + margins.bottom);
450 
451  ZeroMemory(&di, sizeof(di));
452  di.cbSize = sizeof(di);
454 
455  if(pd->Flags & PD_PRINTTOFILE)
456  {
458  if(!di.lpszOutput)
459  return;
460  }
461 
462  if(pd->Flags & PD_SELECTION)
463  {
465  } else
466  {
467  GETTEXTLENGTHEX gt;
468  gt.flags = GTL_DEFAULT;
469  gt.codepage = 1200;
470  fr.chrg.cpMin = 0;
472 
473  if(pd->Flags & PD_PAGENUMS)
475  }
476 
477  StartDocW(fr.hdc, &di);
478  do
479  {
480  if(StartPage(fr.hdc) <= 0)
481  break;
482 
484 
485  if(EndPage(fr.hdc) <= 0)
486  break;
487 
488  printedPages++;
489  if((pd->Flags & PD_PAGENUMS) && (printedPages > (pd->nToPage - pd->nFromPage)))
490  break;
491  }
492  while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax);
493 
494  EndDoc(fr.hdc);
496 }
static void char_from_pagenum(HWND hEditorWnd, FORMATRANGE *fr, int page)
Definition: print.c:269
#define GTL_DEFAULT
Definition: richedit.h:1054
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:71
HWND hwndOwner
Definition: commdlg.h:487
static RECT get_print_rect(HDC hdc)
Definition: print.c:187
#define TRUE
Definition: types.h:120
RECT rcPage
Definition: richedit.h:610
#define ZeroMemory
Definition: winbase.h:1670
LONG cpMax
Definition: richedit.h:501
#define EM_FORMATRANGE
Definition: richedit.h:90
static HWND hEditorWnd
Definition: wordpad.c:61
UINT_PTR WPARAM
Definition: windef.h:207
DWORD Flags
Definition: commdlg.h:491
LONG right
Definition: windef.h:308
int WINAPI EndPage(_In_ HDC)
LPCWSTR lpszOutput
Definition: wingdi.h:1685
int WINAPI StartPage(_In_ HDC)
#define EM_EXGETSEL
Definition: richedit.h:85
#define FALSE
Definition: types.h:117
HDC hDC
Definition: commdlg.h:490
static LPWSTR dialog_print_to_file(HWND hMainWnd)
Definition: print.c:243
#define PD_SELECTION
Definition: commdlg.h:147
LONG_PTR LPARAM
Definition: windef.h:208
int cbSize
Definition: wingdi.h:1683
HDC hdcTarget
Definition: richedit.h:608
#define IDC_EDITOR
Definition: wordpad.h:156
int WINAPI StartDocW(_In_ HDC, _In_ const DOCINFOW *)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
WORD nToPage
Definition: commdlg.h:493
#define PD_PAGENUMS
Definition: commdlg.h:148
CHARRANGE chrg
Definition: richedit.h:611
LPCWSTR lpszDocName
Definition: wingdi.h:1684
#define PD_PRINTTOFILE
Definition: commdlg.h:152
WORD nFromPage
Definition: commdlg.h:492
static RECT margins
Definition: print.c:55
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LONG bottom
Definition: windef.h:309
#define EM_GETTEXTLENGTHEX
Definition: richedit.h:129
LONG cpMin
Definition: richedit.h:500
int WINAPI EndDoc(_In_ HDC)

Referenced by ctype< char >::classic_table(), dialog_print(), main(), print_client(), print_proxy(), print_quick(), print_server(), and printrules().

◆ print_preview()

static LRESULT print_preview ( HWND  hwndPreview)
static

Definition at line 829 of file print.c.

830 {
831  HPEN hPen, oldPen;
832  HDC hdc;
833  HRGN back_rgn, excl_rgn;
834  RECT window, background;
835  PAINTSTRUCT ps;
836  int x, y;
837 
838  hdc = BeginPaint(hwndPreview, &ps);
839  GetClientRect(hwndPreview, &window);
840  back_rgn = CreateRectRgnIndirect(&window);
841 
842  x = preview.spacing.cx - GetScrollPos(hwndPreview, SB_HORZ);
843  y = preview.spacing.cy - GetScrollPos(hwndPreview, SB_VERT);
844 
845  /* draw page outlines */
846  hPen = CreatePen(PS_SOLID|PS_INSIDEFRAME, 2, RGB(0,0,0));
847  oldPen = SelectObject(hdc, hPen);
848  SetRect(&background, x - 2, y - 2, x + preview.bmScaledSize.cx + 2,
849  y + preview.bmScaledSize.cy + 2);
850  Rectangle(hdc, background.left, background.top,
851  background.right, background.bottom);
852  excl_rgn = CreateRectRgnIndirect(&background);
853  CombineRgn(back_rgn, back_rgn, excl_rgn, RGN_DIFF);
854  if(preview.pages_shown > 1)
855  {
856  background.left += preview.bmScaledSize.cx + preview.spacing.cx;
857  background.right += preview.bmScaledSize.cx + preview.spacing.cx;
858  Rectangle(hdc, background.left, background.top,
859  background.right, background.bottom);
860  SetRectRgn(excl_rgn, background.left, background.top,
861  background.right, background.bottom);
862  CombineRgn(back_rgn, back_rgn, excl_rgn, RGN_DIFF);
863  }
864  SelectObject(hdc, oldPen);
865  DeleteObject(hPen);
866  FillRgn(hdc, back_rgn, GetStockObject(GRAY_BRUSH));
867  DeleteObject(excl_rgn);
868  DeleteObject(back_rgn);
869 
872 
874 
875  if(preview.pages_shown > 1)
876  {
879  StretchBlt(hdc, x, y,
881  preview.hdc2, 0, 0,
883 
885  } else {
886  InflateRect(&background, -2, -2);
887  FillRect(hdc, &background, GetStockObject(WHITE_BRUSH));
888  }
889  }
890 
892 
893  EndPaint(hwndPreview, &ps);
894 
895  return 0;
896 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
HDC hdc2
Definition: print.c:41
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
int WINAPI FillRgn(_In_ HDC, _In_ HRGN, _In_ HBRUSH)
Definition: painting.c:183
#define RGB(r, g, b)
Definition: precomp.h:62
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define SB_VERT
Definition: winuser.h:553
SIZE bmSize
Definition: print.c:44
#define SB_HORZ
Definition: winuser.h:552
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define WHITE_BRUSH
Definition: wingdi.h:902
LONG left
Definition: windef.h:306
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
LONG right
Definition: windef.h:308
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define PS_SOLID
Definition: wingdi.h:586
static BOOL is_last_preview_page(int page)
Definition: print.c:730
float zoomratio
Definition: print.c:47
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
static void draw_margin_lines(HDC hdc, int x, int y, float ratio)
Definition: print.c:694
LONG cx
Definition: windef.h:334
#define GRAY_BRUSH
Definition: wingdi.h:898
BOOL WINAPI SetRectRgn(_In_ HRGN, _In_ int, _In_ int, _In_ int, _In_ int)
int pages_shown
Definition: print.c:36
int page
Definition: print.c:35
int WINAPI GetScrollPos(_In_ HWND, _In_ int)
SIZE spacing
Definition: print.c:46
HDC hdc
Definition: main.c:9
HDC hdc
Definition: print.c:40
static IHTMLWindow2 * window
Definition: events.c:77
#define PS_INSIDEFRAME
Definition: wingdi.h:593
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
RECT window
Definition: print.c:42
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
static previewinfo preview
Definition: print.c:56
#define RGN_DIFF
Definition: wingdi.h:358
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
LONG bottom
Definition: windef.h:309
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
LONG cy
Definition: windef.h:335
SIZE bmScaledSize
Definition: print.c:45
#define SRCCOPY
Definition: wingdi.h:333

Referenced by preview_proc().

◆ print_quick()

void print_quick ( HWND  hMainWnd,
LPWSTR  wszFileName 
)

Definition at line 537 of file print.c.

538 {
539  PRINTDLGW pd;
540 
541  ZeroMemory(&pd, sizeof(pd));
542  pd.hwndOwner = hMainWnd;
543  pd.hDC = make_dc();
544 
545  print(&pd, wszFileName);
546  DeleteDC(pd.hDC);
547 }
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:71
HWND hwndOwner
Definition: commdlg.h:487
#define ZeroMemory
Definition: winbase.h:1670
HDC hDC
Definition: commdlg.h:490
HWND hMainWnd
Definition: magnifier.c:32
static void print(LPPRINTDLGW pd, LPWSTR wszFileName)
Definition: print.c:438
BOOL WINAPI DeleteDC(_In_ HDC)
static HDC make_dc(void)
Definition: print.c:145

Referenced by OnCommand().

◆ redraw_ruler()

void redraw_ruler ( HWND  hRulerWnd)

Definition at line 288 of file print.c.

289 {
290  RECT rc;
291 
292  GetClientRect(hRulerWnd, &rc);
293  InvalidateRect(hRulerWnd, &rc, TRUE);
294 }
#define TRUE
Definition: types.h:120
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by OnSize(), and update_ruler().

◆ registry_read_pagemargins()

void registry_read_pagemargins ( HKEY  hKey)

Definition at line 90 of file print.c.

91 {
92  DWORD size = sizeof(RECT);
93 
95  &size) != ERROR_SUCCESS || size != sizeof(RECT))
96  SetRect(&margins, 1757, 1417, 1757, 1417);
97 }
#define ERROR_SUCCESS
Definition: deptool.c:10
struct tagRECT RECT
unsigned char * LPBYTE
Definition: typedefs.h:53
GLsizeiptr size
Definition: glext.h:5919
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
unsigned long DWORD
Definition: ntddk_ex.h:95
static RECT margins
Definition: print.c:55
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
static const WCHAR var_pagemargin[]
Definition: print.c:60

Referenced by registry_read_options().

◆ registry_read_previewpages()

void registry_read_previewpages ( HKEY  hKey)

Definition at line 105 of file print.c.

106 {
107  DWORD size = sizeof(DWORD);
108  if(!hKey ||
111  size != sizeof(DWORD))
112  {
113  preview.pages_shown = 1;
114  } else {
115  if (preview.pages_shown < 1) preview.pages_shown = 1;
116  else if (preview.pages_shown > 2) preview.pages_shown = 2;
117  }
118 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DWORD
Definition: nt_native.h:44
unsigned char * LPBYTE
Definition: typedefs.h:53
int pages_shown
Definition: print.c:36
GLsizeiptr size
Definition: glext.h:5919
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
static const WCHAR var_previewpages[]
Definition: print.c:61
unsigned long DWORD
Definition: ntddk_ex.h:95
static previewinfo preview
Definition: print.c:56
FxAutoRegKey hKey
#define NULL
Definition: types.h:112

Referenced by registry_read_options().

◆ registry_set_pagemargins()

void registry_set_pagemargins ( HKEY  hKey)

Definition at line 85 of file print.c.

86 {
88 }
#define REG_BINARY
Definition: nt_native.h:1496
unsigned char * LPBYTE
Definition: typedefs.h:53
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4899
static RECT margins
Definition: print.c:55
FxAutoRegKey hKey
static const WCHAR var_pagemargin[]
Definition: print.c:60

Referenced by registry_set_options().

◆ registry_set_previewpages()

void registry_set_previewpages ( HKEY  hKey)

Definition at line 99 of file print.c.

100 {
102  (LPBYTE)&preview.pages_shown, sizeof(DWORD));
103 }
unsigned char * LPBYTE
Definition: typedefs.h:53
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4899
int pages_shown
Definition: print.c:36
static const WCHAR var_previewpages[]
Definition: print.c:61
unsigned long DWORD
Definition: ntddk_ex.h:95
static previewinfo preview
Definition: print.c:56
FxAutoRegKey hKey
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by registry_set_options().

◆ ruler_proc()

LRESULT CALLBACK ruler_proc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 410 of file print.c.

411 {
412  static WNDPROC pPrevRulerProc;
413  static LONG EditLeftmost;
414  static BOOL NewMetrics;
415 
416  switch(msg)
417  {
418  case WM_USER:
419  if(wParam)
420  {
421  EditLeftmost = ((POINTL*)wParam)->x;
422  pPrevRulerProc = (WNDPROC)lParam;
423  }
424  NewMetrics = TRUE;
425  break;
426 
427  case WM_PAINT:
428  paint_ruler(hWnd, EditLeftmost, NewMetrics);
429  break;
430 
431  default:
432  return CallWindowProcW(pPrevRulerProc, hWnd, msg, wParam, lParam);
433  }
434 
435  return 0;
436 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static void paint_ruler(HWND hWnd, LONG EditLeftmost, BOOL NewMetrics)
Definition: print.c:377
#define WM_PAINT
Definition: winuser.h:1610
#define WM_USER
Definition: winuser.h:1885
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2896
#define msg(x)
Definition: auth_time.c:54
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPARAM lParam
Definition: combotst.c:139

Referenced by WinMain().

◆ target_device()

void target_device ( HWND  hMainWnd,
DWORD  wordWrap 
)

Definition at line 209 of file print.c.

210 {
212 
214  {
215  int width = 0;
216  LRESULT result;
217  HDC hdc = make_dc();
218  RECT rc = get_print_rect(hdc);
219 
220  width = rc.right - rc.left;
221  if(!hdc)
222  {
223  HDC hMaindc = GetDC(hMainWnd);
224  hdc = CreateCompatibleDC(hMaindc);
225  ReleaseDC(hMainWnd, hMaindc);
226  }
228  DeleteDC(hdc);
229  if (result)
230  return;
231  /* otherwise EM_SETTARGETDEVICE failed, so fall back on wrapping
232  * to window using the NULL DC. */
233  }
234 
235  if (wordWrap != ID_WORDWRAP_NONE) {
237  } else {
239  }
240 
241 }
#define ID_WORDWRAP_MARGIN
Definition: wordpad.h:112
GLint GLint GLsizei width
Definition: gl.h:1546
#define ID_WORDWRAP_NONE
Definition: wordpad.h:110
static RECT get_print_rect(HDC hdc)
Definition: print.c:187
GLuint64EXT * result
Definition: glext.h:11304
HDC WINAPI GetDC(_In_opt_ HWND)
static DWORD wordWrap[2]
Definition: wordpad.c:67
static HDC
Definition: imagelist.c:92
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static HWND hEditorWnd
Definition: wordpad.c:61
UINT_PTR WPARAM
Definition: windef.h:207
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define EM_SETTARGETDEVICE
Definition: richedit.h:105
#define IDC_EDITOR
Definition: wordpad.h:156
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HWND hMainWnd
Definition: magnifier.c:32
HDC hdc
Definition: main.c:9
BOOL WINAPI DeleteDC(_In_ HDC)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LONG_PTR LRESULT
Definition: windef.h:209
static HDC make_dc(void)
Definition: print.c:145

Referenced by dialog_viewproperties(), OnCommand(), set_fileformat(), and WinMain().

◆ toggle_num_pages()

static void toggle_num_pages ( HWND  hMainWnd)
static

Definition at line 972 of file print.c.

973 {
974  HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR);
977  int nPreviewPages;
978 
979  preview.pages_shown = preview.pages_shown > 1 ? 1 : 2;
980 
981  nPreviewPages = preview.zoomlevel > 0 ? preview.saved_pages_shown :
983 
984  LoadStringW(hInst, nPreviewPages > 1 ? STRING_PREVIEW_ONEPAGE :
987 
991 }
#define TRUE
Definition: types.h:120
#define MAX_STRING_LEN
Definition: precomp.h:36
int zoomlevel
Definition: print.c:48
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define STRING_PREVIEW_ONEPAGE
Definition: wordpad.h:222
#define ID_PREVIEW_NUMPAGES
Definition: wordpad.h:50
static void update_preview(HWND hMainWnd)
Definition: print.c:920
int pages_shown
Definition: print.c:36
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hMainWnd
Definition: magnifier.c:32
int saved_pages_shown
Definition: print.c:37
#define IDC_PREVIEW
Definition: wordpad.h:171
HINSTANCE hInst
Definition: dxdiag.c:13
static previewinfo preview
Definition: print.c:56
#define STRING_PREVIEW_TWOPAGES
Definition: wordpad.h:221
Definition: name.c:38
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
static void update_preview_sizes(HWND hwndPreview, BOOL zoomLevelUpdated)
Definition: print.c:649
#define IDC_REBAR
Definition: wordpad.h:159

Referenced by preview_command(), and preview_proc().

◆ twips_to_centmm()

static LONG twips_to_centmm ( int  twips)
static

Definition at line 166 of file print.c.

167 {
168  return MulDiv(twips, CENTMM_PER_INCH, TWIPS_PER_INCH);
169 }
#define CENTMM_PER_INCH
Definition: wordpad.h:25
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
#define TWIPS_PER_INCH
Definition: wordpad.h:24

Referenced by dialog_printsetup().

◆ twips_to_pixels()

static LONG twips_to_pixels ( int  twips,
int  dpi 
)
static

Definition at line 176 of file print.c.

177 {
178  return MulDiv(twips, dpi, TWIPS_PER_INCH);
179 }
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
#define dpi
Definition: sysparams.c:22
#define TWIPS_PER_INCH
Definition: wordpad.h:24

Referenced by add_ruler_units(), draw_margin_lines(), paint_ruler(), and preview_proc().

◆ update_preview()

static void update_preview ( HWND  hMainWnd)
static

Definition at line 920 of file print.c.

921 {
922  RECT paper;
924  HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW);
925  HBITMAP hBitmapCapture;
926  FORMATRANGE fr;
927  HDC hdc = GetDC(hwndPreview);
928 
929  fr.hdcTarget = make_dc();
930  fr.rc = fr.rcPage = preview.rcPage;
931  fr.rc.left += margins.left;
932  fr.rc.top += margins.top;
933  fr.rc.bottom -= margins.bottom;
934  fr.rc.right -= margins.right;
935 
936  fr.chrg.cpMin = 0;
938 
939  SetRect(&paper, 0, 0, preview.bmSize.cx, preview.bmSize.cy);
940 
941  if (!preview.hdc) {
944  SelectObject(preview.hdc, hBitmapCapture);
945  }
946 
947  fr.hdc = preview.hdc;
948  draw_preview(hEditorWnd, &fr, &paper, preview.page);
949 
950  if(preview.pages_shown > 1)
951  {
952  if (!preview.hdc2)
953  {
955  hBitmapCapture = CreateCompatibleBitmap(hdc,
956  preview.bmSize.cx,
957  preview.bmSize.cy);
958  SelectObject(preview.hdc2, hBitmapCapture);
959  }
960 
961  fr.hdc = preview.hdc2;
962  draw_preview(hEditorWnd, &fr, &fr.rcPage, preview.page + 1);
963  }
964  DeleteDC(fr.hdcTarget);
965  ReleaseDC(hwndPreview, hdc);
966 
967  InvalidateRect(hwndPreview, NULL, FALSE);
970 }
HDC hdc2
Definition: print.c:41
static void draw_preview(HWND hEditorWnd, FORMATRANGE *lpFr, RECT *paper, int page)
Definition: print.c:784
HDC WINAPI GetDC(_In_opt_ HWND)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
SIZE bmSize
Definition: print.c:44
RECT rcPage
Definition: print.c:43
RECT rcPage
Definition: richedit.h:610
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
LONG cpMax
Definition: richedit.h:501
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static HWND hEditorWnd
Definition: wordpad.c:61
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define FALSE
Definition: types.h:117
int textlength
Definition: print.c:39
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
LONG cx
Definition: windef.h:334
HDC hdcTarget
Definition: richedit.h:608
int pages_shown
Definition: print.c:36
#define IDC_EDITOR
Definition: wordpad.h:156
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
int page
Definition: print.c:35
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HWND hMainWnd
Definition: magnifier.c:32
HDC hdc
Definition: main.c:9
CHARRANGE chrg
Definition: richedit.h:611
HDC hdc
Definition: print.c:40
#define IDC_PREVIEW
Definition: wordpad.h:171
static RECT margins
Definition: print.c:55
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI DeleteDC(_In_ HDC)
static previewinfo preview
Definition: print.c:56
#define NULL
Definition: types.h:112
static void update_preview_buttons(HWND hMainWnd)
Definition: print.c:815
LONG bottom
Definition: windef.h:309
static HBITMAP
Definition: button.c:44
static void update_preview_statusbar(HWND hMainWnd)
Definition: print.c:898
static HDC make_dc(void)
Definition: print.c:145
LONG cy
Definition: windef.h:335
LONG cpMin
Definition: richedit.h:500

Referenced by preview_command(), preview_proc(), and toggle_num_pages().

◆ update_preview_buttons()

static void update_preview_buttons ( HWND  hMainWnd)
static

Definition at line 815 of file print.c.

816 {
817  HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR);
823  preview.pages_shown > 1 ||
824  (!is_last_preview_page(1) && preview.zoomlevel == 0));
827 }
int zoomlevel
Definition: print.c:48
static BOOL is_last_preview_page(int page)
Definition: print.c:730
#define ID_PREVIEW_NUMPAGES
Definition: wordpad.h:50
int pages_shown
Definition: print.c:36
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
int page
Definition: print.c:35
HWND hMainWnd
Definition: magnifier.c:32
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define ID_PREVIEW_ZOOMOUT
Definition: wordpad.h:52
static previewinfo preview
Definition: print.c:56
#define ID_PREVIEW_ZOOMIN
Definition: wordpad.h:51
#define ID_PREVIEW_NEXTPAGE
Definition: wordpad.h:48
#define ID_PREVIEW_PREVPAGE
Definition: wordpad.h:49
#define IDC_REBAR
Definition: wordpad.h:159

Referenced by preview_command(), preview_proc(), and update_preview().

◆ update_preview_scrollbars()

static void update_preview_scrollbars ( HWND  hwndPreview,
RECT window 
)
static

Definition at line 621 of file print.c.

622 {
623  SCROLLINFO sbi;
624  sbi.cbSize = sizeof(sbi);
625  sbi.fMask = SIF_PAGE|SIF_RANGE;
626  sbi.nMin = 0;
627  if (preview.zoomlevel == 0)
628  {
629  /* Hide scrollbars when zoomed out. */
630  sbi.nMax = 0;
631  sbi.nPage = window->right;
632  SetScrollInfo(hwndPreview, SB_HORZ, &sbi, TRUE);
633  sbi.nPage = window->bottom;
634  SetScrollInfo(hwndPreview, SB_VERT, &sbi, TRUE);
635  } else {
638  sbi.nPage = window->right;
639  SetScrollInfo(hwndPreview, SB_HORZ, &sbi, TRUE);
640  /* Change in the horizontal scrollbar visibility affects the
641  * client rect, so update the client rect. */
642  GetClientRect(hwndPreview, window);
643  sbi.nMax = preview.bmScaledSize.cy + min_spacing * 2;
644  sbi.nPage = window->bottom;
645  SetScrollInfo(hwndPreview, SB_VERT, &sbi, TRUE);
646  }
647 }
#define SIF_RANGE
Definition: winuser.h:1225
#define SB_VERT
Definition: winuser.h:553
#define TRUE
Definition: types.h:120
#define SB_HORZ
Definition: winuser.h:552
int zoomlevel
Definition: print.c:48
#define SIF_PAGE
Definition: winuser.h:1223
static const int min_spacing
Definition: print.c:619
LONG cx
Definition: windef.h:334
int pages_shown
Definition: print.c:36
static IHTMLWindow2 * window
Definition: events.c:77
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
static previewinfo preview
Definition: print.c:56
LONG cy
Definition: windef.h:335
SIZE bmScaledSize
Definition: print.c:45
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

Referenced by update_preview_sizes().

◆ update_preview_sizes()

static void update_preview_sizes ( HWND  hwndPreview,
BOOL  zoomLevelUpdated 
)
static

Definition at line 649 of file print.c.

650 {
651  RECT window;
652 
653  GetClientRect(hwndPreview, &window);
654 
655  /* The zoom ratio isn't updated for partial zoom because of resizing the window. */
656  if (zoomLevelUpdated || preview.zoomlevel != 1)
657  {
658  float ratio, ratioHeight, ratioWidth;
659  if (preview.zoomlevel == 2)
660  {
661  ratio = 1.0;
662  } else {
663  ratioHeight = (window.bottom - min_spacing * 2) / (float)preview.bmSize.cy;
664 
665  ratioWidth = (float)(window.right -
666  min_spacing * (preview.pages_shown + 1)) /
668 
669  if(ratioWidth > ratioHeight)
670  ratio = ratioHeight;
671  else
672  ratio = ratioWidth;
673 
674  if (preview.zoomlevel == 1)
675  ratio += (1.0 - ratio) / 2;
676  }
677  preview.zoomratio = ratio;
678  }
679 
682 
684 
685  preview.spacing.cx = (window.right -
687  (preview.pages_shown + 1);
690 
691  update_preview_scrollbars(hwndPreview, &window);
692 }
#define max(a, b)
Definition: svc.c:63
SIZE bmSize
Definition: print.c:44
int zoomlevel
Definition: print.c:48
float zoomratio
Definition: print.c:47
static const int min_spacing
Definition: print.c:619
LONG cx
Definition: windef.h:334
int pages_shown
Definition: print.c:36
SIZE spacing
Definition: print.c:46
static IHTMLWindow2 * window
Definition: events.c:77
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
static previewinfo preview
Definition: print.c:56
static float(__cdecl *square_half_float)(float x
static void update_preview_scrollbars(HWND hwndPreview, RECT *window)
Definition: print.c:621
LONG cy
Definition: windef.h:335
SIZE bmScaledSize
Definition: print.c:45

Referenced by preview_command(), preview_proc(), and toggle_num_pages().

◆ update_preview_statusbar()

static void update_preview_statusbar ( HWND  hMainWnd)
static

Definition at line 898 of file print.c.

899 {
900  HWND hStatusbar = GetDlgItem(hMainWnd, IDC_STATUSBAR);
902  WCHAR *p;
903  WCHAR wstr[MAX_STRING_LEN];
904 
905  p = wstr;
907  {
908  static const WCHAR fmt[] = {' ','%','d','\0'};
911  } else {
912  static const WCHAR fmt[] = {' ','%','d','-','%','d','\0'};
915  }
916  SetWindowTextW(hStatusbar, wstr);
917 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define IDC_STATUSBAR
Definition: resource.h:12
#define STRING_PREVIEW_PAGE
Definition: wordpad.h:226
#define MAX_STRING_LEN
Definition: precomp.h:36
#define STRING_PREVIEW_PAGES
Definition: wordpad.h:227
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
static BOOL is_last_preview_page(int page)
Definition: print.c:730
int pages_shown
Definition: print.c:36
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
int page
Definition: print.c:35
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hMainWnd
Definition: magnifier.c:32
HINSTANCE hInst
Definition: dxdiag.c:13
static previewinfo preview
Definition: print.c:56
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
GLfloat GLfloat p
Definition: glext.h:8902
Definition: dsound.c:943

Referenced by update_preview().

◆ update_ruler()

static void update_ruler ( HWND  hRulerWnd)
static

Definition at line 296 of file print.c.

297 {
298  SendMessageW(hRulerWnd, WM_USER, 0, 0);
299  redraw_ruler(hRulerWnd);
300 }
void redraw_ruler(HWND hRulerWnd)
Definition: print.c:288
#define WM_USER
Definition: winuser.h:1885
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by dialog_print(), and dialog_printsetup().

Variable Documentation

◆ devMode

HGLOBAL devMode
static

◆ devNames

HGLOBAL devNames
static

Definition at line 53 of file print.c.

Referenced by dialog_print(), dialog_printsetup(), get_default_printer_opts(), and make_dc().

◆ margins

◆ min_spacing

const int min_spacing = 10
static

Definition at line 619 of file print.c.

Referenced by update_preview_scrollbars(), and update_preview_sizes().

◆ preview

◆ var_pagemargin

const WCHAR var_pagemargin[] = {'P','a','g','e','M','a','r','g','i','n',0}
static

Definition at line 60 of file print.c.

Referenced by registry_read_pagemargins(), and registry_set_pagemargins().

◆ var_previewpages

const WCHAR var_previewpages[] = {'P','r','e','v','i','e','w','P','a','g','e','s',0}
static

Definition at line 61 of file print.c.

Referenced by registry_read_previewpages(), and registry_set_previewpages().

◆ wszPreviewWndClass

const WCHAR wszPreviewWndClass[]

Definition at line 57 of file wordpad.c.

Referenced by init_preview(), and WinMain().