80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1 /* Functions for GUI implemented with (HI)Toolbox on the Mac OS.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2 Copyright (C) 2000, 2001, 2002, 2003, 2004,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5 This file is part of GNU Emacs.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
7 GNU Emacs is free software; you can redistribute it and/or modify
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
8 it under the terms of the GNU General Public License as published by
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
9 the Free Software Foundation; either version 3, or (at your option)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
10 any later version.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
11
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
12 GNU Emacs is distributed in the hope that it will be useful,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
15 GNU General Public License for more details.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
16
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
18 along with GNU Emacs; see the file COPYING. If not, write to
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
20 Boston, MA 02110-1301, USA. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
21
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
22 #include <config.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
23
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
24 #include <stdio.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
25
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
26 #include "lisp.h"
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
27 #include "blockinput.h"
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
28
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
29 #include "macterm.h"
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
30
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
31 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
32 #include <Quickdraw.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
33 #include <ToolUtils.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
34 #include <Sound.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
35 #include <Events.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
36 #include <Script.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
37 #include <Resources.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
38 #include <Fonts.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
39 #include <TextUtils.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
40 #include <LowMem.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
41 #include <Controls.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
42 #include <Windows.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
43 #include <Displays.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
44 #if defined (__MRC__) || (__MSL__ >= 0x6000)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
45 #include <ControlDefinitions.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
46 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
47
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
48 #if __profile__
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
49 #include <profiler.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
50 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
51 #endif /* not TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
52
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
53 #include "charset.h"
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
54 #include "coding.h"
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
55 #include "frame.h"
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
56 #include "dispextern.h"
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
57 #include "fontset.h"
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
58 #include "termhooks.h"
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
59 #include "buffer.h"
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
60 #include "window.h"
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
61 #include "keyboard.h"
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
62
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
63 #include <sys/param.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
64
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
65 #ifndef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
66 #include <alloca.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
67 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
68
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
69
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
70 /************************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
71 General
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
72 ************************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
73
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
74 /* The difference in pixels between the top left corner of the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
75 Emacs window (including possible window manager decorations)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
76 and FRAME_MAC_WINDOW (f). */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
77 #define FRAME_OUTER_TO_INNER_DIFF_X(f) ((f)->x_pixels_diff)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
78 #define FRAME_OUTER_TO_INNER_DIFF_Y(f) ((f)->y_pixels_diff)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
79
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
80 #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
81
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
82 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
83 mac_alert_sound_play ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
84 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
85 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
86 AlertSoundPlay ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
87 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
88 SysBeep (1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
89 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
90 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
91
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
92
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
93 /************************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
94 Application
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
95 ************************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
96
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
97 extern struct frame *mac_focus_frame P_ ((struct mac_display_info *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
98 extern void do_keystroke P_ ((EventKind, unsigned char, UInt32, UInt32,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
99 unsigned long, struct input_event *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
100 extern UInt32 mac_mapped_modifiers P_ ((UInt32, UInt32));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
101 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
102 extern int mac_to_emacs_modifiers P_ ((UInt32, UInt32));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
103 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
104 extern int mac_to_emacs_modifiers P_ ((EventModifiers, EventModifiers));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
105 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
106
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
107 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
108 /* Points to the variable `inev' in the function XTread_socket. It is
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
109 used for passing an input event to the function back from
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
110 Carbon/Apple event handlers. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
111 static struct input_event *read_socket_inev = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
112
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
113 extern const unsigned char keycode_to_xkeysym_table[];
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
114 extern EMACS_INT extra_keyboard_modifiers;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
115
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
116 extern Lisp_Object Qhi_command;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
117 #if USE_MAC_TSM
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
118 static TSMDocumentID tsm_document_id;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
119 extern Lisp_Object Qtext_input;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
120 extern Lisp_Object Qupdate_active_input_area, Qunicode_for_key_event;
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
121 extern Lisp_Object Vmac_ts_active_input_overlay, Vmac_ts_active_input_buf;
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
122 extern Lisp_Object Qbefore_string;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
123 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
124
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
125 static int mac_event_to_emacs_modifiers P_ ((EventRef));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
126 static OSStatus install_menu_target_item_handler P_ ((void));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
127 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
128 static OSStatus install_service_handler P_ ((void));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
129 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
130
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
131 extern OSStatus mac_store_event_ref_as_apple_event P_ ((AEEventClass, AEEventID,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
132 Lisp_Object,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
133 Lisp_Object,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
134 EventRef, UInt32,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
135 const EventParamName *,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
136 const EventParamType *));
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
137 extern int fast_find_position P_ ((struct window *, int, int *, int *,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
138 int *, int *, Lisp_Object));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
139 extern struct glyph *x_y_to_hpos_vpos P_ ((struct window *, int, int,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
140 int *, int *, int *, int *, int *));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
141 extern void mac_ax_selected_text_range P_ ((struct frame *, CFRange *));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
142 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
143 extern unsigned int mac_ax_number_of_characters P_ ((struct frame *));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
144 #endif
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
145
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
146 #if USE_MAC_TSM
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
147 extern OSStatus mac_restore_keyboard_input_source P_ ((void));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
148 extern void mac_save_keyboard_input_source P_ ((void));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
149
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
150 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
151 mac_tsm_resume ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
152 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
153 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
154
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
155 err = ActivateTSMDocument (tsm_document_id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
156 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
157 err = mac_restore_keyboard_input_source ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
158
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
159 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
160 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
161
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
162 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
163 mac_tsm_suspend ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
164 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
165 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
166
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
167 mac_save_keyboard_input_source ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
168 err = DeactivateTSMDocument (tsm_document_id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
169
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
170 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
171 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
172
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
173 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
174 init_tsm ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
175 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
176 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
177 static InterfaceTypeList types = {kUnicodeDocument};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
178 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
179 static InterfaceTypeList types = {kTextService};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
180 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
181
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
182 NewTSMDocument (sizeof (types) / sizeof (types[0]), types,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
183 &tsm_document_id, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
184 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
185 #endif /* USE_MAC_TSM */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
186
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
187 static pascal OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
188 mac_handle_keyboard_event (next_handler, event, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
189 EventHandlerCallRef next_handler;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
190 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
191 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
192 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
193 OSStatus err, result = eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
194 UInt32 event_kind, key_code, modifiers;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
195 unsigned char char_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
196
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
197 event_kind = GetEventKind (event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
198 switch (event_kind)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
199 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
200 case kEventRawKeyDown:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
201 case kEventRawKeyRepeat:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
202 case kEventRawKeyUp:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
203 /* When using Carbon Events, we need to pass raw keyboard events
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
204 to the TSM ourselves. If TSM handles it, it will pass back
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
205 noErr, otherwise it will pass back "eventNotHandledErr" and
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
206 we can process it normally. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
207 result = CallNextEventHandler (next_handler, event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
208 if (result != eventNotHandledErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
209 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
210
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
211 if (read_socket_inev == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
212 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
213
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
214 #if USE_MAC_TSM
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
215 if (read_socket_inev->kind != NO_EVENT)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
216 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
217 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
218 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
219 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
220 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
221
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
222 if (event_kind == kEventRawKeyUp)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
223 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
224
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
225 err = GetEventParameter (event, kEventParamKeyMacCharCodes,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
226 typeChar, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
227 sizeof (char), NULL, &char_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
228 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
229 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
230
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
231 err = GetEventParameter (event, kEventParamKeyCode,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
232 typeUInt32, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
233 sizeof (UInt32), NULL, &key_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
234 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
235 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
236
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
237 err = GetEventParameter (event, kEventParamKeyModifiers,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
238 typeUInt32, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
239 sizeof (UInt32), NULL, &modifiers);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
240 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
241 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
242
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
243 do_keystroke ((event_kind == kEventRawKeyDown ? keyDown : autoKey),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
244 char_code, key_code, modifiers,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
245 ((unsigned long)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
246 (GetEventTime (event) / kEventDurationMillisecond)),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
247 read_socket_inev);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
248 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
249 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
250
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
251 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
252 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
253 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
254
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
255 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
256 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
257
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
258 static pascal OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
259 mac_handle_command_event (next_handler, event, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
260 EventHandlerCallRef next_handler;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
261 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
262 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
263 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
264 OSStatus err, result = eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
265 HICommand command;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
266 static const EventParamName names[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
267 {kEventParamDirectObject, kEventParamKeyModifiers};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
268 static const EventParamType types[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
269 {typeHICommand, typeUInt32};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
270 int num_params = sizeof (names) / sizeof (names[0]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
271
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
272 err = GetEventParameter (event, kEventParamDirectObject, typeHICommand,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
273 NULL, sizeof (HICommand), NULL, &command);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
274 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
275 return eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
276
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
277 switch (GetEventKind (event))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
278 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
279 case kEventCommandProcess:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
280 result = CallNextEventHandler (next_handler, event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
281 if (result != eventNotHandledErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
282 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
283
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
284 err = GetEventParameter (event, kEventParamDirectObject,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
285 typeHICommand, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
286 sizeof (HICommand), NULL, &command);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
287
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
288 if (err != noErr || command.commandID == 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
289 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
290
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
291 /* A HI command event is mapped to an Apple event whose event
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
292 class symbol is `hi-command' and event ID is its command
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
293 ID. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
294 err = mac_store_event_ref_as_apple_event (0, command.commandID,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
295 Qhi_command, Qnil,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
296 event, num_params,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
297 names, types);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
298 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
299 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
300 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
301
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
302 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
303 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
304 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
305
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
306 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
307 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
308
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
309 static pascal OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
310 mac_handle_mouse_event (next_handler, event, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
311 EventHandlerCallRef next_handler;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
312 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
313 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
314 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
315 OSStatus err, result = eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
316
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
317 switch (GetEventKind (event))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
318 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
319 case kEventMouseWheelMoved:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
320 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
321 WindowRef wp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
322 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
323 EventMouseWheelAxis axis;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
324 SInt32 delta;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
325 Point point;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
326
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
327 result = CallNextEventHandler (next_handler, event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
328 if (result != eventNotHandledErr || read_socket_inev == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
329 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
330
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
331 f = mac_focus_frame (&one_mac_display_info);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
332
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
333 err = GetEventParameter (event, kEventParamWindowRef, typeWindowRef,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
334 NULL, sizeof (WindowRef), NULL, &wp);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
335 if (err != noErr
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
336 || wp != FRAME_MAC_WINDOW (f))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
337 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
338
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
339 err = GetEventParameter (event, kEventParamMouseWheelAxis,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
340 typeMouseWheelAxis, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
341 sizeof (EventMouseWheelAxis), NULL, &axis);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
342 if (err != noErr || axis != kEventMouseWheelAxisY)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
343 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
344
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
345 err = GetEventParameter (event, kEventParamMouseLocation,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
346 typeQDPoint, NULL, sizeof (Point),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
347 NULL, &point);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
348 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
349 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
350
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
351 point.h -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
352 point.v -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
353 if (point.h < 0 || point.v < 0
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
354 || EQ (window_from_coordinates (f, point.h, point.v, 0, 0, 0, 1),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
355 f->tool_bar_window))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
356 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
357
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
358 err = GetEventParameter (event, kEventParamMouseWheelDelta,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
359 typeSInt32, NULL, sizeof (SInt32),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
360 NULL, &delta);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
361 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
362 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
363
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
364 read_socket_inev->kind = WHEEL_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
365 read_socket_inev->code = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
366 read_socket_inev->modifiers =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
367 (mac_event_to_emacs_modifiers (event)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
368 | ((delta < 0) ? down_modifier : up_modifier));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
369 XSETINT (read_socket_inev->x, point.h);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
370 XSETINT (read_socket_inev->y, point.v);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
371 XSETFRAME (read_socket_inev->frame_or_window, f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
372
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
373 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
374 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
375 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
376
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
377 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
378 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
379 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
380
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
381 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
382 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
383
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
384 #if USE_MAC_TSM
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
385 extern void mac_get_selected_range P_ ((struct window *, CFRange *));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
386 extern int mac_store_buffer_text_to_unicode_chars P_ ((struct buffer *,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
387 int, int, UniChar *));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
388
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
389 static pascal OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
390 mac_handle_text_input_event (next_handler, event, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
391 EventHandlerCallRef next_handler;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
392 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
393 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
394 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
395 OSStatus err, result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
396 Lisp_Object id_key = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
397 int num_params;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
398 const EventParamName *names;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
399 const EventParamType *types;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
400 static UInt32 seqno_uaia = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
401 static const EventParamName names_uaia[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
402 {kEventParamTextInputSendComponentInstance,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
403 kEventParamTextInputSendRefCon,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
404 kEventParamTextInputSendSLRec,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
405 kEventParamTextInputSendFixLen,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
406 kEventParamTextInputSendText,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
407 kEventParamTextInputSendUpdateRng,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
408 kEventParamTextInputSendHiliteRng,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
409 kEventParamTextInputSendClauseRng,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
410 kEventParamTextInputSendPinRng,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
411 kEventParamTextInputSendTextServiceEncoding,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
412 kEventParamTextInputSendTextServiceMacEncoding,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
413 EVENT_PARAM_TEXT_INPUT_SEQUENCE_NUMBER};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
414 static const EventParamType types_uaia[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
415 {typeComponentInstance,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
416 typeLongInteger,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
417 typeIntlWritingCode,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
418 typeLongInteger,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
419 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
420 typeUnicodeText,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
421 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
422 typeChar,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
423 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
424 typeTextRangeArray,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
425 typeTextRangeArray,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
426 typeOffsetArray,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
427 typeTextRange,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
428 typeUInt32,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
429 typeUInt32,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
430 typeUInt32};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
431 static const EventParamName names_ufke[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
432 {kEventParamTextInputSendComponentInstance,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
433 kEventParamTextInputSendRefCon,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
434 kEventParamTextInputSendSLRec,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
435 kEventParamTextInputSendText};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
436 static const EventParamType types_ufke[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
437 {typeComponentInstance,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
438 typeLongInteger,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
439 typeIntlWritingCode,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
440 typeUnicodeText};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
441
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
442 result = CallNextEventHandler (next_handler, event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
443 if (result != eventNotHandledErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
444 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
445
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
446 switch (GetEventKind (event))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
447 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
448 case kEventTextInputUpdateActiveInputArea:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
449 id_key = Qupdate_active_input_area;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
450 num_params = sizeof (names_uaia) / sizeof (names_uaia[0]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
451 names = names_uaia;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
452 types = types_uaia;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
453 SetEventParameter (event, EVENT_PARAM_TEXT_INPUT_SEQUENCE_NUMBER,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
454 typeUInt32, sizeof (UInt32), &seqno_uaia);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
455 seqno_uaia++;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
456 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
457 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
458
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
459 case kEventTextInputUnicodeForKeyEvent:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
460 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
461 EventRef kbd_event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
462 UInt32 actual_size, modifiers, key_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
463
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
464 err = GetEventParameter (event, kEventParamTextInputSendKeyboardEvent,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
465 typeEventRef, NULL, sizeof (EventRef), NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
466 &kbd_event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
467 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
468 err = GetEventParameter (kbd_event, kEventParamKeyModifiers,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
469 typeUInt32, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
470 sizeof (UInt32), NULL, &modifiers);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
471 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
472 err = GetEventParameter (kbd_event, kEventParamKeyCode,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
473 typeUInt32, NULL, sizeof (UInt32),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
474 NULL, &key_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
475 if (err == noErr && mac_mapped_modifiers (modifiers, key_code))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
476 /* There're mapped modifier keys. Process it in
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
477 do_keystroke. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
478 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
479 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
480 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
481 typeUnicodeText, NULL, 0, &actual_size,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
482 NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
483 if (err == noErr && actual_size == sizeof (UniChar))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
484 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
485 UniChar code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
486
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
487 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
488 typeUnicodeText, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
489 sizeof (UniChar), NULL, &code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
490 if (err == noErr && code < 0x80)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
491 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
492 /* ASCII character. Process it in do_keystroke. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
493 if (read_socket_inev && code >= 0x20 && code <= 0x7e
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
494 && !(key_code <= 0x7f
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
495 && keycode_to_xkeysym_table [key_code]))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
496 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
497 struct frame *f = mac_focus_frame (&one_mac_display_info);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
498
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
499 read_socket_inev->kind = ASCII_KEYSTROKE_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
500 read_socket_inev->code = code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
501 read_socket_inev->modifiers =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
502 mac_to_emacs_modifiers (modifiers, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
503 read_socket_inev->modifiers |=
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
504 (extra_keyboard_modifiers
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
505 & (meta_modifier | alt_modifier
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
506 | hyper_modifier | super_modifier));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
507 XSETFRAME (read_socket_inev->frame_or_window, f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
508 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
509 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
510 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
511 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
512 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
513 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
514 /* Non-ASCII keystrokes without mapped modifiers are
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
515 processed at the Lisp level. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
516 id_key = Qunicode_for_key_event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
517 num_params = sizeof (names_ufke) / sizeof (names_ufke[0]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
518 names = names_ufke;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
519 types = types_ufke;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
520 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
521 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
522 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
523 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
524
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
525 case kEventTextInputOffsetToPos:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
526 {
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
527 long byte_offset;
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
528 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
529 struct window *w;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
530 Point p;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
531
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
532 err = GetEventParameter (event, kEventParamTextInputSendTextOffset,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
533 typeLongInteger, NULL, sizeof (long), NULL,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
534 &byte_offset);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
535 if (err != noErr)
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
536 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
537
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
538 if (STRINGP (Vmac_ts_active_input_buf)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
539 && SBYTES (Vmac_ts_active_input_buf) != 0)
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
540 {
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
541 if (!OVERLAYP (Vmac_ts_active_input_overlay))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
542 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
543
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
544 /* Strictly speaking, this is not always correct because
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
545 previous events may change some states about display. */
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
546 if (!NILP (Foverlay_get (Vmac_ts_active_input_overlay, Qbefore_string)))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
547 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
548 /* Active input area is displayed around the current point. */
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
549 f = SELECTED_FRAME ();
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
550 w = XWINDOW (f->selected_window);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
551 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
552 else if (WINDOWP (echo_area_window))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
553 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
554 /* Active input area is displayed in the echo area. */
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
555 w = XWINDOW (echo_area_window);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
556 f = WINDOW_XFRAME (w);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
557 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
558 else
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
559 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
560
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
561 p.h = (WINDOW_TO_FRAME_PIXEL_X (w, w->cursor.x)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
562 + WINDOW_LEFT_FRINGE_WIDTH (w)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
563 + f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
564 p.v = (WINDOW_TO_FRAME_PIXEL_Y (w, w->cursor.y)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
565 + FONT_BASE (FRAME_FONT (f))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
566 + f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f));
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
567 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
568 else
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
569 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
570 #ifndef MAC_OSX
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
571 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
572 #else /* MAC_OSX */
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
573 CFRange sel_range;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
574 int charpos;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
575 int hpos, vpos, x, y;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
576 struct glyph_row *row;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
577 struct glyph *glyph;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
578 XFontStruct *font;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
579
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
580 f = mac_focus_frame (&one_mac_display_info);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
581 w = XWINDOW (f->selected_window);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
582 mac_get_selected_range (w, &sel_range);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
583 charpos = (BUF_BEGV (XBUFFER (w->buffer)) + sel_range.location
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
584 + byte_offset / (long) sizeof (UniChar));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
585
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
586 if (!fast_find_position (w, charpos, &hpos, &vpos, &x, &y, Qnil))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
587 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
588 result = errOffsetInvalid;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
589 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
590 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
591
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
592 row = MATRIX_ROW (w->current_matrix, vpos);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
593 glyph = row->glyphs[TEXT_AREA] + hpos;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
594 if (glyph->type != CHAR_GLYPH || glyph->glyph_not_available_p)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
595 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
596
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
597 p.h = (WINDOW_TEXT_TO_FRAME_PIXEL_X (w, x)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
598 + f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
599 p.v = (WINDOW_TO_FRAME_PIXEL_Y (w, y)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
600 + row->visible_height
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
601 + f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
602
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
603 font = FACE_FROM_ID (f, glyph->face_id)->font;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
604 if (font)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
605 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
606 Fixed point_size = Long2Fix (font->mac_fontsize);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
607 short height = row->visible_height;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
608 short ascent = row->ascent;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
609
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
610 SetEventParameter (event,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
611 kEventParamTextInputReplyPointSize,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
612 typeFixed, sizeof (Fixed), &point_size);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
613 SetEventParameter (event,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
614 kEventParamTextInputReplyLineHeight,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
615 typeShortInteger, sizeof (short), &height);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
616 SetEventParameter (event,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
617 kEventParamTextInputReplyLineAscent,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
618 typeShortInteger, sizeof (short), &ascent);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
619 if (font->mac_fontnum != -1)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
620 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
621 OSStatus err1;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
622 FMFont fm_font;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
623 FMFontStyle style;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
624
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
625 err1 = FMGetFontFromFontFamilyInstance (font->mac_fontnum,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
626 font->mac_fontface,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
627 &fm_font, &style);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
628 if (err1 == noErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
629 SetEventParameter (event, kEventParamTextInputReplyFMFont,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
630 typeUInt32, sizeof (UInt32), &fm_font);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
631 else
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
632 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
633 long qd_font = font->mac_fontnum;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
634
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
635 SetEventParameter (event, kEventParamTextInputReplyFont,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
636 typeLongInteger, sizeof (long),
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
637 &qd_font);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
638 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
639 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
640 else if (font->mac_style)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
641 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
642 OSStatus err1;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
643 ATSUFontID font_id;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
644
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
645 err1 = ATSUGetAttribute (font->mac_style, kATSUFontTag,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
646 sizeof (ATSUFontID), &font_id,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
647 NULL);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
648 if (err1 == noErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
649 SetEventParameter (event, kEventParamTextInputReplyFMFont,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
650 typeUInt32, sizeof (UInt32), &font_id);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
651 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
652 else
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
653 abort ();
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
654 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
655 #endif /* MAC_OSX */
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
656 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
657
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
658 err = SetEventParameter (event, kEventParamTextInputReplyPoint,
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
659 typeQDPoint, sizeof (Point), &p);
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
660 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
661 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
662 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
663 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
664
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
665 #ifdef MAC_OSX
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
666 case kEventTextInputPosToOffset:
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
667 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
668 Point point;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
669 Boolean leading_edge_p = true;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
670 struct frame *f;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
671 int x, y;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
672 Lisp_Object window;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
673 enum window_part part;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
674 long region_class = kTSMOutsideOfBody, byte_offset = 0;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
675
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
676 err = GetEventParameter (event, kEventParamTextInputSendCurrentPoint,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
677 typeQDPoint, NULL, sizeof (Point), NULL,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
678 &point);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
679 if (err != noErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
680 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
681
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
682 GetEventParameter (event, kEventParamTextInputReplyLeadingEdge,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
683 typeBoolean, NULL, sizeof (Boolean), NULL,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
684 &leading_edge_p);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
685
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
686 f = mac_focus_frame (&one_mac_display_info);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
687 x = point.h - (f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
688 y = point.v - (f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
689 window = window_from_coordinates (f, x, y, &part, 0, 0, 1);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
690 if (WINDOWP (window) && EQ (window, f->selected_window))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
691 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
692 struct window *w;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
693 struct buffer *b;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
694
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
695 /* Convert to window-relative pixel coordinates. */
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
696 w = XWINDOW (window);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
697 frame_to_window_pixel_xy (w, &x, &y);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
698
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
699 /* Are we in a window whose display is up to date?
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
700 And verify the buffer's text has not changed. */
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
701 b = XBUFFER (w->buffer);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
702 if (part == ON_TEXT
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
703 && EQ (w->window_end_valid, w->buffer)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
704 && XINT (w->last_modified) == BUF_MODIFF (b)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
705 && XINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
706 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
707 int hpos, vpos, area;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
708 struct glyph *glyph;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
709
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
710 /* Find the glyph under X/Y. */
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
711 glyph = x_y_to_hpos_vpos (w, x, y, &hpos, &vpos, 0, 0, &area);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
712
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
713 if (glyph != NULL && area == TEXT_AREA)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
714 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
715 byte_offset = ((glyph->charpos - BUF_BEGV (b))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
716 * sizeof (UniChar));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
717 region_class = kTSMInsideOfBody;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
718 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
719 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
720 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
721
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
722 err = SetEventParameter (event, kEventParamTextInputReplyRegionClass,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
723 typeLongInteger, sizeof (long),
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
724 ®ion_class);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
725 if (err == noErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
726 err = SetEventParameter (event, kEventParamTextInputReplyTextOffset,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
727 typeLongInteger, sizeof (long),
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
728 &byte_offset);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
729 if (err == noErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
730 result = noErr;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
731 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
732 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
733
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
734 case kEventTextInputGetSelectedText:
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
735 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
736 struct frame *f = mac_focus_frame (&one_mac_display_info);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
737 struct window *w = XWINDOW (f->selected_window);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
738 struct buffer *b = XBUFFER (w->buffer);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
739 CFRange sel_range;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
740 int start, end;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
741 UniChar *characters, c;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
742
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
743 if (poll_suppress_count == 0 && !NILP (Vinhibit_quit))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
744 /* Don't try to get buffer contents as the gap might be
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
745 being altered. */
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
746 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
747
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
748 mac_get_selected_range (w, &sel_range);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
749 if (sel_range.length == 0)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
750 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
751 Boolean leading_edge_p;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
752
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
753 err = GetEventParameter (event,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
754 kEventParamTextInputReplyLeadingEdge,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
755 typeBoolean, NULL, sizeof (Boolean), NULL,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
756 &leading_edge_p);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
757 if (err != noErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
758 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
759
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
760 start = BUF_BEGV (b) + sel_range.location;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
761 if (!leading_edge_p)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
762 start--;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
763 end = start + 1;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
764 characters = &c;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
765
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
766 if (start < BUF_BEGV (b) || end > BUF_ZV (b))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
767 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
768 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
769 else
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
770 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
771 start = BUF_BEGV (b) + sel_range.location;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
772 end = start + sel_range.length;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
773 characters = xmalloc (sel_range.length * sizeof (UniChar));
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
774 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
775
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
776 if (mac_store_buffer_text_to_unicode_chars (b, start, end, characters))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
777 err = SetEventParameter (event, kEventParamTextInputReplyText,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
778 typeUnicodeText,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
779 sel_range.length * sizeof (UniChar),
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
780 characters);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
781 if (characters != &c)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
782 xfree (characters);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
783
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
784 if (err == noErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
785 result = noErr;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
786 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
787 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
788 #endif /* MAC_OSX */
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
789
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
790 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
791 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
792 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
793
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
794 if (!NILP (id_key))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
795 err = mac_store_event_ref_as_apple_event (0, 0, Qtext_input, id_key,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
796 event, num_params,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
797 names, types);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
798 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
799 }
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
800
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
801 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
802 static pascal OSStatus
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
803 mac_handle_document_access_event (next_handler, event, data)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
804 EventHandlerCallRef next_handler;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
805 EventRef event;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
806 void *data;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
807 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
808 OSStatus err, result;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
809 struct frame *f = mac_focus_frame (&one_mac_display_info);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
810
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
811 result = CallNextEventHandler (next_handler, event);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
812 if (result != eventNotHandledErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
813 return result;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
814
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
815 switch (GetEventKind (event))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
816 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
817 case kEventTSMDocumentAccessGetLength:
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
818 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
819 CFIndex count = mac_ax_number_of_characters (f);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
820
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
821 err = SetEventParameter (event, kEventParamTSMDocAccessCharacterCount,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
822 typeCFIndex, sizeof (CFIndex), &count);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
823 if (err == noErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
824 result = noErr;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
825 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
826 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
827
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
828 case kEventTSMDocumentAccessGetSelectedRange:
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
829 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
830 CFRange sel_range;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
831
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
832 mac_ax_selected_text_range (f, &sel_range);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
833 err = SetEventParameter (event,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
834 kEventParamTSMDocAccessReplyCharacterRange,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
835 typeCFRange, sizeof (CFRange), &sel_range);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
836 if (err == noErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
837 result = noErr;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
838 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
839 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
840
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
841 case kEventTSMDocumentAccessGetCharacters:
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
842 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
843 struct buffer *b = XBUFFER (XWINDOW (f->selected_window)->buffer);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
844 CFRange range;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
845 Ptr characters;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
846 int start, end;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
847
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
848 if (poll_suppress_count == 0 && !NILP (Vinhibit_quit))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
849 /* Don't try to get buffer contents as the gap might be
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
850 being altered. */
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
851 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
852
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
853 err = GetEventParameter (event,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
854 kEventParamTSMDocAccessSendCharacterRange,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
855 typeCFRange, NULL, sizeof (CFRange), NULL,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
856 &range);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
857 if (err == noErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
858 err = GetEventParameter (event,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
859 kEventParamTSMDocAccessSendCharactersPtr,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
860 typePtr, NULL, sizeof (Ptr), NULL,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
861 &characters);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
862 if (err != noErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
863 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
864
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
865 start = BUF_BEGV (b) + range.location;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
866 end = start + range.length;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
867 if (mac_store_buffer_text_to_unicode_chars (b, start, end,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
868 (UniChar *) characters))
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
869 result = noErr;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
870 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
871 break;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
872
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
873 default:
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
874 abort ();
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
875 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
876
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
877 return result;
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
878 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
879 #endif
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
880 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
881
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
882 OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
883 install_application_handler ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
884 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
885 OSStatus err = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
886
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
887 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
888 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
889 static const EventTypeSpec specs[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
890 {{kEventClassKeyboard, kEventRawKeyDown},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
891 {kEventClassKeyboard, kEventRawKeyRepeat},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
892 {kEventClassKeyboard, kEventRawKeyUp}};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
893
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
894 err = InstallApplicationEventHandler (NewEventHandlerUPP
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
895 (mac_handle_keyboard_event),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
896 GetEventTypeCount (specs),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
897 specs, NULL, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
898 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
899
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
900 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
901 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
902 static const EventTypeSpec specs[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
903 {{kEventClassCommand, kEventCommandProcess}};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
904
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
905 err = InstallApplicationEventHandler (NewEventHandlerUPP
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
906 (mac_handle_command_event),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
907 GetEventTypeCount (specs),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
908 specs, NULL, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
909 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
910
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
911 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
912 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
913 static const EventTypeSpec specs[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
914 {{kEventClassMouse, kEventMouseWheelMoved}};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
915
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
916 err = InstallApplicationEventHandler (NewEventHandlerUPP
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
917 (mac_handle_mouse_event),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
918 GetEventTypeCount (specs),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
919 specs, NULL, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
920 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
921
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
922 #if USE_MAC_TSM
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
923 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
924 {
|
80517
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
925 static const EventTypeSpec specs[] =
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
926 {{kEventClassTextInput, kEventTextInputUpdateActiveInputArea},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
927 {kEventClassTextInput, kEventTextInputUnicodeForKeyEvent},
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
928 {kEventClassTextInput, kEventTextInputOffsetToPos},
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
929 #ifdef MAC_OSX
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
930 {kEventClassTextInput, kEventTextInputPosToOffset},
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
931 {kEventClassTextInput, kEventTextInputGetSelectedText}
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
932 #endif
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
933 };
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
934
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
935 err = InstallApplicationEventHandler (NewEventHandlerUPP
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
936 (mac_handle_text_input_event),
|
80517
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
937 GetEventTypeCount (specs),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
938 specs, NULL, NULL);
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
939 }
|
80520
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
940
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
941 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
942 if (err == noErr)
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
943 {
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
944 static const EventTypeSpec specs[] =
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
945 {{kEventClassTSMDocumentAccess, kEventTSMDocumentAccessGetLength},
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
946 {kEventClassTSMDocumentAccess, kEventTSMDocumentAccessGetSelectedRange},
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
947 {kEventClassTSMDocumentAccess, kEventTSMDocumentAccessGetCharacters}};
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
948
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
949 err = InstallApplicationEventHandler (mac_handle_document_access_event,
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
950 GetEventTypeCount (specs),
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
951 specs, NULL, NULL);
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
952 }
|
aaff809b3a06
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
953 #endif
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
954 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
955
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
956 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
957 err = install_menu_target_item_handler ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
958
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
959 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
960 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
961 err = install_service_handler ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
962 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
963
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
964 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
965 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
966 #endif /* TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
967
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
968
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
969 /************************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
970 Windows
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
971 ************************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
972
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
973 #define DEFAULT_NUM_COLS 80
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
974
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
975 #define MIN_DOC_SIZE 64
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
976 #define MAX_DOC_SIZE 32767
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
977
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
978 /* Drag and Drop */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
979 static OSErr install_drag_handler P_ ((WindowRef));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
980 static void remove_drag_handler P_ ((WindowRef));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
981
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
982 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
983 static void mac_prepare_for_quickdraw P_ ((struct frame *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
984 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
985
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
986 extern void mac_handle_visibility_change P_ ((struct frame *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
987 extern void mac_handle_origin_change P_ ((struct frame *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
988 extern void mac_handle_size_change P_ ((struct frame *, int, int));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
989
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
990 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
991 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
992 extern Lisp_Object Qwindow;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
993 extern Lisp_Object Qtoolbar_switch_mode;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
994 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
995 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
996
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
997 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
998 do_window_update (WindowRef win)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
999 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1000 struct frame *f = mac_window_to_frame (win);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1001
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1002 BeginUpdate (win);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1003
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1004 /* The tooltip has been drawn already. Avoid the SET_FRAME_GARBAGED
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1005 below. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1006 if (win != tip_window)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1007 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1008 if (f->async_visible == 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1009 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1010 /* Update events may occur when a frame gets iconified. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1011 #if 0
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1012 f->async_visible = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1013 f->async_iconified = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1014 SET_FRAME_GARBAGED (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1015 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1016 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1017 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1018 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1019 Rect r;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1020 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1021 RgnHandle region = NewRgn ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1022
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1023 GetPortVisibleRegion (GetWindowPort (win), region);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1024 GetRegionBounds (region, &r);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1025 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1026 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1027 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1028 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1029 UpdateControls (win, region);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1030 DisposeRgn (region);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1031 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1032 r = (*win->visRgn)->rgnBBox;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1033 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1034 UpdateControls (win, win->visRgn);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1035 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1036 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1037 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1038
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1039 EndUpdate (win);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1040 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1041
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1042 static int
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1043 is_emacs_window (WindowRef win)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1044 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1045 Lisp_Object tail, frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1046
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1047 if (!win)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1048 return 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1049
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1050 FOR_EACH_FRAME (tail, frame)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1051 if (FRAME_MAC_P (XFRAME (frame)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1052 if (FRAME_MAC_WINDOW (XFRAME (frame)) == win)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1053 return 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1054
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1055 return 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1056 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1057
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1058 /* Handle drags in size box. Based on code contributed by Ben
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1059 Mesander and IM - Window Manager A. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1060
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1061 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1062 do_grow_window (w, e)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1063 WindowRef w;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1064 const EventRecord *e;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1065 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1066 Rect limit_rect;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1067 int rows, columns, width, height;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1068 struct frame *f = mac_window_to_frame (w);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1069 XSizeHints *size_hints = FRAME_SIZE_HINTS (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1070 int min_width = MIN_DOC_SIZE, min_height = MIN_DOC_SIZE;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1071 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1072 Rect new_rect;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1073 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1074 long grow_size;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1075 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1076
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1077 if (size_hints->flags & PMinSize)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1078 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1079 min_width = size_hints->min_width;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1080 min_height = size_hints->min_height;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1081 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1082 SetRect (&limit_rect, min_width, min_height, MAX_DOC_SIZE, MAX_DOC_SIZE);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1083
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1084 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1085 if (!ResizeWindow (w, e->where, &limit_rect, &new_rect))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1086 return;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1087 height = new_rect.bottom - new_rect.top;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1088 width = new_rect.right - new_rect.left;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1089 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1090 grow_size = GrowWindow (w, e->where, &limit_rect);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1091 /* see if it really changed size */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1092 if (grow_size == 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1093 return;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1094 height = HiWord (grow_size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1095 width = LoWord (grow_size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1096 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1097
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1098 if (width != FRAME_PIXEL_WIDTH (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1099 || height != FRAME_PIXEL_HEIGHT (f))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1100 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1101 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1102 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1103
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1104 x_set_window_size (f, 0, columns, rows);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1105 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1106 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1107
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1108 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1109 static Point
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1110 mac_get_ideal_size (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1111 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1112 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1113 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1114 WindowRef w = FRAME_MAC_WINDOW (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1115 Point ideal_size;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1116 Rect standard_rect;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1117 int height, width, columns, rows;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1118
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1119 ideal_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1120 ideal_size.v = dpyinfo->height;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1121 IsWindowInStandardState (w, &ideal_size, &standard_rect);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1122 /* Adjust the standard size according to character boundaries. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1123 width = standard_rect.right - standard_rect.left;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1124 height = standard_rect.bottom - standard_rect.top;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1125 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1126 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1127 ideal_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, columns);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1128 ideal_size.v = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1129
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1130 return ideal_size;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1131 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1132
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1133 static pascal OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1134 mac_handle_window_event (next_handler, event, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1135 EventHandlerCallRef next_handler;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1136 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1137 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1138 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1139 WindowRef wp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1140 OSStatus err, result = eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1141 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1142 UInt32 attributes;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1143 XSizeHints *size_hints;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1144
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1145 err = GetEventParameter (event, kEventParamDirectObject, typeWindowRef,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1146 NULL, sizeof (WindowRef), NULL, &wp);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1147 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1148 return eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1149
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1150 f = mac_window_to_frame (wp);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1151 switch (GetEventKind (event))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1152 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1153 /* -- window refresh events -- */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1154
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1155 case kEventWindowUpdate:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1156 result = CallNextEventHandler (next_handler, event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1157 if (result != eventNotHandledErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1158 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1159
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1160 do_window_update (wp);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1161 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1162 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1163
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1164 /* -- window state change events -- */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1165
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1166 case kEventWindowShowing:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1167 size_hints = FRAME_SIZE_HINTS (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1168 if (!(size_hints->flags & (USPosition | PPosition)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1169 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1170 struct frame *sf = SELECTED_FRAME ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1171
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1172 if (!(FRAME_MAC_P (sf) && sf->async_visible))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1173 RepositionWindow (wp, NULL, kWindowCenterOnMainScreen);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1174 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1175 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1176 RepositionWindow (wp, FRAME_MAC_WINDOW (sf),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1177 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1178 kWindowCascadeStartAtParentWindowScreen
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1179 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1180 kWindowCascadeOnParentWindowScreen
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1181 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1182 );
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1183 #if USE_MAC_TOOLBAR
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1184 /* This is a workaround. RepositionWindow fails to put
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1185 a window at the cascading position when its parent
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1186 window has a Carbon HIToolbar. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1187 if ((f->left_pos == sf->left_pos
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1188 && f->top_pos == sf->top_pos)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1189 || (f->left_pos == sf->left_pos + 10 * 2
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1190 && f->top_pos == sf->top_pos + 32 * 2))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1191 MoveWindowStructure (wp, sf->left_pos + 10, sf->top_pos + 32);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1192 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1193 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1194 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1195 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1196 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1197
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1198 case kEventWindowHiding:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1199 /* Before unmapping the window, update the WM_SIZE_HINTS
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1200 property to claim that the current position of the window is
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1201 user-specified, rather than program-specified, so that when
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1202 the window is mapped again, it will be placed at the same
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1203 location, without forcing the user to position it by hand
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1204 again (they have already done that once for this window.) */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1205 x_wm_set_size_hint (f, (long) 0, 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1206 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1207 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1208
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1209 case kEventWindowShown:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1210 case kEventWindowHidden:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1211 case kEventWindowCollapsed:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1212 case kEventWindowExpanded:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1213 mac_handle_visibility_change (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1214 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1215 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1216
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1217 case kEventWindowBoundsChanging:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1218 result = CallNextEventHandler (next_handler, event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1219 if (result != eventNotHandledErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1220 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1221
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1222 err = GetEventParameter (event, kEventParamAttributes, typeUInt32,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1223 NULL, sizeof (UInt32), NULL, &attributes);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1224 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1225 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1226
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1227 size_hints = FRAME_SIZE_HINTS (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1228 if ((attributes & kWindowBoundsChangeUserResize)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1229 && ((size_hints->flags & (PResizeInc | PBaseSize | PMinSize))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1230 == (PResizeInc | PBaseSize | PMinSize)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1231 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1232 Rect bounds;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1233 int width, height;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1234
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1235 err = GetEventParameter (event, kEventParamCurrentBounds,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1236 typeQDRectangle, NULL, sizeof (Rect),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1237 NULL, &bounds);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1238 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1239 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1240
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1241 width = bounds.right - bounds.left;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1242 height = bounds.bottom - bounds.top;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1243
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1244 if (width < size_hints->min_width)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1245 width = size_hints->min_width;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1246 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1247 width = size_hints->base_width
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1248 + (int) ((width - size_hints->base_width)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1249 / (float) size_hints->width_inc + .5)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1250 * size_hints->width_inc;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1251
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1252 if (height < size_hints->min_height)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1253 height = size_hints->min_height;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1254 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1255 height = size_hints->base_height
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1256 + (int) ((height - size_hints->base_height)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1257 / (float) size_hints->height_inc + .5)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1258 * size_hints->height_inc;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1259
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1260 bounds.right = bounds.left + width;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1261 bounds.bottom = bounds.top + height;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1262 SetEventParameter (event, kEventParamCurrentBounds,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1263 typeQDRectangle, sizeof (Rect), &bounds);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1264 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1265 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1266 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1267
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1268 case kEventWindowBoundsChanged:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1269 err = GetEventParameter (event, kEventParamAttributes, typeUInt32,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1270 NULL, sizeof (UInt32), NULL, &attributes);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1271 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1272 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1273
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1274 if (attributes & kWindowBoundsChangeSizeChanged)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1275 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1276 Rect bounds;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1277
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1278 err = GetEventParameter (event, kEventParamCurrentBounds,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1279 typeQDRectangle, NULL, sizeof (Rect),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1280 NULL, &bounds);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1281 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1282 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1283 int width, height;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1284
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1285 width = bounds.right - bounds.left;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1286 height = bounds.bottom - bounds.top;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1287 mac_handle_size_change (f, width, height);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1288 mac_wakeup_from_rne ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1289 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1290 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1291
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1292 if (attributes & kWindowBoundsChangeOriginChanged)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1293 mac_handle_origin_change (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1294
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1295 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1296 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1297
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1298 /* -- window action events -- */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1299
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1300 case kEventWindowClose:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1301 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1302 struct input_event buf;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1303
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1304 EVENT_INIT (buf);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1305 buf.kind = DELETE_WINDOW_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1306 XSETFRAME (buf.frame_or_window, f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1307 buf.arg = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1308 kbd_buffer_store_event (&buf);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1309 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1310 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1311 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1312
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1313 case kEventWindowGetIdealSize:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1314 result = CallNextEventHandler (next_handler, event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1315 if (result != eventNotHandledErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1316 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1317
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1318 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1319 Point ideal_size = mac_get_ideal_size (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1320
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1321 err = SetEventParameter (event, kEventParamDimensions,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1322 typeQDPoint, sizeof (Point), &ideal_size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1323 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1324 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1325 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1326 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1327
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1328 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1329 case kEventWindowToolbarSwitchMode:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1330 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1331 static const EventParamName names[] = {kEventParamDirectObject,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1332 kEventParamWindowMouseLocation,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1333 kEventParamKeyModifiers,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1334 kEventParamMouseButton,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1335 kEventParamClickCount,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1336 kEventParamMouseChord};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1337 static const EventParamType types[] = {typeWindowRef,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1338 typeQDPoint,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1339 typeUInt32,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1340 typeMouseButton,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1341 typeUInt32,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1342 typeUInt32};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1343 int num_params = sizeof (names) / sizeof (names[0]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1344
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1345 err = mac_store_event_ref_as_apple_event (0, 0,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1346 Qwindow,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1347 Qtoolbar_switch_mode,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1348 event, num_params,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1349 names, types);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1350 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1351 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1352 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1353 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1354 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1355
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1356 #if USE_MAC_TSM
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1357 /* -- window focus events -- */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1358
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1359 case kEventWindowFocusAcquired:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1360 err = mac_tsm_resume ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1361 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1362 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1363 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1364
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1365 case kEventWindowFocusRelinquish:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1366 err = mac_tsm_suspend ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1367 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1368 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1369 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1370 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1371
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1372 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1373 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1374 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1375
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1376 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1377 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1378 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1379
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1380 /* Handle clicks in zoom box. Calculation of "standard state" based
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1381 on code in IM - Window Manager A and code contributed by Ben
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1382 Mesander. The standard state of an Emacs window is 80-characters
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1383 wide (DEFAULT_NUM_COLS) and as tall as will fit on the screen. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1384
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1385 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1386 do_zoom_window (WindowRef w, int zoom_in_or_out)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1387 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1388 Rect zoom_rect, port_rect;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1389 int width, height;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1390 struct frame *f = mac_window_to_frame (w);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1391 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1392 Point ideal_size = mac_get_ideal_size (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1393
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1394 GetWindowBounds (w, kWindowContentRgn, &port_rect);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1395 if (IsWindowInStandardState (w, &ideal_size, &zoom_rect)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1396 && port_rect.left == zoom_rect.left
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1397 && port_rect.top == zoom_rect.top)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1398 zoom_in_or_out = inZoomIn;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1399 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1400 zoom_in_or_out = inZoomOut;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1401
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1402 #ifdef MAC_OS8
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1403 mac_clear_area (f, 0, 0, port_rect.right - port_rect.left,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1404 port_rect.bottom - port_rect.top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1405 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1406 ZoomWindowIdeal (w, zoom_in_or_out, &ideal_size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1407 #else /* not TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1408 GrafPtr save_port;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1409 Point top_left;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1410 int w_title_height, rows;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1411 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1412
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1413 GetPort (&save_port);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1414
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1415 SetPortWindowPort (w);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1416
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1417 /* Clear window to avoid flicker. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1418 EraseRect (&(w->portRect));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1419 if (zoom_in_or_out == inZoomOut)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1420 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1421 SetPt (&top_left, w->portRect.left, w->portRect.top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1422 LocalToGlobal (&top_left);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1423
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1424 /* calculate height of window's title bar */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1425 w_title_height = top_left.v - 1
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1426 - (**((WindowPeek) w)->strucRgn).rgnBBox.top + GetMBarHeight ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1427
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1428 /* get maximum height of window into zoom_rect.bottom - zoom_rect.top */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1429 zoom_rect = qd.screenBits.bounds;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1430 zoom_rect.top += w_title_height;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1431 InsetRect (&zoom_rect, 8, 4); /* not too tight */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1432
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1433 zoom_rect.right = zoom_rect.left
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1434 + FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1435
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1436 /* Adjust the standard size according to character boundaries. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1437 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, zoom_rect.bottom - zoom_rect.top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1438 zoom_rect.bottom =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1439 zoom_rect.top + FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1440
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1441 (**((WStateDataHandle) ((WindowPeek) w)->dataHandle)).stdState
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1442 = zoom_rect;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1443 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1444
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1445 ZoomWindow (w, zoom_in_or_out, f == mac_focus_frame (dpyinfo));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1446
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1447 SetPort (save_port);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1448 #endif /* not TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1449
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1450 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1451 /* retrieve window size and update application values */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1452 port_rect = w->portRect;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1453 height = port_rect.bottom - port_rect.top;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1454 width = port_rect.right - port_rect.left;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1455
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1456 mac_handle_size_change (f, width, height);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1457 mac_handle_origin_change (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1458 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1459 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1460
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1461 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1462 install_window_handler (window)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1463 WindowRef window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1464 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1465 OSStatus err = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1466
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1467 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1468 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1469 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1470 static const EventTypeSpec specs[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1471 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1472 /* -- window refresh events -- */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1473 {kEventClassWindow, kEventWindowUpdate},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1474 /* -- window state change events -- */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1475 {kEventClassWindow, kEventWindowShowing},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1476 {kEventClassWindow, kEventWindowHiding},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1477 {kEventClassWindow, kEventWindowShown},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1478 {kEventClassWindow, kEventWindowHidden},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1479 {kEventClassWindow, kEventWindowCollapsed},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1480 {kEventClassWindow, kEventWindowExpanded},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1481 {kEventClassWindow, kEventWindowBoundsChanging},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1482 {kEventClassWindow, kEventWindowBoundsChanged},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1483 /* -- window action events -- */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1484 {kEventClassWindow, kEventWindowClose},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1485 {kEventClassWindow, kEventWindowGetIdealSize},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1486 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1487 {kEventClassWindow, kEventWindowToolbarSwitchMode},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1488 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1489 #if USE_MAC_TSM
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1490 /* -- window focus events -- */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1491 {kEventClassWindow, kEventWindowFocusAcquired},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1492 {kEventClassWindow, kEventWindowFocusRelinquish},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1493 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1494 };
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1495 static EventHandlerUPP handle_window_eventUPP = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1496
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1497 if (handle_window_eventUPP == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1498 handle_window_eventUPP = NewEventHandlerUPP (mac_handle_window_event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1499
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1500 err = InstallWindowEventHandler (window, handle_window_eventUPP,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1501 GetEventTypeCount (specs),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1502 specs, NULL, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1503 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1504 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1505
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1506 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1507 err = install_drag_handler (window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1508
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1509 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1510 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1511
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1512 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1513 remove_window_handler (window)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1514 WindowRef window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1515 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1516 remove_drag_handler (window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1517 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1518
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1519 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1520 mac_get_window_bounds (f, inner, outer)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1521 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1522 Rect *inner, *outer;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1523 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1524 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1525 GetWindowBounds (FRAME_MAC_WINDOW (f), kWindowContentRgn, inner);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1526 GetWindowBounds (FRAME_MAC_WINDOW (f), kWindowStructureRgn, outer);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1527 #else /* not TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1528 RgnHandle region = NewRgn ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1529
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1530 GetWindowRegion (FRAME_MAC_WINDOW (f), kWindowContentRgn, region);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1531 *inner = (*region)->rgnBBox;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1532 GetWindowRegion (FRAME_MAC_WINDOW (f), kWindowStructureRgn, region);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1533 *outer = (*region)->rgnBBox;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1534 DisposeRgn (region);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1535 #endif /* not TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1536 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1537
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1538 Rect *
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1539 mac_get_frame_bounds (f, r)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1540 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1541 Rect *r;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1542 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1543 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1544 return GetWindowPortBounds (FRAME_MAC_WINDOW (f), r);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1545 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1546 *r = FRAME_MAC_WINDOW (f)->portRect;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1547
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1548 return r;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1549 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1550 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1551
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1552 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1553 mac_get_frame_mouse (f, point)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1554 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1555 Point *point;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1556 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1557 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1558 GetGlobalMouse (point);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1559 point->h -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1560 point->v -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1561 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1562 SetPortWindowPort (FRAME_MAC_WINDOW (f));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1563 GetMouse (point);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1564 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1565 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1566
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1567 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1568 mac_convert_frame_point_to_global (f, x, y)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1569 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1570 int *x, *y;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1571 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1572 *x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1573 *y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1574 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1575
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1576 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1577 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1578 mac_update_proxy_icon (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1579 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1580 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1581 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1582 Lisp_Object file_name =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1583 XBUFFER (XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer)->filename;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1584 Window w = FRAME_MAC_WINDOW (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1585 AliasHandle alias = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1586
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1587 err = GetWindowProxyAlias (w, &alias);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1588 if (err == errWindowDoesNotHaveProxy && !STRINGP (file_name))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1589 return;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1590
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1591 if (STRINGP (file_name))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1592 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1593 AEDesc desc;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1594 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1595 FSRef fref, fref_proxy;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1596 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1597 FSSpec fss, fss_proxy;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1598 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1599 Boolean changed;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1600 Lisp_Object encoded_file_name = ENCODE_FILE (file_name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1601
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1602 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1603 err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1604 SBYTES (encoded_file_name), typeFSRef, &desc);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1605 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1606 SetPortWindowPort (w);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1607 err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1608 SBYTES (encoded_file_name), typeFSS, &desc);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1609 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1610 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1611 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1612 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1613 err = AEGetDescData (&desc, &fref, sizeof (FSRef));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1614 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1615 err = AEGetDescData (&desc, &fss, sizeof (FSSpec));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1616 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1617 AEDisposeDesc (&desc);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1618 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1619 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1620 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1621 if (alias)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1622 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1623 /* (FS)ResolveAlias never sets `changed' to true if
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1624 `alias' is minimal. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1625 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1626 err = FSResolveAlias (NULL, alias, &fref_proxy, &changed);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1627 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1628 err = FSCompareFSRefs (&fref, &fref_proxy);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1629 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1630 err = ResolveAlias (NULL, alias, &fss_proxy, &changed);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1631 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1632 err = !(fss.vRefNum == fss_proxy.vRefNum
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1633 && fss.parID == fss_proxy.parID
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1634 && EqualString (fss.name, fss_proxy.name,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1635 false, true));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1636 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1637 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1638 if (err != noErr || alias == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1639 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1640 if (alias)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1641 DisposeHandle ((Handle) alias);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1642 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1643 err = FSNewAliasMinimal (&fref, &alias);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1644 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1645 err = NewAliasMinimal (&fss, &alias);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1646 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1647 changed = true;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1648 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1649 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1650 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1651 if (changed)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1652 err = SetWindowProxyAlias (w, alias);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1653 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1654
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1655 if (alias)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1656 DisposeHandle ((Handle) alias);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1657
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1658 if (err != noErr || !STRINGP (file_name))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1659 RemoveWindowProxy (w);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1660 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1661 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1662
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1663 /* Mac replacement for XSetWindowBackground. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1664
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1665 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1666 mac_set_frame_window_background (f, color)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1667 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1668 unsigned long color;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1669 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1670 WindowRef w = FRAME_MAC_WINDOW (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1671 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1672 AuxWinHandle aw_handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1673 CTabHandle ctab_handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1674 ColorSpecPtr ct_table;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1675 short ct_size;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1676 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1677 RGBColor bg_color;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1678
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1679 bg_color.red = RED16_FROM_ULONG (color);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1680 bg_color.green = GREEN16_FROM_ULONG (color);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1681 bg_color.blue = BLUE16_FROM_ULONG (color);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1682
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1683 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1684 SetWindowContentColor (w, &bg_color);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1685 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1686 if (GetAuxWin (w, &aw_handle))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1687 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1688 ctab_handle = (*aw_handle)->awCTable;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1689 HandToHand ((Handle *) &ctab_handle);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1690 ct_table = (*ctab_handle)->ctTable;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1691 ct_size = (*ctab_handle)->ctSize;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1692 while (ct_size > -1)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1693 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1694 if (ct_table->value == 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1695 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1696 ct_table->rgb = bg_color;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1697 CTabChanged (ctab_handle);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1698 SetWinColor (w, (WCTabHandle) ctab_handle);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1699 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1700 ct_size--;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1701 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1702 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1703 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1704 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1705
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1706 /* Flush display of frame F, or of all frames if F is null. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1707
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1708 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1709 x_flush (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1710 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1711 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1712 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1713 BLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1714 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1715 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1716 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1717 if (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1718 QDFlushPortBuffer (GetWindowPort (FRAME_MAC_WINDOW (f)), NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1719 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1720 QDFlushPortBuffer (GetQDGlobalsThePort (), NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1721 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1722 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1723 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1724
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1725 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1726 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1727 mac_flush_display_optional (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1728 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1729 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1730 BLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1731 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1732 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1733 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1734 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1735
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1736 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1737 mac_update_begin (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1738 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1739 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1740 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1741 /* During update of a frame, availability of input events is
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1742 periodically checked with ReceiveNextEvent if
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1743 redisplay-dont-pause is nil. That normally flushes window buffer
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1744 changes for every check, and thus screen update looks waving even
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1745 if no input is available. So we disable screen updates during
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1746 update of a frame. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1747 DisableScreenUpdates ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1748 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1749 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1750
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1751 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1752 mac_update_end (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1753 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1754 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1755 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1756 EnableScreenUpdates ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1757 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1758 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1759
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1760 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1761 mac_frame_up_to_date (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1762 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1763 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1764 /* Nothing to do. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1765 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1766
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1767 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1768 mac_create_frame_window (f, tooltip_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1769 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1770 int tooltip_p;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1771 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1772 Rect r;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1773 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1774 WindowClass window_class;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1775 WindowAttributes attributes;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1776 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1777 short proc_id;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1778 WindowRef behind;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1779 Boolean go_away_flag;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1780 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1781
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1782 if (!tooltip_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1783 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1784 SetRect (&r, f->left_pos, f->top_pos,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1785 f->left_pos + FRAME_PIXEL_WIDTH (f),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1786 f->top_pos + FRAME_PIXEL_HEIGHT (f));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1787 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1788 window_class = kDocumentWindowClass;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1789 attributes = (kWindowStandardDocumentAttributes
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1790 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1791 | kWindowToolbarButtonAttribute
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1792 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1793 );
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1794 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1795 proc_id = zoomDocProc;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1796 behind = (WindowRef) -1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1797 go_away_flag = true;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1798 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1799 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1800 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1801 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1802 SetRect (&r, 0, 0, 1, 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1803 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1804 window_class = kHelpWindowClass;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1805 attributes = (kWindowNoUpdatesAttribute
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1806 | kWindowNoActivatesAttribute
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1807 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1808 | kWindowIgnoreClicksAttribute
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1809 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1810 );
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1811 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1812 proc_id = plainDBox;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1813 behind = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1814 go_away_flag = false;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1815 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1816 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1817
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1818 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1819 CreateNewWindow (window_class, attributes, &r, &FRAME_MAC_WINDOW (f));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1820 if (FRAME_MAC_WINDOW (f))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1821 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1822 SetWRefCon (FRAME_MAC_WINDOW (f), (long) f->output_data.mac);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1823 if (!tooltip_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1824 if (install_window_handler (FRAME_MAC_WINDOW (f)) != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1825 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1826 DisposeWindow (FRAME_MAC_WINDOW (f));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1827 FRAME_MAC_WINDOW (f) = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1828 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1829 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1830 #else /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1831 FRAME_MAC_WINDOW (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1832 = NewCWindow (NULL, &r, "\p", false, proc_id, behind, go_away_flag,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1833 (long) f->output_data.mac);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1834 #endif /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1835 /* so that update events can find this mac_output struct */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1836 f->output_data.mac->mFP = f; /* point back to emacs frame */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1837
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1838 #ifndef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1839 if (!tooltip_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1840 if (FRAME_MAC_WINDOW (f))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1841 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1842 ControlRef root_control;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1843
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1844 if (CreateRootControl (FRAME_MAC_WINDOW (f), &root_control) != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1845 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1846 DisposeWindow (FRAME_MAC_WINDOW (f));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1847 FRAME_MAC_WINDOW (f) = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1848 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1849 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1850 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1851 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1852
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1853 /* Dispose of the Mac window of the frame F. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1854
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1855 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1856 mac_dispose_frame_window (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1857 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1858 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1859 WindowRef window = FRAME_MAC_WINDOW (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1860
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1861 if (window != tip_window)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1862 remove_window_handler (window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1863
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1864 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1865 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1866 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1867 DisposeWindow (window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1868 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1869
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1870
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1871 /************************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1872 View and Drawing
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1873 ************************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1874
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1875 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1876 #define FRAME_CG_CONTEXT(f) ((f)->output_data.mac->cg_context)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1877
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1878 CGContextRef
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1879 mac_begin_cg_clip (f, gc)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1880 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1881 GC gc;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1882 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1883 CGContextRef context = FRAME_CG_CONTEXT (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1884
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1885 if (!context)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1886 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1887 QDBeginCGContext (GetWindowPort (FRAME_MAC_WINDOW (f)), &context);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1888 FRAME_CG_CONTEXT (f) = context;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1889 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1890
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1891 CGContextSaveGState (context);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1892 CGContextTranslateCTM (context, 0, FRAME_PIXEL_HEIGHT (f));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1893 CGContextScaleCTM (context, 1, -1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1894 if (gc && gc->n_clip_rects)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1895 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1896
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1897 return context;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1898 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1899
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1900 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1901 mac_end_cg_clip (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1902 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1903 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1904 CGContextRestoreGState (FRAME_CG_CONTEXT (f));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1905 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1906
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1907 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1908 mac_prepare_for_quickdraw (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1909 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1910 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1911 if (f == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1912 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1913 Lisp_Object rest, frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1914 FOR_EACH_FRAME (rest, frame)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1915 if (FRAME_MAC_P (XFRAME (frame)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1916 mac_prepare_for_quickdraw (XFRAME (frame));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1917 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1918 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1919 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1920 CGContextRef context = FRAME_CG_CONTEXT (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1921
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1922 if (context)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1923 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1924 CGContextSynchronize (context);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1925 QDEndCGContext (GetWindowPort (FRAME_MAC_WINDOW (f)),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1926 &FRAME_CG_CONTEXT (f));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1927 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1928 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1929 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1930 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1931
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1932 static RgnHandle saved_port_clip_region = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1933
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1934 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1935 mac_begin_clip (f, gc)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1936 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1937 GC gc;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1938 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1939 static RgnHandle new_region = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1940
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1941 if (saved_port_clip_region == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1942 saved_port_clip_region = NewRgn ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1943 if (new_region == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1944 new_region = NewRgn ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1945
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1946 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1947 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1948 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1949 SetPortWindowPort (FRAME_MAC_WINDOW (f));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1950
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1951 if (gc && gc->n_clip_rects)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1952 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1953 GetClip (saved_port_clip_region);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1954 SectRgn (saved_port_clip_region, gc->clip_region, new_region);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1955 SetClip (new_region);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1956 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1957 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1958
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1959 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1960 mac_end_clip (f, gc)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1961 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1962 GC gc;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1963 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1964 if (gc && gc->n_clip_rects)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1965 SetClip (saved_port_clip_region);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1966 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1967
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1968 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1969 /* Mac replacement for XCopyArea: used only for scrolling. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1970
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1971 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1972 mac_scroll_area (f, gc, src_x, src_y, width, height, dest_x, dest_y)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1973 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1974 GC gc;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1975 int src_x, src_y;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1976 unsigned int width, height;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1977 int dest_x, dest_y;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1978 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1979 Rect src_r;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1980 RgnHandle dummy = NewRgn (); /* For avoiding update events. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1981
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1982 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1983 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1984 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1985 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1986 ScrollWindowRect (FRAME_MAC_WINDOW (f),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1987 &src_r, dest_x - src_x, dest_y - src_y,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1988 kScrollWindowNoOptions, dummy);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1989 DisposeRgn (dummy);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1990 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1991 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1992
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1993
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1994 /************************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1995 Scroll bars
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1996 ************************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1997
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1998 extern struct scroll_bar *tracked_scroll_bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1999 extern Lisp_Object last_mouse_scroll_bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2000 extern Time last_mouse_movement_time;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2001
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2002 static void x_scroll_bar_handle_click P_ ((struct scroll_bar *,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2003 ControlPartCode,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2004 const EventRecord *,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2005 struct input_event *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2006 #ifndef USE_TOOLKIT_SCROLL_BARS
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2007 static void x_scroll_bar_note_movement P_ ((struct scroll_bar *, int, Time));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2008 #else /* USE_TOOLKIT_SCROLL_BARS */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2009 static void x_scroll_bar_handle_press P_ ((struct scroll_bar *,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2010 ControlPartCode, Point,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2011 struct input_event *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2012 static void x_scroll_bar_handle_release P_ ((struct scroll_bar *,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2013 struct input_event *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2014 static void x_scroll_bar_handle_drag P_ ((WindowRef, struct scroll_bar *,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2015 Point, struct input_event *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2016 static pascal void scroll_bar_timer_callback P_ ((EventLoopTimerRef, void *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2017 static OSStatus install_scroll_bar_timer P_ ((void));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2018 static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2019 static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2020 static void construct_scroll_bar_click P_ ((struct scroll_bar *, int,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2021 struct input_event *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2022 static OSStatus get_control_part_bounds P_ ((ControlRef, ControlPartCode,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2023 Rect *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2024 static void update_scroll_bar_track_info P_ ((struct scroll_bar *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2025
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2026 /* Last scroll bar part sent in x_scroll_bar_handle_*. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2027
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2028 static int last_scroll_bar_part;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2029
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2030 static EventLoopTimerRef scroll_bar_timer;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2031
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2032 static int scroll_bar_timer_event_posted_p;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2033
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2034 #define SCROLL_BAR_FIRST_DELAY 0.5
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2035 #define SCROLL_BAR_CONTINUOUS_DELAY (1.0 / 15)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2036
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2037 static pascal void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2038 scroll_bar_timer_callback (timer, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2039 EventLoopTimerRef timer;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2040 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2041 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2042 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2043
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2044 err = mac_post_mouse_moved_event ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2045 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2046 scroll_bar_timer_event_posted_p = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2047 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2048
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2049 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2050 install_scroll_bar_timer ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2051 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2052 static EventLoopTimerUPP scroll_bar_timer_callbackUPP = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2053
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2054 if (scroll_bar_timer_callbackUPP == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2055 scroll_bar_timer_callbackUPP =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2056 NewEventLoopTimerUPP (scroll_bar_timer_callback);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2057
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2058 if (scroll_bar_timer == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2059 /* Mac OS X and CarbonLib 1.5 and later allow us to specify
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2060 kEventDurationForever as delays. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2061 return
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2062 InstallEventLoopTimer (GetCurrentEventLoop (),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2063 kEventDurationForever, kEventDurationForever,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2064 scroll_bar_timer_callbackUPP, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2065 &scroll_bar_timer);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2066 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2067
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2068 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2069 set_scroll_bar_timer (delay)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2070 EventTimerInterval delay;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2071 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2072 if (scroll_bar_timer == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2073 install_scroll_bar_timer ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2074
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2075 scroll_bar_timer_event_posted_p = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2076
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2077 return SetEventLoopTimerNextFireTime (scroll_bar_timer, delay);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2078 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2079
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2080 static int
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2081 control_part_code_to_scroll_bar_part (part_code)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2082 ControlPartCode part_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2083 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2084 switch (part_code)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2085 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2086 case kControlUpButtonPart: return scroll_bar_up_arrow;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2087 case kControlDownButtonPart: return scroll_bar_down_arrow;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2088 case kControlPageUpPart: return scroll_bar_above_handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2089 case kControlPageDownPart: return scroll_bar_below_handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2090 case kControlIndicatorPart: return scroll_bar_handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2091 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2092
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2093 return -1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2094 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2095
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2096 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2097 construct_scroll_bar_click (bar, part, bufp)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2098 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2099 int part;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2100 struct input_event *bufp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2101 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2102 bufp->kind = SCROLL_BAR_CLICK_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2103 bufp->frame_or_window = bar->window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2104 bufp->arg = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2105 bufp->part = part;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2106 bufp->code = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2107 XSETINT (bufp->x, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2108 XSETINT (bufp->y, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2109 bufp->modifiers = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2110 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2111
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2112 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2113 get_control_part_bounds (ch, part_code, rect)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2114 ControlRef ch;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2115 ControlPartCode part_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2116 Rect *rect;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2117 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2118 RgnHandle region = NewRgn ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2119 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2120
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2121 err = GetControlRegion (ch, part_code, region);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2122 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2123 GetRegionBounds (region, rect);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2124 DisposeRgn (region);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2125
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2126 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2127 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2128
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2129 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2130 x_scroll_bar_handle_press (bar, part_code, mouse_pos, bufp)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2131 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2132 ControlPartCode part_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2133 Point mouse_pos;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2134 struct input_event *bufp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2135 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2136 int part = control_part_code_to_scroll_bar_part (part_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2137
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2138 if (part < 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2139 return;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2140
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2141 if (part != scroll_bar_handle)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2142 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2143 construct_scroll_bar_click (bar, part, bufp);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2144 HiliteControl (SCROLL_BAR_CONTROL_REF (bar), part_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2145 set_scroll_bar_timer (SCROLL_BAR_FIRST_DELAY);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2146 bar->dragging = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2147 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2148 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2149 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2150 Rect r;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2151
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2152 get_control_part_bounds (SCROLL_BAR_CONTROL_REF (bar),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2153 kControlIndicatorPart, &r);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2154 XSETINT (bar->dragging, - (mouse_pos.v - r.top) - 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2155 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2156
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2157 last_scroll_bar_part = part;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2158 tracked_scroll_bar = bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2159 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2160
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2161 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2162 x_scroll_bar_handle_release (bar, bufp)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2163 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2164 struct input_event *bufp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2165 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2166 if (last_scroll_bar_part != scroll_bar_handle
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2167 || (INTEGERP (bar->dragging) && XINT (bar->dragging) >= 0))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2168 construct_scroll_bar_click (bar, scroll_bar_end_scroll, bufp);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2169
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2170 HiliteControl (SCROLL_BAR_CONTROL_REF (bar), 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2171 set_scroll_bar_timer (kEventDurationForever);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2172
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2173 last_scroll_bar_part = -1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2174 bar->dragging = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2175 tracked_scroll_bar = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2176 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2177
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2178 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2179 x_scroll_bar_handle_drag (win, bar, mouse_pos, bufp)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2180 WindowRef win;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2181 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2182 Point mouse_pos;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2183 struct input_event *bufp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2184 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2185 ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2186
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2187 if (last_scroll_bar_part == scroll_bar_handle)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2188 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2189 int top, top_range;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2190 Rect r;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2191
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2192 get_control_part_bounds (SCROLL_BAR_CONTROL_REF (bar),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2193 kControlIndicatorPart, &r);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2194
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2195 if (INTEGERP (bar->dragging) && XINT (bar->dragging) < 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2196 XSETINT (bar->dragging, - (XINT (bar->dragging) + 1));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2197
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2198 top = mouse_pos.v - XINT (bar->dragging) - XINT (bar->track_top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2199 top_range = XINT (bar->track_height) - XINT (bar->min_handle);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2200
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2201 if (top < 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2202 top = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2203 if (top > top_range)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2204 top = top_range;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2205
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2206 construct_scroll_bar_click (bar, scroll_bar_handle, bufp);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2207 XSETINT (bufp->x, top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2208 XSETINT (bufp->y, top_range);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2209 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2210 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2211 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2212 ControlPartCode part_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2213 int unhilite_p = 0, part;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2214
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2215 if (ch != FindControlUnderMouse (mouse_pos, win, &part_code))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2216 unhilite_p = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2217 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2218 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2219 part = control_part_code_to_scroll_bar_part (part_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2220
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2221 switch (last_scroll_bar_part)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2222 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2223 case scroll_bar_above_handle:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2224 case scroll_bar_below_handle:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2225 if (part != scroll_bar_above_handle
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2226 && part != scroll_bar_below_handle)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2227 unhilite_p = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2228 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2229
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2230 case scroll_bar_up_arrow:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2231 case scroll_bar_down_arrow:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2232 if (part != scroll_bar_up_arrow
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2233 && part != scroll_bar_down_arrow)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2234 unhilite_p = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2235 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2236 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2237 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2238
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2239 if (unhilite_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2240 HiliteControl (SCROLL_BAR_CONTROL_REF (bar), 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2241 else if (part != last_scroll_bar_part
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2242 || scroll_bar_timer_event_posted_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2243 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2244 construct_scroll_bar_click (bar, part, bufp);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2245 last_scroll_bar_part = part;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2246 HiliteControl (SCROLL_BAR_CONTROL_REF (bar), part_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2247 set_scroll_bar_timer (SCROLL_BAR_CONTINUOUS_DELAY);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2248 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2249 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2250 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2251
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2252 /* Update BAR->track_top, BAR->track_height, and BAR->min_handle for
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2253 the scroll bar BAR. This function should be called when the bounds
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2254 of the scroll bar is changed. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2255
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2256 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2257 update_scroll_bar_track_info (bar)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2258 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2259 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2260 ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2261 Rect r0, r1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2262
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2263 GetControlBounds (ch, &r0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2264
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2265 if (r0.right - r0.left >= r0.bottom - r0.top
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2266 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2267 || r0.right - r0.left < MAC_AQUA_SMALL_VERTICAL_SCROLL_BAR_WIDTH
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2268 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2269 )
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2270 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2271 XSETINT (bar->track_top, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2272 XSETINT (bar->track_height, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2273 XSETINT (bar->min_handle, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2274 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2275 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2276 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2277 BLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2278
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2279 SetControl32BitMinimum (ch, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2280 SetControl32BitMaximum (ch, 1 << 30);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2281 SetControlViewSize (ch, 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2282
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2283 /* Move the scroll bar thumb to the top. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2284 SetControl32BitValue (ch, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2285 get_control_part_bounds (ch, kControlIndicatorPart, &r0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2286
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2287 /* Move the scroll bar thumb to the bottom. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2288 SetControl32BitValue (ch, 1 << 30);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2289 get_control_part_bounds (ch, kControlIndicatorPart, &r1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2290
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2291 UnionRect (&r0, &r1, &r0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2292 XSETINT (bar->track_top, r0.top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2293 XSETINT (bar->track_height, r0.bottom - r0.top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2294 XSETINT (bar->min_handle, r1.bottom - r1.top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2295
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2296 /* Don't show the scroll bar if its height is not enough to
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2297 display the scroll bar thumb. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2298 if (r0.bottom - r0.top > 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2299 ShowControl (ch);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2300
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2301 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2302 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2303 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2304
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2305 /* Set the thumb size and position of scroll bar BAR. We are currently
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2306 displaying PORTION out of a whole WHOLE, and our position POSITION. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2307
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2308 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2309 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2310 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2311 int portion, position, whole;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2312 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2313 ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2314 int value, viewsize, maximum;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2315
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2316 if (XINT (bar->track_height) == 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2317 return;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2318
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2319 if (whole <= portion)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2320 value = 0, viewsize = 1, maximum = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2321 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2322 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2323 float scale;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2324
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2325 maximum = XINT (bar->track_height) - XINT (bar->min_handle);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2326 scale = (float) maximum / (whole - portion);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2327 value = position * scale + 0.5f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2328 viewsize = (int) (portion * scale + 0.5f) + XINT (bar->min_handle);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2329 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2330
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2331 BLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2332
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2333 if (GetControlViewSize (ch) != viewsize
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2334 || GetControl32BitValue (ch) != value
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2335 || GetControl32BitMaximum (ch) != maximum)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2336 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2337 /* Temporarily hide the scroll bar to avoid multiple redraws. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2338 SetControlVisibility (ch, false, false);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2339
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2340 SetControl32BitMaximum (ch, maximum);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2341 SetControl32BitValue (ch, value);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2342 SetControlViewSize (ch, viewsize);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2343
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2344 SetControlVisibility (ch, true, true);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2345 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2346
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2347 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2348 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2349
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2350 #endif /* USE_TOOLKIT_SCROLL_BARS */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2351
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2352 /* Create a scroll bar control for BAR. BOUNDS and VISIBLE specifies
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2353 the initial geometry and visibility, respectively. The created
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2354 control is stored in some members of BAR. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2355
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2356 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2357 mac_create_scroll_bar (bar, bounds, visible)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2358 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2359 const Rect *bounds;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2360 Boolean visible;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2361 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2362 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2363 ControlRef ch;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2364
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2365 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2366 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2367 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2368 ch = NewControl (FRAME_MAC_WINDOW (f), bounds, "\p", visible, 0, 0, 0,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2369 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2370 kControlScrollBarProc,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2371 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2372 scrollBarProc,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2373 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2374 (SInt32) bar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2375 SET_SCROLL_BAR_CONTROL_REF (bar, ch);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2376
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2377 XSETINT (bar->start, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2378 XSETINT (bar->end, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2379 bar->dragging = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2380
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2381 #ifdef USE_TOOLKIT_SCROLL_BARS
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2382 update_scroll_bar_track_info (bar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2383 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2384 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2385
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2386 /* Dispose of the scroll bar control stored in some members of
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2387 BAR. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2388
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2389 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2390 mac_dispose_scroll_bar (bar)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2391 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2392 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2393 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2394 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2395
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2396 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2397 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2398 DisposeControl (SCROLL_BAR_CONTROL_REF (bar));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2399 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2400
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2401 /* Set bounds of the scroll bar BAR to BOUNDS. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2402
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2403 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2404 mac_set_scroll_bar_bounds (bar, bounds)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2405 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2406 const Rect *bounds;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2407 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2408 ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2409 SInt16 width, height;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2410 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2411 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2412
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2413 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2414 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2415
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2416 width = bounds->right - bounds->left;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2417 height = bounds->bottom - bounds->top;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2418 HideControl (ch);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2419 MoveControl (ch, bounds->left, bounds->top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2420 SizeControl (ch, width, height);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2421 #ifdef USE_TOOLKIT_SCROLL_BARS
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2422 update_scroll_bar_track_info (bar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2423 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2424 if (width < height)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2425 ShowControl (ch);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2426 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2427 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2428
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2429 /* Draw the scroll bar BAR. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2430
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2431 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2432 mac_redraw_scroll_bar (bar)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2433 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2434 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2435 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2436 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2437
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2438 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2439 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2440 Draw1Control (SCROLL_BAR_CONTROL_REF (bar));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2441 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2442
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2443 /* Handle a mouse click on the scroll bar BAR. If *EMACS_EVENT's kind
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2444 is set to something other than NO_EVENT, it is enqueued.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2445
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2446 This may be called from a signal handler, so we have to ignore GC
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2447 mark bits. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2448
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2449 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2450 x_scroll_bar_handle_click (bar, part_code, er, bufp)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2451 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2452 ControlPartCode part_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2453 const EventRecord *er;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2454 struct input_event *bufp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2455 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2456 int win_y, top_range;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2457
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2458 if (! GC_WINDOWP (bar->window))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2459 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2460
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2461 bufp->kind = SCROLL_BAR_CLICK_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2462 bufp->frame_or_window = bar->window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2463 bufp->arg = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2464
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2465 bar->dragging = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2466
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2467 switch (part_code)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2468 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2469 case kControlUpButtonPart:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2470 bufp->part = scroll_bar_up_arrow;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2471 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2472 case kControlDownButtonPart:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2473 bufp->part = scroll_bar_down_arrow;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2474 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2475 case kControlPageUpPart:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2476 bufp->part = scroll_bar_above_handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2477 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2478 case kControlPageDownPart:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2479 bufp->part = scroll_bar_below_handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2480 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2481 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2482 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2483 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2484 case kControlIndicatorPart:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2485 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2486 if (er->what == mouseDown)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2487 bar->dragging = make_number (0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2488 XSETVECTOR (last_mouse_scroll_bar, bar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2489 bufp->part = scroll_bar_handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2490 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2491 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2492
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2493 win_y = XINT (bufp->y) - XINT (bar->top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2494 top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (0/*dummy*/, XINT (bar->height));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2495
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2496 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2497
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2498 win_y -= 24;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2499
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2500 if (! NILP (bar->dragging))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2501 win_y -= XINT (bar->dragging);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2502
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2503 if (win_y < 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2504 win_y = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2505 if (win_y > top_range)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2506 win_y = top_range;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2507
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2508 XSETINT (bufp->x, win_y);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2509 XSETINT (bufp->y, top_range);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2510 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2511
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2512 /* Return information to the user about the current position of the mouse
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2513 on the scroll bar. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2514
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2515 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2516 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2517 FRAME_PTR *fp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2518 Lisp_Object *bar_window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2519 enum scroll_bar_part *part;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2520 Lisp_Object *x, *y;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2521 unsigned long *time;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2522 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2523 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2524 ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2525 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2526 WindowRef wp = GetControlOwner (ch);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2527 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2528 WindowRef wp = (*ch)->contrlOwner;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2529 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2530 Point mouse_pos;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2531 struct frame *f = mac_window_to_frame (wp);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2532 int win_y, top_range;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2533
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2534 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2535 GetGlobalMouse (&mouse_pos);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2536 mouse_pos.h -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2537 mouse_pos.v -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2538 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2539 SetPortWindowPort (wp);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2540 GetMouse (&mouse_pos);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2541 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2542
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2543 win_y = mouse_pos.v - XINT (bar->top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2544 top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2545
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2546 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2547
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2548 win_y -= 24;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2549
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2550 if (! NILP (bar->dragging))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2551 win_y -= XINT (bar->dragging);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2552
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2553 if (win_y < 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2554 win_y = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2555 if (win_y > top_range)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2556 win_y = top_range;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2557
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2558 *fp = f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2559 *bar_window = bar->window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2560
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2561 if (! NILP (bar->dragging))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2562 *part = scroll_bar_handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2563 else if (win_y < XINT (bar->start))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2564 *part = scroll_bar_above_handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2565 else if (win_y < XINT (bar->end) + VERTICAL_SCROLL_BAR_MIN_HANDLE)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2566 *part = scroll_bar_handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2567 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2568 *part = scroll_bar_below_handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2569
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2570 XSETINT (*x, win_y);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2571 XSETINT (*y, top_range);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2572
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2573 f->mouse_moved = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2574 last_mouse_scroll_bar = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2575
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2576 *time = last_mouse_movement_time;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2577 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2578
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2579 #ifndef USE_TOOLKIT_SCROLL_BARS
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2580 /* Draw BAR's handle in the proper position.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2581
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2582 If the handle is already drawn from START to END, don't bother
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2583 redrawing it, unless REBUILD is non-zero; in that case, always
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2584 redraw it. (REBUILD is handy for drawing the handle after expose
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2585 events.)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2586
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2587 Normally, we want to constrain the start and end of the handle to
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2588 fit inside its rectangle, but if the user is dragging the scroll
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2589 bar handle, we want to let them drag it down all the way, so that
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2590 the bar's top is as far down as it goes; otherwise, there's no way
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2591 to move to the very end of the buffer. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2592
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2593 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2594 x_scroll_bar_set_handle (bar, start, end, rebuild)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2595 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2596 int start, end;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2597 int rebuild;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2598 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2599 int dragging = ! NILP (bar->dragging);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2600 ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2601 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2602 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2603 int length = end - start;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2604
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2605 /* If the display is already accurate, do nothing. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2606 if (! rebuild
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2607 && start == XINT (bar->start)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2608 && end == XINT (bar->end))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2609 return;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2610
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2611 BLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2612
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2613 /* Make sure the values are reasonable, and try to preserve the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2614 distance between start and end. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2615 if (start < 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2616 start = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2617 else if (start > top_range)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2618 start = top_range;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2619 end = start + length;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2620
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2621 if (end < start)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2622 end = start;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2623 else if (end > top_range && ! dragging)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2624 end = top_range;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2625
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2626 /* Store the adjusted setting in the scroll bar. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2627 XSETINT (bar->start, start);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2628 XSETINT (bar->end, end);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2629
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2630 /* Clip the end position, just for display. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2631 if (end > top_range)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2632 end = top_range;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2633
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2634 /* Draw bottom positions VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2635 top positions, to make sure the handle is always at least that
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2636 many pixels tall. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2637 end += VERTICAL_SCROLL_BAR_MIN_HANDLE;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2638
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2639 SetControlMinimum (ch, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2640 /* Don't inadvertently activate deactivated scroll bars */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2641 if (GetControlMaximum (ch) != -1)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2642 SetControlMaximum (ch, top_range + VERTICAL_SCROLL_BAR_MIN_HANDLE
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2643 - (end - start));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2644 SetControlValue (ch, start);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2645 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2646 SetControlViewSize (ch, end - start);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2647 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2648
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2649 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2650 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2651
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2652 /* Handle some mouse motion while someone is dragging the scroll bar.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2653
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2654 This may be called from a signal handler, so we have to ignore GC
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2655 mark bits. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2656
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2657 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2658 x_scroll_bar_note_movement (bar, y_pos, t)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2659 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2660 int y_pos;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2661 Time t;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2662 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2663 FRAME_PTR f = XFRAME (XWINDOW (bar->window)->frame);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2664
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2665 last_mouse_movement_time = t;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2666
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2667 f->mouse_moved = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2668 XSETVECTOR (last_mouse_scroll_bar, bar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2669
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2670 /* If we're dragging the bar, display it. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2671 if (! GC_NILP (bar->dragging))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2672 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2673 /* Where should the handle be now? */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2674 int new_start = y_pos - 24;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2675
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2676 if (new_start != XINT (bar->start))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2677 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2678 int new_end = new_start + (XINT (bar->end) - XINT (bar->start));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2679
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2680 x_scroll_bar_set_handle (bar, new_start, new_end, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2681 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2682 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2683 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2684 #endif /* !USE_TOOLKIT_SCROLL_BARS */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2685
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2686
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2687 /***********************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2688 Tool-bars
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2689 ***********************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2690
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2691 #if USE_MAC_TOOLBAR
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2692 /* In identifiers such as function/variable names, Emacs tool bar is
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2693 referred to as `tool_bar', and Carbon HIToolbar as `toolbar'. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2694
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2695 #define TOOLBAR_IDENTIFIER (CFSTR ("org.gnu.Emacs.toolbar"))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2696 #define TOOLBAR_ICON_ITEM_IDENTIFIER (CFSTR ("org.gnu.Emacs.toolbar.icon"))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2697
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2698 #define TOOLBAR_ITEM_COMMAND_ID_OFFSET 'Tb\0\0'
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2699 #define TOOLBAR_ITEM_COMMAND_ID_P(id) \
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2700 (((id) & ~0xffff) == TOOLBAR_ITEM_COMMAND_ID_OFFSET)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2701 #define TOOLBAR_ITEM_COMMAND_ID_VALUE(id) \
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2702 ((id) - TOOLBAR_ITEM_COMMAND_ID_OFFSET)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2703 #define TOOLBAR_ITEM_MAKE_COMMAND_ID(value) \
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2704 ((value) + TOOLBAR_ITEM_COMMAND_ID_OFFSET)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2705
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2706 static OSStatus mac_handle_toolbar_command_event P_ ((EventHandlerCallRef,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2707 EventRef, void *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2708
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2709 extern Rect last_mouse_glyph;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2710
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2711 extern void mac_move_window_with_gravity P_ ((struct frame *, int,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2712 short, short));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2713 extern void mac_get_window_origin_with_gravity P_ ((struct frame *, int,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2714 short *, short *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2715 extern CGImageRef mac_image_spec_to_cg_image P_ ((struct frame *,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2716 Lisp_Object));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2717
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2718 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2719 mac_handle_toolbar_event (next_handler, event, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2720 EventHandlerCallRef next_handler;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2721 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2722 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2723 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2724 OSStatus result = eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2725
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2726 switch (GetEventKind (event))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2727 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2728 case kEventToolbarGetDefaultIdentifiers:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2729 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2730 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2731
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2732 case kEventToolbarGetAllowedIdentifiers:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2733 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2734 CFMutableArrayRef array;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2735
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2736 GetEventParameter (event, kEventParamMutableArray,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2737 typeCFMutableArrayRef, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2738 sizeof (CFMutableArrayRef), NULL, &array);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2739 CFArrayAppendValue (array, TOOLBAR_ICON_ITEM_IDENTIFIER);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2740 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2741 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2742 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2743
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2744 case kEventToolbarCreateItemWithIdentifier:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2745 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2746 CFStringRef identifier;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2747 HIToolbarItemRef item = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2748
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2749 GetEventParameter (event, kEventParamToolbarItemIdentifier,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2750 typeCFStringRef, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2751 sizeof (CFStringRef), NULL, &identifier);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2752
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2753 if (CFStringCompare (identifier, TOOLBAR_ICON_ITEM_IDENTIFIER, 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2754 == kCFCompareEqualTo)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2755 HIToolbarItemCreate (identifier,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2756 kHIToolbarItemAllowDuplicates
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2757 | kHIToolbarItemCantBeRemoved, &item);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2758
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2759 if (item)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2760 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2761 SetEventParameter (event, kEventParamToolbarItem,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2762 typeHIToolbarItemRef,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2763 sizeof (HIToolbarItemRef), &item);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2764 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2765 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2766 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2767 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2768
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2769 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2770 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2771 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2772
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2773 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2774 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2775
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2776 /* Create a tool bar for frame F. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2777
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2778 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2779 mac_create_frame_tool_bar (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2780 FRAME_PTR f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2781 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2782 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2783 HIToolbarRef toolbar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2784
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2785 err = HIToolbarCreate (TOOLBAR_IDENTIFIER, kHIToolbarNoAttributes,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2786 &toolbar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2787 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2788 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2789 static const EventTypeSpec specs[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2790 {{kEventClassToolbar, kEventToolbarGetDefaultIdentifiers},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2791 {kEventClassToolbar, kEventToolbarGetAllowedIdentifiers},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2792 {kEventClassToolbar, kEventToolbarCreateItemWithIdentifier}};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2793
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2794 err = InstallEventHandler (HIObjectGetEventTarget (toolbar),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2795 mac_handle_toolbar_event,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2796 GetEventTypeCount (specs), specs,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2797 f, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2798 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2799
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2800 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2801 err = HIToolbarSetDisplayMode (toolbar, kHIToolbarDisplayModeIconOnly);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2802 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2803 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2804 static const EventTypeSpec specs[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2805 {{kEventClassCommand, kEventCommandProcess}};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2806
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2807 err = InstallWindowEventHandler (FRAME_MAC_WINDOW (f),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2808 mac_handle_toolbar_command_event,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2809 GetEventTypeCount (specs),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2810 specs, f, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2811 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2812 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2813 err = SetWindowToolbar (FRAME_MAC_WINDOW (f), toolbar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2814
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2815 if (toolbar)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2816 CFRelease (toolbar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2817
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2818 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2819 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2820
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2821 /* Update the tool bar for frame F. Add new buttons and remove old. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2822
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2823 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2824 update_frame_tool_bar (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2825 FRAME_PTR f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2826 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2827 HIToolbarRef toolbar = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2828 short left, top;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2829 CFArrayRef old_items = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2830 CFIndex old_count;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2831 int i, pos, win_gravity = f->output_data.mac->toolbar_win_gravity;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2832 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2833
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2834 BLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2835
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2836 GetWindowToolbar (FRAME_MAC_WINDOW (f), &toolbar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2837 if (toolbar == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2838 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2839 mac_create_frame_tool_bar (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2840 GetWindowToolbar (FRAME_MAC_WINDOW (f), &toolbar);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2841 if (toolbar == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2842 goto out;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2843 if (win_gravity >= NorthWestGravity && win_gravity <= SouthEastGravity)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2844 mac_get_window_origin_with_gravity (f, win_gravity, &left, &top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2845 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2846
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2847 HIToolbarCopyItems (toolbar, &old_items);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2848 if (old_items == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2849 goto out;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2850
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2851 old_count = CFArrayGetCount (old_items);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2852 pos = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2853 for (i = 0; i < f->n_tool_bar_items; ++i)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2854 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2855 #define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2856
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2857 int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2858 int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2859 int idx;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2860 Lisp_Object image;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2861 CGImageRef cg_image;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2862 CFStringRef label;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2863 HIToolbarItemRef item;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2864
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2865 /* If image is a vector, choose the image according to the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2866 button state. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2867 image = PROP (TOOL_BAR_ITEM_IMAGES);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2868 if (VECTORP (image))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2869 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2870 if (enabled_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2871 idx = (selected_p
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2872 ? TOOL_BAR_IMAGE_ENABLED_SELECTED
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2873 : TOOL_BAR_IMAGE_ENABLED_DESELECTED);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2874 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2875 idx = (selected_p
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2876 ? TOOL_BAR_IMAGE_DISABLED_SELECTED
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2877 : TOOL_BAR_IMAGE_DISABLED_DESELECTED);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2878
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2879 xassert (ASIZE (image) >= idx);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2880 image = AREF (image, idx);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2881 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2882 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2883 idx = -1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2884
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2885 cg_image = mac_image_spec_to_cg_image (f, image);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2886 /* Ignore invalid image specifications. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2887 if (cg_image == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2888 continue;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2889
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2890 label = cfstring_create_with_string (PROP (TOOL_BAR_ITEM_CAPTION));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2891 if (label == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2892 label = CFSTR ("");
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2893
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2894 if (pos < old_count)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2895 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2896 CGImageRef old_cg_image = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2897 CFStringRef old_label = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2898 Boolean old_enabled_p;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2899
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2900 item = (HIToolbarItemRef) CFArrayGetValueAtIndex (old_items, pos);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2901
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2902 HIToolbarItemCopyImage (item, &old_cg_image);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2903 if (cg_image != old_cg_image)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2904 HIToolbarItemSetImage (item, cg_image);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2905 CGImageRelease (old_cg_image);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2906
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2907 HIToolbarItemCopyLabel (item, &old_label);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2908 if (CFStringCompare (label, old_label, 0) != kCFCompareEqualTo)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2909 HIToolbarItemSetLabel (item, label);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2910 CFRelease (old_label);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2911
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2912 old_enabled_p = HIToolbarItemIsEnabled (item);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2913 if ((enabled_p || idx >= 0) != old_enabled_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2914 HIToolbarItemSetEnabled (item, (enabled_p || idx >= 0));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2915 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2916 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2917 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2918 item = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2919 HIToolbarCreateItemWithIdentifier (toolbar,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2920 TOOLBAR_ICON_ITEM_IDENTIFIER,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2921 NULL, &item);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2922 if (item)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2923 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2924 HIToolbarItemSetImage (item, cg_image);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2925 HIToolbarItemSetLabel (item, label);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2926 HIToolbarItemSetEnabled (item, (enabled_p || idx >= 0));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2927 HIToolbarAppendItem (toolbar, item);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2928 CFRelease (item);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2929 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2930 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2931
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2932 CFRelease (label);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2933 if (item)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2934 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2935 HIToolbarItemSetCommandID (item, TOOLBAR_ITEM_MAKE_COMMAND_ID (i));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2936 pos++;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2937 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2938 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2939
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2940 CFRelease (old_items);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2941
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2942 while (pos < old_count)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2943 HIToolbarRemoveItemAtIndex (toolbar, --old_count);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2944
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2945 ShowHideWindowToolbar (FRAME_MAC_WINDOW (f), true,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2946 !win_gravity && f == mac_focus_frame (dpyinfo));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2947 /* Mac OS X 10.3 does not issue kEventWindowBoundsChanged events on
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2948 toolbar visibility change. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2949 mac_handle_origin_change (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2950 if (win_gravity >= NorthWestGravity && win_gravity <= SouthEastGravity)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2951 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2952 mac_move_window_with_gravity (f, win_gravity, left, top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2953 /* If the title bar is completely outside the screen, adjust the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2954 position. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2955 ConstrainWindowToScreen (FRAME_MAC_WINDOW (f), kWindowTitleBarRgn,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2956 kWindowConstrainMoveRegardlessOfFit
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2957 | kWindowConstrainAllowPartial, NULL, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2958 f->output_data.mac->toolbar_win_gravity = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2959 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2960
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2961 out:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2962 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2963 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2964
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2965 /* Hide the tool bar on frame F. Unlike the counterpart on GTK+, it
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2966 doesn't deallocate the resources. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2967
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2968 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2969 free_frame_tool_bar (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2970 FRAME_PTR f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2971 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2972 if (IsWindowToolbarVisible (FRAME_MAC_WINDOW (f)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2973 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2974 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2975
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2976 BLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2977 ShowHideWindowToolbar (FRAME_MAC_WINDOW (f), false,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2978 (NILP (find_symbol_value
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2979 (intern ("frame-notice-user-settings")))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2980 && f == mac_focus_frame (dpyinfo)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2981 /* Mac OS X 10.3 does not issue kEventWindowBoundsChanged events
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2982 on toolbar visibility change. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2983 mac_handle_origin_change (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2984 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2985 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2986 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2987
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2988 /* Report a mouse movement over toolbar to the mainstream Emacs
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2989 code. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2990
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2991 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2992 mac_tool_bar_note_mouse_movement (f, event)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2993 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2994 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2995 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2996 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2997 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2998 int mouse_down_p;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
2999 WindowRef window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3000 WindowPartCode part_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3001 HIViewRef item_view;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3002 UInt32 command_id;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3003
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3004 mouse_down_p = (dpyinfo->grabbed
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3005 && f == last_mouse_frame
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3006 && FRAME_LIVE_P (f));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3007 if (mouse_down_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3008 return;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3009
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3010 err = GetEventParameter (event, kEventParamWindowRef, typeWindowRef, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3011 sizeof (WindowRef), NULL, &window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3012 if (err != noErr || window != FRAME_MAC_WINDOW (f))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3013 return;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3014
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3015 err = GetEventParameter (event, kEventParamWindowPartCode,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3016 typeWindowPartCode, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3017 sizeof (WindowPartCode), NULL, &part_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3018 if (err != noErr || part_code != inStructure)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3019 return;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3020
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3021 err = HIViewGetViewForMouseEvent (HIViewGetRoot (window), event, &item_view);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3022 /* This doesn't work on Mac OS X 10.2. On Mac OS X 10.3 and 10.4, a
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3023 toolbar item view seems to have the same command ID with that of
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3024 the toolbar item. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3025 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3026 err = GetControlCommandID (item_view, &command_id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3027 if (err == noErr && TOOLBAR_ITEM_COMMAND_ID_P (command_id))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3028 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3029 int i = TOOLBAR_ITEM_COMMAND_ID_VALUE (command_id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3030
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3031 if (i < f->n_tool_bar_items)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3032 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3033 HIRect bounds;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3034 HIViewRef content_view;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3035
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3036 err = HIViewGetBounds (item_view, &bounds);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3037 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3038 err = HIViewFindByID (HIViewGetRoot (window),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3039 kHIViewWindowContentID, &content_view);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3040 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3041 err = HIViewConvertRect (&bounds, item_view, content_view);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3042 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3043 SetRect (&last_mouse_glyph,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3044 CGRectGetMinX (bounds), CGRectGetMinY (bounds),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3045 CGRectGetMaxX (bounds), CGRectGetMaxY (bounds));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3046
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3047 help_echo_object = help_echo_window = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3048 help_echo_pos = -1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3049 help_echo_string = PROP (TOOL_BAR_ITEM_HELP);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3050 if (NILP (help_echo_string))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3051 help_echo_string = PROP (TOOL_BAR_ITEM_CAPTION);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3052 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3053 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3054 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3055
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3056 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3057 mac_handle_toolbar_command_event (next_handler, event, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3058 EventHandlerCallRef next_handler;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3059 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3060 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3061 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3062 OSStatus err, result = eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3063 struct frame *f = (struct frame *) data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3064 HICommand command;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3065
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3066 err = GetEventParameter (event, kEventParamDirectObject,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3067 typeHICommand, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3068 sizeof (HICommand), NULL, &command);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3069 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3070 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3071
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3072 switch (GetEventKind (event))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3073 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3074 case kEventCommandProcess:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3075 if (!TOOLBAR_ITEM_COMMAND_ID_P (command.commandID))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3076 result = CallNextEventHandler (next_handler, event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3077 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3078 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3079 int i = TOOLBAR_ITEM_COMMAND_ID_VALUE (command.commandID);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3080
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3081 if (i < f->n_tool_bar_items
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3082 && !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3083 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3084 Lisp_Object frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3085 struct input_event buf;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3086
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3087 EVENT_INIT (buf);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3088
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3089 XSETFRAME (frame, f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3090 buf.kind = TOOL_BAR_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3091 buf.frame_or_window = frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3092 buf.arg = frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3093 kbd_buffer_store_event (&buf);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3094
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3095 buf.kind = TOOL_BAR_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3096 buf.frame_or_window = frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3097 buf.arg = PROP (TOOL_BAR_ITEM_KEY);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3098 buf.modifiers = mac_event_to_emacs_modifiers (event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3099 kbd_buffer_store_event (&buf);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3100
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3101 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3102 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3103 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3104 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3105
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3106 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3107 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3108 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3109 #undef PROP
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3110
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3111 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3112 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3113 #endif /* USE_MAC_TOOLBAR */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3114
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3115
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3116 /***********************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3117 Font Panel
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3118 ***********************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3119
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3120 #if USE_MAC_FONT_PANEL
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3121 /* Whether Font Panel has been shown before. The first call to font
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3122 panel functions (FPIsFontPanelVisible, SetFontInfoForSelection) is
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3123 slow. This variable is used for deferring such a call as much as
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3124 possible. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3125 static int font_panel_shown_p = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3126
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3127 extern Lisp_Object Qpanel_closed, Qselection;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3128 extern Lisp_Object Qfont;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3129
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3130 /* Whether the font panel is currently visible. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3131
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3132 int
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3133 mac_font_panel_visible_p ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3134 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3135 return font_panel_shown_p && FPIsFontPanelVisible ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3136 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3137
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3138 static pascal OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3139 mac_handle_font_event (next_handler, event, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3140 EventHandlerCallRef next_handler;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3141 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3142 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3143 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3144 OSStatus result, err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3145 Lisp_Object id_key;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3146 int num_params;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3147 const EventParamName *names;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3148 const EventParamType *types;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3149 static const EventParamName names_sel[] = {kEventParamATSUFontID,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3150 kEventParamATSUFontSize,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3151 kEventParamFMFontFamily,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3152 kEventParamFMFontStyle,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3153 kEventParamFMFontSize,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3154 kEventParamFontColor};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3155 static const EventParamType types_sel[] = {typeATSUFontID,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3156 typeATSUSize,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3157 typeFMFontFamily,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3158 typeFMFontStyle,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3159 typeFMFontSize,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3160 typeFontColor};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3161
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3162 result = CallNextEventHandler (next_handler, event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3163 if (result != eventNotHandledErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3164 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3165
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3166 switch (GetEventKind (event))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3167 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3168 case kEventFontPanelClosed:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3169 id_key = Qpanel_closed;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3170 num_params = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3171 names = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3172 types = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3173 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3174
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3175 case kEventFontSelection:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3176 id_key = Qselection;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3177 num_params = sizeof (names_sel) / sizeof (names_sel[0]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3178 names = names_sel;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3179 types = types_sel;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3180 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3181 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3182
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3183 err = mac_store_event_ref_as_apple_event (0, 0, Qfont, id_key,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3184 event, num_params,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3185 names, types);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3186 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3187 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3188
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3189 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3190 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3191
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3192 /* Toggle visiblity of the font panel. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3193
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3194 OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3195 mac_show_hide_font_panel ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3196 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3197 if (!font_panel_shown_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3198 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3199 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3200
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3201 static const EventTypeSpec specs[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3202 {{kEventClassFont, kEventFontPanelClosed},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3203 {kEventClassFont, kEventFontSelection}};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3204
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3205 err = InstallApplicationEventHandler (mac_handle_font_event,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3206 GetEventTypeCount (specs),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3207 specs, NULL, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3208 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3209 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3210
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3211 font_panel_shown_p = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3212 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3213
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3214 return FPShowHideFontPanel ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3215 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3216
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3217 /* Set the font selected in the font panel to the one corresponding to
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3218 the face FACE_ID and the charcacter C in the frame F. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3219
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3220 OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3221 mac_set_font_info_for_selection (f, face_id, c)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3222 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3223 int face_id, c;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3224 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3225 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3226 EventTargetRef target = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3227 XFontStruct *font = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3228
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3229 if (!mac_font_panel_visible_p ())
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3230 return noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3231
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3232 if (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3233 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3234 target = GetWindowEventTarget (FRAME_MAC_WINDOW (f));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3235
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3236 if (FRAME_FACE_CACHE (f) && CHAR_VALID_P (c, 0))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3237 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3238 struct face *face;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3239
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3240 face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3241 face = FACE_FROM_ID (f, face_id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3242 font = face->font;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3243 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3244 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3245
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3246 if (font == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3247 err = SetFontInfoForSelection (kFontSelectionATSUIType, 0, NULL, target);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3248 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3249 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3250 if (font->mac_fontnum != -1)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3251 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3252 FontSelectionQDStyle qd_style;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3253
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3254 qd_style.version = kFontSelectionQDStyleVersionZero;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3255 qd_style.instance.fontFamily = font->mac_fontnum;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3256 qd_style.instance.fontStyle = font->mac_fontface;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3257 qd_style.size = font->mac_fontsize;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3258 qd_style.hasColor = false;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3259
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3260 err = SetFontInfoForSelection (kFontSelectionQDType,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3261 1, &qd_style, target);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3262 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3263 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3264 err = SetFontInfoForSelection (kFontSelectionATSUIType,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3265 1, &font->mac_style, target);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3266 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3267
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3268 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3269 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3270 #endif /* USE_MAC_FONT_PANEL */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3271
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3272
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3273 /************************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3274 Event Handling
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3275 ************************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3276
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3277 /* Non-zero means that a HELP_EVENT has been generated since Emacs
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3278 start. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3279
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3280 static int any_help_event_p;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3281
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3282 /* Last window where we saw the mouse. Used by mouse-autoselect-window. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3283 static Lisp_Object last_window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3284
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3285 static Point saved_menu_event_location;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3286
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3287 extern struct frame *pending_autoraise_frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3288
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3289 extern FRAME_PTR last_mouse_glyph_frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3290
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3291 #ifdef __STDC__
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3292 extern int volatile input_signal_count;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3293 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3294 extern int input_signal_count;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3295 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3296
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3297 extern int mac_screen_config_changed;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3298
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3299 extern Lisp_Object Vmac_emulate_three_button_mouse;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3300 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3301 extern int mac_wheel_button_is_mouse_2;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3302 extern int mac_pass_command_to_system;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3303 extern int mac_pass_control_to_system;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3304 #endif /* TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3305 extern int mac_ready_for_apple_events;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3306
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3307 extern void mac_focus_changed P_ ((int, struct mac_display_info *,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3308 struct frame *, struct input_event *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3309 extern int mac_get_emulated_btn P_ ((UInt32));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3310 extern int note_mouse_movement P_ ((FRAME_PTR, Point *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3311 extern void mac_get_screen_info P_ ((struct mac_display_info *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3312
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3313 /* The focus may have changed. Figure out if it is a real focus change,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3314 by checking both FocusIn/Out and Enter/LeaveNotify events.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3315
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3316 Returns FOCUS_IN_EVENT event in *BUFP. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3317
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3318 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3319 x_detect_focus_change (dpyinfo, event, bufp)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3320 struct mac_display_info *dpyinfo;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3321 const EventRecord *event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3322 struct input_event *bufp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3323 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3324 struct frame *frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3325
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3326 frame = mac_window_to_frame ((WindowRef) event->message);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3327 if (! frame)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3328 return;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3329
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3330 /* On Mac, this is only called from focus events, so no switch needed. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3331 mac_focus_changed ((event->modifiers & activeFlag),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3332 dpyinfo, frame, bufp);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3333 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3334
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3335 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3336 /* Obtains the event modifiers from the event EVENTREF and then calls
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3337 mac_to_emacs_modifiers. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3338
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3339 static int
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3340 mac_event_to_emacs_modifiers (EventRef eventRef)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3341 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3342 UInt32 mods = 0, class;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3343
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3344 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3345 sizeof (UInt32), NULL, &mods);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3346 class = GetEventClass (eventRef);
|
80517
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
3347 if (!NILP (Vmac_emulate_three_button_mouse)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
3348 && (class == kEventClassMouse || class == kEventClassCommand))
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3349 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3350 mods &= ~(optionKey | cmdKey);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3351 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3352 return mac_to_emacs_modifiers (mods, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3353 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3354
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3355 /* Given an event REF, return the code to use for the mouse button
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3356 code in the emacs input_event. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3357
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3358 static int
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3359 mac_get_mouse_btn (EventRef ref)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3360 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3361 EventMouseButton result = kEventMouseButtonPrimary;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3362 GetEventParameter (ref, kEventParamMouseButton, typeMouseButton, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3363 sizeof (EventMouseButton), NULL, &result);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3364 switch (result)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3365 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3366 case kEventMouseButtonPrimary:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3367 if (NILP (Vmac_emulate_three_button_mouse))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3368 return 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3369 else {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3370 UInt32 mods = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3371 GetEventParameter (ref, kEventParamKeyModifiers, typeUInt32, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3372 sizeof (UInt32), NULL, &mods);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3373 return mac_get_emulated_btn(mods);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3374 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3375 case kEventMouseButtonSecondary:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3376 return mac_wheel_button_is_mouse_2 ? 2 : 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3377 case kEventMouseButtonTertiary:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3378 case 4: /* 4 is the number for the mouse wheel button */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3379 return mac_wheel_button_is_mouse_2 ? 1 : 2;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3380 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3381 return 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3382 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3383 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3384
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3385 /* Normally, ConvertEventRefToEventRecord will correctly handle all
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3386 events. However the click of the mouse wheel is not converted to a
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3387 mouseDown or mouseUp event. Likewise for dead key events. This
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3388 calls ConvertEventRefToEventRecord, but then checks to see if it is
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3389 a mouse up/down, or a dead key Carbon event that has not been
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3390 converted, and if so, converts it by hand (to be picked up in the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3391 XTread_socket loop). */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3392 static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3393 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3394 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3395 Boolean result = ConvertEventRefToEventRecord (eventRef, eventRec);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3396 EventKind action;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3397
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3398 if (result)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3399 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3400
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3401 switch (GetEventClass (eventRef))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3402 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3403 case kEventClassMouse:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3404 switch (GetEventKind (eventRef))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3405 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3406 case kEventMouseDown:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3407 eventRec->what = mouseDown;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3408 result = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3409 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3410
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3411 case kEventMouseUp:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3412 eventRec->what = mouseUp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3413 result = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3414 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3415
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3416 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3417 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3418 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3419 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3420
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3421 case kEventClassKeyboard:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3422 switch (GetEventKind (eventRef))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3423 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3424 case kEventRawKeyDown:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3425 action = keyDown;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3426 goto keystroke_common;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3427 case kEventRawKeyRepeat:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3428 action = autoKey;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3429 goto keystroke_common;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3430 case kEventRawKeyUp:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3431 action = keyUp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3432 keystroke_common:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3433 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3434 unsigned char char_codes;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3435 UInt32 key_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3436
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3437 err = GetEventParameter (eventRef, kEventParamKeyMacCharCodes,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3438 typeChar, NULL, sizeof (char),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3439 NULL, &char_codes);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3440 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3441 err = GetEventParameter (eventRef, kEventParamKeyCode,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3442 typeUInt32, NULL, sizeof (UInt32),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3443 NULL, &key_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3444 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3445 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3446 eventRec->what = action;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3447 eventRec->message = char_codes | ((key_code & 0xff) << 8);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3448 result = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3449 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3450 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3451 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3452
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3453 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3454 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3455 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3456 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3457
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3458 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3459 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3460 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3461
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3462 if (result)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3463 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3464 /* Need where and when. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3465 UInt32 mods = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3466
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3467 GetEventParameter (eventRef, kEventParamMouseLocation, typeQDPoint,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3468 NULL, sizeof (Point), NULL, &eventRec->where);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3469 /* Use two step process because new event modifiers are 32-bit
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3470 and old are 16-bit. Currently, only loss is NumLock & Fn. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3471 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3472 NULL, sizeof (UInt32), NULL, &mods);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3473 eventRec->modifiers = mods;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3474
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3475 eventRec->when = EventTimeToTicks (GetEventTime (eventRef));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3476 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3477
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3478 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3479 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3480 #endif /* TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3481
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3482 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3483 static RgnHandle mouse_region = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3484
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3485 Boolean
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3486 mac_wait_next_event (er, sleep_time, dequeue)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3487 EventRecord *er;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3488 UInt32 sleep_time;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3489 Boolean dequeue;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3490 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3491 static EventRecord er_buf = {nullEvent};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3492 UInt32 target_tick, current_tick;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3493 EventMask event_mask;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3494
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3495 if (mouse_region == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3496 mouse_region = NewRgn ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3497
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3498 event_mask = everyEvent;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3499 if (!mac_ready_for_apple_events)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3500 event_mask -= highLevelEventMask;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3501
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3502 current_tick = TickCount ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3503 target_tick = current_tick + sleep_time;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3504
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3505 if (er_buf.what == nullEvent)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3506 while (!WaitNextEvent (event_mask, &er_buf,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3507 target_tick - current_tick, mouse_region))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3508 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3509 current_tick = TickCount ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3510 if (target_tick <= current_tick)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3511 return false;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3512 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3513
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3514 *er = er_buf;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3515 if (dequeue)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3516 er_buf.what = nullEvent;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3517 return true;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3518 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3519 #endif /* not TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3520
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3521 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3522 OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3523 mac_post_mouse_moved_event ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3524 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3525 EventRef event = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3526 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3527
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3528 err = CreateEvent (NULL, kEventClassMouse, kEventMouseMoved, 0,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3529 kEventAttributeNone, &event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3530 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3531 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3532 Point mouse_pos;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3533
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3534 GetGlobalMouse (&mouse_pos);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3535 err = SetEventParameter (event, kEventParamMouseLocation, typeQDPoint,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3536 sizeof (Point), &mouse_pos);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3537 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3538 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3539 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3540 UInt32 modifiers = GetCurrentKeyModifiers ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3541
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3542 err = SetEventParameter (event, kEventParamKeyModifiers, typeUInt32,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3543 sizeof (UInt32), &modifiers);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3544 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3545 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3546 err = PostEventToQueue (GetCurrentEventQueue (), event,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3547 kEventPriorityStandard);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3548 if (event)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3549 ReleaseEvent (event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3550
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3551 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3552 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3553 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3554
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3555 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3556 /* Run the current run loop in the default mode until some input
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3557 happens or TIMEOUT seconds passes unless it is negative. Return
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3558 true if timeout occurs first. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3559
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3560 Boolean
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3561 mac_run_loop_run_once (timeout)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3562 EventTimeout timeout;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3563 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3564 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3565 mac_prepare_for_quickdraw (NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3566 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3567 return (CFRunLoopRunInMode (kCFRunLoopDefaultMode,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3568 timeout >= 0 ? timeout : 100000, true)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3569 == kCFRunLoopRunTimedOut);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3570 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3571 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3572
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3573 /* Emacs calls this whenever it wants to read an input event from the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3574 user. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3575
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3576 int
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3577 XTread_socket (sd, expected, hold_quit)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3578 int sd, expected;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3579 struct input_event *hold_quit;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3580 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3581 struct input_event inev;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3582 int count = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3583 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3584 EventRef eventRef;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3585 EventTargetRef toolbox_dispatcher;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3586 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3587 EventRecord er;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3588 struct mac_display_info *dpyinfo = &one_mac_display_info;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3589
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3590 if (interrupt_input_blocked)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3591 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3592 interrupt_input_pending = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3593 return -1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3594 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3595
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3596 interrupt_input_pending = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3597 BLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3598
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3599 /* So people can tell when we have read the available input. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3600 input_signal_count++;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3601
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3602 ++handling_signal;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3603
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3604 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3605 toolbox_dispatcher = GetEventDispatcherTarget ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3606
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3607 while (
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3608 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3609 mac_prepare_for_quickdraw (NULL),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3610 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3611 !ReceiveNextEvent (0, NULL, kEventDurationNoWait,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3612 kEventRemoveFromQueue, &eventRef))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3613 #else /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3614 while (mac_wait_next_event (&er, 0, true))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3615 #endif /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3616 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3617 int do_help = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3618 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3619 unsigned long timestamp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3620
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3621 EVENT_INIT (inev);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3622 inev.kind = NO_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3623 inev.arg = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3624
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3625 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3626 timestamp = GetEventTime (eventRef) / kEventDurationMillisecond;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3627
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3628 if (!mac_convert_event_ref (eventRef, &er))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3629 goto OTHER;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3630 #else /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3631 timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3632 #endif /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3633
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3634 switch (er.what)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3635 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3636 case mouseDown:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3637 case mouseUp:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3638 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3639 WindowRef window_ptr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3640 ControlPartCode part_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3641 int tool_bar_p = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3642
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3643 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3644 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3645
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3646 /* This is needed to send mouse events like aqua window
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3647 buttons to the correct handler. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3648 read_socket_inev = &inev;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3649 err = SendEventToEventTarget (eventRef, toolbox_dispatcher);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3650 read_socket_inev = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3651 if (err != eventNotHandledErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3652 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3653 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3654 last_mouse_glyph_frame = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3655
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3656 if (dpyinfo->grabbed && last_mouse_frame
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3657 && FRAME_LIVE_P (last_mouse_frame))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3658 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3659 window_ptr = FRAME_MAC_WINDOW (last_mouse_frame);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3660 part_code = inContent;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3661 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3662 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3663 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3664 part_code = FindWindow (er.where, &window_ptr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3665 if (tip_window && window_ptr == tip_window)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3666 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3667 HideWindow (tip_window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3668 part_code = FindWindow (er.where, &window_ptr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3669 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3670 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3671
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3672 if (er.what != mouseDown
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3673 && (part_code != inContent || dpyinfo->grabbed == 0))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3674 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3675
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3676 switch (part_code)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3677 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3678 case inMenuBar:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3679 f = mac_focus_frame (dpyinfo);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3680 saved_menu_event_location = er.where;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3681 inev.kind = MENU_BAR_ACTIVATE_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3682 XSETFRAME (inev.frame_or_window, f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3683 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3684
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3685 case inContent:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3686 if (
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3687 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3688 FrontNonFloatingWindow ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3689 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3690 FrontWindow ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3691 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3692 != window_ptr
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3693 || (mac_window_to_frame (window_ptr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3694 != dpyinfo->x_focus_frame))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3695 SelectWindow (window_ptr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3696 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3697 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3698 ControlPartCode control_part_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3699 ControlRef ch;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3700 Point mouse_loc;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3701 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3702 ControlKind control_kind;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3703 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3704
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3705 f = mac_window_to_frame (window_ptr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3706 /* convert to local coordinates of new window */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3707 mouse_loc.h = (er.where.h
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3708 - (f->left_pos
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3709 + FRAME_OUTER_TO_INNER_DIFF_X (f)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3710 mouse_loc.v = (er.where.v
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3711 - (f->top_pos
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3712 + FRAME_OUTER_TO_INNER_DIFF_Y (f)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3713 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3714 ch = FindControlUnderMouse (mouse_loc, window_ptr,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3715 &control_part_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3716 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3717 if (ch)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3718 GetControlKind (ch, &control_kind);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3719 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3720 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3721 control_part_code = FindControl (mouse_loc, window_ptr,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3722 &ch);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3723 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3724
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3725 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3726 inev.code = mac_get_mouse_btn (eventRef);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3727 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3728 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3729 inev.code = mac_get_emulated_btn (er.modifiers);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3730 inev.modifiers = mac_to_emacs_modifiers (er.modifiers, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3731 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3732 XSETINT (inev.x, mouse_loc.h);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3733 XSETINT (inev.y, mouse_loc.v);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3734
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3735 if ((dpyinfo->grabbed && tracked_scroll_bar)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3736 || (ch != 0
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3737 #ifndef USE_TOOLKIT_SCROLL_BARS
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3738 /* control_part_code becomes kControlNoPart if
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3739 a progress indicator is clicked. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3740 && control_part_code != kControlNoPart
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3741 #else /* USE_TOOLKIT_SCROLL_BARS */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3742 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3743 && control_kind.kind == kControlKindScrollBar
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3744 #endif /* MAC_OSX */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3745 #endif /* USE_TOOLKIT_SCROLL_BARS */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3746 ))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3747 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3748 struct scroll_bar *bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3749
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3750 if (dpyinfo->grabbed && tracked_scroll_bar)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3751 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3752 bar = tracked_scroll_bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3753 #ifndef USE_TOOLKIT_SCROLL_BARS
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3754 control_part_code = kControlIndicatorPart;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3755 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3756 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3757 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3758 bar = (struct scroll_bar *) GetControlReference (ch);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3759 #ifdef USE_TOOLKIT_SCROLL_BARS
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3760 /* Make the "Ctrl-Mouse-2 splits window" work
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3761 for toolkit scroll bars. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3762 if (inev.modifiers & ctrl_modifier)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3763 x_scroll_bar_handle_click (bar, control_part_code,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3764 &er, &inev);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3765 else if (er.what == mouseDown)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3766 x_scroll_bar_handle_press (bar, control_part_code,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3767 mouse_loc, &inev);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3768 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3769 x_scroll_bar_handle_release (bar, &inev);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3770 #else /* not USE_TOOLKIT_SCROLL_BARS */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3771 x_scroll_bar_handle_click (bar, control_part_code,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3772 &er, &inev);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3773 if (er.what == mouseDown
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3774 && control_part_code == kControlIndicatorPart)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3775 tracked_scroll_bar = bar;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3776 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3777 tracked_scroll_bar = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3778 #endif /* not USE_TOOLKIT_SCROLL_BARS */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3779 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3780 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3781 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3782 Lisp_Object window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3783 int x = mouse_loc.h;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3784 int y = mouse_loc.v;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3785
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3786 window = window_from_coordinates (f, x, y, 0, 0, 0, 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3787 if (EQ (window, f->tool_bar_window))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3788 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3789 if (er.what == mouseDown)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3790 handle_tool_bar_click (f, x, y, 1, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3791 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3792 handle_tool_bar_click (f, x, y, 0,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3793 inev.modifiers);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3794 tool_bar_p = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3795 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3796 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3797 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3798 XSETFRAME (inev.frame_or_window, f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3799 inev.kind = MOUSE_CLICK_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3800 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3801 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3802
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3803 if (er.what == mouseDown)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3804 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3805 dpyinfo->grabbed |= (1 << inev.code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3806 last_mouse_frame = f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3807
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3808 if (!tool_bar_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3809 last_tool_bar_item = -1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3810 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3811 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3812 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3813 if ((dpyinfo->grabbed & (1 << inev.code)) == 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3814 /* If a button is released though it was not
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3815 previously pressed, that would be because
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3816 of multi-button emulation. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3817 dpyinfo->grabbed = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3818 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3819 dpyinfo->grabbed &= ~(1 << inev.code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3820 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3821
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3822 /* Ignore any mouse motion that happened before
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3823 this event; any subsequent mouse-movement Emacs
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3824 events should reflect only motion after the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3825 ButtonPress. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3826 if (f != 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3827 f->mouse_moved = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3828
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3829 #ifdef USE_TOOLKIT_SCROLL_BARS
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3830 if (inev.kind == MOUSE_CLICK_EVENT
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3831 || (inev.kind == SCROLL_BAR_CLICK_EVENT
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3832 && (inev.modifiers & ctrl_modifier)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3833 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3834 switch (er.what)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3835 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3836 case mouseDown:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3837 inev.modifiers |= down_modifier;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3838 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3839 case mouseUp:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3840 inev.modifiers |= up_modifier;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3841 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3842 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3843 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3844 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3845
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3846 case inDrag:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3847 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3848 case inProxyIcon:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3849 if (IsWindowPathSelectClick (window_ptr, &er))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3850 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3851 WindowPathSelect (window_ptr, NULL, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3852 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3853 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3854 if (part_code == inProxyIcon
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3855 && (TrackWindowProxyDrag (window_ptr, er.where)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3856 != errUserWantsToDragWindow))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3857 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3858 DragWindow (window_ptr, er.where, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3859 #else /* not TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3860 DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3861 /* Update the frame parameters. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3862 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3863 struct frame *f = mac_window_to_frame (window_ptr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3864
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3865 if (f && !f->async_iconified)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3866 mac_handle_origin_change (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3867 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3868 #endif /* not TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3869 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3870
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3871 case inGoAway:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3872 if (TrackGoAway (window_ptr, er.where))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3873 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3874 inev.kind = DELETE_WINDOW_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3875 XSETFRAME (inev.frame_or_window,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3876 mac_window_to_frame (window_ptr));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3877 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3878 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3879
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3880 /* window resize handling added --ben */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3881 case inGrow:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3882 do_grow_window (window_ptr, &er);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3883 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3884
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3885 /* window zoom handling added --ben */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3886 case inZoomIn:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3887 case inZoomOut:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3888 if (TrackBox (window_ptr, er.where, part_code))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3889 do_zoom_window (window_ptr, part_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3890 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3891
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3892 #if USE_MAC_TOOLBAR
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3893 case inStructure:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3894 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3895 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3896 HIViewRef ch;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3897
|
80517
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
3898 if (FrontNonFloatingWindow () != window_ptr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
3899 SelectWindow (window_ptr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
3900
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3901 err = HIViewGetViewForMouseEvent (HIViewGetRoot (window_ptr),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3902 eventRef, &ch);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3903 /* This doesn't work on Mac OS X 10.2. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3904 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3905 HIViewClick (ch, eventRef);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3906 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3907 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3908 #endif /* USE_MAC_TOOLBAR */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3909
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3910 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3911 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3912 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3913 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3914 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3915
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3916 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3917 case updateEvt:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3918 do_window_update ((WindowRef) er.message);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3919 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3920 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3921
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3922 case osEvt:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3923 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3924 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3925 != eventNotHandledErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3926 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3927 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3928 switch ((er.message >> 24) & 0x000000FF)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3929 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3930 #if USE_MAC_TSM
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3931 case suspendResumeMessage:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3932 if (er.message & resumeFlag)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3933 mac_tsm_resume ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3934 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3935 mac_tsm_suspend ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3936 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3937 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3938
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3939 case mouseMovedMessage:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3940 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3941 SetRectRgn (mouse_region, er.where.h, er.where.v,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3942 er.where.h + 1, er.where.v + 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3943 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3944 previous_help_echo_string = help_echo_string;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3945 help_echo_string = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3946
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3947 if (dpyinfo->grabbed && last_mouse_frame
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3948 && FRAME_LIVE_P (last_mouse_frame))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3949 f = last_mouse_frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3950 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3951 f = dpyinfo->x_focus_frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3952
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3953 if (dpyinfo->mouse_face_hidden)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3954 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3955 dpyinfo->mouse_face_hidden = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3956 clear_mouse_face (dpyinfo);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3957 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3958
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3959 if (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3960 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3961 WindowRef wp = FRAME_MAC_WINDOW (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3962 Point mouse_pos;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3963
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3964 mouse_pos.h = (er.where.h
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3965 - (f->left_pos
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3966 + FRAME_OUTER_TO_INNER_DIFF_X (f)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3967 mouse_pos.v = (er.where.v
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3968 - (f->top_pos
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3969 + FRAME_OUTER_TO_INNER_DIFF_Y (f)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3970 if (dpyinfo->grabbed && tracked_scroll_bar)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3971 #ifdef USE_TOOLKIT_SCROLL_BARS
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3972 x_scroll_bar_handle_drag (wp, tracked_scroll_bar,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3973 mouse_pos, &inev);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3974 #else /* not USE_TOOLKIT_SCROLL_BARS */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3975 x_scroll_bar_note_movement (tracked_scroll_bar,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3976 mouse_pos.v
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3977 - XINT (tracked_scroll_bar->top),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3978 er.when * (1000 / 60));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3979 #endif /* not USE_TOOLKIT_SCROLL_BARS */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3980 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3981 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3982 /* Generate SELECT_WINDOW_EVENTs when needed. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3983 if (!NILP (Vmouse_autoselect_window))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3984 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3985 Lisp_Object window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3986
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3987 window = window_from_coordinates (f,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3988 mouse_pos.h,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3989 mouse_pos.v,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3990 0, 0, 0, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3991
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3992 /* Window will be selected only when it is
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3993 not selected now and last mouse movement
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3994 event was not in it. Minibuffer window
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3995 will be selected only when it is active. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3996 if (WINDOWP (window)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3997 && !EQ (window, last_window)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3998 && !EQ (window, selected_window)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
3999 /* For click-to-focus window managers
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4000 create event iff we don't leave the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4001 selected frame. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4002 && (focus_follows_mouse
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4003 || (EQ (XWINDOW (window)->frame,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4004 XWINDOW (selected_window)->frame))))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4005 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4006 inev.kind = SELECT_WINDOW_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4007 inev.frame_or_window = window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4008 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4009
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4010 last_window=window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4011 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4012 if (!note_mouse_movement (f, &mouse_pos))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4013 help_echo_string = previous_help_echo_string;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4014 #if USE_MAC_TOOLBAR
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4015 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4016 mac_tool_bar_note_mouse_movement (f, eventRef);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4017 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4018 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4019 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4020
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4021 /* If the contents of the global variable
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4022 help_echo_string has changed, generate a
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4023 HELP_EVENT. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4024 if (!NILP (help_echo_string) || !NILP (previous_help_echo_string))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4025 do_help = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4026 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4027 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4028 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4029
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4030 case activateEvt:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4031 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4032 WindowRef window_ptr = (WindowRef) er.message;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4033 OSErr err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4034 ControlRef root_control;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4035
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4036 if (window_ptr == tip_window)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4037 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4038 HideWindow (tip_window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4039 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4040 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4041
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4042 if (!is_emacs_window (window_ptr))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4043 goto OTHER;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4044
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4045 f = mac_window_to_frame (window_ptr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4046
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4047 if ((er.modifiers & activeFlag) != 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4048 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4049 /* A window has been activated */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4050 Point mouse_loc;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4051
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4052 err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4053 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4054 ActivateControl (root_control);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4055
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4056 x_detect_focus_change (dpyinfo, &er, &inev);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4057
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4058 mouse_loc.h = (er.where.h
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4059 - (f->left_pos
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4060 + FRAME_OUTER_TO_INNER_DIFF_X (f)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4061 mouse_loc.v = (er.where.v
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4062 - (f->top_pos
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4063 + FRAME_OUTER_TO_INNER_DIFF_Y (f)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4064 /* Window-activated event counts as mouse movement,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4065 so update things that depend on mouse position. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4066 note_mouse_movement (f, &mouse_loc);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4067 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4068 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4069 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4070 /* A window has been deactivated */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4071 err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4072 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4073 DeactivateControl (root_control);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4074
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4075 #ifdef USE_TOOLKIT_SCROLL_BARS
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4076 if (dpyinfo->grabbed && tracked_scroll_bar)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4077 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4078 struct input_event event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4079
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4080 EVENT_INIT (event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4081 event.kind = NO_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4082 x_scroll_bar_handle_release (tracked_scroll_bar, &event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4083 if (event.kind != NO_EVENT)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4084 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4085 event.timestamp = timestamp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4086 kbd_buffer_store_event_hold (&event, hold_quit);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4087 count++;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4088 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4089 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4090 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4091 dpyinfo->grabbed = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4092
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4093 x_detect_focus_change (dpyinfo, &er, &inev);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4094
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4095 if (f == dpyinfo->mouse_face_mouse_frame)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4096 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4097 /* If we move outside the frame, then we're
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4098 certainly no longer on any text in the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4099 frame. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4100 clear_mouse_face (dpyinfo);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4101 dpyinfo->mouse_face_mouse_frame = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4102 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4103
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4104 /* Generate a nil HELP_EVENT to cancel a help-echo.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4105 Do it only if there's something to cancel.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4106 Otherwise, the startup message is cleared when the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4107 mouse leaves the frame. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4108 if (any_help_event_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4109 do_help = -1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4110 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4111 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4112 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4113
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4114 case keyDown:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4115 case keyUp:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4116 case autoKey:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4117 ObscureCursor ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4118
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4119 f = mac_focus_frame (dpyinfo);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4120 XSETFRAME (inev.frame_or_window, f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4121
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4122 /* If mouse-highlight is an integer, input clears out mouse
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4123 highlighting. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4124 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4125 && !EQ (f->tool_bar_window, dpyinfo->mouse_face_window))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4126 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4127 clear_mouse_face (dpyinfo);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4128 dpyinfo->mouse_face_hidden = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4129 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4130
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4131 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4132 UInt32 modifiers = er.modifiers, mapped_modifiers;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4133 UInt32 key_code = (er.message & keyCodeMask) >> 8;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4134
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4135 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4136 GetEventParameter (eventRef, kEventParamKeyModifiers,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4137 typeUInt32, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4138 sizeof (UInt32), NULL, &modifiers);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4139 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4140 mapped_modifiers = mac_mapped_modifiers (modifiers, key_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4141
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4142 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4143 if (!(mapped_modifiers
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4144 & ~(mac_pass_command_to_system ? cmdKey : 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4145 & ~(mac_pass_control_to_system ? controlKey : 0)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4146 goto OTHER;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4147 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4148 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4149 if (er.what != keyUp)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4150 do_keystroke (er.what, er.message & charCodeMask,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4151 key_code, modifiers, timestamp, &inev);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4152 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4153 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4154
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4155 case kHighLevelEvent:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4156 AEProcessAppleEvent (&er);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4157 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4158
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4159 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4160 OTHER:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4161 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4162 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4163 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4164
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4165 read_socket_inev = &inev;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4166 err = SendEventToEventTarget (eventRef, toolbox_dispatcher);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4167 read_socket_inev = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4168 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4169 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4170 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4171 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4172 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4173 ReleaseEvent (eventRef);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4174 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4175
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4176 if (inev.kind != NO_EVENT)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4177 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4178 inev.timestamp = timestamp;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4179 kbd_buffer_store_event_hold (&inev, hold_quit);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4180 count++;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4181 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4182
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4183 if (do_help
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4184 && !(hold_quit && hold_quit->kind != NO_EVENT))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4185 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4186 Lisp_Object frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4187
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4188 if (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4189 XSETFRAME (frame, f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4190 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4191 frame = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4192
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4193 if (do_help > 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4194 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4195 any_help_event_p = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4196 gen_help_event (help_echo_string, frame, help_echo_window,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4197 help_echo_object, help_echo_pos);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4198 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4199 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4200 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4201 help_echo_string = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4202 gen_help_event (Qnil, frame, Qnil, Qnil, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4203 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4204 count++;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4205 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4206 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4207
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4208 /* If the focus was just given to an autoraising frame,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4209 raise it now. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4210 /* ??? This ought to be able to handle more than one such frame. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4211 if (pending_autoraise_frame)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4212 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4213 x_raise_frame (pending_autoraise_frame);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4214 pending_autoraise_frame = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4215 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4216
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4217 if (mac_screen_config_changed)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4218 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4219 mac_get_screen_info (dpyinfo);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4220 mac_screen_config_changed = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4221 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4222
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4223 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4224 /* Check which frames are still visible. We do this here because
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4225 there doesn't seem to be any direct notification from the Window
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4226 Manager that the visibility of a window has changed (at least,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4227 not in all cases). */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4228 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4229 Lisp_Object tail, frame;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4230
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4231 FOR_EACH_FRAME (tail, frame)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4232 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4233 struct frame *f = XFRAME (frame);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4234
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4235 /* The tooltip has been drawn already. Avoid the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4236 SET_FRAME_GARBAGED in mac_handle_visibility_change. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4237 if (EQ (frame, tip_frame))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4238 continue;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4239
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4240 if (FRAME_MAC_P (f))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4241 mac_handle_visibility_change (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4242 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4243 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4244 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4245
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4246 --handling_signal;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4247 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4248 return count;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4249 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4250
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4251
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4252 /***********************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4253 Busy cursor
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4254 ***********************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4255
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4256 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4257 /* Show the spinning progress indicator for the frame F. Create it if
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4258 it doesn't exist yet. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4259
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4260 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4261 mac_show_hourglass (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4262 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4263 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4264 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4265 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4266 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4267 if (!f->output_data.mac->hourglass_control)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4268 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4269 Window w = FRAME_MAC_WINDOW (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4270 Rect r;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4271 ControlRef c;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4272
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4273 GetWindowPortBounds (w, &r);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4274 r.left = r.right - HOURGLASS_WIDTH;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4275 r.bottom = r.top + HOURGLASS_HEIGHT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4276 if (CreateChasingArrowsControl (w, &r, &c) == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4277 f->output_data.mac->hourglass_control = c;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4278 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4279
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4280 if (f->output_data.mac->hourglass_control)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4281 ShowControl (f->output_data.mac->hourglass_control);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4282 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4283
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4284 /* Hide the spinning progress indicator for the frame F. Do nothing
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4285 it doesn't exist yet. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4286
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4287 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4288 mac_hide_hourglass (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4289 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4290 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4291 if (f->output_data.mac->hourglass_control)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4292 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4293 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4294 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4295 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4296 HideControl (f->output_data.mac->hourglass_control);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4297 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4298 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4299
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4300 /* Reposition the spinning progress indicator for the frame F. Do
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4301 nothing it doesn't exist yet. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4302
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4303 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4304 mac_reposition_hourglass (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4305 struct frame *f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4306 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4307 if (f->output_data.mac->hourglass_control)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4308 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4309 #if USE_CG_DRAWING
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4310 mac_prepare_for_quickdraw (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4311 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4312 MoveControl (f->output_data.mac->hourglass_control,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4313 FRAME_PIXEL_WIDTH (f) - HOURGLASS_WIDTH, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4314 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4315 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4316 #endif /* TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4317
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4318
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4319 /***********************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4320 File selection dialog
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4321 ***********************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4322
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4323 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4324 extern Lisp_Object Qfile_name_history;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4325
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4326 static pascal void mac_nav_event_callback P_ ((NavEventCallbackMessage,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4327 NavCBRecPtr, void *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4328
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4329 /* The actual implementation of Fx_file_dialog. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4330
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4331 Lisp_Object
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4332 mac_file_dialog (prompt, dir, default_filename, mustmatch, only_dir_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4333 Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4334 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4335 Lisp_Object file = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4336 int count = SPECPDL_INDEX ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4337 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4338 char filename[MAXPATHLEN];
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4339 static NavEventUPP mac_nav_event_callbackUPP = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4340
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4341 check_mac ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4342
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4343 GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4344 CHECK_STRING (prompt);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4345 CHECK_STRING (dir);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4346
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4347 /* Create the dialog with PROMPT as title, using DIR as initial
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4348 directory and using "*" as pattern. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4349 dir = Fexpand_file_name (dir, Qnil);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4350
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4351 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4352 OSStatus status;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4353 NavDialogCreationOptions options;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4354 NavDialogRef dialogRef;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4355 NavTypeListHandle fileTypes = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4356 NavUserAction userAction;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4357 CFStringRef message=NULL, saveName = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4358
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4359 BLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4360 /* No need for a callback function because we are modal */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4361 NavGetDefaultDialogCreationOptions(&options);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4362 options.modality = kWindowModalityAppModal;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4363 options.location.h = options.location.v = -1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4364 options.optionFlags = kNavDefaultNavDlogOptions;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4365 options.optionFlags |= kNavAllFilesInPopup; /* All files allowed */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4366 options.optionFlags |= kNavSelectAllReadableItem;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4367 options.optionFlags &= ~kNavAllowMultipleFiles;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4368 if (!NILP(prompt))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4369 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4370 message = cfstring_create_with_string (prompt);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4371 options.message = message;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4372 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4373 /* Don't set the application, let it use default.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4374 options.clientName = CFSTR ("Emacs");
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4375 */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4376
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4377 if (mac_nav_event_callbackUPP == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4378 mac_nav_event_callbackUPP = NewNavEventUPP (mac_nav_event_callback);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4379
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4380 if (!NILP (only_dir_p))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4381 status = NavCreateChooseFolderDialog(&options, mac_nav_event_callbackUPP,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4382 NULL, NULL, &dialogRef);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4383 else if (NILP (mustmatch))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4384 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4385 /* This is a save dialog */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4386 options.optionFlags |= kNavDontConfirmReplacement;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4387 options.actionButtonLabel = CFSTR ("Ok");
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4388 options.windowTitle = CFSTR ("Enter name");
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4389
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4390 if (STRINGP (default_filename))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4391 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4392 Lisp_Object utf8 = ENCODE_UTF_8 (default_filename);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4393 char *begPtr = SDATA(utf8);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4394 char *filePtr = begPtr + SBYTES(utf8);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4395 while (filePtr != begPtr && !IS_DIRECTORY_SEP(filePtr[-1]))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4396 filePtr--;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4397 saveName = cfstring_create_with_utf8_cstring (filePtr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4398 options.saveFileName = saveName;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4399 options.optionFlags |= kNavSelectDefaultLocation;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4400 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4401 status = NavCreatePutFileDialog(&options,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4402 'TEXT', kNavGenericSignature,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4403 mac_nav_event_callbackUPP, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4404 &dialogRef);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4405 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4406 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4407 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4408 /* This is an open dialog*/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4409 status = NavCreateChooseFileDialog(&options, fileTypes,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4410 mac_nav_event_callbackUPP, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4411 NULL, NULL, &dialogRef);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4412 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4413
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4414 /* Set the default location and continue*/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4415 if (status == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4416 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4417 Lisp_Object encoded_dir = ENCODE_FILE (dir);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4418 AEDesc defLocAed;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4419
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4420 status = AECreateDesc (TYPE_FILE_NAME, SDATA (encoded_dir),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4421 SBYTES (encoded_dir), &defLocAed);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4422 if (status == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4423 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4424 NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4425 AEDisposeDesc(&defLocAed);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4426 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4427 status = NavDialogRun(dialogRef);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4428 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4429
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4430 if (saveName) CFRelease(saveName);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4431 if (message) CFRelease(message);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4432
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4433 if (status == noErr) {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4434 userAction = NavDialogGetUserAction(dialogRef);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4435 switch (userAction)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4436 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4437 case kNavUserActionNone:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4438 case kNavUserActionCancel:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4439 break; /* Treat cancel like C-g */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4440 case kNavUserActionOpen:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4441 case kNavUserActionChoose:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4442 case kNavUserActionSaveAs:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4443 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4444 NavReplyRecord reply;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4445 Size len;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4446
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4447 status = NavDialogGetReply(dialogRef, &reply);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4448 if (status != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4449 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4450 status = AEGetNthPtr (&reply.selection, 1, TYPE_FILE_NAME,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4451 NULL, NULL, filename,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4452 sizeof (filename) - 1, &len);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4453 if (status == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4454 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4455 len = min (len, sizeof (filename) - 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4456 filename[len] = '\0';
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4457 if (reply.saveFileName)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4458 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4459 /* If it was a saved file, we need to add the file name */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4460 if (len && len < sizeof (filename) - 1
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4461 && filename[len-1] != '/')
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4462 filename[len++] = '/';
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4463 CFStringGetCString(reply.saveFileName, filename+len,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4464 sizeof (filename) - len,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4465 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4466 kCFStringEncodingUTF8
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4467 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4468 CFStringGetSystemEncoding ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4469 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4470 );
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4471 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4472 file = DECODE_FILE (make_unibyte_string (filename,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4473 strlen (filename)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4474 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4475 NavDisposeReply(&reply);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4476 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4477 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4478 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4479 NavDialogDispose(dialogRef);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4480 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4481 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4482 else {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4483 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4484 /* Fall back on minibuffer if there was a problem */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4485 file = Fcompleting_read (prompt, intern ("read-file-name-internal"),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4486 dir, mustmatch, dir, Qfile_name_history,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4487 default_filename, Qnil);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4488 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4489 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4490
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4491 UNGCPRO;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4492
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4493 /* Make "Cancel" equivalent to C-g. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4494 if (NILP (file))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4495 Fsignal (Qquit, Qnil);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4496
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4497 return unbind_to (count, file);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4498 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4499
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4500 /* Need to register some event callback function for enabling drag and
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4501 drop in Navigation Service dialogs. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4502 static pascal void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4503 mac_nav_event_callback (selector, parms, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4504 NavEventCallbackMessage selector;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4505 NavCBRecPtr parms;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4506 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4507 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4508 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4509 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4510
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4511
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4512 /************************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4513 Menu
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4514 ************************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4515
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4516 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4517 #include <MacTypes.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4518 #include <Menus.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4519 #include <Quickdraw.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4520 #include <ToolUtils.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4521 #include <Fonts.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4522 #include <Controls.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4523 #include <Windows.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4524 #include <Events.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4525 #if defined (__MRC__) || (__MSL__ >= 0x6000)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4526 #include <ControlDefinitions.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4527 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4528 #endif /* not TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4529
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4530 extern int menu_item_selection;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4531 extern int popup_activated_flag;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4532 extern int name_is_separator P_ ((const char *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4533 extern void find_and_call_menu_selection P_ ((FRAME_PTR, int, Lisp_Object,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4534 void *));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4535 extern void set_frame_menubar P_ ((FRAME_PTR, int, int));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4536
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4537 enum mac_menu_kind { /* Menu ID range */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4538 MAC_MENU_APPLE, /* 0 (Reserved by Apple) */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4539 MAC_MENU_MENU_BAR, /* 1 .. 233 */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4540 MAC_MENU_M_APPLE, /* 234 (== M_APPLE) */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4541 MAC_MENU_POPUP, /* 235 */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4542 MAC_MENU_DRIVER, /* 236 .. 255 (Reserved) */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4543 MAC_MENU_MENU_BAR_SUB, /* 256 .. 16383 */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4544 MAC_MENU_POPUP_SUB, /* 16384 .. 32767 */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4545 MAC_MENU_END /* 32768 */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4546 };
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4547
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4548 static const int min_menu_id[] = {0, 1, 234, 235, 236, 256, 16384, 32768};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4549
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4550 static int fill_menu P_ ((MenuRef, widget_value *, enum mac_menu_kind, int));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4551 static void dispose_menus P_ ((enum mac_menu_kind, int));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4552
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4553 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4554 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4555 do_apple_menu (SInt16 menu_item)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4556 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4557 Str255 item_name;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4558 SInt16 da_driver_refnum;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4559
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4560 if (menu_item == I_ABOUT)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4561 NoteAlert (ABOUT_ALERT_ID, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4562 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4563 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4564 GetMenuItemText (GetMenuRef (M_APPLE), menu_item, item_name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4565 da_driver_refnum = OpenDeskAcc (item_name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4566 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4567 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4568 #endif /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4569
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4570 /* Activate the menu bar of frame F.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4571 This is called from keyboard.c when it gets the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4572 MENU_BAR_ACTIVATE_EVENT out of the Emacs event queue.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4573
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4574 To activate the menu bar, we use the button-press event location
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4575 that was saved in saved_menu_event_location.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4576
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4577 But first we recompute the menu bar contents (the whole tree).
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4578
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4579 The reason for saving the button event until here, instead of
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4580 passing it to the toolkit right away, is that we can safely
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4581 execute Lisp code. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4582
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4583 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4584 x_activate_menubar (f)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4585 FRAME_PTR f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4586 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4587 SInt32 menu_choice;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4588 SInt16 menu_id, menu_item;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4589
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4590 set_frame_menubar (f, 0, 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4591 BLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4592
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4593 popup_activated_flag = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4594 menu_choice = MenuSelect (saved_menu_event_location);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4595 popup_activated_flag = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4596 menu_id = HiWord (menu_choice);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4597 menu_item = LoWord (menu_choice);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4598
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4599 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4600 if (menu_id == min_menu_id[MAC_MENU_M_APPLE])
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4601 do_apple_menu (menu_item);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4602 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4603 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4604 if (menu_id)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4605 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4606 MenuRef menu = GetMenuRef (menu_id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4607
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4608 if (menu)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4609 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4610 UInt32 refcon;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4611
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4612 GetMenuItemRefCon (menu, menu_item, &refcon);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4613 find_and_call_menu_selection (f, f->menu_bar_items_used,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4614 f->menu_bar_vector, (void *) refcon);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4615 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4616 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4617
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4618 HiliteMenu (0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4619
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4620 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4621 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4622
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4623 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4624 extern Lisp_Object Vshow_help_function;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4625
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4626 static Lisp_Object
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4627 restore_show_help_function (old_show_help_function)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4628 Lisp_Object old_show_help_function;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4629 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4630 Vshow_help_function = old_show_help_function;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4631
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4632 return Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4633 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4634
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4635 static pascal OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4636 menu_target_item_handler (next_handler, event, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4637 EventHandlerCallRef next_handler;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4638 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4639 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4640 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4641 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4642 MenuRef menu;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4643 MenuItemIndex menu_item;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4644 Lisp_Object help;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4645 GrafPtr port;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4646 int specpdl_count = SPECPDL_INDEX ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4647
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4648 /* Don't be bothered with the overflowed toolbar items menu. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4649 if (!popup_activated ())
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4650 return eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4651
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4652 err = GetEventParameter (event, kEventParamDirectObject, typeMenuRef,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4653 NULL, sizeof (MenuRef), NULL, &menu);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4654 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4655 err = GetEventParameter (event, kEventParamMenuItemIndex,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4656 typeMenuItemIndex, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4657 sizeof (MenuItemIndex), NULL, &menu_item);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4658 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4659 err = GetMenuItemProperty (menu, menu_item,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4660 MAC_EMACS_CREATOR_CODE, 'help',
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4661 sizeof (Lisp_Object), NULL, &help);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4662 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4663 help = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4664
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4665 /* Temporarily bind Vshow_help_function to Qnil because we don't
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4666 want tooltips during menu tracking. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4667 record_unwind_protect (restore_show_help_function, Vshow_help_function);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4668 Vshow_help_function = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4669 GetPort (&port);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4670 show_help_echo (help, Qnil, Qnil, Qnil, 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4671 SetPort (port);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4672 unbind_to (specpdl_count, Qnil);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4673
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4674 return err == noErr ? noErr : eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4675 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4676
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4677 /* Showing help echo string during menu tracking. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4678
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4679 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4680 install_menu_target_item_handler ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4681 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4682 static const EventTypeSpec specs[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4683 {{kEventClassMenu, kEventMenuTargetItem}};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4684
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4685 return InstallApplicationEventHandler (NewEventHandlerUPP
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4686 (menu_target_item_handler),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4687 GetEventTypeCount (specs),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4688 specs, NULL, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4689 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4690 #endif /* TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4691
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4692 /* Event handler function that pops down a menu on C-g. We can only pop
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4693 down menus if CancelMenuTracking is present (OSX 10.3 or later). */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4694
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4695 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4696 static pascal OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4697 menu_quit_handler (nextHandler, theEvent, userData)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4698 EventHandlerCallRef nextHandler;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4699 EventRef theEvent;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4700 void* userData;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4701 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4702 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4703 UInt32 keyCode;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4704 UInt32 keyModifiers;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4705
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4706 err = GetEventParameter (theEvent, kEventParamKeyCode,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4707 typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4708
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4709 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4710 err = GetEventParameter (theEvent, kEventParamKeyModifiers,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4711 typeUInt32, NULL, sizeof(UInt32),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4712 NULL, &keyModifiers);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4713
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4714 if (err == noErr && mac_quit_char_key_p (keyModifiers, keyCode))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4715 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4716 MenuRef menu = userData != 0
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4717 ? (MenuRef)userData : AcquireRootMenu ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4718
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4719 CancelMenuTracking (menu, true, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4720 if (!userData) ReleaseMenu (menu);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4721 return noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4722 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4723
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4724 return CallNextEventHandler (nextHandler, theEvent);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4725 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4726 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4727
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4728 /* Add event handler to all menus that belong to KIND so we can detect
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4729 C-g. ROOT_MENU is the root menu of the tracking session to dismiss
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4730 when C-g is detected. NULL means the menu bar. If
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4731 CancelMenuTracking isn't available, do nothing. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4732
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4733 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4734 install_menu_quit_handler (kind, root_menu)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4735 enum mac_menu_kind kind;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4736 MenuRef root_menu;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4737 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4738 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4739 static const EventTypeSpec typesList[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4740 {{kEventClassKeyboard, kEventRawKeyDown}};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4741 int id;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4742
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4743 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4744 if (CancelMenuTracking == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4745 return;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4746 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4747 for (id = min_menu_id[kind]; id < min_menu_id[kind + 1]; id++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4748 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4749 MenuRef menu = GetMenuRef (id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4750
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4751 if (menu == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4752 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4753 InstallMenuEventHandler (menu, menu_quit_handler,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4754 GetEventTypeCount (typesList),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4755 typesList, root_menu, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4756 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4757 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4758 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4759
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4760 static Lisp_Object
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4761 pop_down_menu (arg)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4762 Lisp_Object arg;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4763 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4764 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4765 FRAME_PTR f = p->pointer;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4766 MenuRef menu = GetMenuRef (min_menu_id[MAC_MENU_POPUP]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4767
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4768 BLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4769
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4770 /* Must reset this manually because the button release event is not
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4771 passed to Emacs event loop. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4772 FRAME_MAC_DISPLAY_INFO (f)->grabbed = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4773
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4774 /* delete all menus */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4775 dispose_menus (MAC_MENU_POPUP_SUB, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4776 DeleteMenu (min_menu_id[MAC_MENU_POPUP]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4777 DisposeMenu (menu);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4778
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4779 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4780
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4781 return Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4782 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4783
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4784 /* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4785 until the menu pops down. Return the selection. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4786
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4787 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4788 create_and_show_popup_menu (f, first_wv, x, y, for_click)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4789 FRAME_PTR f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4790 widget_value *first_wv;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4791 int x;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4792 int y;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4793 int for_click;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4794 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4795 int result = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4796 MenuRef menu = NewMenu (min_menu_id[MAC_MENU_POPUP], "\p");
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4797 int menu_item_choice;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4798 int specpdl_count = SPECPDL_INDEX ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4799
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4800 InsertMenu (menu, -1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4801 fill_menu (menu, first_wv->contents, MAC_MENU_POPUP_SUB,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4802 min_menu_id[MAC_MENU_POPUP_SUB]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4803
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4804 /* Add event handler so we can detect C-g. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4805 install_menu_quit_handler (MAC_MENU_POPUP, menu);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4806 install_menu_quit_handler (MAC_MENU_POPUP_SUB, menu);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4807
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4808 record_unwind_protect (pop_down_menu, make_save_value (f, 0));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4809
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4810 /* Adjust coordinates to be root-window-relative. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4811 x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4812 y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4813
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4814 /* Display the menu. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4815 popup_activated_flag = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4816 menu_item_choice = PopUpMenuSelect (menu, y, x, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4817 popup_activated_flag = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4818
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4819 /* Get the refcon to find the correct item */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4820 if (menu_item_choice)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4821 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4822 MenuRef sel_menu = GetMenuRef (HiWord (menu_item_choice));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4823
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4824 if (sel_menu)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4825 GetMenuItemRefCon (sel_menu, LoWord (menu_item_choice),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4826 (UInt32 *) &result);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4827 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4828
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4829 unbind_to (specpdl_count, Qnil);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4830
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4831 menu_item_selection = result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4832 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4833
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4834 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4835 add_menu_item (menu, pos, wv)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4836 MenuRef menu;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4837 int pos;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4838 widget_value *wv;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4839 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4840 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4841 CFStringRef item_name;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4842 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4843 Str255 item_name;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4844 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4845
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4846 if (name_is_separator (wv->name))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4847 AppendMenu (menu, "\p-");
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4848 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4849 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4850 AppendMenu (menu, "\pX");
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4851
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4852 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4853 item_name = cfstring_create_with_utf8_cstring (wv->name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4854
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4855 if (wv->key != NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4856 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4857 CFStringRef name, key;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4858
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4859 name = item_name;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4860 key = cfstring_create_with_utf8_cstring (wv->key);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4861 item_name = CFStringCreateWithFormat (NULL, NULL, CFSTR ("%@ %@"),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4862 name, key);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4863 CFRelease (name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4864 CFRelease (key);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4865 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4866
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4867 SetMenuItemTextWithCFString (menu, pos, item_name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4868 CFRelease (item_name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4869
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4870 if (wv->enabled)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4871 EnableMenuItem (menu, pos);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4872 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4873 DisableMenuItem (menu, pos);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4874
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4875 if (STRINGP (wv->help))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4876 SetMenuItemProperty (menu, pos, MAC_EMACS_CREATOR_CODE, 'help',
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4877 sizeof (Lisp_Object), &wv->help);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4878 #else /* ! TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4879 item_name[sizeof (item_name) - 1] = '\0';
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4880 strncpy (item_name, wv->name, sizeof (item_name) - 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4881 if (wv->key != NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4882 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4883 int len = strlen (item_name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4884
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4885 strncpy (item_name + len, " ", sizeof (item_name) - 1 - len);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4886 len = strlen (item_name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4887 strncpy (item_name + len, wv->key, sizeof (item_name) - 1 - len);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4888 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4889 c2pstr (item_name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4890 SetMenuItemText (menu, pos, item_name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4891
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4892 if (wv->enabled)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4893 EnableItem (menu, pos);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4894 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4895 DisableItem (menu, pos);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4896 #endif /* ! TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4897
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4898 /* Draw radio buttons and tickboxes. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4899 if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4900 || wv->button_type == BUTTON_TYPE_RADIO))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4901 SetItemMark (menu, pos, checkMark);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4902 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4903 SetItemMark (menu, pos, noMark);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4904
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4905 SetMenuItemRefCon (menu, pos, (UInt32) wv->call_data);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4906 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4907 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4908
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4909 /* Construct native Mac OS menu based on widget_value tree. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4910
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4911 static int
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4912 fill_menu (menu, wv, kind, submenu_id)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4913 MenuRef menu;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4914 widget_value *wv;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4915 enum mac_menu_kind kind;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4916 int submenu_id;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4917 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4918 int pos;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4919
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4920 for (pos = 1; wv != NULL; wv = wv->next, pos++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4921 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4922 add_menu_item (menu, pos, wv);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4923 if (wv->contents && submenu_id < min_menu_id[kind + 1])
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4924 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4925 MenuRef submenu = NewMenu (submenu_id, "\pX");
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4926
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4927 InsertMenu (submenu, -1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4928 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4929 SetMenuItemHierarchicalMenu (menu, pos, submenu);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4930 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4931 SetMenuItemHierarchicalID (menu, pos, submenu_id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4932 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4933 submenu_id = fill_menu (submenu, wv->contents, kind, submenu_id + 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4934 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4935 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4936
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4937 return submenu_id;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4938 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4939
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4940 /* Fill menu bar with the items defined by WV. If DEEP_P, consider
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4941 the entire menu trees we supply, rather than just the menu bar item
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4942 names. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4943
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4944 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4945 mac_fill_menubar (wv, deep_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4946 widget_value *wv;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4947 int deep_p;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4948 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4949 int id, submenu_id;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4950 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4951 int title_changed_p = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4952 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4953
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4954 /* Clean up the menu bar when filled by the entire menu trees. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4955 if (deep_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4956 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4957 dispose_menus (MAC_MENU_MENU_BAR, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4958 dispose_menus (MAC_MENU_MENU_BAR_SUB, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4959 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4960 title_changed_p = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4961 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4962 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4963
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4964 /* Fill menu bar titles and submenus. Reuse the existing menu bar
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4965 titles as much as possible to minimize redraw (if !deep_p). */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4966 submenu_id = min_menu_id[MAC_MENU_MENU_BAR_SUB];
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4967 for (id = min_menu_id[MAC_MENU_MENU_BAR];
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4968 wv != NULL && id < min_menu_id[MAC_MENU_MENU_BAR + 1];
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4969 wv = wv->next, id++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4970 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4971 OSStatus err = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4972 MenuRef menu;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4973 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4974 CFStringRef title;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4975
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4976 title = CFStringCreateWithCString (NULL, wv->name,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4977 kCFStringEncodingMacRoman);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4978 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4979 Str255 title;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4980
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4981 strncpy (title, wv->name, 255);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4982 title[255] = '\0';
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4983 c2pstr (title);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4984 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4985
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4986 menu = GetMenuRef (id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4987 if (menu)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4988 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4989 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4990 CFStringRef old_title;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4991
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4992 err = CopyMenuTitleAsCFString (menu, &old_title);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4993 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4994 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4995 if (CFStringCompare (title, old_title, 0) != kCFCompareEqualTo)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4996 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4997 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4998 if (id + 1 == min_menu_id[MAC_MENU_MENU_BAR + 1]
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
4999 || GetMenuRef (id + 1) == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5000 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5001 /* This is a workaround for Mac OS X 10.5 where
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5002 just calling SetMenuTitleWithCFString fails
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5003 to change the title of the last (Help) menu
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5004 in the menu bar. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5005 DeleteMenu (id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5006 DisposeMenu (menu);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5007 menu = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5008 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5009 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5010 #endif /* MAC_OSX */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5011 err = SetMenuTitleWithCFString (menu, title);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5012 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5013 CFRelease (old_title);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5014 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5015 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5016 err = SetMenuTitleWithCFString (menu, title);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5017 #else /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5018 if (!EqualString (title, (*menu)->menuData, false, false))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5019 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5020 DeleteMenu (id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5021 DisposeMenu (menu);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5022 menu = NewMenu (id, title);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5023 InsertMenu (menu, GetMenuRef (id + 1) ? id + 1 : 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5024 title_changed_p = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5025 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5026 #endif /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5027 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5028
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5029 if (!menu)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5030 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5031 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5032 err = CreateNewMenu (id, 0, &menu);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5033 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5034 err = SetMenuTitleWithCFString (menu, title);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5035 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5036 menu = NewMenu (id, title);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5037 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5038 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5039 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5040 InsertMenu (menu, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5041 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5042 title_changed_p = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5043 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5044 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5045 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5046 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5047 CFRelease (title);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5048 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5049
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5050 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5051 if (wv->contents)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5052 submenu_id = fill_menu (menu, wv->contents, MAC_MENU_MENU_BAR_SUB,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5053 submenu_id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5054 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5055
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5056 if (id < min_menu_id[MAC_MENU_MENU_BAR + 1] && GetMenuRef (id))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5057 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5058 dispose_menus (MAC_MENU_MENU_BAR, id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5059 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5060 title_changed_p = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5061 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5062 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5063
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5064 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5065 if (title_changed_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5066 InvalMenuBar ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5067 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5068
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5069 /* Add event handler so we can detect C-g. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5070 install_menu_quit_handler (MAC_MENU_MENU_BAR, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5071 install_menu_quit_handler (MAC_MENU_MENU_BAR_SUB, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5072 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5073
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5074 /* Dispose of menus that belong to KIND, and remove them from the menu
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5075 list. ID is the lower bound of menu IDs that will be processed. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5076
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5077 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5078 dispose_menus (kind, id)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5079 enum mac_menu_kind kind;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5080 int id;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5081 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5082 for (id = max (id, min_menu_id[kind]); id < min_menu_id[kind + 1]; id++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5083 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5084 MenuRef menu = GetMenuRef (id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5085
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5086 if (menu == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5087 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5088 DeleteMenu (id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5089 DisposeMenu (menu);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5090 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5091 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5092
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5093 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5094 init_menu_bar ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5095 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5096 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5097 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5098 MenuRef menu;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5099 MenuItemIndex menu_index;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5100
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5101 err = GetIndMenuItemWithCommandID (NULL, kHICommandQuit, 1,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5102 &menu, &menu_index);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5103 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5104 SetMenuItemCommandKey (menu, menu_index, false, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5105 EnableMenuCommand (NULL, kHICommandPreferences);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5106 err = GetIndMenuItemWithCommandID (NULL, kHICommandPreferences, 1,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5107 &menu, &menu_index);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5108 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5109 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5110 SetMenuItemCommandKey (menu, menu_index, false, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5111 InsertMenuItemTextWithCFString (menu, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5112 0, kMenuItemAttrSeparator, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5113 InsertMenuItemTextWithCFString (menu, CFSTR ("About Emacs"),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5114 0, 0, kHICommandAbout);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5115 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5116 #else /* !MAC_OSX */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5117 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5118 SetMenuItemCommandID (GetMenuRef (M_APPLE), I_ABOUT, kHICommandAbout);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5119 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5120 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5121 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5122
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5123
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5124 /***********************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5125 Popup Dialog
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5126 ***********************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5127
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5128 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5129 #define DIALOG_BUTTON_COMMAND_ID_OFFSET 'Bt\0\0'
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5130 #define DIALOG_BUTTON_COMMAND_ID_P(id) \
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5131 (((id) & ~0xffff) == DIALOG_BUTTON_COMMAND_ID_OFFSET)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5132 #define DIALOG_BUTTON_COMMAND_ID_VALUE(id) \
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5133 ((id) - DIALOG_BUTTON_COMMAND_ID_OFFSET)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5134 #define DIALOG_BUTTON_MAKE_COMMAND_ID(value) \
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5135 ((value) + DIALOG_BUTTON_COMMAND_ID_OFFSET)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5136
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5137 extern EMACS_TIME timer_check P_ ((int));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5138 static int quit_dialog_event_loop;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5139
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5140 static pascal OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5141 mac_handle_dialog_event (next_handler, event, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5142 EventHandlerCallRef next_handler;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5143 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5144 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5145 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5146 OSStatus err, result = eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5147 WindowRef window = (WindowRef) data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5148
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5149 switch (GetEventClass (event))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5150 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5151 case kEventClassCommand:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5152 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5153 HICommand command;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5154
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5155 err = GetEventParameter (event, kEventParamDirectObject,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5156 typeHICommand, NULL, sizeof (HICommand),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5157 NULL, &command);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5158 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5159 if (DIALOG_BUTTON_COMMAND_ID_P (command.commandID))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5160 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5161 SetWRefCon (window, command.commandID);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5162 quit_dialog_event_loop = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5163 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5164 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5165
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5166 result = CallNextEventHandler (next_handler, event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5167 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5168 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5169
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5170 case kEventClassKeyboard:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5171 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5172 OSStatus result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5173 char char_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5174
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5175 result = CallNextEventHandler (next_handler, event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5176 if (result != eventNotHandledErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5177 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5178
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5179 err = GetEventParameter (event, kEventParamKeyMacCharCodes,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5180 typeChar, NULL, sizeof (char),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5181 NULL, &char_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5182 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5183 switch (char_code)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5184 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5185 case kEscapeCharCode:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5186 quit_dialog_event_loop = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5187 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5188
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5189 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5190 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5191 UInt32 modifiers, key_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5192
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5193 err = GetEventParameter (event, kEventParamKeyModifiers,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5194 typeUInt32, NULL, sizeof (UInt32),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5195 NULL, &modifiers);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5196 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5197 err = GetEventParameter (event, kEventParamKeyCode,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5198 typeUInt32, NULL, sizeof (UInt32),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5199 NULL, &key_code);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5200 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5201 if (mac_quit_char_key_p (modifiers, key_code))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5202 quit_dialog_event_loop = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5203 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5204 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5205 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5206 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5207 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5208
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5209 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5210 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5211 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5212
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5213 if (quit_dialog_event_loop)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5214 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5215 err = QuitEventLoop (GetCurrentEventLoop ());
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5216 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5217 result = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5218 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5219
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5220 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5221 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5222
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5223 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5224 install_dialog_event_handler (window)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5225 WindowRef window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5226 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5227 static const EventTypeSpec specs[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5228 {{kEventClassCommand, kEventCommandProcess},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5229 {kEventClassKeyboard, kEventRawKeyDown}};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5230 static EventHandlerUPP handle_dialog_eventUPP = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5231
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5232 if (handle_dialog_eventUPP == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5233 handle_dialog_eventUPP = NewEventHandlerUPP (mac_handle_dialog_event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5234 return InstallWindowEventHandler (window, handle_dialog_eventUPP,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5235 GetEventTypeCount (specs), specs,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5236 window, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5237 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5238
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5239 static Lisp_Object
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5240 pop_down_dialog (arg)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5241 Lisp_Object arg;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5242 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5243 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5244 WindowRef window = p->pointer;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5245
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5246 BLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5247
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5248 if (popup_activated_flag)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5249 EndAppModalStateForWindow (window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5250 DisposeWindow (window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5251 popup_activated_flag = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5252
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5253 UNBLOCK_INPUT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5254
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5255 return Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5256 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5257
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5258 /* Pop up the dialog for frame F defined by FIRST_WV and loop until the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5259 dialog pops down.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5260 menu_item_selection will be set to the selection. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5261
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5262 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5263 create_and_show_dialog (f, first_wv)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5264 FRAME_PTR f;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5265 widget_value *first_wv;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5266 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5267 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5268 char *dialog_name, *message;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5269 int nb_buttons, first_group_count, i, result = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5270 widget_value *wv;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5271 short buttons_height, text_height, inner_width, inner_height;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5272 Rect empty_rect, *rects;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5273 WindowRef window = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5274 ControlRef *buttons, default_button = NULL, text;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5275 int specpdl_count = SPECPDL_INDEX ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5276
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5277 dialog_name = first_wv->name;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5278 nb_buttons = dialog_name[1] - '0';
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5279 first_group_count = nb_buttons - (dialog_name[4] - '0');
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5280
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5281 wv = first_wv->contents;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5282 message = wv->value;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5283
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5284 wv = wv->next;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5285 SetRect (&empty_rect, 0, 0, 0, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5286
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5287 /* Create dialog window. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5288 err = CreateNewWindow (kMovableModalWindowClass,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5289 kWindowStandardHandlerAttribute,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5290 &empty_rect, &window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5291 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5292 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5293 record_unwind_protect (pop_down_dialog, make_save_value (window, 0));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5294 err = SetThemeWindowBackground (window, kThemeBrushMovableModalBackground,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5295 true);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5296 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5297 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5298 err = SetWindowTitleWithCFString (window, (dialog_name[0] == 'Q'
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5299 ? CFSTR ("Question")
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5300 : CFSTR ("Information")));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5301
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5302 /* Create button controls and measure their optimal bounds. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5303 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5304 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5305 buttons = alloca (sizeof (ControlRef) * nb_buttons);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5306 rects = alloca (sizeof (Rect) * nb_buttons);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5307 for (i = 0; i < nb_buttons; i++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5308 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5309 CFStringRef label = cfstring_create_with_utf8_cstring (wv->value);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5310
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5311 if (label == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5312 err = memFullErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5313 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5314 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5315 err = CreatePushButtonControl (window, &empty_rect,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5316 label, &buttons[i]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5317 CFRelease (label);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5318 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5319 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5320 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5321 if (!wv->enabled)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5322 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5323 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5324 err = DisableControl (buttons[i]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5325 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5326 err = DeactivateControl (buttons[i]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5327 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5328 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5329 else if (default_button == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5330 default_button = buttons[i];
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5331 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5332 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5333 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5334 SInt16 unused;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5335
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5336 rects[i] = empty_rect;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5337 err = GetBestControlRect (buttons[i], &rects[i], &unused);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5338 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5339 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5340 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5341 UInt32 command_id;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5342
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5343 OffsetRect (&rects[i], -rects[i].left, -rects[i].top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5344 if (rects[i].right < DIALOG_BUTTON_MIN_WIDTH)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5345 rects[i].right = DIALOG_BUTTON_MIN_WIDTH;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5346 else if (rects[i].right > DIALOG_MAX_INNER_WIDTH)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5347 rects[i].right = DIALOG_MAX_INNER_WIDTH;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5348
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5349 command_id = DIALOG_BUTTON_MAKE_COMMAND_ID ((int) wv->call_data);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5350 err = SetControlCommandID (buttons[i], command_id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5351 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5352 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5353 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5354 wv = wv->next;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5355 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5356 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5357
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5358 /* Layout buttons. rects[i] is set relative to the bottom-right
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5359 corner of the inner box. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5360 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5361 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5362 short bottom, right, max_height, left_align_shift;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5363
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5364 inner_width = DIALOG_MIN_INNER_WIDTH;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5365 bottom = right = max_height = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5366 for (i = 0; i < nb_buttons; i++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5367 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5368 if (right - rects[i].right < - inner_width)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5369 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5370 if (i != first_group_count
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5371 && right - rects[i].right >= - DIALOG_MAX_INNER_WIDTH)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5372 inner_width = - (right - rects[i].right);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5373 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5374 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5375 bottom -= max_height + DIALOG_BUTTON_BUTTON_VERTICAL_SPACE;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5376 right = max_height = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5377 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5378 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5379 if (max_height < rects[i].bottom)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5380 max_height = rects[i].bottom;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5381 OffsetRect (&rects[i], right - rects[i].right,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5382 bottom - rects[i].bottom);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5383 right = rects[i].left - DIALOG_BUTTON_BUTTON_HORIZONTAL_SPACE;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5384 if (i == first_group_count - 1)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5385 right -= DIALOG_BUTTON_BUTTON_HORIZONTAL_SPACE;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5386 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5387 buttons_height = - (bottom - max_height);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5388
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5389 left_align_shift = - (inner_width + rects[nb_buttons - 1].left);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5390 for (i = nb_buttons - 1; i >= first_group_count; i--)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5391 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5392 if (bottom != rects[i].bottom)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5393 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5394 left_align_shift = - (inner_width + rects[i].left);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5395 bottom = rects[i].bottom;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5396 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5397 OffsetRect (&rects[i], left_align_shift, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5398 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5399 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5400
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5401 /* Create a static text control and measure its bounds. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5402 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5403 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5404 CFStringRef message_string;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5405 Rect bounds;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5406
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5407 message_string = cfstring_create_with_utf8_cstring (message);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5408 if (message_string == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5409 err = memFullErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5410 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5411 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5412 ControlFontStyleRec text_style;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5413
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5414 text_style.flags = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5415 SetRect (&bounds, 0, 0, inner_width, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5416 err = CreateStaticTextControl (window, &bounds, message_string,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5417 &text_style, &text);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5418 CFRelease (message_string);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5419 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5420 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5421 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5422 SInt16 unused;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5423
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5424 bounds = empty_rect;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5425 err = GetBestControlRect (text, &bounds, &unused);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5426 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5427 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5428 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5429 text_height = bounds.bottom - bounds.top;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5430 if (text_height < DIALOG_TEXT_MIN_HEIGHT)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5431 text_height = DIALOG_TEXT_MIN_HEIGHT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5432 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5433 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5434
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5435 /* Place buttons. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5436 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5437 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5438 inner_height = (text_height + DIALOG_TEXT_BUTTONS_VERTICAL_SPACE
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5439 + buttons_height);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5440
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5441 for (i = 0; i < nb_buttons; i++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5442 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5443 OffsetRect (&rects[i], DIALOG_LEFT_MARGIN + inner_width,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5444 DIALOG_TOP_MARGIN + inner_height);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5445 SetControlBounds (buttons[i], &rects[i]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5446 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5447 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5448
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5449 /* Place text. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5450 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5451 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5452 Rect bounds;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5453
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5454 SetRect (&bounds, DIALOG_LEFT_MARGIN, DIALOG_TOP_MARGIN,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5455 DIALOG_LEFT_MARGIN + inner_width,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5456 DIALOG_TOP_MARGIN + text_height);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5457 SetControlBounds (text, &bounds);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5458 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5459
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5460 /* Create the application icon at the upper-left corner. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5461 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5462 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5463 ControlButtonContentInfo content;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5464 ControlRef icon;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5465 static const ProcessSerialNumber psn = {0, kCurrentProcess};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5466 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5467 FSRef app_location;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5468 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5469 ProcessInfoRec pinfo;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5470 FSSpec app_spec;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5471 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5472 SInt16 unused;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5473
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5474 content.contentType = kControlContentIconRef;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5475 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5476 err = GetProcessBundleLocation (&psn, &app_location);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5477 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5478 err = GetIconRefFromFileInfo (&app_location, 0, NULL, 0, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5479 kIconServicesNormalUsageFlag,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5480 &content.u.iconRef, &unused);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5481 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5482 bzero (&pinfo, sizeof (ProcessInfoRec));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5483 pinfo.processInfoLength = sizeof (ProcessInfoRec);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5484 pinfo.processAppSpec = &app_spec;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5485 err = GetProcessInformation (&psn, &pinfo);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5486 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5487 err = GetIconRefFromFile (&app_spec, &content.u.iconRef, &unused);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5488 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5489 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5490 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5491 Rect bounds;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5492
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5493 SetRect (&bounds, DIALOG_ICON_LEFT_MARGIN, DIALOG_ICON_TOP_MARGIN,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5494 DIALOG_ICON_LEFT_MARGIN + DIALOG_ICON_WIDTH,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5495 DIALOG_ICON_TOP_MARGIN + DIALOG_ICON_HEIGHT);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5496 err = CreateIconControl (window, &bounds, &content, true, &icon);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5497 ReleaseIconRef (content.u.iconRef);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5498 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5499 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5500
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5501 /* Show the dialog window and run event loop. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5502 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5503 if (default_button)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5504 err = SetWindowDefaultButton (window, default_button);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5505 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5506 err = install_dialog_event_handler (window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5507 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5508 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5509 SizeWindow (window,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5510 DIALOG_LEFT_MARGIN + inner_width + DIALOG_RIGHT_MARGIN,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5511 DIALOG_TOP_MARGIN + inner_height + DIALOG_BOTTOM_MARGIN,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5512 true);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5513 err = RepositionWindow (window, FRAME_MAC_WINDOW (f),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5514 kWindowAlertPositionOnParentWindow);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5515 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5516 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5517 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5518 SetWRefCon (window, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5519 ShowWindow (window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5520 BringToFront (window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5521 popup_activated_flag = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5522 err = BeginAppModalStateForWindow (window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5523 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5524 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5525 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5526 EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5527
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5528 quit_dialog_event_loop = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5529 while (1)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5530 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5531 EMACS_TIME next_time = timer_check (1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5532 long secs = EMACS_SECS (next_time);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5533 long usecs = EMACS_USECS (next_time);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5534 EventTimeout timeout;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5535 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5536
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5537 if (secs < 0 || (secs == 0 && usecs == 0))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5538 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5539 /* Sometimes timer_check returns -1 (no timers) even if
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5540 there are timers. So do a timeout anyway. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5541 secs = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5542 usecs = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5543 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5544
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5545 timeout = (secs * kEventDurationSecond
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5546 + usecs * kEventDurationMicrosecond);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5547 err = ReceiveNextEvent (0, NULL, timeout, kEventRemoveFromQueue,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5548 &event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5549 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5550 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5551 SendEventToEventTarget (event, toolbox_dispatcher);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5552 ReleaseEvent (event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5553 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5554 #if 0 /* defined (MAC_OSX) */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5555 else if (err != eventLoopTimedOutErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5556 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5557 if (err == eventLoopQuitErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5558 err = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5559 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5560 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5561 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5562 /* The return value of ReceiveNextEvent seems to be
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5563 unreliable. Use our own global variable instead. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5564 if (quit_dialog_event_loop)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5565 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5566 err = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5567 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5568 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5569 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5570 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5571 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5572 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5573 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5574 UInt32 command_id = GetWRefCon (window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5575
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5576 if (DIALOG_BUTTON_COMMAND_ID_P (command_id))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5577 result = DIALOG_BUTTON_COMMAND_ID_VALUE (command_id);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5578 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5579
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5580 unbind_to (specpdl_count, Qnil);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5581
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5582 menu_item_selection = result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5583 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5584 #else /* not TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5585 #define DIALOG_WINDOW_RESOURCE 130
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5586
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5587 int
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5588 mac_dialog (widget_value *wv)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5589 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5590 char *dialog_name;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5591 char *prompt;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5592 char **button_labels;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5593 UInt32 *ref_cons;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5594 int nb_buttons;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5595 int left_count;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5596 int i;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5597 int dialog_width;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5598 Rect rect;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5599 WindowRef window_ptr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5600 ControlRef ch;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5601 int left;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5602 EventRecord event_record;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5603 SInt16 part_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5604 int control_part_code;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5605 Point mouse;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5606
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5607 dialog_name = wv->name;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5608 nb_buttons = dialog_name[1] - '0';
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5609 left_count = nb_buttons - (dialog_name[4] - '0');
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5610 button_labels = (char **) alloca (sizeof (char *) * nb_buttons);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5611 ref_cons = (UInt32 *) alloca (sizeof (UInt32) * nb_buttons);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5612
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5613 wv = wv->contents;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5614 prompt = (char *) alloca (strlen (wv->value) + 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5615 strcpy (prompt, wv->value);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5616 c2pstr (prompt);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5617
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5618 wv = wv->next;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5619 for (i = 0; i < nb_buttons; i++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5620 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5621 button_labels[i] = wv->value;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5622 button_labels[i] = (char *) alloca (strlen (wv->value) + 1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5623 strcpy (button_labels[i], wv->value);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5624 c2pstr (button_labels[i]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5625 ref_cons[i] = (UInt32) wv->call_data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5626 wv = wv->next;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5627 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5628
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5629 window_ptr = GetNewCWindow (DIALOG_WINDOW_RESOURCE, NULL, (WindowRef) -1);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5630
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5631 SetPortWindowPort (window_ptr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5632
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5633 TextFont (0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5634 /* Left and right margins in the dialog are 13 pixels each.*/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5635 dialog_width = 14;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5636 /* Calculate width of dialog box: 8 pixels on each side of the text
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5637 label in each button, 12 pixels between buttons. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5638 for (i = 0; i < nb_buttons; i++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5639 dialog_width += StringWidth (button_labels[i]) + 16 + 12;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5640
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5641 if (left_count != 0 && nb_buttons - left_count != 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5642 dialog_width += 12;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5643
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5644 dialog_width = max (dialog_width, StringWidth (prompt) + 26);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5645
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5646 SizeWindow (window_ptr, dialog_width, 78, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5647 ShowWindow (window_ptr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5648
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5649 SetPortWindowPort (window_ptr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5650
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5651 TextFont (0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5652
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5653 MoveTo (13, 29);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5654 DrawString (prompt);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5655
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5656 left = 13;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5657 for (i = 0; i < nb_buttons; i++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5658 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5659 int button_width = StringWidth (button_labels[i]) + 16;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5660 SetRect (&rect, left, 45, left + button_width, 65);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5661 ch = NewControl (window_ptr, &rect, button_labels[i], 1, 0, 0, 0,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5662 kControlPushButtonProc, ref_cons[i]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5663 left += button_width + 12;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5664 if (i == left_count - 1)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5665 left += 12;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5666 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5667
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5668 i = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5669 while (!i)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5670 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5671 if (WaitNextEvent (mDownMask, &event_record, 10, NULL))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5672 if (event_record.what == mouseDown)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5673 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5674 part_code = FindWindow (event_record.where, &window_ptr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5675 if (part_code == inContent)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5676 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5677 mouse = event_record.where;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5678 GlobalToLocal (&mouse);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5679 control_part_code = FindControl (mouse, window_ptr, &ch);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5680 if (control_part_code == kControlButtonPart)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5681 if (TrackControl (ch, mouse, NULL))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5682 i = GetControlReference (ch);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5683 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5684 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5685 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5686
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5687 DisposeWindow (window_ptr);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5688
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5689 return i;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5690 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5691 #endif /* not TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5692
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5693
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5694 /***********************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5695 Selection support
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5696 ***********************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5697
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5698 #if !TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5699 #include <Scrap.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5700 #include <Endian.h>
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5701 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5702
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5703 extern Lisp_Object Vselection_converter_alist;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5704 extern Lisp_Object Qmac_scrap_name, Qmac_ostype;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5705
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5706 static ScrapFlavorType get_flavor_type_from_symbol P_ ((Lisp_Object,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5707 Selection));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5708
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5709 /* Get a reference to the selection corresponding to the symbol SYM.
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5710 The reference is set to *SEL, and it becomes NULL if there's no
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5711 corresponding selection. Clear the selection if CLEAR_P is
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5712 non-zero. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5713
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5714 OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5715 mac_get_selection_from_symbol (sym, clear_p, sel)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5716 Lisp_Object sym;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5717 int clear_p;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5718 Selection *sel;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5719 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5720 OSStatus err = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5721 Lisp_Object str = Fget (sym, Qmac_scrap_name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5722
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5723 if (!STRINGP (str))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5724 *sel = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5725 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5726 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5727 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5728 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5729 CFStringRef scrap_name = cfstring_create_with_string (str);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5730 OptionBits options = (clear_p ? kScrapClearNamedScrap
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5731 : kScrapGetNamedScrap);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5732
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5733 err = GetScrapByName (scrap_name, options, sel);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5734 CFRelease (scrap_name);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5735 #else /* !MAC_OSX */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5736 if (clear_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5737 err = ClearCurrentScrap ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5738 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5739 err = GetCurrentScrap (sel);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5740 #endif /* !MAC_OSX */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5741 #else /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5742 if (clear_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5743 err = ZeroScrap ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5744 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5745 *sel = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5746 #endif /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5747 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5748
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5749 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5750 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5751
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5752 /* Get a scrap flavor type from the symbol SYM. Return 0 if no
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5753 corresponding flavor type. If SEL is non-zero, the return value is
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5754 non-zero only when the SEL has the flavor type. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5755
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5756 static ScrapFlavorType
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5757 get_flavor_type_from_symbol (sym, sel)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5758 Lisp_Object sym;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5759 Selection sel;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5760 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5761 Lisp_Object str = Fget (sym, Qmac_ostype);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5762 ScrapFlavorType flavor_type;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5763
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5764 if (STRINGP (str) && SBYTES (str) == 4)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5765 flavor_type = EndianU32_BtoN (*((UInt32 *) SDATA (str)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5766 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5767 flavor_type = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5768
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5769 if (flavor_type && sel)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5770 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5771 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5772 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5773 ScrapFlavorFlags flags;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5774
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5775 err = GetScrapFlavorFlags (sel, flavor_type, &flags);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5776 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5777 flavor_type = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5778 #else /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5779 SInt32 size, offset;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5780
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5781 size = GetScrap (NULL, flavor_type, &offset);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5782 if (size < 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5783 flavor_type = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5784 #endif /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5785 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5786
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5787 return flavor_type;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5788 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5789
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5790 /* Check if the symbol SYM has a corresponding selection target type. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5791
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5792 int
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5793 mac_valid_selection_target_p (sym)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5794 Lisp_Object sym;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5795 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5796 return get_flavor_type_from_symbol (sym, 0) != 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5797 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5798
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5799 /* Clear the selection whose reference is *SEL. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5800
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5801 OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5802 mac_clear_selection (sel)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5803 Selection *sel;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5804 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5805 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5806 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5807 return ClearScrap (sel);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5808 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5809 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5810
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5811 err = ClearCurrentScrap ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5812 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5813 err = GetCurrentScrap (sel);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5814 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5815 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5816 #else /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5817 return ZeroScrap ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5818 #endif /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5819 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5820
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5821 /* Get ownership information for SEL. Emacs can detect a change of
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5822 the ownership by comparing saved and current values of the
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5823 ownership information. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5824
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5825 Lisp_Object
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5826 mac_get_selection_ownership_info (sel)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5827 Selection sel;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5828 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5829 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5830 return long_to_cons ((unsigned long) sel);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5831 #else /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5832 ScrapStuffPtr scrap_info = InfoScrap ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5833
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5834 return make_number (scrap_info->scrapCount);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5835 #endif /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5836 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5837
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5838 /* Return non-zero if VALUE is a valid selection value for TARGET. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5839
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5840 int
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5841 mac_valid_selection_value_p (value, target)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5842 Lisp_Object value, target;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5843 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5844 return STRINGP (value);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5845 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5846
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5847 /* Put Lisp object VALUE to the selection SEL. The target type is
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5848 specified by TARGET. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5849
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5850 OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5851 mac_put_selection_value (sel, target, value)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5852 Selection sel;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5853 Lisp_Object target, value;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5854 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5855 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (target, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5856
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5857 if (flavor_type == 0 || !STRINGP (value))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5858 return noTypeErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5859
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5860 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5861 return PutScrapFlavor (sel, flavor_type, kScrapFlavorMaskNone,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5862 SBYTES (value), SDATA (value));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5863 #else /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5864 return PutScrap (SBYTES (value), flavor_type, SDATA (value));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5865 #endif /* !TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5866 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5867
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5868 /* Check if data for the target type TARGET is available in SEL. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5869
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5870 int
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5871 mac_selection_has_target_p (sel, target)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5872 Selection sel;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5873 Lisp_Object target;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5874 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5875 return get_flavor_type_from_symbol (target, sel) != 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5876 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5877
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5878 /* Get data for the target type TARGET from SEL and create a Lisp
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5879 string. Return nil if failed to get data. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5880
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5881 Lisp_Object
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5882 mac_get_selection_value (sel, target)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5883 Selection sel;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5884 Lisp_Object target;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5885 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5886 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5887 Lisp_Object result = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5888 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (target, sel);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5889 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5890 Size size;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5891
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5892 if (flavor_type)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5893 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5894 err = GetScrapFlavorSize (sel, flavor_type, &size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5895 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5896 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5897 do
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5898 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5899 result = make_uninit_string (size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5900 err = GetScrapFlavorData (sel, flavor_type,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5901 &size, SDATA (result));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5902 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5903 result = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5904 else if (size < SBYTES (result))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5905 result = make_unibyte_string (SDATA (result), size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5906 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5907 while (STRINGP (result) && size > SBYTES (result));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5908 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5909 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5910 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5911 Handle handle;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5912 SInt32 size, offset;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5913
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5914 if (flavor_type)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5915 size = GetScrap (NULL, flavor_type, &offset);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5916 if (size >= 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5917 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5918 handle = NewHandle (size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5919 HLock (handle);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5920 size = GetScrap (handle, flavor_type, &offset);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5921 if (size >= 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5922 result = make_unibyte_string (*handle, size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5923 DisposeHandle (handle);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5924 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5925 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5926
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5927 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5928 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5929
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5930 /* Get the list of target types in SEL. The return value is a list of
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5931 target type symbols possibly followed by scrap flavor type
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5932 strings. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5933
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5934 Lisp_Object
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5935 mac_get_selection_target_list (sel)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5936 Selection sel;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5937 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5938 Lisp_Object result = Qnil, rest, target;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5939 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5940 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5941 UInt32 count, i, type;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5942 ScrapFlavorInfo *flavor_info = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5943 Lisp_Object strings = Qnil;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5944
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5945 err = GetScrapFlavorCount (sel, &count);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5946 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5947 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5948 err = GetScrapFlavorInfoList (sel, &count, flavor_info);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5949 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5950 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5951 xfree (flavor_info);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5952 flavor_info = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5953 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5954 if (flavor_info == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5955 count = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5956 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5957 for (rest = Vselection_converter_alist; CONSP (rest); rest = XCDR (rest))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5958 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5959 ScrapFlavorType flavor_type = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5960
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5961 if (CONSP (XCAR (rest))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5962 && (target = XCAR (XCAR (rest)),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5963 SYMBOLP (target))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5964 && (flavor_type = get_flavor_type_from_symbol (target, sel)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5965 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5966 result = Fcons (target, result);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5967 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5968 for (i = 0; i < count; i++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5969 if (flavor_info[i].flavorType == flavor_type)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5970 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5971 flavor_info[i].flavorType = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5972 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5973 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5974 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5975 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5976 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5977 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5978 if (flavor_info)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5979 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5980 for (i = 0; i < count; i++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5981 if (flavor_info[i].flavorType)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5982 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5983 type = EndianU32_NtoB (flavor_info[i].flavorType);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5984 strings = Fcons (make_unibyte_string ((char *) &type, 4), strings);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5985 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5986 result = nconc2 (result, strings);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5987 xfree (flavor_info);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5988 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5989 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5990
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5991 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5992 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5993
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5994
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5995 /***********************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5996 Apple event support
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5997 ***********************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5998
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
5999 extern pascal OSErr mac_handle_apple_event P_ ((const AppleEvent *,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6000 AppleEvent *, SInt32));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6001 extern void cleanup_all_suspended_apple_events P_ ((void));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6002
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6003 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6004 init_apple_event_handler ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6005 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6006 OSErr err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6007 long result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6008
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6009 /* Make sure we have Apple events before starting. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6010 err = Gestalt (gestaltAppleEventsAttr, &result);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6011 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6012 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6013
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6014 if (!(result & (1 << gestaltAppleEventsPresent)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6015 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6016
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6017 err = AEInstallEventHandler (typeWildCard, typeWildCard,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6018 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6019 NewAEEventHandlerUPP (mac_handle_apple_event),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6020 #else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6021 NewAEEventHandlerProc (mac_handle_apple_event),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6022 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6023 0L, false);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6024 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6025 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6026
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6027 atexit (cleanup_all_suspended_apple_events);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6028 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6029
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6030
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6031 /***********************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6032 Drag and drop support
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6033 ***********************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6034
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6035 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6036 extern Lisp_Object Vmac_dnd_known_types;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6037
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6038 static pascal OSErr mac_do_track_drag P_ ((DragTrackingMessage, WindowRef,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6039 void *, DragRef));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6040 static pascal OSErr mac_do_receive_drag P_ ((WindowRef, void *, DragRef));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6041 static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6042 static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6043
|
80517
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6044 static OSErr
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6045 create_apple_event_from_drag_ref (drag, num_types, types, result)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6046 DragRef drag;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6047 UInt32 num_types;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6048 const FlavorType *types;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6049 AppleEvent *result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6050 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6051 OSErr err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6052 UInt16 num_items;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6053 AppleEvent items;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6054 long index;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6055 char *buf = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6056
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6057 err = CountDragItems (drag, &num_items);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6058 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6059 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6060 err = AECreateList (NULL, 0, false, &items);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6061 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6062 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6063
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6064 for (index = 1; index <= num_items; index++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6065 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6066 ItemReference item;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6067 DescType desc_type = typeNull;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6068 Size size;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6069
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6070 err = GetDragItemReferenceNumber (drag, index, &item);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6071 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6072 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6073 int i;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6074
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6075 for (i = 0; i < num_types; i++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6076 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6077 err = GetFlavorDataSize (drag, item, types[i], &size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6078 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6079 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6080 buf = xrealloc (buf, size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6081 err = GetFlavorData (drag, item, types[i], buf, &size, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6082 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6083 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6084 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6085 desc_type = types[i];
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6086 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6087 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6088 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6089 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6090 err = AEPutPtr (&items, index, desc_type,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6091 desc_type != typeNull ? buf : NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6092 desc_type != typeNull ? size : 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6093 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6094 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6095 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6096 if (buf)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6097 xfree (buf);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6098
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6099 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6100 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6101 err = create_apple_event (0, 0, result); /* Dummy class and ID. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6102 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6103 err = AEPutParamDesc (result, keyDirectObject, &items);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6104 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6105 AEDisposeDesc (result);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6106 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6107
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6108 AEDisposeDesc (&items);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6109
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6110 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6111 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
diff
changeset
|
6112
|
80446
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6113 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6114 mac_store_drag_event (window, mouse_pos, modifiers, desc)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6115 WindowRef window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6116 Point mouse_pos;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6117 SInt16 modifiers;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6118 const AEDesc *desc;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6119 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6120 struct input_event buf;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6121
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6122 EVENT_INIT (buf);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6123
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6124 buf.kind = DRAG_N_DROP_EVENT;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6125 buf.modifiers = mac_to_emacs_modifiers (modifiers, 0);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6126 buf.timestamp = TickCount () * (1000 / 60);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6127 XSETINT (buf.x, mouse_pos.h);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6128 XSETINT (buf.y, mouse_pos.v);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6129 XSETFRAME (buf.frame_or_window, mac_window_to_frame (window));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6130 buf.arg = mac_aedesc_to_lisp (desc);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6131 kbd_buffer_store_event (&buf);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6132 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6133
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6134 static pascal OSErr
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6135 mac_do_track_drag (message, window, refcon, drag)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6136 DragTrackingMessage message;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6137 WindowRef window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6138 void *refcon;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6139 DragRef drag;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6140 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6141 OSErr err = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6142 static int can_accept;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6143 UInt16 num_items, index;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6144
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6145 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6146 return dragNotAcceptedErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6147
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6148 switch (message)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6149 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6150 case kDragTrackingEnterHandler:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6151 err = CountDragItems (drag, &num_items);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6152 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6153 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6154 can_accept = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6155 for (index = 1; index <= num_items; index++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6156 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6157 ItemReference item;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6158 FlavorFlags flags;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6159 Lisp_Object rest;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6160
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6161 err = GetDragItemReferenceNumber (drag, index, &item);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6162 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6163 continue;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6164 for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6165 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6166 Lisp_Object str;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6167 FlavorType type;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6168
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6169 str = XCAR (rest);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6170 if (!(STRINGP (str) && SBYTES (str) == 4))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6171 continue;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6172 type = EndianU32_BtoN (*((UInt32 *) SDATA (str)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6173
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6174 err = GetFlavorFlags (drag, item, type, &flags);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6175 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6176 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6177 can_accept = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6178 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6179 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6180 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6181 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6182 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6183
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6184 case kDragTrackingEnterWindow:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6185 if (can_accept)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6186 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6187 RgnHandle hilite_rgn = NewRgn ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6188
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6189 if (hilite_rgn)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6190 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6191 Rect r;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6192
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6193 GetWindowPortBounds (window, &r);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6194 OffsetRect (&r, -r.left, -r.top);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6195 RectRgn (hilite_rgn, &r);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6196 ShowDragHilite (drag, hilite_rgn, true);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6197 DisposeRgn (hilite_rgn);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6198 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6199 SetThemeCursor (kThemeCopyArrowCursor);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6200 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6201 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6202
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6203 case kDragTrackingInWindow:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6204 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6205
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6206 case kDragTrackingLeaveWindow:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6207 if (can_accept)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6208 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6209 HideDragHilite (drag);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6210 SetThemeCursor (kThemeArrowCursor);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6211 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6212 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6213
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6214 case kDragTrackingLeaveHandler:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6215 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6216 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6217
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6218 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6219 return dragNotAcceptedErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6220 return noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6221 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6222
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6223 static pascal OSErr
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6224 mac_do_receive_drag (window, refcon, drag)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6225 WindowRef window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6226 void *refcon;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6227 DragRef drag;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6228 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6229 OSErr err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6230 int num_types, i;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6231 Lisp_Object rest, str;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6232 FlavorType *types;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6233 AppleEvent apple_event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6234 Point mouse_pos;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6235 SInt16 modifiers;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6236
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6237 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6238 return dragNotAcceptedErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6239
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6240 num_types = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6241 for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6242 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6243 str = XCAR (rest);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6244 if (STRINGP (str) && SBYTES (str) == 4)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6245 num_types++;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6246 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6247
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6248 types = xmalloc (sizeof (FlavorType) * num_types);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6249 i = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6250 for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6251 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6252 str = XCAR (rest);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6253 if (STRINGP (str) && SBYTES (str) == 4)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6254 types[i++] = EndianU32_BtoN (*((UInt32 *) SDATA (str)));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6255 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6256
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6257 err = create_apple_event_from_drag_ref (drag, num_types, types,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6258 &apple_event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6259 xfree (types);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6260
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6261 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6262 err = GetDragMouse (drag, &mouse_pos, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6263 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6264 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6265 GlobalToLocal (&mouse_pos);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6266 err = GetDragModifiers (drag, NULL, NULL, &modifiers);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6267 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6268 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6269 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6270 UInt32 key_modifiers = modifiers;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6271
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6272 err = AEPutParamPtr (&apple_event, kEventParamKeyModifiers,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6273 typeUInt32, &key_modifiers, sizeof (UInt32));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6274 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6275
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6276 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6277 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6278 mac_store_drag_event (window, mouse_pos, 0, &apple_event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6279 AEDisposeDesc (&apple_event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6280 mac_wakeup_from_rne ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6281 return noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6282 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6283 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6284 return dragNotAcceptedErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6285 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6286 #endif /* TARGET_API_MAC_CARBON */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6287
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6288 static OSErr
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6289 install_drag_handler (window)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6290 WindowRef window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6291 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6292 OSErr err = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6293
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6294 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6295 if (mac_do_track_dragUPP == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6296 mac_do_track_dragUPP = NewDragTrackingHandlerUPP (mac_do_track_drag);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6297 if (mac_do_receive_dragUPP == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6298 mac_do_receive_dragUPP = NewDragReceiveHandlerUPP (mac_do_receive_drag);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6299
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6300 err = InstallTrackingHandler (mac_do_track_dragUPP, window, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6301 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6302 err = InstallReceiveHandler (mac_do_receive_dragUPP, window, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6303 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6304
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6305 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6306 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6307
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6308 static void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6309 remove_drag_handler (window)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6310 WindowRef window;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6311 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6312 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6313 if (mac_do_track_dragUPP)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6314 RemoveTrackingHandler (mac_do_track_dragUPP, window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6315 if (mac_do_receive_dragUPP)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6316 RemoveReceiveHandler (mac_do_receive_dragUPP, window);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6317 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6318 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6319
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6320 #if TARGET_API_MAC_CARBON
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6321 /* Return default value for mac-dnd-known-types. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6322
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6323 Lisp_Object
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6324 mac_dnd_default_known_types ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6325 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6326 Lisp_Object result = list4 (build_string ("hfs "), build_string ("utxt"),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6327 build_string ("TEXT"), build_string ("TIFF"));
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6328
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6329 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6330 result = Fcons (build_string ("furl"), result);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6331 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6332
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6333 return result;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6334 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6335 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6336
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6337
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6338 /***********************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6339 Services menu support
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6340 ***********************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6341
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6342 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6343 extern Lisp_Object Qservice, Qpaste, Qperform;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6344 extern Lisp_Object Vmac_service_selection;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6345
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6346 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6347 mac_store_service_event (event)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6348 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6349 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6350 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6351 Lisp_Object id_key;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6352 int num_params;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6353 const EventParamName *names;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6354 const EventParamType *types;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6355 static const EventParamName names_pfm[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6356 {kEventParamServiceMessageName, kEventParamServiceUserData};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6357 static const EventParamType types_pfm[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6358 {typeCFStringRef, typeCFStringRef};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6359
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6360 switch (GetEventKind (event))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6361 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6362 case kEventServicePaste:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6363 id_key = Qpaste;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6364 num_params = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6365 names = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6366 types = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6367 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6368
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6369 case kEventServicePerform:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6370 id_key = Qperform;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6371 num_params = sizeof (names_pfm) / sizeof (names_pfm[0]);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6372 names = names_pfm;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6373 types = types_pfm;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6374 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6375
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6376 default:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6377 abort ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6378 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6379
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6380 err = mac_store_event_ref_as_apple_event (0, 0, Qservice, id_key,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6381 event, num_params,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6382 names, types);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6383
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6384 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6385 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6386
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6387 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6388 copy_scrap_flavor_data (from_scrap, to_scrap, flavor_type)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6389 ScrapRef from_scrap, to_scrap;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6390 ScrapFlavorType flavor_type;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6391 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6392 OSStatus err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6393 Size size, size_allocated;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6394 char *buf = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6395
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6396 err = GetScrapFlavorSize (from_scrap, flavor_type, &size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6397 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6398 buf = xmalloc (size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6399 while (buf)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6400 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6401 size_allocated = size;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6402 err = GetScrapFlavorData (from_scrap, flavor_type, &size, buf);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6403 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6404 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6405 xfree (buf);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6406 buf = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6407 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6408 else if (size_allocated < size)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6409 buf = xrealloc (buf, size);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6410 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6411 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6412 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6413 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6414 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6415 if (buf == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6416 err = memFullErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6417 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6418 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6419 err = PutScrapFlavor (to_scrap, flavor_type, kScrapFlavorMaskNone,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6420 size, buf);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6421 xfree (buf);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6422 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6423 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6424
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6425 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6426 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6427
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6428 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6429 mac_handle_service_event (call_ref, event, data)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6430 EventHandlerCallRef call_ref;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6431 EventRef event;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6432 void *data;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6433 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6434 OSStatus err = noErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6435 ScrapRef cur_scrap, specific_scrap;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6436 UInt32 event_kind = GetEventKind (event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6437 CFMutableArrayRef copy_types, paste_types;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6438 CFStringRef type;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6439 Lisp_Object rest;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6440 ScrapFlavorType flavor_type;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6441
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6442 /* Check if Vmac_service_selection is a valid selection that has a
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6443 corresponding scrap. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6444 if (!SYMBOLP (Vmac_service_selection))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6445 err = eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6446 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6447 err = mac_get_selection_from_symbol (Vmac_service_selection, 0, &cur_scrap);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6448 if (!(err == noErr && cur_scrap))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6449 return eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6450
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6451 switch (event_kind)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6452 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6453 case kEventServiceGetTypes:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6454 /* Set paste types. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6455 err = GetEventParameter (event, kEventParamServicePasteTypes,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6456 typeCFMutableArrayRef, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6457 sizeof (CFMutableArrayRef), NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6458 &paste_types);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6459 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6460 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6461
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6462 for (rest = Vselection_converter_alist; CONSP (rest);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6463 rest = XCDR (rest))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6464 if (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6465 && (flavor_type =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6466 get_flavor_type_from_symbol (XCAR (XCAR (rest)), 0)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6467 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6468 type = CreateTypeStringWithOSType (flavor_type);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6469 if (type)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6470 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6471 CFArrayAppendValue (paste_types, type);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6472 CFRelease (type);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6473 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6474 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6475
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6476 /* Set copy types. */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6477 err = GetEventParameter (event, kEventParamServiceCopyTypes,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6478 typeCFMutableArrayRef, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6479 sizeof (CFMutableArrayRef), NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6480 ©_types);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6481 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6482 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6483
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6484 if (NILP (Fx_selection_owner_p (Vmac_service_selection)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6485 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6486 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6487 goto copy_all_flavors;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6488
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6489 case kEventServiceCopy:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6490 err = GetEventParameter (event, kEventParamScrapRef,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6491 typeScrapRef, NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6492 sizeof (ScrapRef), NULL, &specific_scrap);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6493 if (err != noErr
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6494 || NILP (Fx_selection_owner_p (Vmac_service_selection)))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6495 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6496 err = eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6497 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6498 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6499
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6500 copy_all_flavors:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6501 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6502 UInt32 count, i;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6503 ScrapFlavorInfo *flavor_info = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6504 ScrapFlavorFlags flags;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6505
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6506 err = GetScrapFlavorCount (cur_scrap, &count);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6507 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6508 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6509 err = GetScrapFlavorInfoList (cur_scrap, &count, flavor_info);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6510 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6511 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6512 xfree (flavor_info);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6513 flavor_info = NULL;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6514 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6515 if (flavor_info == NULL)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6516 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6517
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6518 for (i = 0; i < count; i++)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6519 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6520 flavor_type = flavor_info[i].flavorType;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6521 err = GetScrapFlavorFlags (cur_scrap, flavor_type, &flags);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6522 if (err == noErr && !(flags & kScrapFlavorMaskSenderOnly))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6523 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6524 if (event_kind == kEventServiceCopy)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6525 err = copy_scrap_flavor_data (cur_scrap, specific_scrap,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6526 flavor_type);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6527 else /* event_kind == kEventServiceGetTypes */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6528 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6529 type = CreateTypeStringWithOSType (flavor_type);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6530 if (type)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6531 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6532 CFArrayAppendValue (copy_types, type);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6533 CFRelease (type);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6534 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6535 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6536 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6537 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6538 xfree (flavor_info);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6539 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6540 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6541
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6542 case kEventServicePaste:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6543 case kEventServicePerform:
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6544 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6545 int data_exists_p = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6546
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6547 err = GetEventParameter (event, kEventParamScrapRef, typeScrapRef,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6548 NULL, sizeof (ScrapRef), NULL,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6549 &specific_scrap);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6550 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6551 err = mac_clear_selection (&cur_scrap);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6552 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6553 for (rest = Vselection_converter_alist; CONSP (rest);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6554 rest = XCDR (rest))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6555 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6556 if (! (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest)))))
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6557 continue;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6558 flavor_type = get_flavor_type_from_symbol (XCAR (XCAR (rest)),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6559 specific_scrap);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6560 if (flavor_type == 0)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6561 continue;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6562 err = copy_scrap_flavor_data (specific_scrap, cur_scrap,
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6563 flavor_type);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6564 if (err == noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6565 data_exists_p = 1;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6566 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6567 if (!data_exists_p)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6568 err = eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6569 else
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6570 err = mac_store_service_event (event);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6571 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6572 break;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6573 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6574
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6575 if (err != noErr)
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6576 err = eventNotHandledErr;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6577 return err;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6578 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6579
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6580 static OSStatus
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6581 install_service_handler ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6582 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6583 static const EventTypeSpec specs[] =
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6584 {{kEventClassService, kEventServiceGetTypes},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6585 {kEventClassService, kEventServiceCopy},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6586 {kEventClassService, kEventServicePaste},
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6587 {kEventClassService, kEventServicePerform}};
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6588
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6589 return InstallApplicationEventHandler (NewEventHandlerUPP
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6590 (mac_handle_service_event),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6591 GetEventTypeCount (specs),
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6592 specs, NULL, NULL);
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6593 }
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6594 #endif /* MAC_OSX */
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6595
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6596
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6597 /***********************************************************************
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6598 Initialization
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6599 ***********************************************************************/
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6600
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6601 void
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6602 mac_toolbox_initialize ()
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6603 {
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6604 any_help_event_p = 0;
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6605
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6606 init_menu_bar ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6607
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6608 #ifdef MAC_OSX
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6609 init_apple_event_handler ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6610 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6611 #if USE_MAC_TSM
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6612 init_tsm ();
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6613 #endif
|
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
6614 }
|
80464
|
6615
|
|
6616 /* arch-tag: 71a597a8-6e9f-47b0-8b89-5a5ae3e16516
|
|
6617 (do not change this comment) */
|