Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Aug 10, 2024
1 parent 24fe08c commit 2ce3e24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1587,10 +1587,10 @@ void MenuUpdateZoom(MainWindow* win) {

void MenuUpdatePrintItem(MainWindow* win, HMENU menu, bool disableOnly = false) {
bool filePrintEnabled = win->IsDocLoaded();
#ifndef DISABLE_DOCUMENT_RESTRICTIONS
bool filePrintAllowed = !filePrintEnabled || !win->AsFixed() || win->AsFixed()->GetEngine()->AllowsPrinting();
#else
#if defined(DISABLE_DOCUMENT_RESTRICTIONS)
bool filePrintAllowed = true;
#else
bool filePrintAllowed = !filePrintEnabled || !win->AsFixed() || win->AsFixed()->GetEngine()->AllowsPrinting();
#endif

for (auto& def : menuDefFile) {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/WinUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2981,6 +2981,8 @@ static Size HwndMeasureText(HWND hwnd, const WCHAR* txt, HFONT font) {
ScopedSelectFont prev(dc, font);

RECT r{};
// TODO: DT_EDITCONTROL is probably not correct here
// TODO: what about DT_NOPREFIX?
uint fmt = DT_CALCRECT | DT_LEFT | DT_NOCLIP | DT_EDITCONTROL;
size_t txtLen = str::Len(txt);
DrawTextExW(dc, (WCHAR*)txt, (int)txtLen, &r, fmt, nullptr);
Expand All @@ -2999,6 +3001,7 @@ Size HwndMeasureText(HWND hwnd, const char* txt, HFONT font) {
return HwndMeasureText(hwnd, sw, font);
}

// return approximate height of font in pixels
int FontDyPx(HWND hwnd, HFONT hfont) {
Size s = HwndMeasureText(hwnd, "A", hfont);
return s.dy;
Expand Down
5 changes: 4 additions & 1 deletion src/wingui/VirtWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ Size VirtWndText::GetIdealSize(bool onlyIfEmpty) {

void VirtWndText::Draw(HDC hdc) {
ReportIf(lastBounds.IsEmpty());
UINT fmt = DT_NOCLIP | DT_NOPREFIX | (isRtl ? DT_RTLREADING : DT_LEFT);
UINT fmt = DT_NOCLIP | DT_NOPREFIX;
if (isRtl) {
fmt = fmt | DT_RTLREADING;
}
RECT dr = ToRECT(lastBounds);
HdcDrawText(hdc, s, &dr, fmt, font);
if (withUnderline) {
Expand Down

0 comments on commit 2ce3e24

Please sign in to comment.