Skip to content

Feat/print capability#24

Open
electricmessiah wants to merge 7 commits into
mgelsinger:mainfrom
electricmessiah:feat/print-capability
Open

Feat/print capability#24
electricmessiah wants to merge 7 commits into
mgelsinger:mainfrom
electricmessiah:feat/print-capability

Conversation

@electricmessiah

Copy link
Copy Markdown
  • Adds Print capability with an icon and CTRL-P

…ss icons

Replaces the native menu bar with a custom-drawn toolbar row so quick-access
icon buttons can share the same line as File/Edit/View. File/Edit/View are
now flat buttons that open the same native submenus via TrackPopupMenu (all
existing menu content, IDM_* command routing, and keyboard behavior within
each dropdown is unchanged); New and Save As are icon buttons using Segoe
Fluent Icons glyphs, with hover tooltips.

- Custom BS_OWNERDRAW buttons throughout: standard BS_PUSHBUTTON always
  self-draws its 3D face using system colors and ignores WM_CTLCOLORBTN
  regardless of theme, so dark-themed buttons need full owner-draw
  (draw_toolbar_row_button).
- The app's HMENU is now built once and kept in AppState (main_menu) instead
  of attached via SetMenu/CreateWindowExW; every menu-manipulation helper
  (checkmarks, enable/disable, Recent Files rebuild) was updated to read it
  from state directly. This also fixes a related bug: those helpers
  previously read the menu via GetWindowLongPtrW(hwnd, GWLP_USERDATA), which
  isn't set until after create_children() returns — so initial checkmark
  sync at startup was silently a no-op until the user toggled the setting
  manually once.
Font was baked in on first use, often during early WM_CREATE/WM_SIZE
before Windows reports the window's final per-monitor DPI. Button
boxes already re-layout dynamically and pick up the corrected DPI,
but the glyph font stayed frozen at the wrong (usually 96 DPI) size,
so icons rendered undersized relative to their buttons on interactive
launches that hit the transient DPI window.
Dark theme colors the toolbar row the same background as the editor
and tabs below it, so without a seam the row visually blends into the
content area. Draws a DPI-scaled 1px line in a brighter dedicated
shade along the bottom edge to keep the separation visible.
Adds the Print icon button back (removed from the base toolbar PR at
the user's request, to keep that PR free of not-yet-real functionality).
Currently a stub — clicking it shows 'Printing is not yet implemented.'
Real printing (print dialog, pagination, GDI print job) is a separate,
substantially larger feature to build later.
Wires the previously-stub toolbar Print icon (and adds File > Print /
Ctrl+P) to a real print job using the system Print dialog and GDI
StartDoc/StartPage/EndPage/EndDoc, paginated via Scintilla's
SCI_FORMATRANGE.

- Always black text on white, ignoring dark mode and syntax colors
  (SC_PRINT_BLACKONWHITE), so print output looks the same regardless
  of the editor's current theme.
- Word wrap is forced on for the print job specifically via Scintilla's
  print-only wrap mode (SCI_SETPRINTWRAPMODE), independent of the
  live editor's on-screen word-wrap setting.
- Line numbers print if the View > Line Numbers toggle is on, since
  that margin renders as part of the document like on screen.
- Each page gets a header (filename plus date, centered) and footer
  (Page X of Y, centered), drawn directly via GDI DrawTextW.
- A dry-run measurement pass (draw = false) counts total pages before
  the real job starts spooling, so the footer can show the total.
- Adds Win32_Storage_Xps and Win32_System_SystemInformation Cargo
  features for the GDI print-job calls and GetLocalTime.
- Fixes an unrelated but real bug found along the way: heap-allocate
  the accelerator table (.to_vec()) before adding the new Ctrl+P
  entry, since this branch predates that fix and the addition would
  have pushed the array to exactly 35 stack-allocated entries — the
  known release-build-only CreateAcceleratorTableW crash size.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant