summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-05-05 04:58:47 +0000
committerPo Lu <luangruo@yahoo.com>2022-05-05 04:58:47 +0000
commit01e874e1e6e6770ed0a5ba3ba7c9488494a2e61a (patch)
treecc91dfdcd99a99a0dc60d6e138f994f81b167f0f
parentc250d82463eb554e03c8066845464ef0dbb017b7 (diff)
downloademacs-01e874e1e6e6770ed0a5ba3ba7c9488494a2e61a.tar.gz
Take size into account when previewing fonts on Haiku
* src/haiku_support.cc (MessageReceived): Decode size sent and handle `UPDATE_PREVIEW_DIALOG' message. (UpdatePreview): Add current size. (EmacsFontSelectionDialog): Assign correct modification messages to the size entry.
-rw-r--r--src/haiku_support.cc54
1 files changed, 38 insertions, 16 deletions
diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index 32b5302fd66..33acaacaaf4 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -92,20 +92,21 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
/* Some messages that Emacs sends to itself. */
enum
{
- SCROLL_BAR_UPDATE = 3000,
- WAIT_FOR_RELEASE = 3001,
- RELEASE_NOW = 3002,
- CANCEL_DROP = 3003,
- SHOW_MENU_BAR = 3004,
- BE_MENU_BAR_OPEN = 3005,
- QUIT_APPLICATION = 3006,
- REPLAY_MENU_BAR = 3007,
- FONT_FAMILY_SELECTED = 3008,
- FONT_STYLE_SELECTED = 3009,
- FILE_PANEL_SELECTION = 3010,
- QUIT_PREVIEW_DIALOG = 3011,
- SET_FONT_INDICES = 3012,
- SET_PREVIEW_DIALOG = 3013,
+ SCROLL_BAR_UPDATE = 3000,
+ WAIT_FOR_RELEASE = 3001,
+ RELEASE_NOW = 3002,
+ CANCEL_DROP = 3003,
+ SHOW_MENU_BAR = 3004,
+ BE_MENU_BAR_OPEN = 3005,
+ QUIT_APPLICATION = 3006,
+ REPLAY_MENU_BAR = 3007,
+ FONT_FAMILY_SELECTED = 3008,
+ FONT_STYLE_SELECTED = 3009,
+ FILE_PANEL_SELECTION = 3010,
+ QUIT_PREVIEW_DIALOG = 3011,
+ SET_FONT_INDICES = 3012,
+ SET_PREVIEW_DIALOG = 3013,
+ UPDATE_PREVIEW_DIALOG = 3014,
};
/* X11 keysyms that we use. */
@@ -2482,9 +2483,13 @@ class EmacsFontPreviewDialog : public BWindow
font_family name;
font_style sname;
status_t rc;
+ const char *size_name;
+ int size;
if (message->what == SET_FONT_INDICES)
{
+ size_name = message->FindString ("emacs:size");
+
if (message->FindInt32 ("emacs:family", &family) != B_OK
|| message->FindInt32 ("emacs:style", &style) != B_OK)
return;
@@ -2504,8 +2509,14 @@ class EmacsFontPreviewDialog : public BWindow
current_font = new BFont;
current_font->SetFamilyAndStyle (name, sname);
- text_view.SetFont (current_font);
+ if (size_name && strlen (size_name))
+ {
+ size = atoi (size_name);
+ current_font->SetSize (size);
+ }
+
+ text_view.SetFont (current_font);
DoLayout ();
return;
}
@@ -2618,6 +2629,9 @@ class EmacsFontSelectionDialog : public BWindow
message.AddInt32 ("emacs:family", family);
message.AddInt32 ("emacs:style", style);
+ message.AddString ("emacs:size",
+ size_entry.Text ());
+
messenger.SendMessage (&message);
}
@@ -2746,6 +2760,11 @@ class EmacsFontSelectionDialog : public BWindow
preview_checkbox.SetValue (B_CONTROL_OFF);
HidePreview ();
}
+ else if (msg->what == UPDATE_PREVIEW_DIALOG)
+ {
+ if (preview)
+ UpdatePreview ();
+ }
BWindow::MessageReceived (msg);
}
@@ -2810,7 +2829,8 @@ public:
cancel_button ("Cancel", "Cancel",
new BMessage (B_CANCEL)),
ok_button ("OK", "OK", new BMessage (B_OK)),
- size_entry (NULL, "Size:", NULL, NULL),
+ size_entry (NULL, "Size:", NULL,
+ new BMessage (UPDATE_PREVIEW_DIALOG)),
allow_monospace_only (monospace_only),
pending_selection_idx (initial_style_idx),
preview (NULL)
@@ -2846,6 +2866,8 @@ public:
font_style_pane.SetSelectionMessage (selection);
selection = new BMessage (B_OK);
font_style_pane.SetInvocationMessage (selection);
+ selection = new BMessage (UPDATE_PREVIEW_DIALOG);
+ size_entry.SetModificationMessage (selection);
comm_port = create_port (1, "font dialog port");